[Scummvm-git-logs] scummvm master -> f02b71476880c912160f404350dc7c3297eb673c

bluegr noreply at scummvm.org
Sun Jan 12 16:13:08 UTC 2025


This automated email contains information about 249 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
0ed1caeb15 GOT: Skeleton engine
209f754574 GOT: Added resource archive, added to SearchMan
375e9c4bf0 GOT: Create Views namespace
cdbe42a8be GOT: Added file access methods
77f30bdc6d GOT: Added Vars class
8217fb0fa9 GOT: Adding further initialization, statics loading
e05c0ff9be GOT: More palette code
a553a01482 GOT: Beginnings of first screen
b0a4ebd614 GOT: Beginnings of graphics loading
3209a49602 GOT: Adding image decompression
ce3634b170 GOT: Trying to display main menu background
431ba6174d GOT: LZSS decoding of menu background now working
3a7c44a294 GOT: Move drawBackground to View class
bbc92d689c GOT: Added BgPics class to hold background images
26f123cf7b GOT: Beginnings of dialog display
a51cb7839d GOT: Add GfxSurface class to be used in view drawing
77c8e30f8d GOT: Implemented font loading & display
495b3e72ff GOT: Dialog now listing options
b9c6d7c4ea GOT: Split up graphics loading into it's own base class, load hampic
7a2bfc4743 GOT: Hammer icon in dialogs is now properly animated
0f0a5e4dd4 GOT: Added keybinding actions, up/down now working in dialog
daff4e304c GOT: Animation for selecting a dialog item
939153819c GOT: Further selection animation, play_sound placeholder
aa6d5debc3 GOT: Implemented sound effects
9f4e657dee GOT: Prototype sub-menu from Options Menu
249f1e6563 GOT: Added Quit Game dialog
13c1eab13e GOT: Added main menu display
6e285a1075 GOT: Fix graphics having two transparency colors
3943bc17a8 GOT: Split Dialog into SelectOption class, added Quit dialog
e10cdaba23 GOT: Redraw underlying views when switching between dialogs
26d38f6d0d GOT: Quit dialog shows on top of title menu
805e821b33 GOT: Skeleton Play Game dialog class
f046dffb92 GOT: Work on Story view display
1b6c84c705 GOT: Placeholder music code
185b57eb78 GOT: Add icons to story view
7261ea75d1 GOT: Vertical scrolling for Story view
6658a35c02 GOT: Added music_stop method
acbe124d23 GOT: Working on fading
ae0274bf30 GOT: Make screen fades faster
192904476d GOT: Dialog widths should account for options as well as title
8ed24cd498 GOT: Added view for the part title card
2d1510eb21 GOT: Skeleton Game view
2a0b44c874 GOT: Added status methods
0075ebc5e0 GOT: Split status area into it's own subclass
500f71d8c8 GOT: Adding image setup methods
5789b2978b GOT: image.cpp cleanups
bf0a15c45e GOT: Move image.cpp to gfx/, temporarily disable some init code
269df0f92b GOT: Add item display to status area
02acac8a2d GOT: Added setup_player, setup_level methods
715615d3bd GOT: More initialization code
550eae1f38 GOT: Fix demo detection entry not working
c0bfd761f4 GOT: Fix alignment of item display
6b0176fc5a GOT: Add LEVEL structure loading
36f0d5455b GOT: OPENBACK and STORYPIC aren't used by story view
c477386c96 GOT: Level background is now rendering
9f298f5d91 GOT: Add rendering of static objects
6fa83a28f9 GOT: In progress enemies loading
6b4ecbf61e GOT: More level setup
b6ea50837c GOT: Allow res_read calls to fail without error
75cf1fa6cf GOT: Startup fixes
3d5a5448fd GOT: Use the top-left corner of enemy frames as trans color
c8701c98d5 GOT: Added lots of files
1baf9b7d3e GOT: Fix rendering content view
dc6b1724ed GOT: Change key variables into an enum
1d11468a14 GOT: Encapsulate sd data as it's own class
848f9d104b GOT: Setting up sync methods for classes stored in savegames
54f629fc68 GOT: Adding console load command
8c99d99f0e GOT: Further savegame loading code
d6fd50bb7b GOT: Set correct starting level for each area
60daa62acc GOT: Added Select Game view
ce1ae1ac1c GOT: Adding once-per-frame checks
59ca89d57a GOT: Console command for setting magic
e2b7cbd035 GOT: Adding in script parser
7bf87ecabc GOT: Have key and action events set key_flags array
72a5b4c74c GOT: Hook s/l keys to the save/load dialogs
8a3a368532 GOT: Beginnings of select item dialog
fdba0a776d GOT: Finished Select Item dialog
26b26b2bba GOT: Change console load command to use Save file manager
59098c4eca GOT: Implement palette cycling animations
ad12b225d3 GOT: Fix Select Items dialog when inventory empty
4f1bc01563 GOT: Beginning to hook in movement code
4732098859 GOT: Hook in use_item call
dd3542fb14 GOT: Thor and enemy are moving!
881ed9983d GOT: Fix default keybindings
81ac36d5b5 GOT: Implement load_new_thor
95d55c84b4 GOT: Don't draw hammer when not in use
5491cdb7c1 GOT: Add proper decrementing of dead in unused actors
17dc5a72d2 GOT: Clean up constant arrays in script.cpp
d14c5bec8b GOT: Add support for script parser to be paused
d5e79f30e1 GOT: Adding Ask view for script-based queries
20873350f8 GOT: Added Say dialog
4591c4e432 GOT: Compilation fixes
01f7f63fbe GOT: Speed up gameplay to match original
8464712a9a GOT: Introducing a new mode field for GameContent view
1e3e70d53f GOT: Implement area transitions
aefa0ad18e GOT: Fix Thor being drawn twice during area transitions
4177952ff8 GOT: Move game mode enum/value into global vars
ba58536de0 GOT: Move the fire/select actions to Game view msgAction
b83e3abb0e GOT: Added Thor death animation
f2dd139e74 GOT: Hooking up savegame loading
a2b084b73d GOT: Fixes for savegame loading
0c28a0c324 GOT: Fix explosion/sparkle loading
2ceee45724 GOT: More global object loading fixes
13824811d0 GOT: Fix sparkles to appear where enemies die
b008c82d71 GOT: Fix Say dialog crash when talking to NPCs
f9877ec914 GOT: Fix console original save loading, add original save saving
b7d6a92058 GOT: Remove duplication of filenames in console save/load
44f5e0d652 GOT: Adding options dialogs, select option dialogs cleanup
cb53e9cbea GOT: Add Save Game prompt dialog for quitting to DOS/Title
c8476b51b7 GOT: Sound/music toggle dialogs
79986a4b71 GOT: Tweak game speed
18b9e7c512 GOT: Skeleton views for opening screens
8f22c27b67 GOT: Initial background for startup Splash Screen
ef8a39f695 GOT: Splash screen animation
dcbb227bde GOT: Initial fade in for splash screen
98e45ad524 GOT: Background for opening screen
2c3f580d03 GOT: Better decoding and rendering of opening background
9d9cb5a573 GOT: Opening title, sound, and escape action
c6d213fe49 GOT: Add simple shaking of opening screen
72812cccf0 GOT: Credits background
1d33418f24 GOT: Implemented credits view
dad8e86bd0 GOT: Escape key for Credits view
45041dab32 GOT: Title screens fixes
c62e25c658 GOT: Further startup title screen fixes
4e0d3d98b8 GOT: Include player name in ScummVM savegames
f4244049b2 GOT: Fading fixes for title screens
0a9270e051 GOT: Added cheat for infinite health/magic/jewels
297eeacc7f GOT: Change memcpy to C++ implicit copying
a29113c1be GOT: Remove dedundant defines
418a35b957 GOT: Implement loading enemy shot graphics loading
542f99ebc1 GOT: Remove deprecated latch_mem
880601cec1 GOT: Fix underground bats having the wrong transparency
d0b2e0fb84 GOT: Implement phased scene transitions
d32b028be4 GOT: Further fix showing sparkles at correct pos
1d49e2e091 GOT: Add Return as an alternate for SELECT action
f4fa535677 GOT: Be more permissive for loading than for saving
d82cc58cfc GOT: Callbacks for script ending
ff2e9c0a36 GOT: Fix add_health when Thor's health runs out
7ef9c60746 GOT: Tentative implementation of part 1 endgame
debfe267f0 GOT: Renaming fields of Script class
6ac4997178 GOT: Added level console command
a7e9e78cbc GOT: Startup/save fixes for demo mode
1454c1bba5 GOT: Startup cleanups for going in-game demo vs non-demo
7ee9ffb1b9 GOT: In progress demo mode automatic key injection
a72628e20c GOT: Fix loading savegames directly from launcher
cfd46d6a74 GOT: Fix crash getting enchanted apple
d5e3254e6e GOT: Magic keybinding fixes
15ee6c071d GOT: Cleanup of magic using apple
a0f7887884 GOT: Workaround for Ctrl+F5 triggering indefinite magic
ae0ecc47b4 GOT: Fix Say dialog handling ~ at very start of page
b00c03bd52 GOT: Better implementation of sprite transparency
0270df43b7 GOT: Only resume running scripts after ask/say fully closed
e39e3e9e12 GOT: Fix object_name field for loaded savegames
fd13b2175f GOT: Fix loading of enemy projectile graphics
c2a2b834fe GOT: Fix console freezing magic
d7fdfe6252 GOT: Throw lightning implemented
4a530c7e25 GOT: Fix saving yet again
8b2f503361 GOT: Fix under-run error in script parser
7ae8ce87ca GOT: Flying console command
ba1ee75b19 GOT: Hooking up boss 1 logic
7568cecd1a GOT: Fixes for area 1 closing sequence
071f33e1fb GOT: Ignore insta-kills if cheat invulnerability is on
56845f76e8 GOT: Fix returning to main menu from Quit Game dialog
c1c12926fc GOT: Add starting positions for part 2 & 3
0e33103ff6 GOT: Default magic spells for each area
d74625f69e GOT: Fix palette after GMM loading from splash screen
65053af633 GOT: Fix area for savegames in areas 2/3
d9e9836ec3 GOT: Parts 2 and 3 have full magic at the start
3082dab708 GOT: Implement wind power magic
ecfacdb482 GOT: Remove deprecated image mask buffers
acb2013a57 GOT: More magic disablement after using Ctrl+F5
38e6cb1d6a GOT: Kill Thor if spiked by a stake
74d7b65743 GOT: Only count room 59 as boss room for part 1
483257d9a0 GOT: Yet more can save fixes
c3228c293c GOT: Simplify scrn load/saving
7b9a9cf67d GOT: Loading, correct area must be set before sd_data loaded
146274c587 GOT: Implement part 2 slipping movement
496e01633f GOT: Added game-specific special tile logic
e8989c6845 GOT: Fix adding dynamic objects and displaying them
1c781daf9f GOT: Fix static object 0 not showing
1f953f85e1 GOT: Add boss 2 health bar
ff48ca3c7d GOT: Hooking up boss 2 logic
a4d02a1cbc GOT: Handle Bifrost ending the way the original did it
402eda6b16 GOT: Allow actions during boss 2 fight thunder
3316ff6daf GOT: Properly reset state variables when starting new area
cd42ea6fb7 GOT: Hooking up part 3 boss and game logic
b51f535e54 GOT: Implement shield magic
c6a99b4093 GOT: Fixes for getting arrested
81af9bd23d GOT: Implemented cmd_itemgive
e635d1e387 GOT: Add Loki shot patterns, pattern cleanups
3f7c7b4e19 GOT: Various endgame fixes
dde8d6d37b GOT: Fix improper copying of actors causing later crash
ea3845e87c GOT: Adding HighScores class
23bbaebbda GOT: Fixes for high scores insertion
69d6df5988 GOT: Add Load Game option to main menu
c16078f3bc GOT: Added high scores view, hooked it up
af6262443e GOT: Updated credits.pl
ec518d0488 GOT: Removed demo detection entry
c722dcfa62 GOT: Add parser for music data that dumps it out
c91e38ddb3 GOT: Janitorial
6ea2c5647f GOT: Create engine-data file for executable graphics
d443895448 GOT: Added got.gfx to engine_data.mk
1ad07f0b6a GOT: Cleanup of HighScores class
59abcd5176 GOT: Janitorial provided by eientei
93aadd42bc GOT: Detections provided by eientei
c06a08ea2f GOT: Clang fixes
9a09b66a9f GOT: More Clang fixes
dfa699d3dc GOT: Allow the splash screen frame count to vary
dc3e8055fb GOT: Cleaner implementation of bitflags & saving
7e77e80036 GOT: Change blitFrom to simpleBlitFrom
3593a2c8e9 GOT: Fixes for story display
a2bb5c89b2 GOT: Further fixes for Story display
3d62dedbc6 GOT: Remove unused file_size methods
dec0a1fa7f GOT: Rework high score defaults to avoid x64 build error
b9da852663 GOT: Preliminary fixes for demo mode
c96bf9840f GOT: Hide Demo main menu option for now
b3ef91d3b5 GOT: Create ACTOR::operator=
1ad616231a GOT: More x64 build warning fixes
b3564a1d74 GOT: Janitorial for script.cpp
860070f223 GOT: Further x64 warning fixes
fb2666a57a GOT: More x64 warning fixes
deff5a3137 GOT: Refactor Common::Array GfxPics to use raw array
d93bcf3c81 GOT: Fix blank lines at bottom of Story display
2b6d0ac7b9 GOT: Slightly increase the Part title timeout
2e578f8c83 GOT: Removed unneeded arrays, variables assigned to themselves
99302bd8e9 GOT: Reduce some variable scopes (CppCheck), enforce the use of boolean with play_sound()
0fd2b98620 GOT: Some more work on booleans in vars.h
d2639d4e72 GOT: more work n vars.h - Remove unused variables, more work on booleans
bcfabf0a62 GOT: remove REPEAT and IN_RANGE macros, remove unused #defines
064b42fde4 GOT: more work on CppCheck issues
08732af25a NEWS: Added God of Thunder support line
370c72e268 GOT: Some cleanup in move_patterns()
14df0afe1a GOT: modify access to global arrays in move and move_patterns to avoid formatting issues
a44be565ae GOT: Code formatting in move and move_patterns
807e103261 GOT: Some more cleanup in move and move_patterns
943918a029 GOT: Modify access to global arrays in back.cpp and boss1.cpp
b94e80a198 GOT: code formatting in back and boss1
b5299d123b GOT: remove extra semicolumn in boss1
364789718e GOT: Modify access to global arrays in boss2 and boss3
556d84cc8d GOT: Code formatting in boss2 and boss3
8f8269eb5f GOT: janitorial - remove extra semi-column in boss2 and boss3
844b41c577 GOT: some more small cleanups in boss 2 and boss3
07e3aaa20a GOT: Modify access to global arrays in init, main and object
9cd3af680a GOT: Code formatting in init, main and object
e334ef6c76 GOT: add a comment in object, small cleanup
8ee0a057b1 GOT: remove useless "else" checks in object
9bbfd746df GOT: modify access to global arrays in 3 more source files
c9c9f22705 GOT: Code formatting in script, shot_movement, shot_pattern and special_tile
f02b714768 GOT: Join declaration and assignment when possible in script, shot_movement and shot_pattern


Commit: 0ed1caeb15d8a88fca75bf0c454364115c8e60e3
    https://github.com/scummvm/scummvm/commit/0ed1caeb15d8a88fca75bf0c454364115c8e60e3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Skeleton engine

Changed paths:
  A engines/got/POTFILES
  A engines/got/configure.engine
  A engines/got/console.cpp
  A engines/got/console.h
  A engines/got/credits.pl
  A engines/got/detection.cpp
  A engines/got/detection.h
  A engines/got/detection_tables.h
  A engines/got/events.cpp
  A engines/got/events.h
  A engines/got/got.cpp
  A engines/got/got.h
  A engines/got/messages.cpp
  A engines/got/messages.h
  A engines/got/metaengine.cpp
  A engines/got/metaengine.h
  A engines/got/module.mk
  A engines/got/view.cpp
  A engines/got/view.h
  A engines/got/view1.cpp
  A engines/got/view1.h
  A engines/got/views.h


diff --git a/engines/got/POTFILES b/engines/got/POTFILES
new file mode 100644
index 00000000000..f7765bbd556
--- /dev/null
+++ b/engines/got/POTFILES
@@ -0,0 +1 @@
+engines/got/metaengine.cpp
diff --git a/engines/got/configure.engine b/engines/got/configure.engine
new file mode 100644
index 00000000000..201f55bae58
--- /dev/null
+++ b/engines/got/configure.engine
@@ -0,0 +1,3 @@
+# This file is included from the main "configure" script
+# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
+add_engine got "Got" no "" "" ""
diff --git a/engines/got/console.cpp b/engines/got/console.cpp
new file mode 100644
index 00000000000..d3fbc3652bd
--- /dev/null
+++ b/engines/got/console.cpp
@@ -0,0 +1,38 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/console.h"
+
+namespace Got {
+
+Console::Console() : GUI::Debugger() {
+	registerCmd("test",   WRAP_METHOD(Console, Cmd_test));
+}
+
+Console::~Console() {
+}
+
+bool Console::Cmd_test(int argc, const char **argv) {
+	debugPrintf("Test\n");
+	return true;
+}
+
+} // End of namespace Got
diff --git a/engines/got/console.h b/engines/got/console.h
new file mode 100644
index 00000000000..057c0ed5535
--- /dev/null
+++ b/engines/got/console.h
@@ -0,0 +1,40 @@
+
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_CONSOLE_H
+#define GOT_CONSOLE_H
+
+#include "gui/debugger.h"
+
+namespace Got {
+
+class Console : public GUI::Debugger {
+private:
+	bool Cmd_test(int argc, const char **argv);
+public:
+	Console();
+	~Console() override;
+};
+
+} // End of namespace Got
+
+#endif // GOT_CONSOLE_H
diff --git a/engines/got/credits.pl b/engines/got/credits.pl
new file mode 100644
index 00000000000..ca1868df67e
--- /dev/null
+++ b/engines/got/credits.pl
@@ -0,0 +1,3 @@
+begin_section("Got");
+	add_person("Name 1", "Handle 1", "");
+end_section();
diff --git a/engines/got/detection.cpp b/engines/got/detection.cpp
new file mode 100644
index 00000000000..20d69f6e50f
--- /dev/null
+++ b/engines/got/detection.cpp
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "base/plugins.h"
+#include "common/config-manager.h"
+#include "common/file.h"
+#include "common/md5.h"
+#include "common/str-array.h"
+#include "common/translation.h"
+#include "common/util.h"
+#include "got/detection.h"
+#include "got/detection_tables.h"
+
+const DebugChannelDef GotMetaEngineDetection::debugFlagList[] = {
+	{ Got::kDebugGraphics, "Graphics", "Graphics debug level" },
+	{ Got::kDebugPath, "Path", "Pathfinding debug level" },
+	{ Got::kDebugFilePath, "FilePath", "File path debug level" },
+	{ Got::kDebugScan, "Scan", "Scan for unrecognised games" },
+	{ Got::kDebugScript, "Script", "Enable debug script dump" },
+	DEBUG_CHANNEL_END
+};
+
+GotMetaEngineDetection::GotMetaEngineDetection() : AdvancedMetaEngineDetection(
+	Got::gameDescriptions, Got::gotGames) {
+}
+
+REGISTER_PLUGIN_STATIC(GOT_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, GotMetaEngineDetection);
diff --git a/engines/got/detection.h b/engines/got/detection.h
new file mode 100644
index 00000000000..b9238d19804
--- /dev/null
+++ b/engines/got/detection.h
@@ -0,0 +1,69 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_DETECTION_H
+#define GOT_DETECTION_H
+
+#include "engines/advancedDetector.h"
+
+namespace Got {
+
+enum GotDebugChannels {
+	kDebugGraphics = 1,
+	kDebugPath,
+	kDebugScan,
+	kDebugFilePath,
+	kDebugScript,
+};
+
+extern const PlainGameDescriptor gotGames[];
+
+extern const ADGameDescription gameDescriptions[];
+
+#define GAMEOPTION_ORIGINAL_SAVELOAD GUIO_GAMEOPTIONS1
+
+} // End of namespace Got
+
+class GotMetaEngineDetection : public AdvancedMetaEngineDetection<ADGameDescription> {
+	static const DebugChannelDef debugFlagList[];
+
+public:
+	GotMetaEngineDetection();
+	~GotMetaEngineDetection() override {}
+
+	const char *getName() const override {
+		return "got";
+	}
+
+	const char *getEngineName() const override {
+		return "Got";
+	}
+
+	const char *getOriginalCopyright() const override {
+		return "Got (C)";
+	}
+
+	const DebugChannelDef *getDebugChannels() const override {
+		return debugFlagList;
+	}
+};
+
+#endif // GOT_DETECTION_H
diff --git a/engines/got/detection_tables.h b/engines/got/detection_tables.h
new file mode 100644
index 00000000000..26f57538719
--- /dev/null
+++ b/engines/got/detection_tables.h
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Got {
+
+const PlainGameDescriptor gotGames[] = {
+	{ "got", "God of Thunder" },
+	{ 0, 0 }
+};
+
+const ADGameDescription gameDescriptions[] = {
+	{
+		"got",
+		nullptr,
+		AD_ENTRY1s("gotres.dat", "747ed508ffa3808156a4eb080e9859f8", 739710),
+		Common::EN_ANY,
+		Common::kPlatformDOS,
+		ADGF_UNSTABLE,
+		GUIO1(GUIO_NONE)
+	},
+
+	AD_TABLE_END_MARKER
+};
+
+} // End of namespace Got
diff --git a/engines/got/events.cpp b/engines/got/events.cpp
new file mode 100644
index 00000000000..a1194d4d630
--- /dev/null
+++ b/engines/got/events.cpp
@@ -0,0 +1,344 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/config-manager.h"
+#include "graphics/screen.h"
+#include "got/events.h"
+#include "got/got.h"
+#include "got/views.h"
+
+namespace Got {
+
+Events *g_events;
+
+Events::Events() : UIElement("Root", nullptr) {
+	g_events = this;
+}
+
+Events::~Events() {
+	g_events = nullptr;
+}
+
+void Events::runGame() {
+	uint currTime, nextFrameTime = 0;
+	_screen = new Graphics::Screen();
+	Views views;	// Loads all views in the structure
+
+	// Run the game
+	int saveSlot = ConfMan.getInt("save_slot");
+	if (saveSlot != -1)
+		g_engine->loadGameState(saveSlot);
+
+	addView("View1");
+
+	Common::Event e;
+	while (!_views.empty() && !shouldQuit()) {
+		while (g_system->getEventManager()->pollEvent(e)) {
+			if (e.type == Common::EVENT_QUIT ||
+					e.type == Common::EVENT_RETURN_TO_LAUNCHER) {
+				_views.clear();
+				break;
+			} else {
+				processEvent(e);
+			}
+		}
+
+		if (_views.empty())
+			break;
+
+		g_system->delayMillis(10);
+		if ((currTime = g_system->getMillis()) >= nextFrameTime) {
+			nextFrameTime = currTime + FRAME_DELAY;
+			tick();
+			drawElements();
+			_screen->update();
+		}
+	}
+
+	delete _screen;
+}
+
+void Events::processEvent(Common::Event &ev) {
+	switch (ev.type) {
+	case Common::EVENT_KEYDOWN:
+		if (ev.kbd.keycode < Common::KEYCODE_NUMLOCK)
+			msgKeypress(KeypressMessage(ev.kbd));
+		break;
+	case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+		msgAction(ActionMessage(ev.customType));
+		break;
+	case Common::EVENT_LBUTTONDOWN:
+	case Common::EVENT_RBUTTONDOWN:
+	case Common::EVENT_MBUTTONDOWN:
+		msgMouseDown(MouseDownMessage(ev.type, ev.mouse));
+		break;
+	case Common::EVENT_LBUTTONUP:
+	case Common::EVENT_RBUTTONUP:
+	case Common::EVENT_MBUTTONUP:
+		msgMouseUp(MouseUpMessage(ev.type, ev.mouse));
+		break;
+	case Common::EVENT_MOUSEMOVE:
+		msgMouseMove(MouseMoveMessage(ev.type, ev.mouse));
+		break;
+	default:
+		break;
+	}
+}
+
+void Events::replaceView(UIElement *ui, bool replaceAllViews) {
+	assert(ui);
+	UIElement *priorView = focusedView();
+
+	if (replaceAllViews) {
+		clearViews();
+
+	} else if (!_views.empty()) {
+		priorView->msgUnfocus(UnfocusMessage());
+		_views.pop();
+	}
+
+	_views.push(ui);
+	ui->redraw();
+	ui->msgFocus(FocusMessage(priorView));
+}
+
+void Events::replaceView(const Common::String &name, bool replaceAllViews) {
+	replaceView(findView(name));
+}
+
+void Events::addView(UIElement *ui) {
+	assert(ui);
+	UIElement *priorView = focusedView();
+
+	if (!_views.empty())
+		priorView->msgUnfocus(UnfocusMessage());
+
+	_views.push(ui);
+	ui->redraw();
+	ui->msgFocus(FocusMessage(priorView));
+}
+
+void Events::addView(const Common::String &name) {
+	addView(findView(name));
+}
+
+void Events::popView() {
+	UIElement *priorView = focusedView();
+	priorView->msgUnfocus(UnfocusMessage());
+	_views.pop();
+
+	for (int i = 0; i < (int)_views.size() - 1; ++i) {
+		_views[i]->redraw();
+		_views[i]->draw();
+	}
+
+	if (!_views.empty()) {
+		UIElement *view = focusedView();
+		view->msgFocus(FocusMessage(priorView));
+		view->redraw();
+		view->draw();
+	}
+}
+
+void Events::redrawViews() {
+	for (uint i = 0; i < _views.size(); ++i) {
+		_views[i]->redraw();
+		_views[i]->draw();
+	}
+}
+
+bool Events::isPresent(const Common::String &name) const {
+	for (uint i = 0; i < _views.size(); ++i) {
+		if (_views[i]->_name == name)
+			return true;
+	}
+
+	return false;
+}
+
+void Events::clearViews() {
+	if (!_views.empty())
+		focusedView()->msgUnfocus(UnfocusMessage());
+
+	_views.clear();
+}
+
+void Events::addKeypress(const Common::KeyCode kc) {
+	Common::KeyState ks;
+	ks.keycode = kc;
+	if (kc >= Common::KEYCODE_SPACE && kc <= Common::KEYCODE_TILDE)
+		ks.ascii = kc;
+
+	focusedView()->msgKeypress(KeypressMessage(ks));
+}
+
+/*------------------------------------------------------------------------*/
+
+Bounds::Bounds(Common::Rect &innerBounds) :
+		_bounds(0, 0, 320, 200),
+		_innerBounds(innerBounds),
+		left(_bounds.left), top(_bounds.top),
+		right(_bounds.right), bottom(_bounds.bottom) {
+}
+
+Bounds &Bounds::operator=(const Common::Rect &r) {
+	_bounds = r;
+	_innerBounds = r;
+	_innerBounds.grow(-_borderSize);
+	return *this;
+}
+
+void Bounds::setBorderSize(size_t borderSize) {
+	_borderSize = borderSize;
+	_innerBounds = *this;
+	_innerBounds.grow(-_borderSize);
+}
+
+/*------------------------------------------------------------------------*/
+
+UIElement::UIElement(const Common::String &name) :
+		_name(name), _parent(g_engine), _bounds(_innerBounds) {
+	g_engine->_children.push_back(this);
+}
+
+UIElement::UIElement(const Common::String &name, UIElement *uiParent) :
+		_name(name), _parent(uiParent),
+		_bounds(_innerBounds) {
+	if (_parent)
+		_parent->_children.push_back(this);
+}
+
+void UIElement::redraw() {
+	_needsRedraw = true;
+
+	for (size_t i = 0; i < _children.size(); ++i)
+		_children[i]->redraw();
+}
+
+void UIElement::drawElements() {
+	if (_needsRedraw) {
+		draw();
+		_needsRedraw = false;
+	}
+
+	for (size_t i = 0; i < _children.size(); ++i)
+		_children[i]->drawElements();
+}
+
+UIElement *UIElement::findViewGlobally(const Common::String &name) {
+	return g_events->findView(name);
+}
+
+void UIElement::focus() {
+	g_events->replaceView(this);
+}
+
+void UIElement::close() {
+	assert(g_events->focusedView() == this);
+	g_events->popView();
+}
+
+bool UIElement::isFocused() const {
+	return g_events->focusedView() == this;
+}
+
+void UIElement::clearSurface() {
+	Graphics::ManagedSurface s = getSurface();
+	s.fillRect(Common::Rect(s.w, s.h), 0);
+}
+
+void UIElement::draw() {
+	for (size_t i = 0; i < _children.size(); ++i) {
+		_children[i]->draw();
+	}
+}
+
+bool UIElement::tick() {
+	if (_timeoutCtr && --_timeoutCtr == 0) {
+		timeout();
+	}
+
+	for (size_t i = 0; i < _children.size(); ++i) {
+		if (_children[i]->tick())
+			return true;
+	}
+
+	return false;
+}
+
+UIElement *UIElement::findView(const Common::String &name) {
+	if (_name.equalsIgnoreCase(name))
+		return this;
+
+	UIElement *result;
+	for (size_t i = 0; i < _children.size(); ++i) {
+		if ((result = _children[i]->findView(name)) != nullptr)
+			return result;
+	}
+
+	return nullptr;
+}
+
+void UIElement::replaceView(UIElement *ui, bool replaceAllViews) {
+	g_events->replaceView(ui, replaceAllViews);
+}
+
+void UIElement::replaceView(const Common::String &name, bool replaceAllViews) {
+	g_events->replaceView(name, replaceAllViews);
+}
+
+void UIElement::addView(UIElement *ui) {
+	g_events->addView(ui);
+}
+
+void UIElement::addView(const Common::String &name) {
+	g_events->addView(name);
+}
+
+void UIElement::addView() {
+	g_events->addView(this);
+}
+
+Graphics::ManagedSurface UIElement::getSurface() const {
+	return Graphics::ManagedSurface(*g_events->getScreen(), _bounds);
+}
+
+int UIElement::getRandomNumber(int minNumber, int maxNumber) {
+	return g_engine->getRandomNumber(maxNumber - minNumber + 1) + minNumber;
+}
+
+int UIElement::getRandomNumber(int maxNumber) {
+	return g_engine->getRandomNumber(maxNumber);
+}
+
+void UIElement::delaySeconds(uint seconds) {
+	_timeoutCtr = seconds * FRAME_RATE;
+}
+
+void UIElement::delayFrames(uint frames) {
+	_timeoutCtr = frames;
+}
+
+void UIElement::timeout() {
+	redraw();
+}
+
+} // namespace Got
diff --git a/engines/got/events.h b/engines/got/events.h
new file mode 100644
index 00000000000..4b75805c1ba
--- /dev/null
+++ b/engines/got/events.h
@@ -0,0 +1,397 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_EVENTS_H
+#define GOT_EVENTS_H
+
+#include "common/array.h"
+#include "common/stack.h"
+#include "graphics/screen.h"
+#include "got/messages.h"
+
+namespace Got {
+
+#define FRAME_RATE 20
+#define FRAME_DELAY (1000 / FRAME_RATE)
+
+class Events;
+
+/**
+ * Implements a thunk layer around an element's bounds,
+ * allowing access to it as if it were a simple Common::Rect,
+ * but any changes to it will also be applied to a linked inner bounds
+ */
+struct Bounds {
+private:
+	Common::Rect _bounds;
+	Common::Rect &_innerBounds;
+	int _borderSize = 0;
+public:
+	const int16 &left;
+	const int16 ⊤
+	const int16 &right;
+	const int16 ⊥
+public:
+	Bounds(Common::Rect &innerBounds);
+	operator const Common::Rect &() const { return _bounds; }
+	Bounds &operator=(const Common::Rect &r);
+	void setBorderSize(size_t borderSize);
+	size_t borderSize() const { return _borderSize; }
+	int16 width() const { return _bounds.width(); }
+	int16 height() const { return _bounds.height(); }
+};
+
+/**
+ * User interface element
+ */
+class UIElement {
+	friend class Events;
+private:
+	int _timeoutCtr = 0;
+protected:
+	UIElement *_parent;
+	Common::Array<UIElement *> _children;
+	Common::Rect _innerBounds;
+	Bounds _bounds;
+	bool _needsRedraw = true;
+	Common::String _name;
+protected:
+	/**
+	 * Set a delay countdown in seconds, after which timeout() is called
+	 */
+	void delaySeconds(uint seconds);
+
+	/**
+	 * Set a delay countdown in frames, after which timeout() is called
+	 */
+	void delayFrames(uint frames);
+
+	/**
+	 * Returns true if a delay is active
+	 */
+	bool isDelayActive() const {
+		return _timeoutCtr != 0;
+	}
+
+	/**
+	 * Cancels any active delay
+	 */
+	void cancelDelay() {
+		_timeoutCtr = 0;
+	}
+
+	/**
+	 * Called when an active timeout countdown expired
+	 */
+	virtual void timeout();
+
+private:
+	/**
+	 * Outer method for doing drawing
+	 *
+	 */
+	void drawElements();
+
+	/**
+	 * Finds a view globally
+	 */
+	static UIElement *findViewGlobally(const Common::String &name);
+public:
+	UIElement(const Common::String &name, UIElement *uiParent);
+	UIElement(const Common::String &name);
+	virtual ~UIElement() {}
+
+	/**
+	 * Returns true if the elements needs to be redrawn
+	 */
+	bool needsRedraw() const { return _needsRedraw; }
+
+	/**
+	 * Sets that the element needs to be redrawn
+	 */
+	void redraw();
+
+	/**
+	 * Focuses the element as the current view
+	 */
+	void focus();
+
+	/**
+	 * Closes the current view. The view must have been added
+	 * via addView, so there's a remaining view afterwards
+	 */
+	virtual void close();
+
+	/*
+	 * Returns true if the view is focused
+	 */
+	bool isFocused() const;
+
+	/**
+	 * Sets the focus to a new view
+	 */
+	void replaceView(UIElement *ui, bool replaceAllViews = false);
+	void replaceView(const Common::String &name, bool replaceAllViews = false);
+
+	/**
+	 * Adds a focused view to the view stack without replacing current one
+	 */
+	void addView(UIElement *ui);
+	void addView(const Common::String &name);
+	void addView();
+	void open() { addView(); }
+
+	/**
+	 * Returns a random number
+	 */
+	int getRandomNumber(int minNumber, int maxNumber);
+	int getRandomNumber(int maxNumber);
+
+	/**
+	 * Sets the element's bounds
+	 */
+	virtual void setBounds(const Common::Rect &r) {
+		_bounds = r;
+	}
+
+	/**
+	 * Gets the element's bounds
+	 */
+	Common::Rect getBounds() const {
+		return _bounds;
+	}
+
+	/**
+	 * Returns a surface for drawing the element
+	 */
+	Graphics::ManagedSurface getSurface() const;
+
+	/**
+	 * Clear the surface
+	 */
+	virtual void clearSurface();
+
+	/**
+	 * Draws the element
+	 */
+	virtual void draw();
+
+	/**
+	 * Called for game frame ticks
+	 */
+	virtual bool tick();
+
+	/**
+	 * Find a view by name
+	 */
+	virtual UIElement *findView(const Common::String &name);
+
+	/**
+	 * Handles events
+	 */
+	// Mouse move only has a minimal implementation for performance reasons
+protected:
+	virtual bool msgMouseMove(const MouseMoveMessage &msg) { return false; }
+public:
+	bool send(const MouseMoveMessage &msg) { return msgMouseMove(msg); }
+
+	#define MESSAGE(NAME) \
+	protected: \
+		virtual bool msg##NAME(const NAME##Message &e) { \
+			for (Common::Array<UIElement *>::iterator it = _children.begin(); \
+					it != _children.end(); ++it) { \
+				if ((*it)->msg##NAME(e)) return true; \
+			} \
+			return false; \
+		} \
+	public: \
+		bool send(const Common::String &viewName, const NAME##Message &msg) { \
+			UIElement *view = UIElement::findViewGlobally(viewName); \
+			assert(view); \
+			return view->msg##NAME(msg); \
+		} \
+		bool send(const NAME##Message &msg) { \
+			return msg##NAME(msg); \
+		} \
+
+	MESSAGE(Focus);
+	MESSAGE(Unfocus);
+	MESSAGE(MouseEnter);
+	MESSAGE(MouseLeave);
+	MESSAGE(Keypress);
+	MESSAGE(MouseDown);
+	MESSAGE(MouseUp);
+	MESSAGE(Action);
+	MESSAGE(Game);
+	MESSAGE(Value);
+	#undef MESSAGE
+};
+
+/**
+ * Main events and view manager. This is kept separate from the engine
+ * class because the engine may add a lot of globals and bring in other
+ * classes. So to save on compilation time, classes that only need to
+ * access basic view management methods like addView or replaceView
+ * only need to include events.h rather than the whole engine.
+ */
+class Events : public UIElement {
+private:
+	Graphics::Screen *_screen = nullptr;
+	Common::Stack<UIElement *> _views;
+protected:
+	/**
+	 * Process an event
+	 */
+	void processEvent(Common::Event &ev);
+
+	/**
+	 * Returns true if the game should quit
+	 */
+	virtual bool shouldQuit() const = 0;
+
+	/**
+	 * Overrides events we want to only go to the focused view
+	 */
+	#define MESSAGE(NAME) \
+		bool msg##NAME(const NAME##Message &e) override { \
+			return !_views.empty() ? focusedView()->msg##NAME(e) : false; \
+		}
+	MESSAGE(Action);
+	MESSAGE(Focus);
+	MESSAGE(Unfocus);
+	MESSAGE(MouseEnter);
+	MESSAGE(MouseLeave);
+	MESSAGE(Keypress);
+	MESSAGE(MouseDown);
+	MESSAGE(MouseUp);
+	MESSAGE(MouseMove);
+	#undef MESSAGE
+public:
+	Events();
+	virtual ~Events();
+
+	/**
+	 * Main game loop
+	 */
+	void runGame();
+
+	/**
+	 * Sets the focus to a new view
+	 */
+	void replaceView(UIElement *ui, bool replaceAllViews = false);
+	void replaceView(const Common::String &name, bool replaceAllViews = false);
+
+	/**
+	 * Adds a focused view to the view stack without replacing current one
+	 */
+	void addView(UIElement *ui);
+	void addView(const Common::String &name);
+
+	/**
+	 * Clears the view list
+	 */
+	void clearViews();
+
+	/**
+	 * Pops a view from the view stack
+	 */
+	void popView();
+
+	/**
+	 * Redraws the views in order. This is used in rare cases
+	 * where a view draws outside it's defined area, and needs
+	 * to restore whether the background was before
+	 */
+	void redrawViews();
+
+	/**
+	 * Returns the currently focused view, if any
+	 */
+	UIElement *focusedView() const {
+		return _views.empty() ? nullptr : _views.top();
+	}
+
+	/**
+	 * Returns the view prior to the current view, if any
+	 */
+	UIElement *priorView() const {
+		return _views.size() < 2 ? nullptr :
+			_views[_views.size() - 2];
+	}
+
+	/**
+	 * Returns true if a view of a given name is present
+	 * at all in the visible view stack
+	 */
+	bool isPresent(const Common::String &name) const;
+
+	/**
+	 * Returns true if combat is active
+	 */
+	bool isInCombat() const {
+		return isPresent("Combat");
+	}
+
+	/**
+	 * Returns the underlying screen
+	 */
+	Graphics::Screen *getScreen() const {
+		return _screen;
+	}
+
+	/**
+	 * Draws the focused view
+	 */
+	void drawElements() {
+		if (!_views.empty())
+			focusedView()->drawElements();
+	}
+
+	/**
+	 * Add a keypress to the event queue
+	 */
+	void addKeypress(const Common::KeyCode kc);
+
+	/**
+	 * Events manager doesn't have any intrinsic drawing
+	 */
+	void draw() override {}
+
+	/**
+	 * Called once every game frame
+	 */
+	bool tick() override {
+		return !_views.empty() ? focusedView()->tick() : false;
+	}
+
+	/**
+	 * Calling the close method for g_events closes the active view
+	 */
+	void close() override {
+		focusedView()->close();
+	}
+};
+
+extern Events *g_events;
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
new file mode 100644
index 00000000000..18153873db6
--- /dev/null
+++ b/engines/got/got.cpp
@@ -0,0 +1,76 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/got.h"
+#include "got/detection.h"
+#include "got/console.h"
+#include "common/scummsys.h"
+#include "common/config-manager.h"
+#include "common/debug-channels.h"
+#include "common/events.h"
+#include "common/system.h"
+#include "engines/util.h"
+#include "graphics/paletteman.h"
+
+namespace Got {
+
+GotEngine *g_engine;
+
+GotEngine::GotEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst),
+	_gameDescription(gameDesc), _randomSource("Got") {
+	g_engine = this;
+}
+
+GotEngine::~GotEngine() {
+}
+
+uint32 GotEngine::getFeatures() const {
+	return _gameDescription->flags;
+}
+
+Common::String GotEngine::getGameId() const {
+	return _gameDescription->gameId;
+}
+
+Common::Error GotEngine::run() {
+	// Initialize 320x200 paletted graphics mode
+	initGraphics(320, 200);
+
+	// Set the engine's debugger console
+	setDebugger(new Console());
+
+	runGame();
+
+	return Common::kNoError;
+}
+
+Common::Error GotEngine::syncGame(Common::Serializer &s) {
+	// The Serializer has methods isLoading() and isSaving()
+	// if you need to specific steps; for example setting
+	// an array size after reading it's length, whereas
+	// for saving it would write the existing array's length
+	int dummy = 0;
+	s.syncAsUint32LE(dummy);
+
+	return Common::kNoError;
+}
+
+} // End of namespace Got
diff --git a/engines/got/got.h b/engines/got/got.h
new file mode 100644
index 00000000000..16fe0d867b2
--- /dev/null
+++ b/engines/got/got.h
@@ -0,0 +1,112 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_H
+#define GOT_H
+
+#include "common/scummsys.h"
+#include "common/system.h"
+#include "common/error.h"
+#include "common/fs.h"
+#include "common/hash-str.h"
+#include "common/random.h"
+#include "common/serializer.h"
+#include "common/util.h"
+#include "engines/engine.h"
+#include "engines/savestate.h"
+#include "graphics/screen.h"
+
+#include "got/detection.h"
+#include "got/events.h"
+
+namespace Got {
+
+struct GotGameDescription;
+
+class GotEngine : public Engine, public Events {
+private:
+	const ADGameDescription *_gameDescription;
+	Common::RandomSource _randomSource;
+protected:
+	// Engine APIs
+	Common::Error run() override;
+
+	/**
+	 * Returns true if the game should quit
+	 */
+	bool shouldQuit() const override {
+		return Engine::shouldQuit();
+	}
+
+public:
+	GotEngine(OSystem *syst, const ADGameDescription *gameDesc);
+	~GotEngine() override;
+
+	uint32 getFeatures() const;
+
+	/**
+	 * Returns the game Id
+	 */
+	Common::String getGameId() const;
+
+	/**
+	 * Gets a random number
+	 */
+	uint32 getRandomNumber(uint maxNum) {
+		return _randomSource.getRandomNumber(maxNum);
+	}
+
+	bool hasFeature(EngineFeature f) const override {
+		return
+		    (f == kSupportsLoadingDuringRuntime) ||
+		    (f == kSupportsSavingDuringRuntime) ||
+		    (f == kSupportsReturnToLauncher);
+	};
+
+	bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override {
+		return true;
+	}
+	bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override {
+		return true;
+	}
+
+	/**
+	 * Uses a serializer to allow implementing savegame
+	 * loading and saving using a single method
+	 */
+	Common::Error syncGame(Common::Serializer &s);
+
+	Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override {
+		Common::Serializer s(nullptr, stream);
+		return syncGame(s);
+	}
+	Common::Error loadGameStream(Common::SeekableReadStream *stream) override {
+		Common::Serializer s(stream, nullptr);
+		return syncGame(s);
+	}
+};
+
+extern GotEngine *g_engine;
+#define SHOULD_QUIT ::Got::g_engine->shouldQuit()
+
+} // End of namespace Got
+
+#endif // GOT_H
diff --git a/engines/got/messages.cpp b/engines/got/messages.cpp
new file mode 100644
index 00000000000..c0a3e914b91
--- /dev/null
+++ b/engines/got/messages.cpp
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/messages.h"
+
+namespace Got {
+
+MouseMessage::MouseMessage(Common::EventType type,
+		const Common::Point &pos) : Message(), _pos(pos) {
+	switch (type) {
+	case Common::EVENT_RBUTTONDOWN:
+	case Common::EVENT_RBUTTONUP:
+		_button = MB_RIGHT;
+		break;
+	case Common::EVENT_MBUTTONDOWN:
+	case Common::EVENT_MBUTTONUP:
+		_button = MB_MIDDLE;
+		break;
+	default:
+		_button = MB_LEFT;
+		break;
+	}
+}
+
+} // namespace Got
diff --git a/engines/got/messages.h b/engines/got/messages.h
new file mode 100644
index 00000000000..3982679c4a2
--- /dev/null
+++ b/engines/got/messages.h
@@ -0,0 +1,111 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_MESSAGES_H
+#define GOT_MESSAGES_H
+
+#include "common/array.h"
+#include "common/events.h"
+#include "common/str.h"
+
+namespace Got {
+
+class UIElement;
+
+struct Message {};
+
+struct FocusMessage : public Message {
+	UIElement *_priorView = nullptr;
+	FocusMessage() : Message() {}
+	FocusMessage(UIElement *priorView) : Message(),
+		_priorView(priorView) {}
+};
+
+struct UnfocusMessage : public Message {};
+struct MouseEnterMessage : public Message {};
+struct MouseLeaveMessage : public Message {};
+
+struct KeypressMessage : public Message, public Common::KeyState {
+	KeypressMessage() : Message() {}
+	KeypressMessage(const Common::KeyState &ks) :
+		Message(), Common::KeyState(ks) {}
+};
+
+struct MouseMessage : public Message {
+	enum Button { MB_LEFT, MB_RIGHT, MB_MIDDLE };
+	Button _button;
+	Common::Point _pos;
+
+	MouseMessage() : Message(), _button(MB_LEFT) {}
+	MouseMessage(Button btn, const Common::Point &pos) :
+		Message(), _button(btn), _pos(pos) {}
+	MouseMessage(Common::EventType type, const Common::Point &pos);
+};
+struct MouseDownMessage : public MouseMessage {
+	MouseDownMessage() : MouseMessage() {}
+	MouseDownMessage(Button btn, const Common::Point &pos) :
+		MouseMessage(btn, pos) {}
+	MouseDownMessage(Common::EventType type, const Common::Point &pos) :
+		MouseMessage(type, pos) {}
+};
+struct MouseUpMessage : public MouseMessage {
+	MouseUpMessage() : MouseMessage() {}
+	MouseUpMessage(Button btn, const Common::Point &pos) :
+		MouseMessage(btn, pos) {}
+	MouseUpMessage(Common::EventType type, const Common::Point &pos) :
+		MouseMessage(type, pos) {}
+};
+typedef MouseMessage MouseMoveMessage;
+
+struct GameMessage : public Message {
+	Common::String _name;
+	int _value;
+	Common::String _stringValue;
+
+	GameMessage() : Message(), _value(-1) {}
+	GameMessage(const Common::String &name) : Message(),
+		_name(name), _value(-1) {}
+	GameMessage(const Common::String &name, int value) : Message(),
+		_name(name), _value(value) {}
+	GameMessage(const Common::String &name, const Common::String &value) :
+		Message(), _name(name), _stringValue(value) {}
+};
+
+struct ValueMessage : public Message {
+	int _value;
+
+	ValueMessage() : Message(), _value(0) {}
+	ValueMessage(int value) : Message(),
+		_value(value) {}
+};
+
+struct ActionMessage : public Message {
+	int _action;
+	ActionMessage() : Message(), _action(0) {
+	}
+	ActionMessage(int action) : Message(),
+		_action(action) {
+	}
+};
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/metaengine.cpp b/engines/got/metaengine.cpp
new file mode 100644
index 00000000000..a63a96e3459
--- /dev/null
+++ b/engines/got/metaengine.cpp
@@ -0,0 +1,69 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/translation.h"
+
+#include "got/metaengine.h"
+#include "got/detection.h"
+#include "got/got.h"
+
+namespace Got {
+
+static const ADExtraGuiOptionsMap optionsList[] = {
+	{
+		GAMEOPTION_ORIGINAL_SAVELOAD,
+		{
+			_s("Use original save/load screens"),
+			_s("Use the original save/load screens instead of the ScummVM ones"),
+			"original_menus",
+			false,
+			0,
+			0
+		}
+	},
+	AD_EXTRA_GUI_OPTIONS_TERMINATOR
+};
+
+} // End of namespace Got
+
+const char *GotMetaEngine::getName() const {
+	return "got";
+}
+
+const ADExtraGuiOptionsMap *GotMetaEngine::getAdvancedExtraGuiOptions() const {
+	return Got::optionsList;
+}
+
+Common::Error GotMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+	*engine = new Got::GotEngine(syst, desc);
+	return Common::kNoError;
+}
+
+bool GotMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return checkExtendedSaves(f) ||
+		(f == kSupportsLoadingDuringStartup);
+}
+
+#if PLUGIN_ENABLED_DYNAMIC(GOT)
+REGISTER_PLUGIN_DYNAMIC(GOT, PLUGIN_TYPE_ENGINE, GotMetaEngine);
+#else
+REGISTER_PLUGIN_STATIC(GOT, PLUGIN_TYPE_ENGINE, GotMetaEngine);
+#endif
diff --git a/engines/got/metaengine.h b/engines/got/metaengine.h
new file mode 100644
index 00000000000..8422c6527ff
--- /dev/null
+++ b/engines/got/metaengine.h
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_METAENGINE_H
+#define GOT_METAENGINE_H
+
+#include "engines/advancedDetector.h"
+
+class GotMetaEngine : public AdvancedMetaEngine<ADGameDescription> {
+public:
+	const char *getName() const override;
+
+	Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
+
+	/**
+	 * Determine whether the engine supports the specified MetaEngine feature.
+	 *
+	 * Used by e.g. the launcher to determine whether to enable the Load button.
+	 */
+	bool hasFeature(MetaEngineFeature f) const override;
+
+	const ADExtraGuiOptionsMap *getAdvancedExtraGuiOptions() const override;
+};
+
+#endif // GOT_METAENGINE_H
diff --git a/engines/got/module.mk b/engines/got/module.mk
new file mode 100644
index 00000000000..28f85ed60b9
--- /dev/null
+++ b/engines/got/module.mk
@@ -0,0 +1,21 @@
+MODULE := engines/got
+
+MODULE_OBJS = \
+	got.o \
+	console.o \
+	events.o \
+	messages.o \
+	metaengine.o \
+	view.o \
+	view1.o
+
+# This module can be built as a plugin
+ifeq ($(ENABLE_GOT), DYNAMIC_PLUGIN)
+PLUGIN := 1
+endif
+
+# Include common rules
+include $(srcdir)/rules.mk
+
+# Detection objects
+DETECT_OBJS += $(MODULE)/detection.o
diff --git a/engines/got/view.cpp b/engines/got/view.cpp
new file mode 100644
index 00000000000..b81e2625d26
--- /dev/null
+++ b/engines/got/view.cpp
@@ -0,0 +1,81 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/view.h"
+
+namespace Got {
+
+void View::checkFocusedControl(const Common::Point &mousePos) {
+	if (_focusedElement) {
+		if (!_focusedElement->getBounds().contains(mousePos)) {
+			_focusedElement->send(MouseLeaveMessage());
+			_focusedElement = nullptr;
+		}
+
+	} else {
+		for (UIElement *child : _children) {
+			if (child->getBounds().contains(mousePos)) {
+				_focusedElement = child;
+				child->send(MouseEnterMessage());
+				break;
+			}
+		}
+	}
+}
+
+UIElement *View::getElementAtPos(const Common::Point &pos) const {
+	for (UIElement *child : _children) {
+		if (child->getBounds().contains(pos))
+			return child;
+	}
+
+	return nullptr;
+}
+
+
+bool View::msgFocus(const FocusMessage &msg) {
+	_focusedElement = nullptr;
+	return UIElement::msgFocus(msg);
+}
+
+bool View::msgUnfocus(const UnfocusMessage &msg) {
+	if (_focusedElement)
+		_focusedElement->send(MouseLeaveMessage());
+
+	return UIElement::msgUnfocus(msg);
+}
+
+bool View::msgMouseMove(const MouseMoveMessage &msg) {
+	checkFocusedControl(msg._pos);
+	return true;
+}
+
+bool View::msgMouseDown(const MouseDownMessage &msg) {
+	UIElement *child = getElementAtPos(msg._pos);
+	return child ? child->send(msg) : false;
+}
+
+bool View::msgMouseUp(const MouseUpMessage &msg) {
+	UIElement *child = getElementAtPos(msg._pos);
+	return child ? child->send(msg) : false;
+}
+
+} // namespace Got
diff --git a/engines/got/view.h b/engines/got/view.h
new file mode 100644
index 00000000000..3b58255d323
--- /dev/null
+++ b/engines/got/view.h
@@ -0,0 +1,73 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEW_H
+#define GOT_VIEW_H
+
+#include "got/events.h"
+
+namespace Got {
+
+/**
+ * Base view class for screens and dialogs that appear on-screen.
+ * The View class takes care of two important things:
+ * 1) By default events get sent to all controls on a view until one
+ * handles it. For mouse events, we instead want only the control the
+ * mouse cursor is over to receive the events, saving the individual
+ * controls from having to check if the mouse is within their bounds.
+ * 2) Individual elements will get a Focus/Unfocus message as the
+ * mouse enters and leaves them. This allows, for example, buttons
+ * that have been pressed to de-select if the mouse leaves their bounds.
+ */
+class View : public UIElement {
+private:
+	UIElement *_focusedElement = nullptr;
+
+	/**
+	 * Checks if a control is entered or left
+	 */
+	void checkFocusedControl(const Common::Point &mousePos);
+
+	/**
+	 * Check for an element at the given position
+	 */
+	UIElement *getElementAtPos(const Common::Point &pos) const;
+
+public:
+	View(const Common::String &name, UIElement *uiParent) :
+		UIElement(name, uiParent) {
+	}
+	View(const Common::String &name) :
+		UIElement(name) {
+	}
+	virtual ~View() {
+	}
+
+	bool msgFocus(const FocusMessage &msg) override;
+	bool msgUnfocus(const UnfocusMessage &msg) override;
+	bool msgMouseMove(const MouseMoveMessage &msg) override;
+	bool msgMouseDown(const MouseDownMessage &msg) override;
+	bool msgMouseUp(const MouseUpMessage &msg) override;
+};
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/view1.cpp b/engines/got/view1.cpp
new file mode 100644
index 00000000000..7205f25bcd8
--- /dev/null
+++ b/engines/got/view1.cpp
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/system.h"
+#include "graphics/paletteman.h"
+#include "got/view1.h"
+
+namespace Got {
+
+bool View1::msgFocus(const FocusMessage &msg) {
+	Common::fill(&_pal[0], &_pal[256 * 3], 0);
+	_offset = 128;
+	return true;
+}
+
+bool View1::msgKeypress(const KeypressMessage &msg) {
+	// Any keypress to close the view
+	close();
+	return true;
+}
+
+void View1::draw() {
+	// Draw a bunch of squares on screen
+	Graphics::ManagedSurface s = getSurface();
+
+	for (int i = 0; i < 100; ++i)
+		s.frameRect(Common::Rect(i, i, 320 - i, 200 - i), i);
+}
+
+bool View1::tick() {
+	// Cycle the palette
+	++_offset;
+	for (int i = 0; i < 256; ++i)
+		_pal[i * 3 + 1] = (i + _offset) % 256;
+	g_system->getPaletteManager()->setPalette(_pal, 0, 256);
+
+	// Below is redundant since we're only cycling the palette, but it demonstrates
+	// how to trigger the view to do further draws after the first time, since views
+	// don't automatically keep redrawing unless you tell it to
+	if ((_offset % 256) == 0)
+		redraw();
+
+	return true;
+}
+
+} // namespace Got
diff --git a/engines/got/view1.h b/engines/got/view1.h
new file mode 100644
index 00000000000..c7494af71b0
--- /dev/null
+++ b/engines/got/view1.h
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEW1_H
+#define GOT_VIEW1_H
+
+#include "got/view.h"
+
+namespace Got {
+
+class View1 : public View {
+private:
+	byte _pal[256 * 3] = { 0 };
+	int _offset = 0;
+
+public:
+	View1() : View("View1") {}
+	virtual ~View1() {}
+
+	bool msgFocus(const FocusMessage &msg) override;
+	bool msgKeypress(const KeypressMessage &msg) override;
+	void draw() override;
+	bool tick() override;
+};
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/views.h b/engines/got/views.h
new file mode 100644
index 00000000000..8c00ccfa910
--- /dev/null
+++ b/engines/got/views.h
@@ -0,0 +1,35 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_H
+#define GOT_VIEWS_H
+
+#include "got/view1.h"
+
+namespace Got {
+
+struct Views {
+	View1 _view1;
+};
+
+} // namespace Got
+
+#endif


Commit: 209f7545741724253c99744ef86cc14934a66ba1
    https://github.com/scummvm/scummvm/commit/209f7545741724253c99744ef86cc14934a66ba1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added resource archive, added to SearchMan

Changed paths:
  A engines/got/utils/res_archive.cpp
  A engines/got/utils/res_archive.h
    engines/got/got.cpp
    engines/got/module.mk


diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 18153873db6..65c56185374 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -19,9 +19,6 @@
  *
  */
 
-#include "got/got.h"
-#include "got/detection.h"
-#include "got/console.h"
 #include "common/scummsys.h"
 #include "common/config-manager.h"
 #include "common/debug-channels.h"
@@ -29,6 +26,10 @@
 #include "common/system.h"
 #include "engines/util.h"
 #include "graphics/paletteman.h"
+#include "got/got.h"
+#include "got/detection.h"
+#include "got/console.h"
+#include "got/utils/res_archive.h"
 
 namespace Got {
 
@@ -57,6 +58,9 @@ Common::Error GotEngine::run() {
 	// Set the engine's debugger console
 	setDebugger(new Console());
 
+	// Initialize resource access
+	resInit();
+
 	runGame();
 
 	return Common::kNoError;
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 28f85ed60b9..7822e094793 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -7,7 +7,8 @@ MODULE_OBJS = \
 	messages.o \
 	metaengine.o \
 	view.o \
-	view1.o
+	view1.o \
+	utils/res_archive.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_GOT), DYNAMIC_PLUGIN)
diff --git a/engines/got/utils/res_archive.cpp b/engines/got/utils/res_archive.cpp
new file mode 100644
index 00000000000..5922aba5189
--- /dev/null
+++ b/engines/got/utils/res_archive.cpp
@@ -0,0 +1,169 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/archive.h"
+#include "common/file.h"
+#include "common/memstream.h"
+#include "got/utils/res_archive.h"
+
+namespace Got {
+
+static const char *RES_FILENAME = "gotres.dat";
+
+void resInit() {
+	ResArchive *a = new ResArchive();
+	SearchMan.add("Res", a);
+}
+
+void ResHeader::load(Common::SeekableReadStream *src) {
+	char buf[10];
+	src->read(buf, 9);
+	buf[9] = '\0';
+	_name = buf;
+
+	_offset = src->readUint32LE();
+	_size = src->readUint32LE();
+	_originalSize = src->readUint32LE();
+	_key = src->readUint16LE();
+}
+
+ResArchive::ResArchive() {
+	Common::File f;
+	if (!f.open(RES_FILENAME))
+		error("Could not open %s", RES_FILENAME);
+
+	// Read in header data and decrypt it
+	byte buf[RES_MAX_ENTRIES * RES_HEADER_ENTRY_SIZE];
+	if (f.read(buf, RES_MAX_ENTRIES * RES_HEADER_ENTRY_SIZE) !=
+		(RES_MAX_ENTRIES * RES_HEADER_ENTRY_SIZE))
+		error("Could not read in resource headers");
+
+	decrypt(buf, RES_MAX_ENTRIES * RES_HEADER_ENTRY_SIZE, 128);
+
+	// Load headers
+	Common::MemoryReadStream hdrData(buf, RES_MAX_ENTRIES * RES_HEADER_ENTRY_SIZE);
+	for (int i = 0; i < RES_MAX_ENTRIES; ++i) {
+		ResHeader hdr;
+		hdr.load(&hdrData);
+		if (!(hdr._offset == 0 && hdr._size == 0))
+			_headers.push_back(hdr);
+	}
+}
+
+void ResArchive::decrypt(byte *buf, size_t len, byte key) const {
+	for (size_t i = 0; i < len; ++i)
+		*buf++ ^= key++;
+}
+
+int ResArchive::indexOf(const Common::String &name) const {
+	for (uint i = 0; i < _headers.size(); ++i) {
+		if (_headers[i]._name.equalsIgnoreCase(name))
+			return i;
+	}
+
+	return -1;
+}
+
+bool ResArchive::hasFile(const Common::Path &path) const {
+	return indexOf(path.baseName()) != -1;
+}
+
+int ResArchive::listMembers(Common::ArchiveMemberList &list) const {
+	int count = 0;
+
+	for (uint i = 0; i < _headers.size(); ++i) {
+		list.push_back(Common::ArchiveMemberList::value_type(
+			new Common::GenericArchiveMember(_headers[i]._name, *this)));
+		++count;
+	}
+
+	return count;
+}
+
+const Common::ArchiveMemberPtr ResArchive::getMember(const Common::Path &path) const {
+	if (!hasFile(path))
+		return Common::ArchiveMemberPtr();
+
+	return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(path, *this));
+}
+
+Common::SeekableReadStream *ResArchive::createReadStreamForMember(const Common::Path &path) const {
+	// Get the index of the header entry for this file
+	int hdrIndex = indexOf(path.baseName());
+	if (hdrIndex == -1)
+		return nullptr;
+
+	Common::File f;
+	if (!f.open(RES_FILENAME))
+		error("Error reading resource");
+
+	// Set up buffers
+	const ResHeader &hdr = _headers[hdrIndex];
+	byte *buf = (byte *)malloc(hdr._size);
+
+	f.seek(hdr._offset);
+	if (f.read(buf, hdr._size) != hdr._size)
+		error("Error reading resource");
+
+	// Decrypt if necessary
+	if (hdr._key != 0) {
+		byte *temp = buf;
+		buf = (byte *)malloc(hdr._originalSize);
+
+		lzssDecompress(temp, buf);
+		free(temp);
+	}
+
+	return new Common::MemoryReadStream(buf, hdr._originalSize,
+		DisposeAfterUse::YES);
+}
+
+void ResArchive::lzssDecompress(const byte *src, byte *dest) const {
+	uint16 size = READ_LE_UINT16(src);
+	byte *endP = dest + size;
+	assert(READ_LE_UINT16(src + 2) == 1);
+	src += 4;
+
+	for (;;) {
+		byte v = *src++;
+
+		for (int bits = 8; bits > 0; --bits) {
+			if (endP == dest)
+				return;
+
+			bool bit = (v & 1) != 0;
+			v >>= 1;
+			if (bit) {
+				*dest++ = *src++;
+			} else {
+				uint offset = READ_LE_UINT16(src);
+				src += 2;
+				int count = (offset >> 12) & 0xf + 2;
+				offset &= 0xfff;
+
+				Common::copy(dest - offset, dest - offset + count, dest);
+				dest += count;
+			}
+		}
+	}
+}
+
+} // namespace Got
diff --git a/engines/got/utils/res_archive.h b/engines/got/utils/res_archive.h
new file mode 100644
index 00000000000..ff21d9fbe45
--- /dev/null
+++ b/engines/got/utils/res_archive.h
@@ -0,0 +1,101 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_UTILS_RES_ARCHIVE_H
+#define GOT_UTILS_RES_ARCHIVE_H
+
+#include "got/view.h"
+
+namespace Got {
+
+struct ResHeader {
+	Common::String _name;
+	uint32 _offset = 0;
+	uint32 _size = 0;
+	uint32 _originalSize = 0;
+	int _key = 0;
+
+	void load(Common::SeekableReadStream *src);
+};
+
+#define RES_MAX_ENTRIES 256  // Max # of elements
+#define RES_HEADER_ENTRY_SIZE 23	// Size of a single header entry
+class ResArchive : public Common::Archive {
+private:
+	Common::Array<ResHeader> _headers;
+
+	/**
+	 * Decrypts a passed buffer
+	 * @param buf	Pointer to buffer
+	 * @param len	Buffer size
+	 * @param key	Starting key to use for decryption
+	 */
+	void decrypt(byte *buf, size_t len, byte key) const;
+
+	/**
+	 * Decodes a passed buffer
+	 */
+	void lzssDecompress(const byte *src, byte *dest) const;
+
+	/**
+	 * Returns the index of a header for a given filename
+	*/
+	int indexOf(const Common::String &name) const;
+
+public:
+	/**
+	 * Constructor
+	 */
+	ResArchive();
+
+	/**
+	 * Check if a member with the given name is present in the Archive.
+	 * Patterns are not allowed, as this is meant to be a quick File::exists()
+	 * replacement.
+	 */
+	bool hasFile(const Common::Path &path) const override;
+
+	/**
+	 * Add all members of the Archive to list.
+	 * Must only append to list, and not remove elements from it.
+	 *
+	 * @return the number of names added to list
+	 */
+	int listMembers(Common::ArchiveMemberList &list) const override;
+
+	/**
+	 * Returns a ArchiveMember representation of the given file.
+	 */
+	const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
+
+	/**
+	 * Create a stream bound to a member with the specified name in the
+	 * archive. If no member with this name exists, 0 is returned.
+	 * @return the newly created input stream
+	 */
+	Common::SeekableReadStream *createReadStreamForMember(const Common::Path &path) const override;
+};
+
+extern void resInit();
+
+} // namespace Got
+
+#endif


Commit: 375e9c4bf01252736f0ef8b46b96bd49b070a272
    https://github.com/scummvm/scummvm/commit/375e9c4bf01252736f0ef8b46b96bd49b070a272
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Create Views namespace

Changed paths:
  A engines/got/views/view.cpp
  A engines/got/views/view.h
  A engines/got/views/view1.cpp
  A engines/got/views/view1.h
  A engines/got/views/views.h
  R engines/got/view.cpp
  R engines/got/view.h
  R engines/got/view1.cpp
  R engines/got/view1.h
  R engines/got/views.h
    engines/got/events.cpp
    engines/got/module.mk
    engines/got/utils/res_archive.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index a1194d4d630..ae1e7a20a65 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -23,7 +23,7 @@
 #include "graphics/screen.h"
 #include "got/events.h"
 #include "got/got.h"
-#include "got/views.h"
+#include "got/views/views.h"
 
 namespace Got {
 
@@ -40,7 +40,7 @@ Events::~Events() {
 void Events::runGame() {
 	uint currTime, nextFrameTime = 0;
 	_screen = new Graphics::Screen();
-	Views views;	// Loads all views in the structure
+	Views::Views views;	// Loads all views in the structure
 
 	// Run the game
 	int saveSlot = ConfMan.getInt("save_slot");
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 7822e094793..b27da9be196 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -6,9 +6,9 @@ MODULE_OBJS = \
 	events.o \
 	messages.o \
 	metaengine.o \
-	view.o \
-	view1.o \
-	utils/res_archive.o
+	utils/res_archive.o \
+	views/view.o \
+	views/view1.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_GOT), DYNAMIC_PLUGIN)
diff --git a/engines/got/utils/res_archive.h b/engines/got/utils/res_archive.h
index ff21d9fbe45..bd712b16fb7 100644
--- a/engines/got/utils/res_archive.h
+++ b/engines/got/utils/res_archive.h
@@ -22,7 +22,7 @@
 #ifndef GOT_UTILS_RES_ARCHIVE_H
 #define GOT_UTILS_RES_ARCHIVE_H
 
-#include "got/view.h"
+#include "common/stream.h"
 
 namespace Got {
 
diff --git a/engines/got/view.cpp b/engines/got/views/view.cpp
similarity index 97%
rename from engines/got/view.cpp
rename to engines/got/views/view.cpp
index b81e2625d26..8c386a3e68d 100644
--- a/engines/got/view.cpp
+++ b/engines/got/views/view.cpp
@@ -19,9 +19,10 @@
  *
  */
 
-#include "got/view.h"
+#include "got/views/view.h"
 
 namespace Got {
+namespace Views {
 
 void View::checkFocusedControl(const Common::Point &mousePos) {
 	if (_focusedElement) {
@@ -78,4 +79,5 @@ bool View::msgMouseUp(const MouseUpMessage &msg) {
 	return child ? child->send(msg) : false;
 }
 
+} // namespace Views
 } // namespace Got
diff --git a/engines/got/view.h b/engines/got/views/view.h
similarity index 96%
rename from engines/got/view.h
rename to engines/got/views/view.h
index 3b58255d323..e174f476731 100644
--- a/engines/got/view.h
+++ b/engines/got/views/view.h
@@ -19,12 +19,13 @@
  *
  */
 
-#ifndef GOT_VIEW_H
-#define GOT_VIEW_H
+#ifndef GOT_VIEWS_VIEW_H
+#define GOT_VIEWS_VIEW_H
 
 #include "got/events.h"
 
 namespace Got {
+namespace Views {
 
 /**
  * Base view class for screens and dialogs that appear on-screen.
@@ -68,6 +69,7 @@ public:
 	bool msgMouseUp(const MouseUpMessage &msg) override;
 };
 
+} // namespace Views
 } // namespace Got
 
 #endif
diff --git a/engines/got/view1.cpp b/engines/got/views/view1.cpp
similarity index 96%
rename from engines/got/view1.cpp
rename to engines/got/views/view1.cpp
index 7205f25bcd8..c978432becd 100644
--- a/engines/got/view1.cpp
+++ b/engines/got/views/view1.cpp
@@ -21,9 +21,10 @@
 
 #include "common/system.h"
 #include "graphics/paletteman.h"
-#include "got/view1.h"
+#include "got/views/view1.h"
 
 namespace Got {
+namespace Views {
 
 bool View1::msgFocus(const FocusMessage &msg) {
 	Common::fill(&_pal[0], &_pal[256 * 3], 0);
@@ -61,4 +62,5 @@ bool View1::tick() {
 	return true;
 }
 
+} // namespace Views
 } // namespace Got
diff --git a/engines/got/view1.h b/engines/got/views/view1.h
similarity index 87%
rename from engines/got/view1.h
rename to engines/got/views/view1.h
index c7494af71b0..beeb4f56998 100644
--- a/engines/got/view1.h
+++ b/engines/got/views/view1.h
@@ -19,12 +19,13 @@
  *
  */
 
-#ifndef GOT_VIEW1_H
-#define GOT_VIEW1_H
+#ifndef GOT_VIEWS_VIEW1_H
+#define GOT_VIEWS_VIEW1_H
 
-#include "got/view.h"
+#include "got/views/view.h"
 
 namespace Got {
+namespace Views {
 
 class View1 : public View {
 private:
@@ -32,8 +33,10 @@ private:
 	int _offset = 0;
 
 public:
-	View1() : View("View1") {}
-	virtual ~View1() {}
+	View1() : View("View1") {
+	}
+	virtual ~View1() {
+	}
 
 	bool msgFocus(const FocusMessage &msg) override;
 	bool msgKeypress(const KeypressMessage &msg) override;
@@ -41,6 +44,7 @@ public:
 	bool tick() override;
 };
 
+} // namespace Views
 } // namespace Got
 
 #endif
diff --git a/engines/got/views.h b/engines/got/views/views.h
similarity index 93%
rename from engines/got/views.h
rename to engines/got/views/views.h
index 8c00ccfa910..c8045818900 100644
--- a/engines/got/views.h
+++ b/engines/got/views/views.h
@@ -22,14 +22,16 @@
 #ifndef GOT_VIEWS_H
 #define GOT_VIEWS_H
 
-#include "got/view1.h"
+#include "got/views/view1.h"
 
 namespace Got {
+namespace Views {
 
 struct Views {
 	View1 _view1;
 };
 
+} // namespace Views
 } // namespace Got
 
 #endif


Commit: cdbe42a8be365b39b4ccfd1bd5b4606bb824ce37
    https://github.com/scummvm/scummvm/commit/cdbe42a8be365b39b4ccfd1bd5b4606bb824ce37
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added file access methods

Changed paths:
  A engines/got/defines.h
  A engines/got/prototypes.h
  A engines/got/utils/file.cpp
  A engines/got/utils/file.h
    engines/got/module.mk


diff --git a/engines/got/defines.h b/engines/got/defines.h
new file mode 100644
index 00000000000..cac754698a0
--- /dev/null
+++ b/engines/got/defines.h
@@ -0,0 +1,471 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_DEFINES_H
+#define GOT_DEFINES_H
+
+#include "common/scummsys.h"
+
+namespace Got {
+
+/**
+ * Describes one alignment of a mask - image pair
+ */
+struct ALIGNED_MASK_IMAGE {
+	int image_width;		// Image width in addresses in display memory
+	uint image_ptr;			// Offset of image bitmap in display mem
+	const char *mask_ptr;   // Pointer to mask bitmap
+};
+
+struct MASK_IMAGE {
+	// ptrs to AlignedMaskedImage
+	// structs for four possible destination
+	// image alignments
+	ALIGNED_MASK_IMAGE *alignments[4];
+};
+
+struct LEVEL {               //size=512
+	char icon[12][20];       //0   grid of icons
+	char bg_color;           //240 background color
+	char type;               //241 music
+	char actor_type[16];     //242 type of enemies (12 max)
+	char actor_loc[16];      //254 location of enemies
+	char actor_value[16];    //pass value
+	char pal_colors[3];      //change 251,253,254 to these three
+	char actor_invis[16];
+	char extra[13];
+	char static_obj[30];     //302 static objects (treasure, keys,etc)
+	int  static_x[30];       //332 X coor of static objects
+	int  static_y[30];       //392 Y coor of static objects
+	char new_level[10];      //452 level jump for icon 200-204
+	char new_level_loc[10];  //462 grid location to jump in to
+	char area;               //472 game area (1=forest,etc)
+	char actor_dir[16];      //initial dir
+	char future[3];          //473
+};
+
+struct ACTOR {                    //size=256
+	// first part loaded from disk    (size=40)
+	char move;                  //movement pattern (0=none)
+	char width;                 //physical width
+	char height;                //physical height
+	char directions;            //1,2 or 4 (1=uni-directional)
+	char frames;                //# frames per direction
+	char frame_speed;           //# cycles between frame changes
+	char frame_sequence[4];     //sequence
+	char speed;                 //move every Nth cycle
+	char size_x;                 //non-physical padding on X coor
+	char size_y;                 //non-phsyical padding on Y coor
+	char strength;              //hit strength
+	char health;                //
+	char num_moves;             //# of moves every <speed> cycles
+	char shot_type;             //actor # of shot
+	char shot_pattern;          //func number to decide to shoot
+	char shots_allowed;         //# shots allowed on screen
+	char solid;                 //1=solid (not ghost,etc)
+	char flying;                //
+	char rating;                //rnd(100) < rating = jewel
+	char type;                  //actor (0=thor,1=hammer,2=enemy,3=shot)
+	char name[9];               //actors name
+	char func_num;              //special function when thor touches
+	char func_pass;             //value to pass to func
+	int  magic_hurts;           //bitwise magic hurts flags
+	char future1[4];
+
+	//the rest is dynamic    //size=216
+	MASK_IMAGE pic[4][4];       //mask image pointers
+	char frame_count;           //count to switch frames
+	char dir;                   //direction of travel
+	char last_dir;              //last direction of travel
+	int  x;                     //actual X coor
+	int  y;                     //actual Y coor
+	int  center;                //center of object
+	int  last_x[2];             //last X coor on each page
+	int  last_y[2];             //last Y coor on each page
+	char used;                  //1=active, 0=not active
+	char next;                  //next frame to be shown
+	char speed_count;           //count down to movement
+	char vunerable;             //count down to vunerability
+	char shot_cnt;              //count down to another shot
+	char num_shots;             //# of shots currently on screen
+	char creator;               //which actor # created this actor
+	char pause;                 //pause must be 0 to move
+	char actor_num;
+	char move_count;
+	char dead;
+	char toggle;
+	char center_x;
+	char center_y;
+	char show;                  //display or not (for blinking)
+	char temp1;
+	char temp2;
+	char counter;
+	char move_counter;
+	char edge_counter;
+	char temp3;
+	char temp4;
+	char temp5;
+	char hit_thor;
+	int  rand;
+	char init_dir;
+	char pass_value;
+	char shot_actor;
+	char magic_hit;
+	char temp6;
+	int  i1, i2, i3, i4, i5, i6;
+	char init_health;
+	char talk_counter;
+	char etype;
+	char future2[25];
+};
+
+struct ACTOR_NFO {				//size=40
+	char move;                  //movement pattern (0=none)
+	char width;                 //physical width
+	char height;                //physical height
+	char directions;            //1,2 or 4 (1=uni-directional)
+	char frames;                //# frames per direction
+	char frame_speed;           //# cycles between frame changes
+	char frame_sequence[4];     //sequence
+	char speed;                 //move every Nth cycle
+	char size_x;                 //non-physical padding on X coor
+	char size_y;                 //non-phsyical padding on Y coor
+	char strength;              //hit strength
+	char health;                //
+	char num_moves;             //# of moves every <speed> cycles
+	char shot_type;             //actor # of shot
+	char shot_pattern;          //func number to decide to shoot
+	char shots_allowed;         //# shots allowed on screen
+	char solid;                 //1=solid (not ghost,etc)
+	char flying;                //
+	char rating;                //rnd(100) < rating = jewel
+	char type;                  //actor (0=thor,1=hammer,2=enemy,3=shot)
+	char name[9];               //actors name
+	char func_num;              //special function when thor touches
+	char func_pass;             //value to pass to func
+	char future1[6];
+};
+
+struct ACTOR_DATA {               //5200
+	char pic[16][256];            //4096
+	char shot[4][256];            //1024
+	ACTOR_NFO actor_info;         //40
+	ACTOR_NFO shot_info;          //40
+} ;
+
+struct SETUP {
+	unsigned int  f00 : 1;
+	unsigned int  f01 : 1;
+	unsigned int  f02 : 1;
+	unsigned int  f03 : 1;
+	unsigned int  f04 : 1;
+	unsigned int  f05 : 1;
+	unsigned int  f06 : 1;
+	unsigned int  f07 : 1;
+
+	unsigned int  f08 : 1;
+	unsigned int  f09 : 1;
+	unsigned int  f10 : 1;
+	unsigned int  f11 : 1;
+	unsigned int  f12 : 1;
+	unsigned int  f13 : 1;
+	unsigned int  f14 : 1;
+	unsigned int  f15 : 1;
+
+	unsigned int  f16 : 1;
+	unsigned int  f17 : 1;
+	unsigned int  f18 : 1;
+	unsigned int  f19 : 1;
+	unsigned int  f20 : 1;
+	unsigned int  f21 : 1;
+	unsigned int  f22 : 1;
+	unsigned int  f23 : 1;
+
+	unsigned int  f24 : 1;
+	unsigned int  f25 : 1;
+	unsigned int  f26 : 1;
+	unsigned int  f27 : 1;
+	unsigned int  f28 : 1;
+	unsigned int  f29 : 1;
+	unsigned int  f30 : 1;
+	unsigned int  f31 : 1;
+
+	unsigned int  f32 : 1;
+	unsigned int  f33 : 1;
+	unsigned int  f34 : 1;
+	unsigned int  f35 : 1;
+	unsigned int  f36 : 1;
+	unsigned int  f37 : 1;
+	unsigned int  f38 : 1;
+	unsigned int  f39 : 1;
+
+	unsigned int  f40 : 1;
+	unsigned int  f41 : 1;
+	unsigned int  f42 : 1;
+	unsigned int  f43 : 1;
+	unsigned int  f44 : 1;
+	unsigned int  f45 : 1;
+	unsigned int  f46 : 1;
+	unsigned int  f47 : 1;
+
+	unsigned int  f48 : 1;
+	unsigned int  f49 : 1;
+	unsigned int  f50 : 1;
+	unsigned int  f51 : 1;
+	unsigned int  f52 : 1;
+	unsigned int  f53 : 1;
+	unsigned int  f54 : 1;
+	unsigned int  f55 : 1;
+
+	unsigned int  f56 : 1;
+	unsigned int  f57 : 1;
+	unsigned int  f58 : 1;
+	unsigned int  f59 : 1;
+	unsigned int  f60 : 1;
+	unsigned int  f61 : 1;
+	unsigned int  f62 : 1;
+	unsigned int  f63 : 1;
+
+	char value[16];
+	char junk;
+	char game;
+	char area;          //1,2,3
+	char pc_sound;      //1=enabled
+	char dig_sound;     //1 & !pc_sound = enabled
+	char music;         //1=enabled
+	char speed;         //1=slow mode (for slower 286's)
+	char scroll_flag;   //unused
+	char boss_dead[3];
+	char skill;         //0=easy, 1=normal, 2=hard
+	char game_over;
+	char future[19];    //probably not needed
+};
+
+struct PIC_HEADER {
+	char width;
+	char height;
+};
+
+struct THOR_INFO {
+	char magic;
+	char keys;
+	int  jewels;
+	char last_area;
+	char last_screen;
+	char last_icon;
+	char last_dir;
+	int  inventory;
+	char item;         //currently selected item
+	char last_health;
+	char last_magic;
+	int  last_jewels;
+	char last_keys;
+	char last_item;
+	int  last_inventory;
+	char level;         //current level (1,2,3)
+	long score;
+	long last_score;
+	char object;
+	char *object_name;
+	char last_object;
+	char *last_object_name;
+	char armor;
+	char future[65];
+};
+
+struct HEADER {
+	long offset;
+	long length;
+};
+
+//==========================================================================
+// Defines
+
+#define PAGES 0u
+//#define PAGE0 3840u
+//#define PAGE1 19200u
+//#define PAGE2 34560u
+//#define PAGE3 49920u
+
+#define PAGE0 3840u
+#define PAGE1 19280u
+#define PAGE2 34720u
+#define PAGE3 50160u
+
+#define X_MAX  319
+#define Y_MAX  191
+#define MO_BUFF 56688u
+#define MO_OFFSET 55968u
+#define ENEMY_OFFSET 59664u
+#define ENEMY_SHOT_OFFSET 64272u
+#define MAX_ACTORS  35
+#define MAX_ENEMIES 16
+#define MAX_SHOTS   16
+#define STAMINA 20
+
+#define THOR 0
+#define UP     72
+#define DOWN   80
+#define LEFT   75
+#define RIGHT  77
+#define HOME   71
+#define PGUP   73
+#define END    79
+#define PGDN   81
+#define ESC     1
+#define SPACE  57
+#define ENTER  28
+#define ALT    56
+#define CTRL   29
+#define TAB    15
+#define LSHIFT 42
+#define _Z     44
+#define _ONE   2
+#define _TWO   3
+#define _THREE 4
+#define _FOUR  5
+#define _S     31
+#define _L     38
+#define _K     37
+#define _D     32
+#define _B     48
+#define _F1    59
+#define AMI_LEN 1800
+#define TMP_SIZE 5800
+
+#define sc_Index 0x3C4
+enum {
+	sc_Reset,
+	sc_Clock,
+	sc_MapMask,
+	sc_CharMap,
+	sc_MemMode
+};
+
+#define crtc_Index 0x3D4
+
+enum {
+	crtc_H_Total,
+	crtc_H_DispEnd,
+	crtc_H_Blank,
+	crtc_H_EndBlank,
+	crtc_H_Retrace,
+	crtc_H_EndRetrace,
+	crtc_V_Total,
+	crtc_OverFlow,
+	crtc_RowScan,
+	crtc_MaxScanLine,
+	crtc_CursorStart,
+	crtc_CursorEnd,
+	crtc_StartHigh,
+	crtc_StartLow,
+	crtc_CursorHigh,
+	crtc_CursorLow,
+	crtc_V_Retrace,
+	crtc_V_EndRetrace,
+	crtc_V_DispEnd,
+	crtc_Offset,
+	crtc_Underline,
+	crtc_V_Blank,
+	crtc_V_EndBlank,
+	crtc_Mode,
+	crtc_LineCompare
+};
+
+#define gc_Index 0x3CE
+enum {
+	gc_SetReset,
+	gc_EnableSetReset,
+	gc_ColorCompare,
+	gc_DataRotate,
+	gc_ReadMap,
+	gc_Mode,
+	gc_Misc,
+	gc_ColorDontCare,
+	gc_BitMask
+};
+
+#define atr_Index 0x3c0
+enum {
+	atr_Mode = 16,
+	atr_Overscan,
+	atr_ColorPlaneEnable,
+	atr_PelPan,
+	atr_ColorSelect
+};
+#define	status_Reg1 0x3da
+
+enum {
+	OW,
+	GULP,
+	SWISH,
+	YAH,
+	ELECTRIC,
+	THUNDER,
+	DOOR,
+	FALL,
+	ANGEL,
+	WOOP,
+	DEAD,
+	BRAAPP,
+	WIND,
+	PUNCH1,
+	CLANG,
+	EXPLODE,
+	BOSS11,
+	BOSS12,
+	BOSS13,
+};
+
+#define	status_Reg1 0x3da
+
+#define GAME1 (area==1)
+#define GAME2 (area==2)
+#define GAME3 (area==3)
+#define BP    (key_flag[_B])
+
+#define NUM_SOUNDS  19
+#define NUM_OBJECTS 32
+
+#define APPLE_MAGIC     1
+#define HOURGLASS_MAGIC 2
+#define LIGHTNING_MAGIC 4
+
+#define BOOTS_MAGIC    8
+#define BOMB_MAGIC     16
+#define WIND_MAGIC     32
+
+#define QUESTION_MAGIC 64
+#define SHIELD_MAGIC   128
+#define THUNDER_MAGIC  256
+
+#define BOSS_LEVEL1  59
+#define BOSS_LEVEL21 200
+#define BOSS_LEVEL22 118
+
+//#define DEBUG 1
+//#define IDE 1
+//#define CRIPPLED 1
+#define DEMO_LEN 3600
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/module.mk b/engines/got/module.mk
index b27da9be196..a1dbfba72ad 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS = \
 	events.o \
 	messages.o \
 	metaengine.o \
+	utils/file.o \
 	utils/res_archive.o \
 	views/view.o \
 	views/view1.o
diff --git a/engines/got/prototypes.h b/engines/got/prototypes.h
new file mode 100644
index 00000000000..c1813211724
--- /dev/null
+++ b/engines/got/prototypes.h
@@ -0,0 +1,283 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_PROTOTYPES_H
+#define GOT_PROTOTYPES_H
+
+#include "common/scummsys.h"
+
+namespace Got {
+
+//G_LIB.LIB
+
+void xsetmode(void);
+void xshowpage(unsigned page);
+void xline(int x0, int y0, int x1, int y1, int page, int color);
+void xfillrectangle(int StartX, int StartY, int EndX, int EndY,
+	unsigned int PageBase, int Color);
+void xpset(int X, int Y, unsigned int PageBase, int Color);
+int  xpoint(int X, int Y, unsigned int PageBase);
+void xget(int x1, int y1, int x2, int y2, unsigned int pagebase,
+	char *buff, int invis);
+void xput(int x, int y, unsigned int pagebase, char *buff);
+void xput2(int x, int y, unsigned int pagebase, char *buff);
+void xtext(int x, int y, unsigned int pagebase, char *buff, int color);
+void xtext1(int x, int y, unsigned int pagebase, char *buff, int color);
+void xtextx(int x, int y, unsigned int pagebase, char *buff, int color);
+
+void xfput(int x, int y, unsigned int pagebase, char *buff);
+void xfarput(int x, int y, unsigned int pagebase, char *buff);
+void xcopyd2dmasked(int SourceStartX,
+	int SourceStartY, int SourceEndX, int SourceEndY,
+	int DestStartX, int DestStartY, MASK_IMAGE *Source,
+	unsigned int DestPageBase, int DestBitmapWidth);
+void xcopyd2dmasked2(
+	int SourceEndX, int SourceEndY,
+	int DestStartX, int DestStartY, MASK_IMAGE *Source,
+	unsigned int DestPageBase);
+void xcopys2d(int SourceStartX, int SourceStartY,
+	int SourceEndX, int SourceEndY, int DestStartX,
+	int DestStartY, char *SourcePtr, unsigned int DestPageBase,
+	int SourceBitmapWidth, int DestBitmapWidth);
+void xcopyd2d(int SourceStartX, int SourceStartY,
+	int SourceEndX, int SourceEndY, int DestStartX,
+	int DestStartY, unsigned int SourcePageBase,
+	unsigned int DestPageBase, int SourceBitmapWidth,
+	int DestBitmapWidth);
+unsigned int xcreatmaskimage(MASK_IMAGE *ImageToSet,
+	unsigned int DispMemStart, char *Image, int ImageWidth,
+	int ImageHeight, char *Mask);
+unsigned int xcreatmaskimage2(MASK_IMAGE *ImageToSet,
+	unsigned int DispMemStart, char *Image, int ImageWidth,
+	int ImageHeight, char *Mask);
+
+void xddfast(int source_x, int source_y, int width, int height,
+	int dest_x, int dest_y,
+	unsigned int source_page, unsigned int dest_page);
+void xsetpal(unsigned char color, unsigned char R, unsigned char G, unsigned char B);
+void xgetpal(char *pal, int num_colrs, int start_index);
+
+//G_MAIN.C
+void run_gotm(void);
+void printt(int val);
+void thor_dies(void);
+void thor_spins(int flag);
+void thor_spins(int flag);
+void pause(int delay);
+void rotate_pal(void);
+int  rnd(int max);
+
+//G_GRP.C
+
+void xprint(int x, int y, char *string, unsigned int page, int color);
+void xprintx(int x, int y, char *string, unsigned int page, int color);
+void split_screen(void);
+int  load_palette(void);
+void xbox(int x1, int y1, int x2, int y2, unsigned page, int color);
+void fade_in(void);
+void fade_out(void);
+void unsplit_screen(void);
+void screen_dump(void);
+void show_all_actors(void);
+
+//G_INIT.C
+int initialize(void);
+void exit_code(int ex_flag);
+//void keyboard_int();              // interrupt prototype
+void demo_key_set(void);
+void wait_not_response(void);
+int  wait_response(void);
+int  get_response(void);
+void wait_key(int index);
+void wait_not_key(int index);
+int  wait_ekey(int index);
+int  wait_not_ekey(int index);
+void joy_key(void);
+void set_joy(void);
+void merge_keys(void);
+int  setup_boss(int num);
+void story(void);
+
+
+//G_PANEL.C
+void status_panel(void);
+void display_health(void);
+void display_magic(void);
+void display_jewels(void);
+void display_score(void);
+void display_keys(void);
+void display_item(void);
+int  init_status_panel(void);
+void add_jewels(int num);
+void add_score(int num);
+void add_magic(int num);
+void add_health(int num);
+void add_keys(int num);
+void fill_health(void);
+void fill_magic(void);
+void fill_score(int num);
+void score_for_inv(void);
+void boss_status(int health);
+int  select_option(const char *option[], const char *title, int ipos);
+int  option_menu(void);
+int  ask_exit(void);
+int  select_sound(void);
+int  select_music(void);
+int  select_slow(void);
+int  select_scroll(void);
+void select_fastmode(void);
+void select_skill(void);
+void hammer_smack(int x, int y);
+void show_scr(void);
+
+
+//G_BACK.C
+void build_screen(unsigned int pg);
+void show_level(int new_level);
+void scroll_level_left(void);
+void scroll_level_up(void);
+void scroll_level_right(void);
+void scroll_level_down(void);
+void phase_level(void);
+void copy_bg_icon(int num, unsigned int src_page, unsigned int dst_page);
+int  odin_speaks(int index, int item);
+void d_restore(void);
+int  actor_speaks(ACTOR *actr, int index, int item);
+int  display_speech(int item, char *pic, int tf);
+void select_item(void);
+void show_item(int item);
+int  use_thunder(int flag);
+int  use_hourglass(int flag);
+int  use_boots(int flag);
+void use_item(void);
+int  switch_icons(void);
+int  rotate_arrows(void);
+void kill_enemies(int iy, int ix);
+void remove_objects(int y, int x);
+void place_tile(int x, int y, int tile);
+int  bgtile(int x, int y);
+
+//G_IMAGE.C
+unsigned int make_mask(MASK_IMAGE *image,
+	unsigned int page_start, char *Image, int image_width,
+	int image_height);
+int  load_standard_actors(void);
+void setup_actor(ACTOR *actr, char num, char dir, int x, int y);
+void show_enemies(void);
+int  load_enemy(int type);
+int actor_visible(int invis_num);
+void setup_magic_item(int item);
+void load_new_thor(void);
+
+//G_MOVE.C
+void next_frame(ACTOR *actr);
+int  point_within(int x, int y, int x1, int y1, int x2, int y2);
+int  overlap(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
+int  reverse_direction(ACTOR *actr);
+void thor_shoots(void);
+void actor_damaged(ACTOR *actr, int damage);
+void thor_damaged(ACTOR *actr);
+void actor_destroyed(ACTOR *actr);
+int  actor_shoots(ACTOR *actr, int dir);
+void actor_always_shoots(ACTOR *actr, int dir);
+void move_actor(ACTOR *actr);
+
+//G_MOVPAT.C
+int  check_move0(int x, int y, ACTOR *actr);
+int  check_move1(int x, int y, ACTOR *actr);
+int  check_move2(int x, int y, ACTOR *actr);
+int  check_move3(int x, int y, ACTOR *actr);
+int  check_move4(int x, int y, ACTOR *actr);
+int  check_thor_move(int x, int y, ACTOR *actr);
+void set_thor_vars(void);
+
+//G_OBJECT.C
+void show_objects(int level, unsigned int pg);
+void pick_up_object(int p);
+int  drop_object(ACTOR *actr);
+int  _drop_obj(ACTOR *actr, int o);
+void delete_object(void);
+
+//G_SPTILE.C
+int special_tile_thor(int x, int y, int icon);
+int special_tile(ACTOR *actr, int x, int y, int icon);
+
+//G_SBFX.C
+int  sbfx_init(void);
+void sbfx_exit(void);
+
+//G_SOUND.C
+int  sound_init(void);
+void sound_exit(void);
+void play_sound(int index, int priority_override);
+int  sound_playing(void);
+
+//G_MUSIC.C
+int  music_init(void);
+void music_play(int num, int override);
+void music_pause(void);
+void music_resume(void);
+int  music_is_on(void);
+
+//G_SCRIPT.C
+void execute_script(long index, char *pic);
+
+//G_BOSS1.C   //serpent
+
+int  boss1_movement(ACTOR *actr);
+void check_boss1_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num);
+void boss_level1(void);
+int  boss_dead1(void);
+void closing_sequence1(void);
+
+//G_BOSS21.C  //wraith
+
+int  boss21_movement(ACTOR *actr);
+void check_boss21_hit(void);
+void boss_level21(void);
+int  boss_dead21(void);
+void closing_sequence21(void);
+
+//G_BOSS22.C  //skull
+
+int  boss22_movement(ACTOR *actr);
+void check_boss22_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num);
+void boss_level22(void);
+int  boss_dead22(void);
+void check_boss21_hit(void);
+void closing_sequence22(void);
+void boss22_set(int d, int x, int y);
+int  boss22a_movement(ACTOR *actr);
+int  boss22b_movement(ACTOR *actr);
+
+//G_ASM.ASM
+void xdisplay_actors(ACTOR *act, unsigned int page);
+void xerase_actors(ACTOR *act, unsigned int page);
+void pal_fade_in(char *buff);
+void pal_fade_out(char *buff);
+void read_joystick(void);
+void UnLZSS(char *src, char *dest, int len);
+#define REPEAT(a) for(rep=0;rep<a;rep++)
+#define IN_RANGE(v,l,h) (v>=l && v<=h)
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/utils/file.cpp b/engines/got/utils/file.cpp
new file mode 100644
index 00000000000..7ce2426dc87
--- /dev/null
+++ b/engines/got/utils/file.cpp
@@ -0,0 +1,333 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/file.h"
+#include "got/utils/file.h"
+#include "got/prototypes.h"
+
+namespace Got {
+
+extern byte *bg_pics;
+extern char objects[NUM_OBJECTS][262];
+extern byte *sd_data;
+extern char *tmp_buff;
+extern char res_file[];
+extern THOR_INFO thor_info;
+extern int current_area;
+extern ACTOR *thor;
+extern char *save_filename;
+extern union REGS in, out;
+extern SETUP setup;
+extern char level_type, slow_mode;
+extern int  boss_active;
+extern char area;
+extern char test_sdf[];
+extern char *song;
+extern char *lzss_buff;
+extern char *options_yesno[];
+extern int music_flag, sound_flag, pcsound_flag;
+extern char game_over;
+extern unsigned int display_page, draw_page;
+extern volatile char key_flag[100];
+
+static const char *gotres = "GOTRES.00";
+
+long file_size(char *path) {
+	Common::File f;
+	return f.open(Common::Path(path)) ? f.size() : -1;
+}
+
+bool load_bg_data() {
+	bg_pics = new byte[60460];
+	if (!bg_pics)
+		return false;
+
+	if (GAME1) {
+		if (res_read("BPICS1", bg_pics) < 0)
+			return false;
+	}
+
+	return true;
+}
+
+bool load_sd_data() {
+	Common::String fname = Common::String::format("SDAT%d", area);
+
+	if (!sd_data)
+		sd_data = new byte[61440];
+	if (!sd_data)
+		return false;
+
+	return res_read(fname, sd_data) > 0;
+}
+
+bool load_objects() {
+	return res_read("OBJECTS", (char *)objects) > 0;
+}
+
+bool load_actor(int file, int num) {
+	Common::String fname = Common::String::format("ACTOR%d", num);
+
+	if (res_read(fname, tmp_buff) < 0)
+		return false;
+
+	//file = file;
+	return true;
+}
+
+bool load_speech(int index) {
+	int  cnt;
+	char *p;
+	char *pm;
+	char *sp;
+	char tmps[5];
+
+	Common::String fname = Common::String::format("SPEAK%d", area);
+
+	sp = new char[30000];
+	if (!sp)
+		return false;
+
+	if (res_read(fname, sp) < 0) {
+		delete[] sp;
+		return 0;
+	}
+
+	p = sp;
+
+	cnt = 0;
+	for (;;) {
+		if (*p == ':') {
+			p++;
+			cnt++;
+			strncpy(tmps, p, 4);
+			tmps[4] = '\0';
+
+			if (atoi(tmps) == index) {
+				break;
+			}
+		}
+
+		p++;
+		cnt++;
+	}
+
+	while (*p != 10)
+		p++;
+	p++;
+
+	pm = p;
+	cnt = 0;
+
+	for (;;) {
+		if (*p == 13)
+			*p = 32;
+		if (*p == ':') {
+			if ((*(p + 1) == 'E') && (*(p + 2) == 'N') && (*(p + 3) == 'D')) break;
+		}
+
+		p++;
+		cnt++;
+
+		if (cnt > 5799) {
+			delete[] sp;
+			return false;
+		}
+	}
+
+	if (*(p - 1) == 10)
+		*(p - 1) = 0;
+	*p = 0;
+
+	Common::copy(pm, pm + cnt, tmp_buff);
+	tmp_buff[cnt] = 0;
+
+	delete[] sp;
+	return true;
+}
+
+void setup_filenames(int level) {
+}
+
+void help(void) {
+	odin_speaks(2008, -1);
+}
+
+void save_game() {
+#if TODO
+	int handle;
+	unsigned int total;
+	char buff[32];
+
+	if (game_over)
+		return;
+
+	setup.area = area;
+	setup.game_over = game_over;
+
+	if (select_option(options_yesno, "Save Game?", 0) != 1) {
+		d_restore();
+		return;
+	}
+
+	d_restore();
+
+
+	if (_dos_open(save_filename, O_RDONLY, &handle) != 0) return;
+	_dos_read(handle, buff, 32, &total);
+	_dos_close(handle);
+
+	if (_dos_open(save_filename, O_WRONLY, &handle) != 0) return;
+	_dos_write(handle, buff, 32, &total);
+	_dos_write(handle, &setup, sizeof(SETUP), &total);
+	_dos_write(handle, &thor_info, sizeof(THOR_INFO), &total);
+	_dos_write(handle, sd_data, 61440u, &total);
+	_dos_close(handle);
+	odin_speaks(2009, 0);
+#endif
+}
+
+bool load_game(int flag) {
+#ifdef TODO
+	int handle;
+	unsigned int total;
+	char buff[32];
+
+	if (flag) {
+		if (select_option(options_yesno, "Load Game?", 0) != 1) {
+			d_restore();
+			return 0;
+		}
+		d_restore();
+	}
+	if (_dos_open(save_filename, O_RDONLY, &handle) != 0) return 0;
+	_dos_read(handle, buff, 32, &total);
+	_dos_read(handle, &setup, sizeof(SETUP), &total);
+	_dos_read(handle, &thor_info, sizeof(THOR_INFO), &total);
+	_dos_read(handle, sd_data, 61440u, &total);
+	_dos_close(handle);
+
+	current_area = thor_info.last_screen;
+	area = setup.area;
+	if (area == 0) area = 1;
+
+	thor->x = (thor_info.last_icon % 20) * 16;
+	thor->y = ((thor_info.last_icon / 20) * 16) - 1;
+	if (thor->x < 1) thor->x = 1;
+	if (thor->y < 0) thor->y = 0;
+	thor->dir = thor_info.last_dir;
+	thor->last_dir = thor_info.last_dir;
+	thor->health = thor_info.last_health;
+	thor->num_moves = 1;
+	thor->vunerable = 60;
+	thor->show = 60;
+	thor->speed_count = 6;
+	load_new_thor();
+	display_health();
+	display_magic();
+	display_jewels();
+	display_keys();
+	display_item();
+	if (!music_flag) setup.music = 0;
+	if (!sound_flag) setup.dig_sound = 0;
+	if (setup.music == 1) {
+		if (GAME1 == 1 && current_area == 59) {
+			if (flag) music_play(5, 1);
+		} else if (flag) music_play(level_type, 1);
+	} else {
+		setup.music = 1;
+		music_pause();
+		setup.music = 0;
+	}
+	game_over = setup.game_over;
+	slow_mode = setup.speed;
+#endif
+	return true;
+}
+
+/*
+long res_read(char *name,char *buff){
+int num,bytes;
+size_t len;
+size_t total;
+char bf[256];
+char *p;
+unsigned int clen;
+unsigned int *up;
+
+if(!res_active) return RES_NOT_ACTIVE;
+if(!res_fp) return RES_NOT_OPEN;
+
+num=res_find_name(name);
+if(num<0) return RES_CANT_FIND;
+
+if(fseek(res_fp,res_header[num].offset,SEEK_SET)) return RES_CANT_SEEK;
+len=(size_t) res_header[num].length;
+
+total=0;
+if(res_header[num].key) p=buff;
+else p=lzss_buff;
+while(total<len){
+	 if(((len-total) >255) && (len > 255)) bytes=fread(bf,1,256,res_fp);
+	 else bytes=fread(bf,1,len-total,res_fp);
+	 if(!bytes) break;
+	 total+=bytes;
+	 movedata(FP_SEG(bf),FP_OFF(bf),FP_SEG(p),FP_OFF(p),bytes);
+	 p+=bytes;
+}
+if(res_header[num].key) res_decode(buff,len,res_header[num].key);
+else{
+  p=lzss_buff;
+  up=(unsigned int *) p;
+  clen=*up;
+  p+=4;
+  UnLZSS(p,buff,clen);
+}
+return res_header[num].length;
+}
+*/
+
+bool load_music(int num) {
+	switch (num) {
+	case 0:
+		res_read("SONG1", song);
+		break;
+	case 1:
+		res_read("SONG2", song);
+		break;
+	case 2:
+		res_read("SONG3", song);
+		break;
+	case 3:
+		res_read("SONG4", song);
+		break;
+	case 4:
+		res_read("WINSONG", song);
+		break;
+	case 5:
+		res_read("BOSSSONG", song);
+		break;
+	}
+
+	return song != nullptr;
+}
+
+} // End of namespace Got
diff --git a/engines/got/utils/file.h b/engines/got/utils/file.h
new file mode 100644
index 00000000000..89f8bca486b
--- /dev/null
+++ b/engines/got/utils/file.h
@@ -0,0 +1,50 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_UTILS_FILE_H
+#define GOT_UTILS_FILE_H
+
+#include "common/str.h"
+#include "got/defines.h"
+
+namespace Got {
+
+extern long file_size(const char *path);
+extern unsigned int read_file(const char *filename, const char *buff,
+	long offset, unsigned int amount, int key);
+extern bool load_bg_data();
+extern bool load_sd_data();
+extern bool load_objects();
+extern bool load_actor(int file, int num);
+extern bool load_picture(int index, char *buff);
+extern void setup_filenames(int level);
+extern bool  load_speech(int index);
+extern long file_size(const char *path);
+extern void *get_file(const char *filename, int key);
+extern void save_game();
+extern bool load_game(int flag);
+extern void help();
+extern long res_read(const Common::String &name, void *buff);
+extern bool load_music(int num);
+
+} // namespace Got
+
+#endif


Commit: 77f30bdc6dc58a7aa4de9094c57cc7cee0790e41
    https://github.com/scummvm/scummvm/commit/77f30bdc6dc58a7aa4de9094c57cc7cee0790e41
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added Vars class

Changed paths:
  A engines/got/vars.cpp
  A engines/got/vars.h
    engines/got/defines.h
    engines/got/got.h
    engines/got/module.mk
    engines/got/utils/file.cpp


diff --git a/engines/got/defines.h b/engines/got/defines.h
index cac754698a0..fac3a78929c 100644
--- a/engines/got/defines.h
+++ b/engines/got/defines.h
@@ -30,146 +30,146 @@ namespace Got {
  * Describes one alignment of a mask - image pair
  */
 struct ALIGNED_MASK_IMAGE {
-	int image_width;		// Image width in addresses in display memory
-	uint image_ptr;			// Offset of image bitmap in display mem
-	const char *mask_ptr;   // Pointer to mask bitmap
+	int image_width = 0;		// Image width in addresses in display memory
+	uint image_ptr = 0;			// Offset of image bitmap in display mem
+	const byte *mask_ptr = nullptr;   // Pointer to mask bitmap
 };
 
 struct MASK_IMAGE {
 	// ptrs to AlignedMaskedImage
 	// structs for four possible destination
 	// image alignments
-	ALIGNED_MASK_IMAGE *alignments[4];
+	ALIGNED_MASK_IMAGE *alignments[4] = { nullptr, nullptr, nullptr, nullptr };
 };
 
-struct LEVEL {               //size=512
-	char icon[12][20];       //0   grid of icons
-	char bg_color;           //240 background color
-	char type;               //241 music
-	char actor_type[16];     //242 type of enemies (12 max)
-	char actor_loc[16];      //254 location of enemies
-	char actor_value[16];    //pass value
-	char pal_colors[3];      //change 251,253,254 to these three
-	char actor_invis[16];
-	char extra[13];
-	char static_obj[30];     //302 static objects (treasure, keys,etc)
-	int  static_x[30];       //332 X coor of static objects
-	int  static_y[30];       //392 Y coor of static objects
-	char new_level[10];      //452 level jump for icon 200-204
-	char new_level_loc[10];  //462 grid location to jump in to
-	char area;               //472 game area (1=forest,etc)
-	char actor_dir[16];      //initial dir
-	char future[3];          //473
+struct LEVEL {                    // size=512
+	byte icon[12][20] = {};       // 0   grid of icons
+	byte bg_color = 0;            // 240 background color
+	byte type = 0;                // 241 music
+	byte actor_type[16] = {};     // 242 type of enemies (12 max)
+	byte actor_loc[16] = {};      // 254 location of enemies
+	byte actor_value[16] = {};    // pass value
+	byte pal_colors[3] = {};      // change 251,253,254 to these three
+	byte actor_invis[16] = {};
+	byte extra[13] = {};
+	byte static_obj[30] = {};     // 302 static objects (treasure, keys,etc)
+	int  static_x[30] = {};       // 332 X coor of static objects
+	int  static_y[30] = {};       // 392 Y coor of static objects
+	byte new_level[10] = {};      // 452 level jump for icon 200-204
+	byte new_level_loc[10] = {};  // 462 grid location to jump in to
+	byte area = 0;                // 472 game area (1=forest,etc)
+	byte actor_dir[16] = {};      // initial dir
+	byte future[3] = {};          // 473
 };
 
-struct ACTOR {                    //size=256
-	// first part loaded from disk    (size=40)
-	char move;                  //movement pattern (0=none)
-	char width;                 //physical width
-	char height;                //physical height
-	char directions;            //1,2 or 4 (1=uni-directional)
-	char frames;                //# frames per direction
-	char frame_speed;           //# cycles between frame changes
-	char frame_sequence[4];     //sequence
-	char speed;                 //move every Nth cycle
-	char size_x;                 //non-physical padding on X coor
-	char size_y;                 //non-phsyical padding on Y coor
-	char strength;              //hit strength
-	char health;                //
-	char num_moves;             //# of moves every <speed> cycles
-	char shot_type;             //actor # of shot
-	char shot_pattern;          //func number to decide to shoot
-	char shots_allowed;         //# shots allowed on screen
-	char solid;                 //1=solid (not ghost,etc)
-	char flying;                //
-	char rating;                //rnd(100) < rating = jewel
-	char type;                  //actor (0=thor,1=hammer,2=enemy,3=shot)
-	char name[9];               //actors name
-	char func_num;              //special function when thor touches
-	char func_pass;             //value to pass to func
-	int  magic_hurts;           //bitwise magic hurts flags
-	char future1[4];
+struct ACTOR {                      //size=256
+	// first part loaded from disk  (size=40)
+	byte move = 0;                  //movement pattern (0=none)
+	byte width = 0;                 //physical width
+	byte height = 0;                //physical height
+	byte directions = 0;            //1,2 or 4 (1=uni-directional)
+	byte frames = 0;                //# frames per direction
+	byte frame_speed = 0;           //# cycles between frame changes
+	byte frame_sequence[4] = {};    //sequence
+	byte speed = 0;                 //move every Nth cycle
+	byte size_x = 0;                //non-physical padding on X coor
+	byte size_y = 0;                //non-phsyical padding on Y coor
+	byte strength = 0;              //hit strength
+	byte health = 0;                //
+	byte num_moves = 0;             //# of moves every <speed> cycles
+	byte shot_type = 0;             //actor # of shot
+	byte shot_pattern = 0;          //func number to decide to shoot
+	byte shots_allowed = 0;         //# shots allowed on screen
+	byte solid = 0;                 //1=solid (not ghost,etc)
+	byte flying = 0;                //
+	byte rating = 0;                //rnd(100) < rating = jewel
+	byte type = 0;                  //actor (0=thor,1=hammer,2=enemy,3=shot)
+	byte name[9] = {};              //actors name
+	byte func_num = 0;              //special function when thor touches
+	byte func_pass = 0;             //value to pass to func
+	int  magic_hurts = 0;           //bitwise magic hurts flags
+	byte future1[4] = {};
 
 	//the rest is dynamic    //size=216
-	MASK_IMAGE pic[4][4];       //mask image pointers
-	char frame_count;           //count to switch frames
-	char dir;                   //direction of travel
-	char last_dir;              //last direction of travel
-	int  x;                     //actual X coor
-	int  y;                     //actual Y coor
-	int  center;                //center of object
-	int  last_x[2];             //last X coor on each page
-	int  last_y[2];             //last Y coor on each page
-	char used;                  //1=active, 0=not active
-	char next;                  //next frame to be shown
-	char speed_count;           //count down to movement
-	char vunerable;             //count down to vunerability
-	char shot_cnt;              //count down to another shot
-	char num_shots;             //# of shots currently on screen
-	char creator;               //which actor # created this actor
-	char pause;                 //pause must be 0 to move
-	char actor_num;
-	char move_count;
-	char dead;
-	char toggle;
-	char center_x;
-	char center_y;
-	char show;                  //display or not (for blinking)
-	char temp1;
-	char temp2;
-	char counter;
-	char move_counter;
-	char edge_counter;
-	char temp3;
-	char temp4;
-	char temp5;
-	char hit_thor;
-	int  rand;
-	char init_dir;
-	char pass_value;
-	char shot_actor;
-	char magic_hit;
-	char temp6;
-	int  i1, i2, i3, i4, i5, i6;
-	char init_health;
-	char talk_counter;
-	char etype;
-	char future2[25];
+	MASK_IMAGE pic[4][4] = {};      //mask image pointers
+	byte frame_count = 0;           //count to switch frames
+	byte dir = 0;                   //direction of travel
+	byte last_dir = 0;              //last direction of travel
+	int  x = 0;                     //actual X coor
+	int  y = 0;                     //actual Y coor
+	int  center = 0;                //center of object
+	int  last_x[2] = {};            //last X coor on each page
+	int  last_y[2] = {};            //last Y coor on each page
+	byte used = 0;                  //1=active, 0=not active
+	byte next = 0;                  //next frame to be shown
+	byte speed_count = 0;           //count down to movement
+	byte vunerable = 0;             //count down to vunerability
+	byte shot_cnt = 0;              //count down to another shot
+	byte num_shots = 0;             //# of shots currently on screen
+	byte creator = 0;               //which actor # created this actor
+	byte pause = 0;                 //pause must be 0 to move
+	byte actor_num = 0;
+	byte move_count = 0;
+	byte dead = 0;
+	byte toggle = 0;
+	byte center_x = 0;
+	byte center_y = 0;
+	byte show = 0;                  //display or not (for blinking)
+	byte temp1 = 0;
+	byte temp2 = 0;
+	byte counter = 0;
+	byte move_counter = 0;
+	byte edge_counter = 0;
+	byte temp3 = 0;
+	byte temp4 = 0;
+	byte temp5 = 0;
+	byte hit_thor = 0;
+	int  rand = 0;
+	byte init_dir = 0;
+	byte pass_value = 0;
+	byte shot_actor = 0;
+	byte magic_hit = 0;
+	byte temp6 = 0;
+	int  i1, i2, i3, i4, i5, i6 = 0;
+	byte init_health = 0;
+	byte talk_counter = 0;
+	byte etype = 0;
+	byte future2[25] = {};
 };
 
 struct ACTOR_NFO {				//size=40
-	char move;                  //movement pattern (0=none)
-	char width;                 //physical width
-	char height;                //physical height
-	char directions;            //1,2 or 4 (1=uni-directional)
-	char frames;                //# frames per direction
-	char frame_speed;           //# cycles between frame changes
-	char frame_sequence[4];     //sequence
-	char speed;                 //move every Nth cycle
-	char size_x;                 //non-physical padding on X coor
-	char size_y;                 //non-phsyical padding on Y coor
-	char strength;              //hit strength
-	char health;                //
-	char num_moves;             //# of moves every <speed> cycles
-	char shot_type;             //actor # of shot
-	char shot_pattern;          //func number to decide to shoot
-	char shots_allowed;         //# shots allowed on screen
-	char solid;                 //1=solid (not ghost,etc)
-	char flying;                //
-	char rating;                //rnd(100) < rating = jewel
-	char type;                  //actor (0=thor,1=hammer,2=enemy,3=shot)
-	char name[9];               //actors name
-	char func_num;              //special function when thor touches
-	char func_pass;             //value to pass to func
-	char future1[6];
+	byte move = 0;                  //movement pattern (0=none)
+	byte width = 0;                 //physical width
+	byte height = 0;                //physical height
+	byte directions = 0;            //1,2 or 4 (1=uni-directional)
+	byte frames = 0;                //# frames per direction
+	byte frame_speed = 0;           //# cycles between frame changes
+	byte frame_sequence[4] = {};    //sequence
+	byte speed = 0;                 //move every Nth cycle
+	byte size_x = 0;                //non-physical padding on X coor
+	byte size_y = 0;                //non-phsyical padding on Y coor
+	byte strength = 0;              //hit strength
+	byte health = 0;                //
+	byte num_moves = 0;             //# of moves every <speed> cycles
+	byte shot_type = 0;             //actor # of shot
+	byte shot_pattern = 0;          //func number to decide to shoot
+	byte shots_allowed = 0;         //# shots allowed on screen
+	byte solid = 0;                 //1=solid (not ghost,etc)
+	byte flying = 0;                //
+	byte rating = 0;                //rnd(100) < rating = jewel
+	byte type = 0;                  //actor (0=thor,1=hammer,2=enemy,3=shot)
+	byte name[9] = {};              //actors name
+	byte func_num = 0;              //special function when thor touches
+	byte func_pass = 0;             //value to pass to func
+	byte future1[6] = {};
 };
 
-struct ACTOR_DATA {               //5200
-	char pic[16][256];            //4096
-	char shot[4][256];            //1024
-	ACTOR_NFO actor_info;         //40
-	ACTOR_NFO shot_info;          //40
-} ;
+struct ACTOR_DATA {                 //5200
+	byte pic[16][256] = {};         //4096
+	byte shot[4][256] = {};         //1024
+	ACTOR_NFO actor_info = {};      //40
+	ACTOR_NFO shot_info = {};       //40
+};
 
 struct SETUP {
 	unsigned int  f00 : 1;
@@ -244,56 +244,56 @@ struct SETUP {
 	unsigned int  f62 : 1;
 	unsigned int  f63 : 1;
 
-	char value[16];
-	char junk;
-	char game;
-	char area;          //1,2,3
-	char pc_sound;      //1=enabled
-	char dig_sound;     //1 & !pc_sound = enabled
-	char music;         //1=enabled
-	char speed;         //1=slow mode (for slower 286's)
-	char scroll_flag;   //unused
-	char boss_dead[3];
-	char skill;         //0=easy, 1=normal, 2=hard
-	char game_over;
-	char future[19];    //probably not needed
+	byte value[16] = {};
+	byte junk = 0;
+	byte game = 0;
+	byte area = 0;          //1,2,3
+	byte pc_sound = 0;      //1=enabled
+	byte dig_sound = 0;     //1 & !pc_sound = enabled
+	byte music = 0;         //1=enabled
+	byte speed = 0;         //1=slow mode (for slower 286's)
+	byte scroll_flag = 0;   //unused
+	byte boss_dead[3] = {};
+	byte skill = 0;         //0=easy, 1=normal, 2=hard
+	byte game_over = 0;
+	byte future[19] = {};   //probably not needed
 };
 
 struct PIC_HEADER {
-	char width;
-	char height;
+	byte width = 0;
+	byte height = 0;
 };
 
 struct THOR_INFO {
-	char magic;
-	char keys;
-	int  jewels;
-	char last_area;
-	char last_screen;
-	char last_icon;
-	char last_dir;
-	int  inventory;
-	char item;         //currently selected item
-	char last_health;
-	char last_magic;
-	int  last_jewels;
-	char last_keys;
-	char last_item;
-	int  last_inventory;
-	char level;         //current level (1,2,3)
-	long score;
-	long last_score;
-	char object;
-	char *object_name;
-	char last_object;
-	char *last_object_name;
-	char armor;
-	char future[65];
+	byte magic = 0;
+	byte keys = 0;
+	int  jewels = 0;
+	byte last_area = 0;
+	byte last_screen = 0;
+	byte last_icon = 0;
+	byte last_dir = 0;
+	int  inventory = 0;
+	byte item = 0;         //currently selected item
+	byte last_health = 0;
+	byte last_magic = 0;
+	int  last_jewels = 0;
+	byte last_keys = 0;
+	byte last_item = 0;
+	int  last_inventory = 0;
+	byte level = 0;         //current level (1,2,3)
+	long score = 0;
+	long last_score = 0;
+	byte object = 0;
+	byte *object_name = 0;
+	byte last_object = 0;
+	byte *last_object_name = 0;
+	byte armor = 0;
+	byte future[65] = {};
 };
 
 struct HEADER {
-	long offset;
-	long length;
+	long offset = 0;
+	long length = 0;
 };
 
 //==========================================================================
@@ -437,10 +437,10 @@ enum {
 
 #define	status_Reg1 0x3da
 
-#define GAME1 (area==1)
-#define GAME2 (area==2)
-#define GAME3 (area==3)
-#define BP    (key_flag[_B])
+#define GAME1 (_G(area)==1)
+#define GAME2 (_G(area)==2)
+#define GAME3 (_G(area)==3)
+#define BP    (_G(key_flag)[_B])
 
 #define NUM_SOUNDS  19
 #define NUM_OBJECTS 32
diff --git a/engines/got/got.h b/engines/got/got.h
index 16fe0d867b2..ef1d70fc9d6 100644
--- a/engines/got/got.h
+++ b/engines/got/got.h
@@ -36,6 +36,7 @@
 
 #include "got/detection.h"
 #include "got/events.h"
+#include "got/vars.h"
 
 namespace Got {
 
@@ -56,6 +57,9 @@ protected:
 		return Engine::shouldQuit();
 	}
 
+public:
+	Vars _vars;
+
 public:
 	GotEngine(OSystem *syst, const ADGameDescription *gameDesc);
 	~GotEngine() override;
diff --git a/engines/got/module.mk b/engines/got/module.mk
index a1dbfba72ad..c4ab95f0d4b 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS = \
 	events.o \
 	messages.o \
 	metaengine.o \
+	vars.o \
 	utils/file.o \
 	utils/res_archive.o \
 	views/view.o \
diff --git a/engines/got/utils/file.cpp b/engines/got/utils/file.cpp
index 7ce2426dc87..996ae79da9e 100644
--- a/engines/got/utils/file.cpp
+++ b/engines/got/utils/file.cpp
@@ -22,32 +22,10 @@
 #include "common/file.h"
 #include "got/utils/file.h"
 #include "got/prototypes.h"
+#include "got/vars.h"
 
 namespace Got {
 
-extern byte *bg_pics;
-extern char objects[NUM_OBJECTS][262];
-extern byte *sd_data;
-extern char *tmp_buff;
-extern char res_file[];
-extern THOR_INFO thor_info;
-extern int current_area;
-extern ACTOR *thor;
-extern char *save_filename;
-extern union REGS in, out;
-extern SETUP setup;
-extern char level_type, slow_mode;
-extern int  boss_active;
-extern char area;
-extern char test_sdf[];
-extern char *song;
-extern char *lzss_buff;
-extern char *options_yesno[];
-extern int music_flag, sound_flag, pcsound_flag;
-extern char game_over;
-extern unsigned int display_page, draw_page;
-extern volatile char key_flag[100];
-
 static const char *gotres = "GOTRES.00";
 
 long file_size(char *path) {
@@ -56,12 +34,12 @@ long file_size(char *path) {
 }
 
 bool load_bg_data() {
-	bg_pics = new byte[60460];
-	if (!bg_pics)
+	_G(bg_pics) = new byte[60460];
+	if (!_G(bg_pics))
 		return false;
 
 	if (GAME1) {
-		if (res_read("BPICS1", bg_pics) < 0)
+		if (res_read("BPICS1", _G(bg_pics)) < 0)
 			return false;
 	}
 
@@ -69,24 +47,24 @@ bool load_bg_data() {
 }
 
 bool load_sd_data() {
-	Common::String fname = Common::String::format("SDAT%d", area);
+	Common::String fname = Common::String::format("SDAT%d", _G(area));
 
-	if (!sd_data)
-		sd_data = new byte[61440];
-	if (!sd_data)
+	if (!_G(sd_data))
+		_G(sd_data) = new byte[61440];
+	if (!_G(sd_data))
 		return false;
 
-	return res_read(fname, sd_data) > 0;
+	return res_read(fname, _G(sd_data)) > 0;
 }
 
 bool load_objects() {
-	return res_read("OBJECTS", (char *)objects) > 0;
+	return res_read("OBJECTS", _G(objects)) > 0;
 }
 
 bool load_actor(int file, int num) {
 	Common::String fname = Common::String::format("ACTOR%d", num);
 
-	if (res_read(fname, tmp_buff) < 0)
+	if (res_read(fname, _G(tmp_buff)) < 0)
 		return false;
 
 	//file = file;
@@ -100,7 +78,7 @@ bool load_speech(int index) {
 	char *sp;
 	char tmps[5];
 
-	Common::String fname = Common::String::format("SPEAK%d", area);
+	Common::String fname = Common::String::format("SPEAK%d", _G(area));
 
 	sp = new char[30000];
 	if (!sp)
@@ -157,8 +135,8 @@ bool load_speech(int index) {
 		*(p - 1) = 0;
 	*p = 0;
 
-	Common::copy(pm, pm + cnt, tmp_buff);
-	tmp_buff[cnt] = 0;
+	Common::copy(pm, pm + cnt, _G(tmp_buff));
+	_G(tmp_buff)[cnt] = 0;
 
 	delete[] sp;
 	return true;
@@ -180,7 +158,7 @@ void save_game() {
 	if (game_over)
 		return;
 
-	setup.area = area;
+	setup.area = _G(area);
 	setup.game_over = game_over;
 
 	if (select_option(options_yesno, "Save Game?", 0) != 1) {
@@ -199,7 +177,7 @@ void save_game() {
 	_dos_write(handle, buff, 32, &total);
 	_dos_write(handle, &setup, sizeof(SETUP), &total);
 	_dos_write(handle, &thor_info, sizeof(THOR_INFO), &total);
-	_dos_write(handle, sd_data, 61440u, &total);
+	_dos_write(handle, _G(sd_data), 61440u, &total);
 	_dos_close(handle);
 	odin_speaks(2009, 0);
 #endif
@@ -222,7 +200,7 @@ bool load_game(int flag) {
 	_dos_read(handle, buff, 32, &total);
 	_dos_read(handle, &setup, sizeof(SETUP), &total);
 	_dos_read(handle, &thor_info, sizeof(THOR_INFO), &total);
-	_dos_read(handle, sd_data, 61440u, &total);
+	_dos_read(handle, _G(sd_data), 61440u, &total);
 	_dos_close(handle);
 
 	current_area = thor_info.last_screen;
@@ -308,26 +286,26 @@ return res_header[num].length;
 bool load_music(int num) {
 	switch (num) {
 	case 0:
-		res_read("SONG1", song);
+		res_read("SONG1", _G(song));
 		break;
 	case 1:
-		res_read("SONG2", song);
+		res_read("SONG2", _G(song));
 		break;
 	case 2:
-		res_read("SONG3", song);
+		res_read("SONG3", _G(song));
 		break;
 	case 3:
-		res_read("SONG4", song);
+		res_read("SONG4", _G(song));
 		break;
 	case 4:
-		res_read("WINSONG", song);
+		res_read("WINSONG", _G(song));
 		break;
 	case 5:
-		res_read("BOSSSONG", song);
+		res_read("BOSSSONG", _G(song));
 		break;
 	}
 
-	return song != nullptr;
+	return _G(song) != nullptr;
 }
 
 } // End of namespace Got
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
new file mode 100644
index 00000000000..334fa554a09
--- /dev/null
+++ b/engines/got/vars.cpp
@@ -0,0 +1,35 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/algorithm.h"
+#include "got/vars.h"
+
+namespace Got {
+
+byte dialog_color[] = { 14,54,120,138,15,0,0,0,0,0,0,0,0,0,0,0 };
+const char *options_yesno[] = { "Yes","No", nullptr };
+const char *save_filename = "XXXXXXXX.XXX";
+
+
+Vars::Vars() {
+}
+
+} // namespace Got
diff --git a/engines/got/vars.h b/engines/got/vars.h
new file mode 100644
index 00000000000..e96943fc7f4
--- /dev/null
+++ b/engines/got/vars.h
@@ -0,0 +1,172 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VARS_H
+#define GOT_VARS_H
+
+#include "got/defines.h"
+
+namespace Got {
+
+class Vars;
+
+extern Vars *g_vars;
+
+class Vars {
+public:
+	Vars();
+
+	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
+	uint _display_page = 0, _draw_page = 0;
+	uint _page3_offset = 0;
+	int8 _pge = 0;
+	int _exit_flag = 0;
+
+	byte _key_flag[100] = {};
+	byte _joy_flag[100] = {};
+	byte _tmp_flag[100] = {};
+	int8 _break_code = 0;
+	int8 _scan_code, _last_scan_code = 0;
+	int8 _diag = 0;
+	int8 _slow_mode = 0, _startup = 0;
+	int8 _shot_ok = 0;
+	int _thor_x1 = 0, _thor_y1 = 0, _thor_x2 = 0, _thor_y2 = 0,
+		_thor_real_y1 = 0;
+	int _thor_pos = 0;
+	int _max_shot = 0;
+
+	uint _timer_cnt = 0, _vbl_cnt = 0, _magic_cnt = 0, _extra_cnt = 0;
+
+	byte _text[94][72] = {};
+	//union REGS in, out = 0;
+	//struct SREGS seg = 0;
+	byte *_bg_pics = nullptr;
+	byte _objects[NUM_OBJECTS][262] = {};
+	int _ox = 0, _oy = 0, _of = 0;
+	byte _object_map[240] = {};
+	byte _object_index[240] = {};
+	byte *_bleep = nullptr;
+	int8 _thor_icon1 = 0, _thor_icon2 = 0, _thor_icon3 = 0,
+		_thor_icon4 = 0;
+	int8 _level_type = 0;
+	byte *_song = nullptr;
+	int8 _music_current = 0;
+	int8 _boss_loaded = 0;
+	int8 _apple_drop = 0;
+	int8 _cheat = 0;
+	int8 _area = 0;
+	byte _last_setup[32] = {};
+
+	LEVEL _scrn;
+	byte *_scrnp = nullptr;
+
+	byte *_sd_data = nullptr;
+	int _current_level = 0, _new_level = 0, _new_level_tile = 0,
+		_current_area = 0;
+
+	SETUP _setup;
+	byte *_tmp_buff = nullptr;
+	int _reps = 0;
+
+	byte *_mask_buff = nullptr;
+	byte *_mask_buff_start = nullptr;
+	byte _abuff[AMI_LEN] = {};
+	byte *_ami_buff = nullptr;
+	ACTOR _actor[MAX_ACTORS] = {};   //current actors
+	ACTOR _enemy[MAX_ENEMIES] = {};  //current enemies
+	ACTOR _shot[MAX_ENEMIES] = {};   //current shots
+	int8 _enemy_type[MAX_ENEMIES] = {};
+
+	ACTOR _magic_item[2] = {};
+	byte _magic_pic[2][1024] = {};
+	int8 _warp_scroll = 0;
+
+	ACTOR *_thor = nullptr;
+	ACTOR *_hammer = nullptr;
+	ACTOR _explosion;
+	ACTOR _sparkle;
+	THOR_INFO _thor_info;
+	int _key_fire = 0, _key_up = 0, _key_down = 0, _key_left = 0,
+		_key_right = 0, _key_magic = 0, _key_select = 0;
+	int _boss_dead = 0;
+
+	int _warp_flag = 0;
+
+	int8 *_std_sound_start = nullptr;
+	int8 *_pcstd_sound_start = nullptr;
+	int8 *_std_sound = nullptr;
+	int8 *_pcstd_sounds = nullptr;
+	byte *_boss_sound[3] = {};
+	byte *_boss_pcsound[3] = {};
+	long _pcsound_length[NUM_SOUNDS] = {};
+	int _rand1 = 0, _rand2 = 0;
+	int _restore_screen = 0;
+	int _last_oracle = 0;
+	int _hourglass_flag = 0, _thunder_flag = 0, _shield_on = 0,
+		_lightning_used = 0, _tornado_used = 0;
+	int _apple_flag = 0, _bomb_flag = 0;
+	int _switch_flag = 0;
+	uint _joy_x = 0, _joy_y = 0;
+	int8 _joy_b1 = 0, _joy_b2 = 0;
+	int _joystick = 0, _joylx = 0, _joyly = 0,
+		_joyhx = 0, _joyhy = 0;
+	byte _res_file[16] = {};
+	byte _odin[4][262] = {};
+	byte _hampic[4][262] = {};
+	int _load_game_flag = 0;
+	int _music_flag = 0, _sound_flag = 0, _pcsound_flag = 0;
+	int _cash1_inform = 0, _cash2_inform = 0, _door_inform = 0,
+		_magic_inform = 0, _carry_inform = 0;
+	int _killgg_inform = 0;
+
+	int8 *_std_sounds = nullptr;
+	byte *_pc_sound[NUM_SOUNDS] = {};
+	byte *_dig_sound[NUM_SOUNDS] = {};
+	int  _boss_active = 0;
+	int8 _story_flag = 0;
+	int8 *_scr = nullptr;
+	char _demo_key[DEMO_LEN] = {};
+	int  _demo_cnt = 0;
+	int8 _demo = 0, _record = 0;
+	int8 _demo_enable = 0;
+	int  _rnd_index = 0;
+	int  _rnd_array[100] = {};
+	int8 _rdemo = 0;
+	int8 _test_sdf[80] = {};
+	int8 _lzss_buff = 0;
+	int8 _game_over = 0;
+	int8 _noal = 0, _nosb = 0, _ret = 0;
+	char _tempstr[80] = {};
+	int8 _auto_load = 0;
+	int8 _ide_run = 0, _fast_exit = 0, _nojoy = 0, _gr = 0, _xdos = 0;
+	int8 _main_loop = 0;
+	int8 _end_tile = 0;
+};
+
+#define _G(X) (g_vars->_##X)
+
+extern byte dialog_color[];
+extern const char *options_yesno[];
+extern const char *save_filename;
+
+} // namespace Got
+
+#endif


Commit: 8217fb0fa959bdc6b057a7018a4b1b197c00b890
    https://github.com/scummvm/scummvm/commit/8217fb0fa959bdc6b057a7018a4b1b197c00b890
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Adding further initialization, statics loading

Changed paths:
  A engines/got/gfx/palette.cpp
  A engines/got/gfx/palette.h
    engines/got/detection_tables.h
    engines/got/got.cpp
    engines/got/got.h
    engines/got/module.mk
    engines/got/utils/file.cpp
    engines/got/vars.cpp
    engines/got/vars.h


diff --git a/engines/got/detection_tables.h b/engines/got/detection_tables.h
index 26f57538719..58f1ca5c75f 100644
--- a/engines/got/detection_tables.h
+++ b/engines/got/detection_tables.h
@@ -37,6 +37,16 @@ const ADGameDescription gameDescriptions[] = {
 		GUIO1(GUIO_NONE)
 	},
 
+{
+		"got",
+		"Demo",
+		AD_ENTRY1s("gotres.dat", "747ed508ffa3808156a4eb080e9859f8", 739710),
+		Common::EN_ANY,
+		Common::kPlatformDOS,
+		ADGF_UNSTABLE | ADGF_DEMO,
+		GUIO1(GUIO_NONE)
+	},
+
 	AD_TABLE_END_MARKER
 };
 
diff --git a/engines/got/gfx/palette.cpp b/engines/got/gfx/palette.cpp
new file mode 100644
index 00000000000..e6efdf17b7e
--- /dev/null
+++ b/engines/got/gfx/palette.cpp
@@ -0,0 +1,59 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/system.h"
+#include "graphics/paletteman.h"
+#include "got/gfx/palette.h"
+#include "got/utils/file.h"
+#include "got/vars.h"
+
+namespace Got {
+
+void load_palette() {
+	byte buff[256 * 3];
+
+	if (res_read("PALETTE", buff) < 0)
+		error("Cannot Read PALETTE");
+
+	g_system->getPaletteManager()->setPalette(buff, 0, 256);
+
+	set_screen_pal();
+}
+
+void set_screen_pal() {
+	char pal[3];
+
+	xgetpal(pal, 1, _G(scrn).pal_colors[0]);
+	xsetpal(251, pal[0], pal[1], pal[2]);
+	xgetpal(pal, 1, _G(scrn).pal_colors[1]);
+	xsetpal(252, pal[0], pal[1], pal[2]);
+	xgetpal(pal, 1, _G(scrn).pal_colors[2]);
+	xsetpal(253, pal[0], pal[1], pal[2]);
+}
+
+void xsetpal(byte color, byte R, byte G, byte B) {
+
+}
+void xgetpal(void *pal, int num_colrs, int start_index) {
+
+}
+
+} // namespace Got
diff --git a/engines/got/gfx/palette.h b/engines/got/gfx/palette.h
new file mode 100644
index 00000000000..b5604aee7c7
--- /dev/null
+++ b/engines/got/gfx/palette.h
@@ -0,0 +1,36 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GFX_PALETTE_H
+#define GOT_GFX_PALETTE_H
+
+#include "graphics/paletteman.h"
+
+namespace Got {
+
+extern void load_palette();
+extern void set_screen_pal();
+extern void xsetpal(byte color, byte R, byte G, byte B);
+extern void xgetpal(void *pal, int num_colrs, int start_index);
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 65c56185374..4c1e90939f9 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -47,6 +47,10 @@ uint32 GotEngine::getFeatures() const {
 	return _gameDescription->flags;
 }
 
+bool GotEngine::isDemo() const {
+	return (_gameDescription->flags & ADGF_DEMO) != 0;
+}
+
 Common::String GotEngine::getGameId() const {
 	return _gameDescription->gameId;
 }
@@ -58,8 +62,9 @@ Common::Error GotEngine::run() {
 	// Set the engine's debugger console
 	setDebugger(new Console());
 
-	// Initialize resource access
+	// Initialize resources and variables
 	resInit();
+	_vars.load();
 
 	runGame();
 
diff --git a/engines/got/got.h b/engines/got/got.h
index ef1d70fc9d6..6d8ffd5e831 100644
--- a/engines/got/got.h
+++ b/engines/got/got.h
@@ -65,6 +65,7 @@ public:
 	~GotEngine() override;
 
 	uint32 getFeatures() const;
+	bool isDemo() const;
 
 	/**
 	 * Returns the game Id
diff --git a/engines/got/module.mk b/engines/got/module.mk
index c4ab95f0d4b..73bcd7d1488 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -7,6 +7,7 @@ MODULE_OBJS = \
 	messages.o \
 	metaengine.o \
 	vars.o \
+	gfx/palette.o \
 	utils/file.o \
 	utils/res_archive.o \
 	views/view.o \
diff --git a/engines/got/utils/file.cpp b/engines/got/utils/file.cpp
index 996ae79da9e..d321097ddb1 100644
--- a/engines/got/utils/file.cpp
+++ b/engines/got/utils/file.cpp
@@ -146,7 +146,9 @@ void setup_filenames(int level) {
 }
 
 void help(void) {
+#ifdef TODO
 	odin_speaks(2008, -1);
+#endif
 }
 
 void save_game() {
@@ -241,47 +243,14 @@ bool load_game(int flag) {
 	return true;
 }
 
-/*
-long res_read(char *name,char *buff){
-int num,bytes;
-size_t len;
-size_t total;
-char bf[256];
-char *p;
-unsigned int clen;
-unsigned int *up;
-
-if(!res_active) return RES_NOT_ACTIVE;
-if(!res_fp) return RES_NOT_OPEN;
-
-num=res_find_name(name);
-if(num<0) return RES_CANT_FIND;
-
-if(fseek(res_fp,res_header[num].offset,SEEK_SET)) return RES_CANT_SEEK;
-len=(size_t) res_header[num].length;
-
-total=0;
-if(res_header[num].key) p=buff;
-else p=lzss_buff;
-while(total<len){
-	 if(((len-total) >255) && (len > 255)) bytes=fread(bf,1,256,res_fp);
-	 else bytes=fread(bf,1,len-total,res_fp);
-	 if(!bytes) break;
-	 total+=bytes;
-	 movedata(FP_SEG(bf),FP_OFF(bf),FP_SEG(p),FP_OFF(p),bytes);
-	 p+=bytes;
-}
-if(res_header[num].key) res_decode(buff,len,res_header[num].key);
-else{
-  p=lzss_buff;
-  up=(unsigned int *) p;
-  clen=*up;
-  p+=4;
-  UnLZSS(p,buff,clen);
-}
-return res_header[num].length;
+long res_read(const Common::String &name, void *buff) {
+	Common::File f;
+	if (f.open(Common::Path(name))) {
+		return f.read(buff, f.size());
+	} else {
+		return -1;
+	}
 }
-*/
 
 bool load_music(int num) {
 	switch (num) {
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 334fa554a09..aa30cdc3b46 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -20,16 +20,79 @@
  */
 
 #include "common/algorithm.h"
+#include "common/config-manager.h"
 #include "got/vars.h"
+#include "got/gfx/palette.h"
+#include "got/utils/file.h"
+#include "got/got.h"
 
 namespace Got {
 
+Vars *g_vars;
+
 byte dialog_color[] = { 14,54,120,138,15,0,0,0,0,0,0,0,0,0,0,0 };
 const char *options_yesno[] = { "Yes","No", nullptr };
 const char *save_filename = "XXXXXXXX.XXX";
 
 
 Vars::Vars() {
+	g_vars = this;
+}
+
+void Vars::load() {
+	_music_flag = !ConfMan.getBool("music_mute");
+	_sound_flag = _pcsound_flag = !ConfMan.getBool("sfx_mute");
+
+	if (g_engine->isDemo()) {
+		_demo = _cheat = true;
+		_rdemo = ConfMan.getBool("rdemo");
+	}
+
+	if (_demo || _record) {
+		if (_record)
+			_demo = 0;
+
+		_area = 1;
+		_setup.area = 1;
+		_cash1_inform = 1;
+		_cash2_inform = 1;
+		_door_inform = 1;
+		_magic_inform = 1;
+		_carry_inform = 1;
+		_story_flag = 0;
+	}
+
+	if (_current_level != 23)
+		_story_flag = 0;
+
+	_setup.music = _music_flag;
+	_setup.dig_sound = _sound_flag;
+	_setup.pc_sound = _pcsound_flag;
+	if (_sound_flag)
+		_setup.pc_sound = false;
+	_setup.scroll_flag = true;
+	_setup.speed = _slow_mode;
+	_setup.skill = 1;
+
+	_tmp_buff = new byte[TMP_SIZE];
+	_mask_buff = new byte[15300];
+	_mask_buff_start = _mask_buff;
+ 
+	if (res_read("RANDOM", _rnd_array) < 0
+		|| res_read("DEMO", _demo_key) < 0
+		|| res_read("TEXT", _text) < 0
+		|| res_read("ODINPIC", _odin) < 0
+		|| res_read("HAMPIC", _hampic) < 0)
+		error("Error loading static data");
+
+	load_palette();
+}
+
+Vars::~Vars() {
+	g_vars = nullptr;
+
+	delete[] _tmp_buff;
+	delete[] _mask_buff;
 }
 
 } // namespace Got
diff --git a/engines/got/vars.h b/engines/got/vars.h
index e96943fc7f4..4b33b73b0c6 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -22,6 +22,7 @@
 #ifndef GOT_VARS_H
 #define GOT_VARS_H
 
+#include "common/events.h"
 #include "got/defines.h"
 
 namespace Got {
@@ -33,6 +34,9 @@ extern Vars *g_vars;
 class Vars {
 public:
 	Vars();
+	~Vars();
+
+	void load();
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
 	uint _display_page = 0, _draw_page = 0;
@@ -71,16 +75,16 @@ public:
 	int8 _music_current = 0;
 	int8 _boss_loaded = 0;
 	int8 _apple_drop = 0;
-	int8 _cheat = 0;
-	int8 _area = 0;
+	bool _cheat = false;
+	int8 _area = 1;
 	byte _last_setup[32] = {};
 
 	LEVEL _scrn;
 	byte *_scrnp = nullptr;
 
 	byte *_sd_data = nullptr;
-	int _current_level = 0, _new_level = 0, _new_level_tile = 0,
-		_current_area = 0;
+	int _current_level = 23;
+	int _new_level = 0, _new_level_tile = 0, _current_area = 0;
 
 	SETUP _setup;
 	byte *_tmp_buff = nullptr;
@@ -104,8 +108,10 @@ public:
 	ACTOR _explosion;
 	ACTOR _sparkle;
 	THOR_INFO _thor_info;
-	int _key_fire = 0, _key_up = 0, _key_down = 0, _key_left = 0,
-		_key_right = 0, _key_magic = 0, _key_select = 0;
+	Common::KeyCode _key_fire = Common::KEYCODE_LALT,
+		_key_up = Common::KEYCODE_UP, _key_down = Common::KEYCODE_DOWN,
+		_key_left = Common::KEYCODE_LEFT, _key_right = Common::KEYCODE_RIGHT,
+		_key_magic = Common::KEYCODE_LCTRL, _key_select = Common::KEYCODE_SPACE;
 	int _boss_dead = 0;
 
 	int _warp_flag = 0;
@@ -132,7 +138,7 @@ public:
 	byte _odin[4][262] = {};
 	byte _hampic[4][262] = {};
 	int _load_game_flag = 0;
-	int _music_flag = 0, _sound_flag = 0, _pcsound_flag = 0;
+	bool _music_flag = false, _sound_flag = false, _pcsound_flag = false;
 	int _cash1_inform = 0, _cash2_inform = 0, _door_inform = 0,
 		_magic_inform = 0, _carry_inform = 0;
 	int _killgg_inform = 0;
@@ -141,11 +147,11 @@ public:
 	byte *_pc_sound[NUM_SOUNDS] = {};
 	byte *_dig_sound[NUM_SOUNDS] = {};
 	int  _boss_active = 0;
-	int8 _story_flag = 0;
+	int8 _story_flag = 1;
 	int8 *_scr = nullptr;
 	char _demo_key[DEMO_LEN] = {};
 	int  _demo_cnt = 0;
-	int8 _demo = 0, _record = 0;
+	bool _demo = false, _record = false;
 	int8 _demo_enable = 0;
 	int  _rnd_index = 0;
 	int  _rnd_array[100] = {};


Commit: e05c0ff9be62f54252e30a8937b1ff208173dd85
    https://github.com/scummvm/scummvm/commit/e05c0ff9be62f54252e30a8937b1ff208173dd85
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: More palette code

Changed paths:
    engines/got/gfx/palette.cpp
    engines/got/gfx/palette.h


diff --git a/engines/got/gfx/palette.cpp b/engines/got/gfx/palette.cpp
index e6efdf17b7e..1f54499a60e 100644
--- a/engines/got/gfx/palette.cpp
+++ b/engines/got/gfx/palette.cpp
@@ -39,7 +39,7 @@ void load_palette() {
 }
 
 void set_screen_pal() {
-	char pal[3];
+	byte pal[3];
 
 	xgetpal(pal, 1, _G(scrn).pal_colors[0]);
 	xsetpal(251, pal[0], pal[1], pal[2]);
@@ -50,10 +50,12 @@ void set_screen_pal() {
 }
 
 void xsetpal(byte color, byte R, byte G, byte B) {
-
+	byte rgb[3] = { R, G, B };
+	g_system->getPaletteManager()->setPalette(rgb, color, 1);
 }
-void xgetpal(void *pal, int num_colrs, int start_index) {
 
+void xgetpal(byte *pal, int num_colrs, int start_index) {
+	g_system->getPaletteManager()->grabPalette(pal, start_index, num_colrs);
 }
 
 } // namespace Got
diff --git a/engines/got/gfx/palette.h b/engines/got/gfx/palette.h
index b5604aee7c7..20064157570 100644
--- a/engines/got/gfx/palette.h
+++ b/engines/got/gfx/palette.h
@@ -29,7 +29,7 @@ namespace Got {
 extern void load_palette();
 extern void set_screen_pal();
 extern void xsetpal(byte color, byte R, byte G, byte B);
-extern void xgetpal(void *pal, int num_colrs, int start_index);
+extern void xgetpal(byte *pal, int num_colrs, int start_index);
 
 } // namespace Got
 


Commit: a553a01482c80f820f0f2598fc1cbddbc4d10c73
    https://github.com/scummvm/scummvm/commit/a553a01482c80f820f0f2598fc1cbddbc4d10c73
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Beginnings of first screen

Changed paths:
  A engines/got/views/story.cpp
  A engines/got/views/story.h
  R engines/got/views/view1.cpp
  R engines/got/views/view1.h
    engines/got/events.cpp
    engines/got/gfx/palette.cpp
    engines/got/gfx/palette.h
    engines/got/got.cpp
    engines/got/module.mk
    engines/got/utils/file.cpp
    engines/got/vars.cpp
    engines/got/vars.h
    engines/got/views/views.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index ae1e7a20a65..95a8a9fc84e 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -47,7 +47,7 @@ void Events::runGame() {
 	if (saveSlot != -1)
 		g_engine->loadGameState(saveSlot);
 
-	addView("View1");
+	addView("Story");
 
 	Common::Event e;
 	while (!_views.empty() && !shouldQuit()) {
diff --git a/engines/got/gfx/palette.cpp b/engines/got/gfx/palette.cpp
index 1f54499a60e..b15a1966e1c 100644
--- a/engines/got/gfx/palette.cpp
+++ b/engines/got/gfx/palette.cpp
@@ -58,4 +58,9 @@ void xgetpal(byte *pal, int num_colrs, int start_index) {
 	g_system->getPaletteManager()->grabPalette(pal, start_index, num_colrs);
 }
 
+void set_palette() {
+	const byte *pal = _G(pbuff);
+	g_system->getPaletteManager()->setPalette(pal, 0, PALETTE_COUNT);
+}
+
 } // namespace Got
diff --git a/engines/got/gfx/palette.h b/engines/got/gfx/palette.h
index 20064157570..49826c3f812 100644
--- a/engines/got/gfx/palette.h
+++ b/engines/got/gfx/palette.h
@@ -30,6 +30,7 @@ extern void load_palette();
 extern void set_screen_pal();
 extern void xsetpal(byte color, byte R, byte G, byte B);
 extern void xgetpal(byte *pal, int num_colrs, int start_index);
+extern void set_palette();
 
 } // namespace Got
 
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 4c1e90939f9..6d52004d0d9 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -56,8 +56,8 @@ Common::String GotEngine::getGameId() const {
 }
 
 Common::Error GotEngine::run() {
-	// Initialize 320x200 paletted graphics mode
-	initGraphics(320, 200);
+	// Initialize 320x240 palleted graphics mode
+	initGraphics(320, 240);
 
 	// Set the engine's debugger console
 	setDebugger(new Console());
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 73bcd7d1488..08093c3b31c 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -11,7 +11,7 @@ MODULE_OBJS = \
 	utils/file.o \
 	utils/res_archive.o \
 	views/view.o \
-	views/view1.o
+	views/story.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_GOT), DYNAMIC_PLUGIN)
diff --git a/engines/got/utils/file.cpp b/engines/got/utils/file.cpp
index d321097ddb1..0aae3ec6c4e 100644
--- a/engines/got/utils/file.cpp
+++ b/engines/got/utils/file.cpp
@@ -248,6 +248,7 @@ long res_read(const Common::String &name, void *buff) {
 	if (f.open(Common::Path(name))) {
 		return f.read(buff, f.size());
 	} else {
+		error("Could not load - %s", name.c_str());
 		return -1;
 	}
 }
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index aa30cdc3b46..610bf88b8ba 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -86,6 +86,8 @@ void Vars::load() {
 		error("Error loading static data");
 
 	load_palette();
+
+	_song = new byte[20000];
 }
 
 Vars::~Vars() {
@@ -93,6 +95,7 @@ Vars::~Vars() {
 
 	delete[] _tmp_buff;
 	delete[] _mask_buff;
+	delete[] _song;
 }
 
 } // namespace Got
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 4b33b73b0c6..661d3be8eac 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -23,6 +23,7 @@
 #define GOT_VARS_H
 
 #include "common/events.h"
+#include "graphics/screen.h"
 #include "got/defines.h"
 
 namespace Got {
@@ -165,6 +166,8 @@ public:
 	int8 _ide_run = 0, _fast_exit = 0, _nojoy = 0, _gr = 0, _xdos = 0;
 	int8 _main_loop = 0;
 	int8 _end_tile = 0;
+
+	byte _pbuff[PALETTE_SIZE];
 };
 
 #define _G(X) (g_vars->_##X)
diff --git a/engines/got/views/view1.cpp b/engines/got/views/story.cpp
similarity index 54%
rename from engines/got/views/view1.cpp
rename to engines/got/views/story.cpp
index c978432becd..5430fc11d85 100644
--- a/engines/got/views/view1.cpp
+++ b/engines/got/views/story.cpp
@@ -19,46 +19,60 @@
  *
  */
 
-#include "common/system.h"
-#include "graphics/paletteman.h"
-#include "got/views/view1.h"
+#include "got/views/story.h"
+#include "got/gfx/palette.h"
+#include "got/utils/file.h"
+#include "got/vars.h"
 
 namespace Got {
 namespace Views {
 
-bool View1::msgFocus(const FocusMessage &msg) {
-	Common::fill(&_pal[0], &_pal[256 * 3], 0);
-	_offset = 128;
+bool Story::msgFocus(const FocusMessage &msg) {
+	char back[4][262];
+
+	res_read("OPENSONG", _G(song));
+	res_read("STORY1", _G(tmp_buff));
+	res_read("OPENBACK", back);
+	res_read("STORYPIC", back);
+
+	// Load the images
+	_image1.create(320, 240);
+	_image2.create(320, 240);
+
+	for (int i = 0; i < 12; i++) {
+		Graphics::ManagedSurface *s = (i < 6) ? &_image1 : &_image2;
+		byte *destP = (byte *)s->getBasePtr(0, (i % 6) * 40);
+		res_read(Common::String::format("OPENP%d", i + 1), destP);
+	}
+
+	res_read("STORYPAL", _G(pbuff));
+	_G(pbuff)[2] = 0;
+	_G(pbuff)[1] = 0;
+	_G(pbuff)[0] = 0;
+	set_palette();
+
 	return true;
 }
 
-bool View1::msgKeypress(const KeypressMessage &msg) {
+bool Story::msgUnfocus(const UnfocusMessage &msg) {
+	_image1.clear();
+	_image2.clear();
+	return true;
+}
+
+bool Story::msgKeypress(const KeypressMessage &msg) {
 	// Any keypress to close the view
 	close();
 	return true;
 }
 
-void View1::draw() {
-	// Draw a bunch of squares on screen
+void Story::draw() {
 	Graphics::ManagedSurface s = getSurface();
 
-	for (int i = 0; i < 100; ++i)
-		s.frameRect(Common::Rect(i, i, 320 - i, 200 - i), i);
+	s.blitFrom(_image1);
 }
 
-bool View1::tick() {
-	// Cycle the palette
-	++_offset;
-	for (int i = 0; i < 256; ++i)
-		_pal[i * 3 + 1] = (i + _offset) % 256;
-	g_system->getPaletteManager()->setPalette(_pal, 0, 256);
-
-	// Below is redundant since we're only cycling the palette, but it demonstrates
-	// how to trigger the view to do further draws after the first time, since views
-	// don't automatically keep redrawing unless you tell it to
-	if ((_offset % 256) == 0)
-		redraw();
-
+bool Story::tick() {
 	return true;
 }
 
diff --git a/engines/got/views/view1.h b/engines/got/views/story.h
similarity index 81%
rename from engines/got/views/view1.h
rename to engines/got/views/story.h
index beeb4f56998..bd1fc090af8 100644
--- a/engines/got/views/view1.h
+++ b/engines/got/views/story.h
@@ -19,26 +19,25 @@
  *
  */
 
-#ifndef GOT_VIEWS_VIEW1_H
-#define GOT_VIEWS_VIEW1_H
+#ifndef GOT_VIEWS_STORY_H
+#define GOT_VIEWS_STORY_H
 
+#include "graphics/managed_surface.h"
 #include "got/views/view.h"
 
 namespace Got {
 namespace Views {
 
-class View1 : public View {
+class Story : public View {
 private:
-	byte _pal[256 * 3] = { 0 };
-	int _offset = 0;
+	Graphics::ManagedSurface _image1, _image2;
 
 public:
-	View1() : View("View1") {
-	}
-	virtual ~View1() {
-	}
+	Story() : View("Story") {}
+	virtual ~Story() {}
 
 	bool msgFocus(const FocusMessage &msg) override;
+	bool msgUnfocus(const UnfocusMessage &msg) override;
 	bool msgKeypress(const KeypressMessage &msg) override;
 	void draw() override;
 	bool tick() override;
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index c8045818900..e3d427d21c6 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -22,13 +22,13 @@
 #ifndef GOT_VIEWS_H
 #define GOT_VIEWS_H
 
-#include "got/views/view1.h"
+#include "got/views/story.h"
 
 namespace Got {
 namespace Views {
 
 struct Views {
-	View1 _view1;
+	Story _story;
 };
 
 } // namespace Views


Commit: b0a4ebd61411bf5ae4803a7b4373b85c0b718aa5
    https://github.com/scummvm/scummvm/commit/b0a4ebd61411bf5ae4803a7b4373b85c0b718aa5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Beginnings of graphics loading

Changed paths:
  A engines/got/gfx/images.cpp
  A engines/got/gfx/images.h
  A engines/got/views/main_menu.cpp
  A engines/got/views/main_menu.h
    engines/got/events.cpp
    engines/got/module.mk
    engines/got/views/views.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 95a8a9fc84e..a2c7d1c6d21 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -47,7 +47,7 @@ void Events::runGame() {
 	if (saveSlot != -1)
 		g_engine->loadGameState(saveSlot);
 
-	addView("Story");
+	addView("MainMenu");
 
 	Common::Event e;
 	while (!_views.empty() && !shouldQuit()) {
diff --git a/engines/got/gfx/images.cpp b/engines/got/gfx/images.cpp
new file mode 100644
index 00000000000..40c9146875d
--- /dev/null
+++ b/engines/got/gfx/images.cpp
@@ -0,0 +1,109 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/file.h"
+#include "got/gfx/images.h"
+
+namespace Got {
+namespace Gfx {
+
+void GraphicChunk::loadInfo(GfxChunks *owner, int index, Common::SeekableReadStream *src) {
+	_owner = owner;
+	_index = index;
+
+	_field0 = src->readUint16LE();
+	_field2 = src->readUint16LE();
+	_field4 = src->readUint16LE();
+	_uncompressedSize = src->readUint16LE();
+	_compressedSize = src->readUint16LE();
+	_width = src->readUint16LE();
+	_height = src->readUint16LE();
+}
+
+void GraphicChunk::load() {
+	_owner->load(_index);
+}
+
+void GraphicChunk::unload() {
+	_owner->unload(_index);
+}
+
+GfxChunks::~GfxChunks() {
+	delete[] _data;
+}
+
+void GfxChunks::load() {
+	// Get stream to access images
+	Common::SeekableReadStream *f = getStream();
+
+	// Set the number of images
+	_images.resize(f->readUint16LE());
+
+	// Iterate through loading the image metrics
+	for (uint i = 0; i < _images.size(); ++i)
+		_images[i].loadInfo(this, i, f);
+
+	// Close the file
+	delete f;
+}
+
+Common::SeekableReadStream *GfxChunks::getStream() const {
+	// Check for stand-alone graphics file
+	Common::File *f = new Common::File;
+	if (f->open("graphics.got"))
+		return f;
+	delete f;
+
+	// Check for got.exe executable
+	Common::File fExe;
+	if (!fExe.open("got.exe"))
+		error("Could not locate got graphics");
+
+	if (fExe.readUint16BE() != MKTAG16('M', 'Z'))
+		error("Invalid exe header");
+
+	int lastPageSize = f->readUint16LE();
+	int totalPages = f->readUint16LE();
+	int offset = lastPageSize ? ((totalPages - 1) << 9) + lastPageSize :
+		totalPages << 9;
+
+	fExe.seek(offset);
+	if (fExe.readUint16BE() != MKTAG16(0xe2, 0x4a))
+		error("Invalid embedded graphics signature");
+
+	return fExe.readStream(fExe.size() - fExe.pos());
+}
+
+void GfxChunks::load(int index) {
+
+}
+
+void GfxChunks::unload(int index) {
+	_images[index]._image.clear();
+}
+
+void GfxChunks::loadRange(int start, int count) {
+	for (; count > 0; ++start, --count)
+		load(start);
+}
+
+} // namespace Gfx
+} // namespace Got
diff --git a/engines/got/gfx/images.h b/engines/got/gfx/images.h
new file mode 100644
index 00000000000..8ebbfb808f4
--- /dev/null
+++ b/engines/got/gfx/images.h
@@ -0,0 +1,88 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GFX_IMAGES_H
+#define GOT_GFX_IMAGES_H
+
+#include "common/stream.h"
+#include "graphics/managed_surface.h"
+
+namespace Got {
+namespace Gfx {
+
+class GfxChunks;
+
+struct GraphicChunk {
+private:
+	GfxChunks *_owner = nullptr;
+	int _index = 0;
+
+public:
+	Graphics::ManagedSurface _image;
+	uint16 _field0 = 0;
+	uint16 _field2 = 0;
+	uint16 _field4 = 0;
+	uint16 _uncompressedSize = 0;
+	uint16 _compressedSize = 0;
+	uint16 _width = 0;
+	uint16 _height = 0;
+
+	/**
+	 * Load the overall info for a chunk
+	 */
+	void loadInfo(GfxChunks *owner, int index, Common::SeekableReadStream *src);
+
+	void load();
+	void unload();
+};
+
+/**
+ * Interface for accessing the graphics.got file.
+ * In the release, this is embedded in the executable starting
+ * at offset 18af2h onwards. The preceding two bytes should be E2 4A.
+ */
+class GfxChunks {
+private:
+	Common::Array<GraphicChunk> _images;
+	byte *_data = nullptr;
+
+	/**
+	 * Opens the graphics for access
+	 */
+	Common::SeekableReadStream *getStream() const;
+
+public:
+	~GfxChunks();
+
+	/**
+	 * Loads the graphic data
+	 */
+	void load();
+
+	void load(int index);
+	void unload(int index);
+	void loadRange(int start, int count);
+};
+
+} // namespace Gfx
+} // namespace Got
+
+#endif
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 08093c3b31c..7ac91a98971 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -7,9 +7,11 @@ MODULE_OBJS = \
 	messages.o \
 	metaengine.o \
 	vars.o \
+	gfx/images.o \
 	gfx/palette.o \
 	utils/file.o \
 	utils/res_archive.o \
+	views/main_menu.o \
 	views/view.o \
 	views/story.o
 
diff --git a/engines/got/views/main_menu.cpp b/engines/got/views/main_menu.cpp
new file mode 100644
index 00000000000..dfbdf857845
--- /dev/null
+++ b/engines/got/views/main_menu.cpp
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/main_menu.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+
+bool MainMenu::msgFocus(const FocusMessage &msg) {
+	return true;
+}
+
+bool MainMenu::msgUnfocus(const UnfocusMessage &msg) {
+	return true;
+}
+
+bool MainMenu::msgKeypress(const KeypressMessage &msg) {
+	// Any keypress to close the view
+	close();
+	return true;
+}
+
+void MainMenu::draw() {
+	Graphics::ManagedSurface s = getSurface();
+
+	s.clear();
+}
+
+bool MainMenu::tick() {
+	return true;
+}
+
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/main_menu.h b/engines/got/views/main_menu.h
new file mode 100644
index 00000000000..1abf7f609c4
--- /dev/null
+++ b/engines/got/views/main_menu.h
@@ -0,0 +1,48 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_MAIN_MENU_H
+#define GOT_VIEWS_MAIN_MENU_H
+
+#include "graphics/managed_surface.h"
+#include "got/views/view.h"
+
+namespace Got {
+namespace Views {
+
+class MainMenu : public View {
+private:
+
+public:
+	MainMenu() : View("MainMenu") {}
+	virtual ~MainMenu() {}
+
+	bool msgFocus(const FocusMessage &msg) override;
+	bool msgUnfocus(const UnfocusMessage &msg) override;
+	bool msgKeypress(const KeypressMessage &msg) override;
+	void draw() override;
+	bool tick() override;
+};
+
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index e3d427d21c6..49aa63fb769 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -22,12 +22,14 @@
 #ifndef GOT_VIEWS_H
 #define GOT_VIEWS_H
 
+#include "got/views/main_menu.h"
 #include "got/views/story.h"
 
 namespace Got {
 namespace Views {
 
 struct Views {
+	MainMenu _mainMenu;
 	Story _story;
 };
 


Commit: 3209a49602d1c5c4a8a968c49945dae0ac717577
    https://github.com/scummvm/scummvm/commit/3209a49602d1c5c4a8a968c49945dae0ac717577
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Adding image decompression

Changed paths:
  A engines/got/utils/compression.cpp
  A engines/got/utils/compression.h
    engines/got/gfx/images.cpp
    engines/got/gfx/images.h
    engines/got/module.mk
    engines/got/utils/res_archive.cpp
    engines/got/vars.cpp
    engines/got/vars.h


diff --git a/engines/got/gfx/images.cpp b/engines/got/gfx/images.cpp
index 40c9146875d..3223fb41799 100644
--- a/engines/got/gfx/images.cpp
+++ b/engines/got/gfx/images.cpp
@@ -21,45 +21,71 @@
 
 #include "common/file.h"
 #include "got/gfx/images.h"
+#include "got/utils/compression.h"
 
 namespace Got {
 namespace Gfx {
 
-void GraphicChunk::loadInfo(GfxChunks *owner, int index, Common::SeekableReadStream *src) {
-	_owner = owner;
-	_index = index;
+void GraphicChunk::load(Common::SeekableReadStream *src, const byte *data) {
+	_data = data;
 
-	_field0 = src->readUint16LE();
-	_field2 = src->readUint16LE();
-	_field4 = src->readUint16LE();
+	_compressMode = src->readUint16LE();
+	_offset = src->readUint32LE();
 	_uncompressedSize = src->readUint16LE();
 	_compressedSize = src->readUint16LE();
 	_width = src->readUint16LE();
 	_height = src->readUint16LE();
 }
 
-void GraphicChunk::load() {
-	_owner->load(_index);
-}
+GraphicChunk::operator Graphics::ManagedSurface &() {
+	assert(_height != 0 && _width != 0);
 
-void GraphicChunk::unload() {
-	_owner->unload(_index);
-}
+	// Create the managed surface
+	_image.create(_width, _height);
+
+	const byte *src = _data + _offset;
+
+	size_t size = MIN((int)_uncompressedSize, _width * _height);
+
+	switch (_compressMode) {
+	case UNCOMPRESSED:
+		// Uncompressed image, simply read it in
+		Common::copy(src, src + size, (byte *)_image.getPixels());
+		break;
 
-GfxChunks::~GfxChunks() {
-	delete[] _data;
+	case LZSS:
+		lzss_decompress(src + _offset, (byte *)_image.getPixels(), size);
+		break;
+
+	case RLE:
+		rle_decompress(src + _offset, (byte *)_image.getPixels(), size);
+		break;
+
+	default:
+		error("Unknown compression type %d", _compressMode);
+		break;
+	}
+
+	// Return a reference to the now loaded surface
+	return _image;
 }
 
+
 void GfxChunks::load() {
 	// Get stream to access images
 	Common::SeekableReadStream *f = getStream();
 
+	// Keep a copy in memory for decoding images as needed
+	_data = new byte[f->size()];
+	f->read(_data, f->size());
+
 	// Set the number of images
+	f->seek(0);
 	_images.resize(f->readUint16LE());
 
 	// Iterate through loading the image metrics
 	for (uint i = 0; i < _images.size(); ++i)
-		_images[i].loadInfo(this, i, f);
+		_images[i].load(f, _data);
 
 	// Close the file
 	delete f;
@@ -80,8 +106,8 @@ Common::SeekableReadStream *GfxChunks::getStream() const {
 	if (fExe.readUint16BE() != MKTAG16('M', 'Z'))
 		error("Invalid exe header");
 
-	int lastPageSize = f->readUint16LE();
-	int totalPages = f->readUint16LE();
+	int lastPageSize = fExe.readUint16LE();
+	int totalPages = fExe.readUint16LE();
 	int offset = lastPageSize ? ((totalPages - 1) << 9) + lastPageSize :
 		totalPages << 9;
 
@@ -92,18 +118,5 @@ Common::SeekableReadStream *GfxChunks::getStream() const {
 	return fExe.readStream(fExe.size() - fExe.pos());
 }
 
-void GfxChunks::load(int index) {
-
-}
-
-void GfxChunks::unload(int index) {
-	_images[index]._image.clear();
-}
-
-void GfxChunks::loadRange(int start, int count) {
-	for (; count > 0; ++start, --count)
-		load(start);
-}
-
 } // namespace Gfx
 } // namespace Got
diff --git a/engines/got/gfx/images.h b/engines/got/gfx/images.h
index 8ebbfb808f4..18d7998caef 100644
--- a/engines/got/gfx/images.h
+++ b/engines/got/gfx/images.h
@@ -30,16 +30,16 @@ namespace Gfx {
 
 class GfxChunks;
 
-struct GraphicChunk {
+enum CompressMode { UNCOMPRESSED = 0, LZSS = 1, RLE = 2 };
+
+struct GraphicChunk  {
 private:
-	GfxChunks *_owner = nullptr;
-	int _index = 0;
+	Graphics::ManagedSurface _image;
+	const byte *_data = nullptr;
 
 public:
-	Graphics::ManagedSurface _image;
-	uint16 _field0 = 0;
-	uint16 _field2 = 0;
-	uint16 _field4 = 0;
+	int _compressMode = UNCOMPRESSED;
+	uint32 _offset = 0;
 	uint16 _uncompressedSize = 0;
 	uint16 _compressedSize = 0;
 	uint16 _width = 0;
@@ -48,10 +48,9 @@ public:
 	/**
 	 * Load the overall info for a chunk
 	 */
-	void loadInfo(GfxChunks *owner, int index, Common::SeekableReadStream *src);
+	void load(Common::SeekableReadStream *src, const byte *data);
 
-	void load();
-	void unload();
+	operator Graphics::ManagedSurface &();
 };
 
 /**
@@ -70,16 +69,14 @@ private:
 	Common::SeekableReadStream *getStream() const;
 
 public:
-	~GfxChunks();
+	~GfxChunks() {
+		delete[] _data;
+	}
 
 	/**
 	 * Loads the graphic data
 	 */
 	void load();
-
-	void load(int index);
-	void unload(int index);
-	void loadRange(int start, int count);
 };
 
 } // namespace Gfx
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 7ac91a98971..0f861bc7a54 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -9,6 +9,7 @@ MODULE_OBJS = \
 	vars.o \
 	gfx/images.o \
 	gfx/palette.o \
+	utils/compression.o \
 	utils/file.o \
 	utils/res_archive.o \
 	views/main_menu.o \
diff --git a/engines/got/utils/compression.cpp b/engines/got/utils/compression.cpp
new file mode 100644
index 00000000000..aa1ac10b1b3
--- /dev/null
+++ b/engines/got/utils/compression.cpp
@@ -0,0 +1,79 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/algorithm.h"
+#include "common/endian.h"
+#include "got/utils/compression.h"
+
+namespace Got {
+
+void lzss_decompress(const byte *src, byte *dest, size_t destSize) {
+	byte *endP = dest + destSize;
+
+	for (;;) {
+		byte v = *src++;
+
+		for (int bits = 8; bits > 0; --bits) {
+			if (endP == dest)
+				return;
+
+			bool bit = (v & 1) != 0;
+			v >>= 1;
+			if (bit) {
+				*dest++ = *src++;
+			} else {
+				uint offset = READ_LE_UINT16(src);
+				src += 2;
+				int count = (offset >> 12) & 0xf + 2;
+				offset &= 0xfff;
+
+				Common::copy(dest - offset, dest - offset + count, dest);
+				dest += count;
+			}
+		}
+	}
+}
+
+void rle_decompress(const byte *src, byte *dest, size_t destSize) {
+	byte *endP = dest + destSize;
+	byte val;
+
+	for (;;) {
+		val = *src++;
+
+		if ((val &0x80) != 0) {
+			byte rep = *src++;
+			val &= 0x7f;
+			Common::fill(dest, dest + val, rep);
+			dest += val;
+		} else if (val > 0) {
+			Common::copy(src, src + val, dest);
+			src += val;
+			dest += val;
+		} else {
+			break;
+		}
+	}
+
+	assert(dest == endP);
+}
+
+} // namespace Got
diff --git a/engines/got/utils/compression.h b/engines/got/utils/compression.h
new file mode 100644
index 00000000000..8ac04d4dead
--- /dev/null
+++ b/engines/got/utils/compression.h
@@ -0,0 +1,41 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_UTILS_COMPRESSION_H
+#define GOT_UTILS_COMPRESSION_H
+
+#include "common/scummsys.h"
+
+namespace Got {
+
+/**
+ * LXSS decompressor
+ */
+void lzss_decompress(const byte *src, byte *dest, size_t destSize);
+
+/**
+ * RLE decoding
+ */
+void rle_decompress(const byte *src, byte *dest, size_t destSize);
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/utils/res_archive.cpp b/engines/got/utils/res_archive.cpp
index 5922aba5189..0b2f8ce9f9e 100644
--- a/engines/got/utils/res_archive.cpp
+++ b/engines/got/utils/res_archive.cpp
@@ -23,6 +23,7 @@
 #include "common/file.h"
 #include "common/memstream.h"
 #include "got/utils/res_archive.h"
+#include "got/utils/compression.h"
 
 namespace Got {
 
@@ -138,32 +139,10 @@ Common::SeekableReadStream *ResArchive::createReadStreamForMember(const Common::
 
 void ResArchive::lzssDecompress(const byte *src, byte *dest) const {
 	uint16 size = READ_LE_UINT16(src);
-	byte *endP = dest + size;
 	assert(READ_LE_UINT16(src + 2) == 1);
 	src += 4;
 
-	for (;;) {
-		byte v = *src++;
-
-		for (int bits = 8; bits > 0; --bits) {
-			if (endP == dest)
-				return;
-
-			bool bit = (v & 1) != 0;
-			v >>= 1;
-			if (bit) {
-				*dest++ = *src++;
-			} else {
-				uint offset = READ_LE_UINT16(src);
-				src += 2;
-				int count = (offset >> 12) & 0xf + 2;
-				offset &= 0xfff;
-
-				Common::copy(dest - offset, dest - offset + count, dest);
-				dest += count;
-			}
-		}
-	}
+	lzss_decompress(src, dest, size);
 }
 
 } // namespace Got
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 610bf88b8ba..ab9f4a5720a 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -40,6 +40,8 @@ Vars::Vars() {
 }
 
 void Vars::load() {
+	_images.load();
+
 	_music_flag = !ConfMan.getBool("music_mute");
 	_sound_flag = _pcsound_flag = !ConfMan.getBool("sfx_mute");
 
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 661d3be8eac..ad10fd03399 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -25,6 +25,7 @@
 #include "common/events.h"
 #include "graphics/screen.h"
 #include "got/defines.h"
+#include "got/gfx/images.h"
 
 namespace Got {
 
@@ -39,6 +40,8 @@ public:
 
 	void load();
 
+	Gfx::GfxChunks _images;
+
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
 	uint _display_page = 0, _draw_page = 0;
 	uint _page3_offset = 0;


Commit: ce3634b17097f8b8a8d8a11fe9cb2fe38c026d56
    https://github.com/scummvm/scummvm/commit/ce3634b17097f8b8a8d8a11fe9cb2fe38c026d56
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Trying to display main menu background

Changed paths:
  A engines/got/gfx/gfx_chunks.cpp
  A engines/got/gfx/gfx_chunks.h
  R engines/got/gfx/images.cpp
  R engines/got/gfx/images.h
    engines/got/gfx/palette.cpp
    engines/got/gfx/palette.h
    engines/got/module.mk
    engines/got/vars.cpp
    engines/got/vars.h
    engines/got/views/main_menu.cpp
    engines/got/views/main_menu.h


diff --git a/engines/got/gfx/images.cpp b/engines/got/gfx/gfx_chunks.cpp
similarity index 70%
rename from engines/got/gfx/images.cpp
rename to engines/got/gfx/gfx_chunks.cpp
index 3223fb41799..53777568f80 100644
--- a/engines/got/gfx/images.cpp
+++ b/engines/got/gfx/gfx_chunks.cpp
@@ -20,45 +20,37 @@
  */
 
 #include "common/file.h"
-#include "got/gfx/images.h"
+#include "got/gfx/gfx_chunks.h"
 #include "got/utils/compression.h"
 
 namespace Got {
 namespace Gfx {
 
 void GraphicChunk::load(Common::SeekableReadStream *src, const byte *data) {
-	_data = data;
-
 	_compressMode = src->readUint16LE();
 	_offset = src->readUint32LE();
 	_uncompressedSize = src->readUint16LE();
 	_compressedSize = src->readUint16LE();
 	_width = src->readUint16LE();
 	_height = src->readUint16LE();
-}
 
-GraphicChunk::operator Graphics::ManagedSurface &() {
-	assert(_height != 0 && _width != 0);
-
-	// Create the managed surface
-	_image.create(_width, _height);
+	_data = data + _offset;
+}
 
-	const byte *src = _data + _offset;
+void GraphicChunk::enable() {
+	// Data already uncompressed, nothing further needed
+	if (_compressMode == UNCOMPRESSED)
+		return;
 
-	size_t size = MIN((int)_uncompressedSize, _width * _height);
+	_decompressedData.resize(_uncompressedSize);
 
 	switch (_compressMode) {
-	case UNCOMPRESSED:
-		// Uncompressed image, simply read it in
-		Common::copy(src, src + size, (byte *)_image.getPixels());
-		break;
-
 	case LZSS:
-		lzss_decompress(src + _offset, (byte *)_image.getPixels(), size);
+		lzss_decompress(_data, &_decompressedData[0], _uncompressedSize);
 		break;
 
 	case RLE:
-		rle_decompress(src + _offset, (byte *)_image.getPixels(), size);
+		rle_decompress(_data, &_decompressedData[0], _uncompressedSize);
 		break;
 
 	default:
@@ -66,8 +58,19 @@ GraphicChunk::operator Graphics::ManagedSurface &() {
 		break;
 	}
 
-	// Return a reference to the now loaded surface
-	return _image;
+	// Mark the entry as uncompressed, and point to the data
+	_compressMode = UNCOMPRESSED;
+	_data = &_decompressedData[0];
+}
+
+GraphicChunk::operator const Graphics::ManagedSurface() const {
+	Graphics::ManagedSurface s;
+	s.w = s.pitch = _width;
+	s.h = _height;
+	s.format = Graphics::PixelFormat::createFormatCLUT8();
+	s.setPixels(const_cast<byte *>(_data));
+
+	return s;
 }
 
 
@@ -81,14 +84,25 @@ void GfxChunks::load() {
 
 	// Set the number of images
 	f->seek(0);
-	_images.resize(f->readUint16LE());
+	_chunks.resize(f->readUint16LE());
 
 	// Iterate through loading the image metrics
-	for (uint i = 0; i < _images.size(); ++i)
-		_images[i].load(f, _data);
+	for (uint i = 0; i < _chunks.size(); ++i)
+		_chunks[i].load(f, _data);
 
 	// Close the file
 	delete f;
+
+	// Decompress two ranges of chunks by default
+	for (uint i = 0; i < 34; ++i)
+		_chunks[i].enable();
+}
+
+GraphicChunk &GfxChunks::operator[](uint idx) {
+	GraphicChunk &chunk = _chunks[idx];
+	chunk.enable();
+
+	return chunk;
 }
 
 Common::SeekableReadStream *GfxChunks::getStream() const {
diff --git a/engines/got/gfx/images.h b/engines/got/gfx/gfx_chunks.h
similarity index 79%
rename from engines/got/gfx/images.h
rename to engines/got/gfx/gfx_chunks.h
index 18d7998caef..ce571dcdcac 100644
--- a/engines/got/gfx/images.h
+++ b/engines/got/gfx/gfx_chunks.h
@@ -19,8 +19,8 @@
  *
  */
 
-#ifndef GOT_GFX_IMAGES_H
-#define GOT_GFX_IMAGES_H
+#ifndef GOT_GFX_GFX_CHUNKS_H
+#define GOT_GFX_GFX_CHUNKS_H
 
 #include "common/stream.h"
 #include "graphics/managed_surface.h"
@@ -34,8 +34,7 @@ enum CompressMode { UNCOMPRESSED = 0, LZSS = 1, RLE = 2 };
 
 struct GraphicChunk  {
 private:
-	Graphics::ManagedSurface _image;
-	const byte *_data = nullptr;
+	Common::Array<byte> _decompressedData;
 
 public:
 	int _compressMode = UNCOMPRESSED;
@@ -45,22 +44,34 @@ public:
 	uint16 _width = 0;
 	uint16 _height = 0;
 
+	const byte *_data = nullptr;
+
 	/**
 	 * Load the overall info for a chunk
 	 */
 	void load(Common::SeekableReadStream *src, const byte *data);
 
-	operator Graphics::ManagedSurface &();
+	/**
+	 * Handles any decompression necessary for the entry
+	 */
+	void enable();
+
+	/**
+	 * Provides a managed surface wrapper for raw data
+	 */
+	operator const Graphics::ManagedSurface() const;
 };
 
 /**
  * Interface for accessing the graphics.got file.
  * In the release, this is embedded in the executable starting
  * at offset 18af2h onwards. The preceding two bytes should be E2 4A.
+ * The collection is mostly images, but there are some palettes and
+ * sounds included as well.
  */
 class GfxChunks {
 private:
-	Common::Array<GraphicChunk> _images;
+	Common::Array<GraphicChunk> _chunks;
 	byte *_data = nullptr;
 
 	/**
@@ -77,6 +88,11 @@ public:
 	 * Loads the graphic data
 	 */
 	void load();
+
+	/**
+	 * Access a chunk
+	 */
+	GraphicChunk &operator[](uint idx);
 };
 
 } // namespace Gfx
diff --git a/engines/got/gfx/palette.cpp b/engines/got/gfx/palette.cpp
index b15a1966e1c..f22620c901c 100644
--- a/engines/got/gfx/palette.cpp
+++ b/engines/got/gfx/palette.cpp
@@ -54,6 +54,10 @@ void xsetpal(byte color, byte R, byte G, byte B) {
 	g_system->getPaletteManager()->setPalette(rgb, color, 1);
 }
 
+void xsetpal(const byte *pal) {
+	g_system->getPaletteManager()->setPalette(pal, 0, PALETTE_COUNT);
+}
+
 void xgetpal(byte *pal, int num_colrs, int start_index) {
 	g_system->getPaletteManager()->grabPalette(pal, start_index, num_colrs);
 }
diff --git a/engines/got/gfx/palette.h b/engines/got/gfx/palette.h
index 49826c3f812..1030b1d62db 100644
--- a/engines/got/gfx/palette.h
+++ b/engines/got/gfx/palette.h
@@ -29,6 +29,7 @@ namespace Got {
 extern void load_palette();
 extern void set_screen_pal();
 extern void xsetpal(byte color, byte R, byte G, byte B);
+extern void xsetpal(const byte *pal);
 extern void xgetpal(byte *pal, int num_colrs, int start_index);
 extern void set_palette();
 
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 0f861bc7a54..009dd5a1dc9 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -7,7 +7,7 @@ MODULE_OBJS = \
 	messages.o \
 	metaengine.o \
 	vars.o \
-	gfx/images.o \
+	gfx/gfx_chunks.o \
 	gfx/palette.o \
 	utils/compression.o \
 	utils/file.o \
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index ab9f4a5720a..b7e61f773cd 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -40,7 +40,7 @@ Vars::Vars() {
 }
 
 void Vars::load() {
-	_images.load();
+	_gfx.load();
 
 	_music_flag = !ConfMan.getBool("music_mute");
 	_sound_flag = _pcsound_flag = !ConfMan.getBool("sfx_mute");
diff --git a/engines/got/vars.h b/engines/got/vars.h
index ad10fd03399..f5d60ca4525 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -25,7 +25,7 @@
 #include "common/events.h"
 #include "graphics/screen.h"
 #include "got/defines.h"
-#include "got/gfx/images.h"
+#include "got/gfx/gfx_chunks.h"
 
 namespace Got {
 
@@ -40,7 +40,7 @@ public:
 
 	void load();
 
-	Gfx::GfxChunks _images;
+	Gfx::GfxChunks _gfx;
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
 	uint _display_page = 0, _draw_page = 0;
diff --git a/engines/got/views/main_menu.cpp b/engines/got/views/main_menu.cpp
index dfbdf857845..0af4691e011 100644
--- a/engines/got/views/main_menu.cpp
+++ b/engines/got/views/main_menu.cpp
@@ -20,12 +20,14 @@
  */
 
 #include "got/views/main_menu.h"
+#include "got/gfx/palette.h"
 #include "got/vars.h"
 
 namespace Got {
 namespace Views {
 
 bool MainMenu::msgFocus(const FocusMessage &msg) {
+	xsetpal(_G(gfx)[0]._data);
 	return true;
 }
 
@@ -40,13 +42,19 @@ bool MainMenu::msgKeypress(const KeypressMessage &msg) {
 }
 
 void MainMenu::draw() {
+	//Graphics::ManagedSurface s = getSurface();
+	drawBackground();
+}
+
+void MainMenu::drawBackground() {
 	Graphics::ManagedSurface s = getSurface();
 
-	s.clear();
-}
+	for (int col = 0, xp = 0; col < 10; ++col, xp += 32) {
+		for (int yp = 0; yp < 192; yp += 32)
+			s.blitFrom(_G(gfx)[26], Common::Point(xp, yp));
 
-bool MainMenu::tick() {
-	return true;
+		s.blitFrom(_G(gfx)[27], Common::Point(xp, 192));
+	}
 }
 
 } // namespace Views
diff --git a/engines/got/views/main_menu.h b/engines/got/views/main_menu.h
index 1abf7f609c4..7377ce15a09 100644
--- a/engines/got/views/main_menu.h
+++ b/engines/got/views/main_menu.h
@@ -30,6 +30,7 @@ namespace Views {
 
 class MainMenu : public View {
 private:
+	void drawBackground();
 
 public:
 	MainMenu() : View("MainMenu") {}
@@ -39,7 +40,6 @@ public:
 	bool msgUnfocus(const UnfocusMessage &msg) override;
 	bool msgKeypress(const KeypressMessage &msg) override;
 	void draw() override;
-	bool tick() override;
 };
 
 } // namespace Views


Commit: 431ba6174de3d3f7be9e31d80bf16034e12a60f2
    https://github.com/scummvm/scummvm/commit/431ba6174de3d3f7be9e31d80bf16034e12a60f2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: LZSS decoding of menu background now working

Changed paths:
    engines/got/got.cpp
    engines/got/utils/compression.cpp


diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 6d52004d0d9..6237cc77d6a 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -56,8 +56,8 @@ Common::String GotEngine::getGameId() const {
 }
 
 Common::Error GotEngine::run() {
-	// Initialize 320x240 palleted graphics mode
-	initGraphics(320, 240);
+	// Initialize 320x200 palleted graphics mode
+	initGraphics(320, 200);
 
 	// Set the engine's debugger console
 	setDebugger(new Console());
diff --git a/engines/got/utils/compression.cpp b/engines/got/utils/compression.cpp
index aa1ac10b1b3..c3c5f368efd 100644
--- a/engines/got/utils/compression.cpp
+++ b/engines/got/utils/compression.cpp
@@ -40,9 +40,9 @@ void lzss_decompress(const byte *src, byte *dest, size_t destSize) {
 			if (bit) {
 				*dest++ = *src++;
 			} else {
-				uint offset = READ_LE_UINT16(src);
+				uint16 offset = READ_LE_UINT16(src);
 				src += 2;
-				int count = (offset >> 12) & 0xf + 2;
+				int count = (offset >> 12) + 2;
 				offset &= 0xfff;
 
 				Common::copy(dest - offset, dest - offset + count, dest);


Commit: 3a7c44a29421568fdf471d711d3c7bb99ae8d26e
    https://github.com/scummvm/scummvm/commit/3a7c44a29421568fdf471d711d3c7bb99ae8d26e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Move drawBackground to View class

Changed paths:
    engines/got/views/main_menu.cpp
    engines/got/views/main_menu.h
    engines/got/views/view.cpp
    engines/got/views/view.h


diff --git a/engines/got/views/main_menu.cpp b/engines/got/views/main_menu.cpp
index 0af4691e011..1537ff901bf 100644
--- a/engines/got/views/main_menu.cpp
+++ b/engines/got/views/main_menu.cpp
@@ -46,16 +46,5 @@ void MainMenu::draw() {
 	drawBackground();
 }
 
-void MainMenu::drawBackground() {
-	Graphics::ManagedSurface s = getSurface();
-
-	for (int col = 0, xp = 0; col < 10; ++col, xp += 32) {
-		for (int yp = 0; yp < 192; yp += 32)
-			s.blitFrom(_G(gfx)[26], Common::Point(xp, yp));
-
-		s.blitFrom(_G(gfx)[27], Common::Point(xp, 192));
-	}
-}
-
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/main_menu.h b/engines/got/views/main_menu.h
index 7377ce15a09..cdad84ddde3 100644
--- a/engines/got/views/main_menu.h
+++ b/engines/got/views/main_menu.h
@@ -29,9 +29,6 @@ namespace Got {
 namespace Views {
 
 class MainMenu : public View {
-private:
-	void drawBackground();
-
 public:
 	MainMenu() : View("MainMenu") {}
 	virtual ~MainMenu() {}
diff --git a/engines/got/views/view.cpp b/engines/got/views/view.cpp
index 8c386a3e68d..fc0af2e5666 100644
--- a/engines/got/views/view.cpp
+++ b/engines/got/views/view.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "got/views/view.h"
+#include "got/vars.h"
 
 namespace Got {
 namespace Views {
@@ -79,5 +80,17 @@ bool View::msgMouseUp(const MouseUpMessage &msg) {
 	return child ? child->send(msg) : false;
 }
 
+void View::drawBackground() {
+	Graphics::ManagedSurface s = getSurface();
+
+	for (int col = 0, xp = 0; col < 10; ++col, xp += 32) {
+		for (int yp = 0; yp < 192; yp += 32)
+			s.blitFrom(_G(gfx)[26], Common::Point(xp, yp));
+
+		s.blitFrom(_G(gfx)[27], Common::Point(xp, 192));
+	}
+}
+
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/view.h b/engines/got/views/view.h
index e174f476731..6e630a11586 100644
--- a/engines/got/views/view.h
+++ b/engines/got/views/view.h
@@ -52,6 +52,9 @@ private:
 	 */
 	UIElement *getElementAtPos(const Common::Point &pos) const;
 
+protected:
+	void drawBackground();
+
 public:
 	View(const Common::String &name, UIElement *uiParent) :
 		UIElement(name, uiParent) {


Commit: bbc92d689c79090b7660de74e7486cb6ba0d9cca
    https://github.com/scummvm/scummvm/commit/bbc92d689c79090b7660de74e7486cb6ba0d9cca
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added BgPics class to hold background images

Changed paths:
  A engines/got/gfx/gfx_pics.cpp
  A engines/got/gfx/gfx_pics.h
    engines/got/events.cpp
    engines/got/module.mk
    engines/got/utils/file.cpp
    engines/got/utils/file.h
    engines/got/vars.cpp
    engines/got/vars.h
    engines/got/views/story.cpp


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index a2c7d1c6d21..95a8a9fc84e 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -47,7 +47,7 @@ void Events::runGame() {
 	if (saveSlot != -1)
 		g_engine->loadGameState(saveSlot);
 
-	addView("MainMenu");
+	addView("Story");
 
 	Common::Event e;
 	while (!_views.empty() && !shouldQuit()) {
diff --git a/engines/got/gfx/gfx_pics.cpp b/engines/got/gfx/gfx_pics.cpp
new file mode 100644
index 00000000000..26560941d0f
--- /dev/null
+++ b/engines/got/gfx/gfx_pics.cpp
@@ -0,0 +1,75 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/textconsole.h"
+#include "common/file.h"
+#include "got/gfx/gfx_pics.h"
+
+namespace Got {
+namespace Gfx {
+
+void BgPics::setArea(int area) {
+	if (area != _area) {
+		_area = area;
+		load();
+	}
+}
+
+void BgPics::load() {
+	Common::String fname = Common::String::format("BPICS%d", _area);
+	Common::File f;
+	if (!f.open(Common::Path(fname)))
+		error("Could not open - %s", fname.c_str());
+
+	// Process the sprites - they're each 262 bytes
+	clear();
+	resize(f.size() / 262);
+
+	byte buff[256];
+	for (uint idx = 0; idx < size(); ++idx) {
+		Graphics::ManagedSurface &s = (*this)[idx];
+
+		s.create(16, 16);
+		s.setTransparentColor(15);
+
+		f.skip(6);
+		f.read(buff, 16 * 16);
+
+		// It's split into 4 panes per 4 pixels, so we need
+		// to juggle the pixels into their correct order
+		const byte *src = buff;
+		for (int plane = 0; plane < 4; ++plane) {
+			for (int y = 0; y < 16; ++y) {
+				byte *dest = (byte *)s.getBasePtr(plane, y);
+
+				for (int x = 0; x < (16 / 4); ++x, dest += 4)
+					*dest = *src++;
+			}
+		}
+	}
+}
+
+void Pics::load() {
+
+}
+
+} // namespace Gfx
+} // namespace Got
diff --git a/engines/got/gfx/gfx_pics.h b/engines/got/gfx/gfx_pics.h
new file mode 100644
index 00000000000..ca495b4ceb1
--- /dev/null
+++ b/engines/got/gfx/gfx_pics.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GFX_GFX_PICS_H
+#define GOT_GFX_GFX_PICS_H
+
+#include "common/array.h"
+#include "graphics/managed_surface.h"
+
+namespace Got {
+namespace Gfx {
+
+class BgPics : public Common::Array<Graphics::ManagedSurface> {
+private:
+	int _area = 1;
+
+public:
+	void load();
+
+	bool getArea() const {
+		return _area;
+	}
+	void setArea(int area);
+};
+
+class Pics : public Common::Array<Graphics::ManagedSurface> {
+public:
+	void load();
+};
+
+} // namespace Gfx
+} // namespace Got
+
+#endif
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 009dd5a1dc9..2f82c53f69a 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -8,6 +8,7 @@ MODULE_OBJS = \
 	metaengine.o \
 	vars.o \
 	gfx/gfx_chunks.o \
+	gfx/gfx_pics.o \
 	gfx/palette.o \
 	utils/compression.o \
 	utils/file.o \
diff --git a/engines/got/utils/file.cpp b/engines/got/utils/file.cpp
index 0aae3ec6c4e..9029c62accd 100644
--- a/engines/got/utils/file.cpp
+++ b/engines/got/utils/file.cpp
@@ -33,19 +33,6 @@ long file_size(char *path) {
 	return f.open(Common::Path(path)) ? f.size() : -1;
 }
 
-bool load_bg_data() {
-	_G(bg_pics) = new byte[60460];
-	if (!_G(bg_pics))
-		return false;
-
-	if (GAME1) {
-		if (res_read("BPICS1", _G(bg_pics)) < 0)
-			return false;
-	}
-
-	return true;
-}
-
 bool load_sd_data() {
 	Common::String fname = Common::String::format("SDAT%d", _G(area));
 
diff --git a/engines/got/utils/file.h b/engines/got/utils/file.h
index 89f8bca486b..a68bc748b05 100644
--- a/engines/got/utils/file.h
+++ b/engines/got/utils/file.h
@@ -30,7 +30,7 @@ namespace Got {
 extern long file_size(const char *path);
 extern unsigned int read_file(const char *filename, const char *buff,
 	long offset, unsigned int amount, int key);
-extern bool load_bg_data();
+
 extern bool load_sd_data();
 extern bool load_objects();
 extern bool load_actor(int file, int num);
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index b7e61f773cd..e69ee2b7197 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -41,6 +41,7 @@ Vars::Vars() {
 
 void Vars::load() {
 	_gfx.load();
+	_bgPics.load();
 
 	_music_flag = !ConfMan.getBool("music_mute");
 	_sound_flag = _pcsound_flag = !ConfMan.getBool("sfx_mute");
@@ -80,12 +81,11 @@ void Vars::load() {
 	_mask_buff = new byte[15300];
 	_mask_buff_start = _mask_buff;
  
-	if (res_read("RANDOM", _rnd_array) < 0
-		|| res_read("DEMO", _demo_key) < 0
-		|| res_read("TEXT", _text) < 0
-		|| res_read("ODINPIC", _odin) < 0
-		|| res_read("HAMPIC", _hampic) < 0)
-		error("Error loading static data");
+	res_read("RANDOM", _rnd_array);
+	res_read("DEMO", _demo_key);
+	res_read("TEXT", _text);
+	res_read("ODINPIC", _odin);
+	res_read("HAMPIC", _hampic);
 
 	load_palette();
 
diff --git a/engines/got/vars.h b/engines/got/vars.h
index f5d60ca4525..476bfd3cc24 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -26,6 +26,7 @@
 #include "graphics/screen.h"
 #include "got/defines.h"
 #include "got/gfx/gfx_chunks.h"
+#include "got/gfx/gfx_pics.h"
 
 namespace Got {
 
@@ -41,6 +42,7 @@ public:
 	void load();
 
 	Gfx::GfxChunks _gfx;
+	Gfx::BgPics _bgPics;
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
 	uint _display_page = 0, _draw_page = 0;
@@ -66,7 +68,6 @@ public:
 	byte _text[94][72] = {};
 	//union REGS in, out = 0;
 	//struct SREGS seg = 0;
-	byte *_bg_pics = nullptr;
 	byte _objects[NUM_OBJECTS][262] = {};
 	int _ox = 0, _oy = 0, _of = 0;
 	byte _object_map[240] = {};
diff --git a/engines/got/views/story.cpp b/engines/got/views/story.cpp
index 5430fc11d85..80666f2fa40 100644
--- a/engines/got/views/story.cpp
+++ b/engines/got/views/story.cpp
@@ -34,7 +34,7 @@ bool Story::msgFocus(const FocusMessage &msg) {
 	res_read("STORY1", _G(tmp_buff));
 	res_read("OPENBACK", back);
 	res_read("STORYPIC", back);
-
+#if 0
 	// Load the images
 	_image1.create(320, 240);
 	_image2.create(320, 240);
@@ -44,7 +44,7 @@ bool Story::msgFocus(const FocusMessage &msg) {
 		byte *destP = (byte *)s->getBasePtr(0, (i % 6) * 40);
 		res_read(Common::String::format("OPENP%d", i + 1), destP);
 	}
-
+#endif
 	res_read("STORYPAL", _G(pbuff));
 	_G(pbuff)[2] = 0;
 	_G(pbuff)[1] = 0;
@@ -69,7 +69,11 @@ bool Story::msgKeypress(const KeypressMessage &msg) {
 void Story::draw() {
 	Graphics::ManagedSurface s = getSurface();
 
-	s.blitFrom(_image1);
+	//s.blitFrom(_image1);
+	for (int i = 0; i < 10 * 10; ++i) {
+		Graphics::ManagedSurface & img = _G(bgPics)[i];
+		s.blitFrom(img, Common::Point((i % 10) * 32, (i / 10) * 16));
+	}
 }
 
 bool Story::tick() {


Commit: 26f123cf7b177b7201e6de593e17fe2fae749e67
    https://github.com/scummvm/scummvm/commit/26f123cf7b177b7201e6de593e17fe2fae749e67
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Beginnings of dialog display

Changed paths:
  A engines/got/views/dialogs/dialog.cpp
  A engines/got/views/dialogs/dialog.h
  A engines/got/views/dialogs/options_menu.cpp
  A engines/got/views/dialogs/options_menu.h
    engines/got/events.cpp
    engines/got/got.cpp
    engines/got/module.mk
    engines/got/views/views.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 95a8a9fc84e..e63f2ee9d34 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -47,7 +47,7 @@ void Events::runGame() {
 	if (saveSlot != -1)
 		g_engine->loadGameState(saveSlot);
 
-	addView("Story");
+	addView("OptionsMenu");
 
 	Common::Event e;
 	while (!_views.empty() && !shouldQuit()) {
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 6237cc77d6a..0147fa43e2a 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -56,8 +56,9 @@ Common::String GotEngine::getGameId() const {
 }
 
 Common::Error GotEngine::run() {
-	// Initialize 320x200 palleted graphics mode
-	initGraphics(320, 200);
+	// Initialize 320x240 palleted graphics mode. Note that the original
+	// main menu/dialogs ran at 320x200, but the game ran at 320x240.
+	initGraphics(320, 240);
 
 	// Set the engine's debugger console
 	setDebugger(new Console());
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 2f82c53f69a..56b7ca39b1b 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -15,7 +15,9 @@ MODULE_OBJS = \
 	utils/res_archive.o \
 	views/main_menu.o \
 	views/view.o \
-	views/story.o
+	views/story.o \
+	views/dialogs/dialog.o \
+	views/dialogs/options_menu.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_GOT), DYNAMIC_PLUGIN)
diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
new file mode 100644
index 00000000000..4f2777fca94
--- /dev/null
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -0,0 +1,113 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/dialog.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+// Forms a class name for the view hierarchy from the dialog title
+static Common::String getDialogName(const char *title) {
+	Common::String result = title;
+	size_t idx;
+	while ((idx = result.findFirstOf(' ')) != Common::String::npos)
+		result.deleteChar(idx);
+	return result;
+}
+
+Dialog::Dialog(const char *title, const char *options[]) :
+		View(getDialogName(title)) {
+	// Load the options list into the string array
+	for (const char **option = options; *option; ++option)
+		_options.push_back(*option);
+
+	// Calculate the bounds for the dialog
+	int w, h, x1, y1, x2, y2;
+	w = strlen(title);
+	if (w & 1)
+		w++;
+	w = (w * 8) + 32;
+
+	h = (_options.size() * 16) + 32;
+	x1 = (320 - w) / 2;
+	x2 = (x1 + w);
+	y1 = (192 - h) / 2;
+	y2 = (y1 + h);
+
+	_bounds = Common::Rect(x1 - 16, y1 - 16, x2 + 16, y2 + 16);
+	_bounds.setBorderSize(16);
+}
+
+bool Dialog::msgFocus(const FocusMessage &msg) {
+	return true;
+}
+
+bool Dialog::msgUnfocus(const UnfocusMessage &msg) {
+	return true;
+}
+
+bool Dialog::msgKeypress(const KeypressMessage &msg) {
+	return true;
+}
+
+void Dialog::draw() {
+	Graphics::ManagedSurface s = getSurface();
+
+	// Draw four corners
+	s.clear(215);
+
+	s.blitFrom(_G(bgPics)[192], Common::Point(0, 0));
+	s.blitFrom(_G(bgPics)[193], Common::Point(_bounds.width() - 16, 0));
+	s.blitFrom(_G(bgPics)[194], Common::Point(0, _bounds.height() - 16));
+	s.blitFrom(_G(bgPics)[195], Common::Point(_bounds.width() - 16, _bounds.height() - 16));
+
+	// Draw horizontal
+	for (int x = 16; x < _bounds.width() - 16; x += 16) {
+		s.blitFrom(_G(bgPics)[196], Common::Point(x, 0));
+		s.blitFrom(_G(bgPics)[197], Common::Point(x, _bounds.height() - 16));
+	}
+	for (int y = 16; y < _bounds.height() - 16; y += 16) {
+		s.blitFrom(_G(bgPics)[198], Common::Point(0, y));
+		s.blitFrom(_G(bgPics)[199], Common::Point(_bounds.width() - 16, y));
+	}
+
+#ifdef TODO
+	int titleStart = (_bounds.width() - strlen(_title) * 8) / 2;
+
+	xprint(i, y1 + 4, title, pg, 54);
+
+	op = option;
+	for (i = 0; i < num_opts; i++) {
+		xprint(x1 + 32, (y1 + 28) + (i * 16), *op, pg, 14);
+		op++;
+	}
+#endif
+}
+
+bool Dialog::tick() {
+	return true;
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/dialog.h b/engines/got/views/dialogs/dialog.h
new file mode 100644
index 00000000000..e0840b7d566
--- /dev/null
+++ b/engines/got/views/dialogs/dialog.h
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_DIALOG_H
+#define GOT_VIEWS_DIALOGS_DIALOG_H
+
+#include "graphics/managed_surface.h"
+#include "got/views/view.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class Dialog : public View {
+private:
+	const char *_title;
+	Common::StringArray _options;
+	int _selectedItem = 0;
+
+public:
+	Dialog(const char *title, const char *options[]);
+	virtual ~Dialog() {
+	}
+
+	bool msgFocus(const FocusMessage &msg) override;
+	bool msgUnfocus(const UnfocusMessage &msg) override;
+	bool msgKeypress(const KeypressMessage &msg) override;
+	void draw() override;
+	bool tick() override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/dialogs/options_menu.cpp b/engines/got/views/dialogs/options_menu.cpp
new file mode 100644
index 00000000000..d56a81091fe
--- /dev/null
+++ b/engines/got/views/dialogs/options_menu.cpp
@@ -0,0 +1,41 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/options_menu.h"
+#include "got/gfx/palette.h"
+#include "got/utils/file.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+static const char *OPTIONS[] = {
+	"Sound/Music", "Skill Level", "Save Game", "Load Game",
+		"Die", "Turbo Mode", "Help", "Quit", nullptr
+};
+
+OptionsMenu::OptionsMenu() : Dialog("Options Menu", OPTIONS) {
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/options_menu.h b/engines/got/views/dialogs/options_menu.h
new file mode 100644
index 00000000000..fbde1333828
--- /dev/null
+++ b/engines/got/views/dialogs/options_menu.h
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_OPTIONS_MENU_H
+#define GOT_VIEWS_DIALOGS_OPTIONS_MENU_H
+
+#include "got/views/dialogs/dialog.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class OptionsMenu : public Dialog {
+public:
+	OptionsMenu();
+	virtual ~OptionsMenu() {
+	}
+
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index 49aa63fb769..384629a2322 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -24,6 +24,7 @@
 
 #include "got/views/main_menu.h"
 #include "got/views/story.h"
+#include "got/views/dialogs/options_menu.h"
 
 namespace Got {
 namespace Views {
@@ -31,6 +32,8 @@ namespace Views {
 struct Views {
 	MainMenu _mainMenu;
 	Story _story;
+
+	Dialogs::OptionsMenu _optionsMenu;
 };
 
 } // namespace Views


Commit: a51cb7839db88bbdc49964eaeb9bf821fde2b337
    https://github.com/scummvm/scummvm/commit/a51cb7839db88bbdc49964eaeb9bf821fde2b337
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Add GfxSurface class to be used in view drawing

Changed paths:
  A engines/got/gfx/gfx_surface.cpp
  A engines/got/gfx/gfx_surface.h
    engines/got/events.cpp
    engines/got/events.h
    engines/got/module.mk
    engines/got/views/dialogs/dialog.cpp
    engines/got/views/main_menu.cpp
    engines/got/views/story.cpp
    engines/got/views/view.cpp


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index e63f2ee9d34..d9dfba9e22f 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -261,7 +261,7 @@ bool UIElement::isFocused() const {
 }
 
 void UIElement::clearSurface() {
-	Graphics::ManagedSurface s = getSurface();
+	GfxSurface s = getSurface();
 	s.fillRect(Common::Rect(s.w, s.h), 0);
 }
 
@@ -317,8 +317,8 @@ void UIElement::addView() {
 	g_events->addView(this);
 }
 
-Graphics::ManagedSurface UIElement::getSurface() const {
-	return Graphics::ManagedSurface(*g_events->getScreen(), _bounds);
+GfxSurface UIElement::getSurface() const {
+	return GfxSurface(*g_events->getScreen(), _bounds);
 }
 
 int UIElement::getRandomNumber(int minNumber, int maxNumber) {
diff --git a/engines/got/events.h b/engines/got/events.h
index 4b75805c1ba..6b70b5fb2e3 100644
--- a/engines/got/events.h
+++ b/engines/got/events.h
@@ -26,12 +26,14 @@
 #include "common/stack.h"
 #include "graphics/screen.h"
 #include "got/messages.h"
+#include "got/gfx/gfx_surface.h"
 
 namespace Got {
 
 #define FRAME_RATE 20
 #define FRAME_DELAY (1000 / FRAME_RATE)
 
+using Gfx::GfxSurface;
 class Events;
 
 /**
@@ -182,7 +184,7 @@ public:
 	/**
 	 * Returns a surface for drawing the element
 	 */
-	Graphics::ManagedSurface getSurface() const;
+	Gfx::GfxSurface getSurface() const;
 
 	/**
 	 * Clear the surface
diff --git a/engines/got/gfx/gfx_surface.cpp b/engines/got/gfx/gfx_surface.cpp
new file mode 100644
index 00000000000..91f8e521d19
--- /dev/null
+++ b/engines/got/gfx/gfx_surface.cpp
@@ -0,0 +1,33 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/gfx/gfx_surface.h"
+
+namespace Got {
+namespace Gfx {
+
+void GfxSurface::print(const Common::Point &pos,
+		const Common::String &str, int color) {
+	// TODO
+}
+
+} // namespace Gfx
+} // namespace Got
diff --git a/engines/got/gfx/gfx_surface.h b/engines/got/gfx/gfx_surface.h
new file mode 100644
index 00000000000..65f91bd08ef
--- /dev/null
+++ b/engines/got/gfx/gfx_surface.h
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GFX_SURFACE_H
+#define GOT_GFX_SURFACE_H
+
+#include "graphics/managed_surface.h"
+
+namespace Got {
+namespace Gfx {
+
+class GfxSurface : public Graphics::ManagedSurface {
+public:
+	GfxSurface(Graphics::ManagedSurface &surf, const Common::Rect &bounds) :
+		Graphics::ManagedSurface(surf, bounds) {
+	}
+
+	/**
+	 * Write some text to the surface
+	 */
+	void print(const Common::Point &pos, const Common::String &str,
+		int color);
+};
+
+} // namespace Gfx
+} // namespace Got
+
+#endif
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 56b7ca39b1b..7da70dbe36a 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -9,6 +9,7 @@ MODULE_OBJS = \
 	vars.o \
 	gfx/gfx_chunks.o \
 	gfx/gfx_pics.o \
+	gfx/gfx_surface.o \
 	gfx/palette.o \
 	utils/compression.o \
 	utils/file.o \
diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
index 4f2777fca94..f0431d24537 100644
--- a/engines/got/views/dialogs/dialog.cpp
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -71,7 +71,7 @@ bool Dialog::msgKeypress(const KeypressMessage &msg) {
 }
 
 void Dialog::draw() {
-	Graphics::ManagedSurface s = getSurface();
+	GfxSurface s = getSurface();
 
 	// Draw four corners
 	s.clear(215);
diff --git a/engines/got/views/main_menu.cpp b/engines/got/views/main_menu.cpp
index 1537ff901bf..43280b1438b 100644
--- a/engines/got/views/main_menu.cpp
+++ b/engines/got/views/main_menu.cpp
@@ -42,7 +42,7 @@ bool MainMenu::msgKeypress(const KeypressMessage &msg) {
 }
 
 void MainMenu::draw() {
-	//Graphics::ManagedSurface s = getSurface();
+	//GfxSurface s = getSurface();
 	drawBackground();
 }
 
diff --git a/engines/got/views/story.cpp b/engines/got/views/story.cpp
index 80666f2fa40..7576ea2e8d2 100644
--- a/engines/got/views/story.cpp
+++ b/engines/got/views/story.cpp
@@ -67,7 +67,7 @@ bool Story::msgKeypress(const KeypressMessage &msg) {
 }
 
 void Story::draw() {
-	Graphics::ManagedSurface s = getSurface();
+	GfxSurface s = getSurface();
 
 	//s.blitFrom(_image1);
 	for (int i = 0; i < 10 * 10; ++i) {
diff --git a/engines/got/views/view.cpp b/engines/got/views/view.cpp
index fc0af2e5666..753f3a93d8e 100644
--- a/engines/got/views/view.cpp
+++ b/engines/got/views/view.cpp
@@ -81,7 +81,7 @@ bool View::msgMouseUp(const MouseUpMessage &msg) {
 }
 
 void View::drawBackground() {
-	Graphics::ManagedSurface s = getSurface();
+	GfxSurface s = getSurface();
 
 	for (int col = 0, xp = 0; col < 10; ++col, xp += 32) {
 		for (int yp = 0; yp < 192; yp += 32)


Commit: 77c8e30f8d1aa53f3253f6fdd93e174621a3ac0e
    https://github.com/scummvm/scummvm/commit/77c8e30f8d1aa53f3253f6fdd93e174621a3ac0e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Implemented font loading & display

Changed paths:
  A engines/got/gfx/font.cpp
  A engines/got/gfx/font.h
    engines/got/defines.h
    engines/got/gfx/gfx_pics.cpp
    engines/got/gfx/gfx_pics.h
    engines/got/gfx/gfx_surface.cpp
    engines/got/gfx/gfx_surface.h
    engines/got/messages.h
    engines/got/module.mk
    engines/got/vars.cpp
    engines/got/vars.h
    engines/got/views/dialogs/dialog.cpp


diff --git a/engines/got/defines.h b/engines/got/defines.h
index fac3a78929c..a54014cff6e 100644
--- a/engines/got/defines.h
+++ b/engines/got/defines.h
@@ -172,6 +172,16 @@ struct ACTOR_DATA {                 //5200
 };
 
 struct SETUP {
+	SETUP() :
+		f00(0), f01(0), f02(0), f03(0), f04(0), f05(0), f06(0), f07(0), f08(0), f09(0),
+		f10(0), f11(0), f12(0), f13(0), f14(0), f15(0), f16(0), f17(0), f18(0), f19(0),
+		f20(0), f21(0), f22(0), f23(0), f24(0), f25(0), f26(0), f27(0), f28(0), f29(0),
+		f30(0), f31(0), f32(0), f33(0), f34(0), f35(0), f36(0), f37(0), f38(0), f39(0),
+		f40(0), f41(0), f42(0), f43(0), f44(0), f45(0), f46(0), f47(0), f48(0), f49(0),
+		f50(0), f51(0), f52(0), f53(0), f54(0), f55(0), f56(0), f57(0), f58(0), f59(0),
+		f60(0), f61(0), f62(0), f63(0) {
+	}
+
 	unsigned int  f00 : 1;
 	unsigned int  f01 : 1;
 	unsigned int  f02 : 1;
diff --git a/engines/got/gfx/font.cpp b/engines/got/gfx/font.cpp
new file mode 100644
index 00000000000..b3ede04261e
--- /dev/null
+++ b/engines/got/gfx/font.cpp
@@ -0,0 +1,96 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/file.h"
+#include "got/gfx/font.h"
+#include "got/gfx/gfx_pics.h"
+
+namespace Got {
+namespace Gfx {
+
+static const byte DIALOG_COLOR[] = { 14,54,120,138,15,0,0,0,0,0,0,0,0,0,0,0 };
+
+void Font::load() {
+	Common::File f;
+	if (!f.open("TEXT"))
+		error("Could not open font");
+
+	_font.resize(f.size() / 72 + 32);
+
+	for (uint i = 32; i < _font.size(); ++i) {
+		byte buff[8 * 9];
+		f.read(buff, 8 * 9);
+
+		_font[i].create(8, 9);
+		convertPaneDataToSurface(buff, _font[i]);
+	}
+}
+
+void Font::drawString(Graphics::ManagedSurface *src, const Common::Point &pos,
+		const Common::String &text, int color) {
+	char ch;
+	char str[4];
+	const char *string = text.c_str();
+	Common::Point pt = pos;
+
+	str[3] = 0;
+	while (*string) {
+		ch = *string++;
+		if (ch == '~' && Common::isXDigit(*string)) {
+			ch = *string++;
+			if (Common::isDigit(ch)) {
+				ch -= 48;
+			} else {
+				ch = toupper(ch) - 55;
+			}
+			color = DIALOG_COLOR[ch];
+			continue;
+		}
+		if (ch > 31 && ch < 127)
+			drawChar(src, ch, pt.x, pt.y, color);
+
+		pt.x += 8;
+	}
+}
+
+void Font::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const {
+	const Graphics::ManagedSurface &glyph = _font[chr];
+
+	// Character drawing is done twice in the original:
+	// first at y + 1 with color 0, then at y with the given color
+	for (int pass = 0; pass < 2; ++pass) {
+		int col = (pass == 0) ? 0 : color;
+
+		for (int yp = 0; yp < glyph.h; ++yp) {
+			int startY = y + yp + (pass == 0 ? 1 : 0);
+			const byte *srcP = (const byte *)glyph.getBasePtr(0, yp);
+			byte *destP = (byte *)dst->getBasePtr(x, startY);
+
+			for (int xp = 0; xp < glyph.w; ++xp, ++srcP, ++destP) {
+				if (*srcP)
+					*destP = col;
+			}
+		}
+	}
+}
+
+} // namespace Gfx
+} // namespace Got
diff --git a/engines/got/gfx/font.h b/engines/got/gfx/font.h
new file mode 100644
index 00000000000..7c7be236851
--- /dev/null
+++ b/engines/got/gfx/font.h
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GFX_FONT_H
+#define GOT_GFX_FONT_H
+
+#include "common/array.h"
+#include "graphics/font.h"
+#include "graphics/managed_surface.h"
+
+namespace Got {
+namespace Gfx {
+
+class Font : public Graphics::Font {
+private:
+	Common::Array<Graphics::ManagedSurface> _font;
+
+public:
+	void load();
+
+	int getFontHeight() const override {
+		return 9;
+	}
+	int getMaxCharWidth() const override {
+		return 8;
+	}
+	int getCharWidth(uint32 chr) const override {
+		return 8;
+	}
+	void drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const override;
+	void drawChar(Graphics::ManagedSurface *dst, uint32 chr, int x, int y, uint32 color) const override {
+		Graphics::Font::drawChar(dst, chr, x, y, color);
+	}
+
+	void drawString(Graphics::ManagedSurface *src, const Common::Point &pos,
+		const Common::String &text, int color);
+};
+
+} // namespace Gfx
+} // namespace Got
+
+#endif
diff --git a/engines/got/gfx/gfx_pics.cpp b/engines/got/gfx/gfx_pics.cpp
index 26560941d0f..387521ecee8 100644
--- a/engines/got/gfx/gfx_pics.cpp
+++ b/engines/got/gfx/gfx_pics.cpp
@@ -26,6 +26,19 @@
 namespace Got {
 namespace Gfx {
 
+void convertPaneDataToSurface(const byte *src, Graphics::ManagedSurface &surf) {
+	// It's split into 4 panes per 4 pixels, so we need
+	// to juggle the pixels into their correct order
+	for (int plane = 0; plane < 4; ++plane) {
+		for (int y = 0; y < surf.h; ++y) {
+			byte *dest = (byte *)surf.getBasePtr(plane, y);
+
+			for (int x = 0; x < (surf.w / 4); ++x, dest += 4)
+				*dest = *src++;
+		}
+	}
+}
+
 void BgPics::setArea(int area) {
 	if (area != _area) {
 		_area = area;
@@ -43,7 +56,7 @@ void BgPics::load() {
 	clear();
 	resize(f.size() / 262);
 
-	byte buff[256];
+	byte buff[16 * 16];
 	for (uint idx = 0; idx < size(); ++idx) {
 		Graphics::ManagedSurface &s = (*this)[idx];
 
@@ -52,18 +65,7 @@ void BgPics::load() {
 
 		f.skip(6);
 		f.read(buff, 16 * 16);
-
-		// It's split into 4 panes per 4 pixels, so we need
-		// to juggle the pixels into their correct order
-		const byte *src = buff;
-		for (int plane = 0; plane < 4; ++plane) {
-			for (int y = 0; y < 16; ++y) {
-				byte *dest = (byte *)s.getBasePtr(plane, y);
-
-				for (int x = 0; x < (16 / 4); ++x, dest += 4)
-					*dest = *src++;
-			}
-		}
+		convertPaneDataToSurface(buff, s);
 	}
 }
 
diff --git a/engines/got/gfx/gfx_pics.h b/engines/got/gfx/gfx_pics.h
index ca495b4ceb1..e5c0b0ea9a1 100644
--- a/engines/got/gfx/gfx_pics.h
+++ b/engines/got/gfx/gfx_pics.h
@@ -28,6 +28,15 @@
 namespace Got {
 namespace Gfx {
 
+/**
+ * The original graphics screen was set up to use 4 panes,
+ * where each pane had a single pixel, repeating every 4 pixels.
+ * Because of this, graphics were stored with all the data for
+ * each pane one at a time. This helper methods takes care of
+ * "de-paneing" the graphics into a provided surface
+*/
+extern void convertPaneDataToSurface(const byte *src, Graphics::ManagedSurface &surf);
+
 class BgPics : public Common::Array<Graphics::ManagedSurface> {
 private:
 	int _area = 1;
diff --git a/engines/got/gfx/gfx_surface.cpp b/engines/got/gfx/gfx_surface.cpp
index 91f8e521d19..ed18242461a 100644
--- a/engines/got/gfx/gfx_surface.cpp
+++ b/engines/got/gfx/gfx_surface.cpp
@@ -20,13 +20,14 @@
  */
 
 #include "got/gfx/gfx_surface.h"
+#include "got/vars.h"
 
 namespace Got {
 namespace Gfx {
 
 void GfxSurface::print(const Common::Point &pos,
-		const Common::String &str, int color) {
-	// TODO
+		const Common::String &text, int color) {
+	_G(font).drawString(this, pos, text, color);
 }
 
 } // namespace Gfx
diff --git a/engines/got/gfx/gfx_surface.h b/engines/got/gfx/gfx_surface.h
index 65f91bd08ef..3192a7b09b6 100644
--- a/engines/got/gfx/gfx_surface.h
+++ b/engines/got/gfx/gfx_surface.h
@@ -36,8 +36,7 @@ public:
 	/**
 	 * Write some text to the surface
 	 */
-	void print(const Common::Point &pos, const Common::String &str,
-		int color);
+	void print(const Common::Point &pos, const Common::String &text, int color);
 };
 
 } // namespace Gfx
diff --git a/engines/got/messages.h b/engines/got/messages.h
index 3982679c4a2..150015202ca 100644
--- a/engines/got/messages.h
+++ b/engines/got/messages.h
@@ -86,7 +86,7 @@ struct GameMessage : public Message {
 	GameMessage(const Common::String &name, int value) : Message(),
 		_name(name), _value(value) {}
 	GameMessage(const Common::String &name, const Common::String &value) :
-		Message(), _name(name), _stringValue(value) {}
+		Message(), _name(name), _stringValue(value), _value(0) {}
 };
 
 struct ValueMessage : public Message {
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 7da70dbe36a..6c48eb98670 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -7,6 +7,7 @@ MODULE_OBJS = \
 	messages.o \
 	metaengine.o \
 	vars.o \
+	gfx/font.o \
 	gfx/gfx_chunks.o \
 	gfx/gfx_pics.o \
 	gfx/gfx_surface.o \
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index e69ee2b7197..56930ed44d2 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -30,16 +30,12 @@ namespace Got {
 
 Vars *g_vars;
 
-byte dialog_color[] = { 14,54,120,138,15,0,0,0,0,0,0,0,0,0,0,0 };
-const char *options_yesno[] = { "Yes","No", nullptr };
-const char *save_filename = "XXXXXXXX.XXX";
-
-
 Vars::Vars() {
 	g_vars = this;
 }
 
 void Vars::load() {
+	_font.load();
 	_gfx.load();
 	_bgPics.load();
 
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 476bfd3cc24..187988f58ab 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -25,6 +25,7 @@
 #include "common/events.h"
 #include "graphics/screen.h"
 #include "got/defines.h"
+#include "got/gfx/font.h"
 #include "got/gfx/gfx_chunks.h"
 #include "got/gfx/gfx_pics.h"
 
@@ -43,6 +44,7 @@ public:
 
 	Gfx::GfxChunks _gfx;
 	Gfx::BgPics _bgPics;
+	Gfx::Font _font;
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
 	uint _display_page = 0, _draw_page = 0;
@@ -54,7 +56,7 @@ public:
 	byte _joy_flag[100] = {};
 	byte _tmp_flag[100] = {};
 	int8 _break_code = 0;
-	int8 _scan_code, _last_scan_code = 0;
+	int8 _scan_code = 0, _last_scan_code = 0;
 	int8 _diag = 0;
 	int8 _slow_mode = 0, _startup = 0;
 	int8 _shot_ok = 0;
@@ -171,7 +173,7 @@ public:
 	int8 _main_loop = 0;
 	int8 _end_tile = 0;
 
-	byte _pbuff[PALETTE_SIZE];
+	byte _pbuff[PALETTE_SIZE] = {};
 };
 
 #define _G(X) (g_vars->_##X)
diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
index f0431d24537..6d20b47e417 100644
--- a/engines/got/views/dialogs/dialog.cpp
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -36,7 +36,7 @@ static Common::String getDialogName(const char *title) {
 }
 
 Dialog::Dialog(const char *title, const char *options[]) :
-		View(getDialogName(title)) {
+		View(getDialogName(title)), _title(title) {
 	// Load the options list into the string array
 	for (const char **option = options; *option; ++option)
 		_options.push_back(*option);
@@ -81,18 +81,23 @@ void Dialog::draw() {
 	s.blitFrom(_G(bgPics)[194], Common::Point(0, _bounds.height() - 16));
 	s.blitFrom(_G(bgPics)[195], Common::Point(_bounds.width() - 16, _bounds.height() - 16));
 
-	// Draw horizontal
+	// Draw top/bottom horizontal lines
 	for (int x = 16; x < _bounds.width() - 16; x += 16) {
 		s.blitFrom(_G(bgPics)[196], Common::Point(x, 0));
 		s.blitFrom(_G(bgPics)[197], Common::Point(x, _bounds.height() - 16));
 	}
+
+	// Draw left/right vertical lines
 	for (int y = 16; y < _bounds.height() - 16; y += 16) {
 		s.blitFrom(_G(bgPics)[198], Common::Point(0, y));
 		s.blitFrom(_G(bgPics)[199], Common::Point(_bounds.width() - 16, y));
 	}
 
-#ifdef TODO
+	// Write the title
 	int titleStart = (_bounds.width() - strlen(_title) * 8) / 2;
+	s.print(Common::Point(titleStart, 16), _title, 54);
+
+#ifdef TODO
 
 	xprint(i, y1 + 4, title, pg, 54);
 


Commit: 495b3e72ffd29eb3c4d53d521f6ad6362f36a814
    https://github.com/scummvm/scummvm/commit/495b3e72ffd29eb3c4d53d521f6ad6362f36a814
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Dialog now listing options

Changed paths:
    engines/got/events.cpp
    engines/got/events.h
    engines/got/views/dialogs/dialog.cpp


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index d9dfba9e22f..49c3aedef9f 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -317,8 +317,9 @@ void UIElement::addView() {
 	g_events->addView(this);
 }
 
-GfxSurface UIElement::getSurface() const {
-	return GfxSurface(*g_events->getScreen(), _bounds);
+GfxSurface UIElement::getSurface(bool innerBounds) const {
+	return GfxSurface(*g_events->getScreen(),
+		innerBounds ? _innerBounds : _bounds);
 }
 
 int UIElement::getRandomNumber(int minNumber, int maxNumber) {
diff --git a/engines/got/events.h b/engines/got/events.h
index 6b70b5fb2e3..f280de28aed 100644
--- a/engines/got/events.h
+++ b/engines/got/events.h
@@ -184,7 +184,7 @@ public:
 	/**
 	 * Returns a surface for drawing the element
 	 */
-	Gfx::GfxSurface getSurface() const;
+	Gfx::GfxSurface getSurface(bool innerBounds = false) const;
 
 	/**
 	 * Clear the surface
diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
index 6d20b47e417..5e746d00956 100644
--- a/engines/got/views/dialogs/dialog.cpp
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -94,19 +94,13 @@ void Dialog::draw() {
 	}
 
 	// Write the title
-	int titleStart = (_bounds.width() - strlen(_title) * 8) / 2;
-	s.print(Common::Point(titleStart, 16), _title, 54);
+	s = getSurface(true);
+	int titleStart = (s.w - strlen(_title) * 8) / 2;
+	s.print(Common::Point(titleStart, 4), _title, 54);
 
-#ifdef TODO
-
-	xprint(i, y1 + 4, title, pg, 54);
-
-	op = option;
-	for (i = 0; i < num_opts; i++) {
-		xprint(x1 + 32, (y1 + 28) + (i * 16), *op, pg, 14);
-		op++;
-	}
-#endif
+	// Write the options
+	for (uint i = 0; i < _options.size(); ++i)
+		s.print(Common::Point(32, 28 + i * 16), _options[i], 14);
 }
 
 bool Dialog::tick() {


Commit: b9c6d7c4eac11f12a757cb3272b1b61631fc0669
    https://github.com/scummvm/scummvm/commit/b9c6d7c4eac11f12a757cb3272b1b61631fc0669
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Split up graphics loading into it's own base class, load hampic

Changed paths:
    engines/got/gfx/gfx_pics.cpp
    engines/got/gfx/gfx_pics.h
    engines/got/utils/file.cpp
    engines/got/utils/file.h
    engines/got/vars.cpp
    engines/got/vars.h
    engines/got/views/dialogs/dialog.cpp


diff --git a/engines/got/gfx/gfx_pics.cpp b/engines/got/gfx/gfx_pics.cpp
index 387521ecee8..375ef23839a 100644
--- a/engines/got/gfx/gfx_pics.cpp
+++ b/engines/got/gfx/gfx_pics.cpp
@@ -22,6 +22,7 @@
 #include "common/textconsole.h"
 #include "common/file.h"
 #include "got/gfx/gfx_pics.h"
+#include "got/utils/file.h"
 
 namespace Got {
 namespace Gfx {
@@ -39,38 +40,43 @@ void convertPaneDataToSurface(const byte *src, Graphics::ManagedSurface &surf) {
 	}
 }
 
-void BgPics::setArea(int area) {
-	if (area != _area) {
-		_area = area;
-		load();
-	}
-}
 
-void BgPics::load() {
-	Common::String fname = Common::String::format("BPICS%d", _area);
-	Common::File f;
-	if (!f.open(Common::Path(fname)))
-		error("Could not open - %s", fname.c_str());
+void GfxPics::load(const Common::String &name, int blockSize) {
+	File f(name);
 
-	// Process the sprites - they're each 262 bytes
+	// Set up array of images
 	clear();
-	resize(f.size() / 262);
+	resize(f.size() / blockSize);
+
+	byte *buff = new byte[blockSize];
 
-	byte buff[16 * 16];
 	for (uint idx = 0; idx < size(); ++idx) {
-		Graphics::ManagedSurface &s = (*this)[idx];
+		int w = f.readUint16LE() * 4;
+		int h = f.readUint16LE();
+		f.skip(2);	// Unused transparent color. It's always 15
+		f.read(buff, 16 * 16);
 
-		s.create(16, 16);
+		Graphics::ManagedSurface &s = (*this)[idx];
+		s.create(w, h);
 		s.setTransparentColor(15);
 
-		f.skip(6);
-		f.read(buff, 16 * 16);
 		convertPaneDataToSurface(buff, s);
 	}
+
+	delete[] buff;
 }
 
-void Pics::load() {
 
+void BgPics::setArea(int area) {
+	if (area != _area) {
+		_area = area;
+		load();
+	}
+}
+
+void BgPics::load() {
+	Common::String fname = Common::String::format("BPICS%d", _area);
+	GfxPics::load(fname, 262);
 }
 
 } // namespace Gfx
diff --git a/engines/got/gfx/gfx_pics.h b/engines/got/gfx/gfx_pics.h
index e5c0b0ea9a1..315265ee2e1 100644
--- a/engines/got/gfx/gfx_pics.h
+++ b/engines/got/gfx/gfx_pics.h
@@ -37,7 +37,13 @@ namespace Gfx {
 */
 extern void convertPaneDataToSurface(const byte *src, Graphics::ManagedSurface &surf);
 
-class BgPics : public Common::Array<Graphics::ManagedSurface> {
+
+class GfxPics : public Common::Array<Graphics::ManagedSurface> {
+public:
+	void load(const Common::String &name, int blockSize);
+};
+
+class BgPics : public GfxPics {
 private:
 	int _area = 1;
 
@@ -50,9 +56,18 @@ public:
 	void setArea(int area);
 };
 
-class Pics : public Common::Array<Graphics::ManagedSurface> {
+class Pics : public GfxPics {
+private:
+	const char *_resName;
+	int _blockSize;
+
 public:
-	void load();
+	Pics(const char *resName, int blockSize) :
+		_resName(resName), _blockSize(blockSize) {}
+
+	void load() {
+		GfxPics::load(_resName, _blockSize);
+	}
 };
 
 } // namespace Gfx
diff --git a/engines/got/utils/file.cpp b/engines/got/utils/file.cpp
index 9029c62accd..d5d59458e53 100644
--- a/engines/got/utils/file.cpp
+++ b/engines/got/utils/file.cpp
@@ -28,6 +28,13 @@ namespace Got {
 
 static const char *gotres = "GOTRES.00";
 
+bool File::open(const Common::Path &filename) {
+	if (!Common::File::open(filename))
+		error("Could not open - %s", filename.baseName().c_str());
+	return true;
+}
+
+
 long file_size(char *path) {
 	Common::File f;
 	return f.open(Common::Path(path)) ? f.size() : -1;
diff --git a/engines/got/utils/file.h b/engines/got/utils/file.h
index a68bc748b05..38121322ca0 100644
--- a/engines/got/utils/file.h
+++ b/engines/got/utils/file.h
@@ -22,7 +22,7 @@
 #ifndef GOT_UTILS_FILE_H
 #define GOT_UTILS_FILE_H
 
-#include "common/str.h"
+#include "common/file.h"
 #include "got/defines.h"
 
 namespace Got {
@@ -45,6 +45,16 @@ extern void help();
 extern long res_read(const Common::String &name, void *buff);
 extern bool load_music(int num);
 
+class File : public Common::File {
+public:
+	File() : Common::File() {}
+	File(const Common::String &filename) : Common::File() {
+		File::open(Common::Path(filename));
+	}
+
+	bool open(const Common::Path &filename) override;
+};
+
 } // namespace Got
 
 #endif
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 56930ed44d2..722f0ca0b90 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -30,7 +30,7 @@ namespace Got {
 
 Vars *g_vars;
 
-Vars::Vars() {
+Vars::Vars() : _hampic("HAMPIC", 262) {
 	g_vars = this;
 }
 
@@ -38,6 +38,7 @@ void Vars::load() {
 	_font.load();
 	_gfx.load();
 	_bgPics.load();
+	_hampic.load();
 
 	_music_flag = !ConfMan.getBool("music_mute");
 	_sound_flag = _pcsound_flag = !ConfMan.getBool("sfx_mute");
@@ -79,9 +80,7 @@ void Vars::load() {
  
 	res_read("RANDOM", _rnd_array);
 	res_read("DEMO", _demo_key);
-	res_read("TEXT", _text);
 	res_read("ODINPIC", _odin);
-	res_read("HAMPIC", _hampic);
 
 	load_palette();
 
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 187988f58ab..06f4a0ecd35 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -45,6 +45,7 @@ public:
 	Gfx::GfxChunks _gfx;
 	Gfx::BgPics _bgPics;
 	Gfx::Font _font;
+	Gfx::Pics _hampic;
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
 	uint _display_page = 0, _draw_page = 0;
@@ -67,7 +68,6 @@ public:
 
 	uint _timer_cnt = 0, _vbl_cnt = 0, _magic_cnt = 0, _extra_cnt = 0;
 
-	byte _text[94][72] = {};
 	//union REGS in, out = 0;
 	//struct SREGS seg = 0;
 	byte _objects[NUM_OBJECTS][262] = {};
@@ -143,7 +143,6 @@ public:
 		_joyhx = 0, _joyhy = 0;
 	byte _res_file[16] = {};
 	byte _odin[4][262] = {};
-	byte _hampic[4][262] = {};
 	int _load_game_flag = 0;
 	bool _music_flag = false, _sound_flag = false, _pcsound_flag = false;
 	int _cash1_inform = 0, _cash2_inform = 0, _door_inform = 0,
diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
index 5e746d00956..4148298eee2 100644
--- a/engines/got/views/dialogs/dialog.cpp
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -101,6 +101,9 @@ void Dialog::draw() {
 	// Write the options
 	for (uint i = 0; i < _options.size(); ++i)
 		s.print(Common::Point(32, 28 + i * 16), _options[i], 14);
+
+	// Draw selection pointer
+	s.blitFrom(_G(hampic)[0], Common::Point(8, 24 + (_selectedItem * 16)));
 }
 
 bool Dialog::tick() {


Commit: 7a2bfc4743345f9481aaef615050fd79882c9504
    https://github.com/scummvm/scummvm/commit/7a2bfc4743345f9481aaef615050fd79882c9504
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Hammer icon in dialogs is now properly animated

Changed paths:
    engines/got/views/dialogs/dialog.cpp
    engines/got/views/dialogs/dialog.h


diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
index 4148298eee2..29256e24a93 100644
--- a/engines/got/views/dialogs/dialog.cpp
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -103,10 +103,15 @@ void Dialog::draw() {
 		s.print(Common::Point(32, 28 + i * 16), _options[i], 14);
 
 	// Draw selection pointer
-	s.blitFrom(_G(hampic)[0], Common::Point(8, 24 + (_selectedItem * 16)));
+	s.blitFrom(_G(hampic)[_hammerFrame],
+		Common::Point(8, 24 + (_selectedItem * 16)));
 }
 
 bool Dialog::tick() {
+	if (++_hammerFrame == 4)
+		_hammerFrame = 0;
+
+	redraw();
 	return true;
 }
 
diff --git a/engines/got/views/dialogs/dialog.h b/engines/got/views/dialogs/dialog.h
index e0840b7d566..4bc1ff1193b 100644
--- a/engines/got/views/dialogs/dialog.h
+++ b/engines/got/views/dialogs/dialog.h
@@ -34,6 +34,7 @@ private:
 	const char *_title;
 	Common::StringArray _options;
 	int _selectedItem = 0;
+	int _hammerFrame = 0;
 
 public:
 	Dialog(const char *title, const char *options[]);


Commit: 0f0a5e4dd4d907571dc329c637083c819ffe3856
    https://github.com/scummvm/scummvm/commit/0f0a5e4dd4d907571dc329c637083c819ffe3856
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added keybinding actions, up/down now working in dialog

Changed paths:
    engines/got/metaengine.cpp
    engines/got/metaengine.h
    engines/got/views/dialogs/dialog.cpp
    engines/got/views/dialogs/dialog.h


diff --git a/engines/got/metaengine.cpp b/engines/got/metaengine.cpp
index a63a96e3459..b7fc58cf80d 100644
--- a/engines/got/metaengine.cpp
+++ b/engines/got/metaengine.cpp
@@ -20,7 +20,9 @@
  */
 
 #include "common/translation.h"
-
+#include "backends/keymapper/action.h"
+#include "backends/keymapper/keymapper.h"
+#include "backends/keymapper/standard-actions.h"
 #include "got/metaengine.h"
 #include "got/detection.h"
 #include "got/got.h"
@@ -42,6 +44,23 @@ static const ADExtraGuiOptionsMap optionsList[] = {
 	AD_EXTRA_GUI_OPTIONS_TERMINATOR
 };
 
+struct KeybindingRecord {
+	KeybindingAction _action;
+	const char *_id;
+	const char *_desc;
+	const char *_key;
+	const char *_joy;
+};
+
+static const KeybindingRecord GAME_KEYS[] = {
+	{ KEYBIND_SELECT, "SELECT", _s("Select"), "RETURN", "JOY_A" },
+	{ KEYBIND_UP, "UP", _s("Up"), "UP", "JOY_UP"},
+	{ KEYBIND_DOWN, "DOWN", _s("Down"), "DOWN", "JOY_DOWN"},
+	{ KEYBIND_LEFT, "LEFT", _s("Left"), "LEFT", "JOY_LEFT"},
+	{ KEYBIND_RIGHT, "RIGHT", _s("Right"), "RIGHT", "JOY_RIGHT"},
+	{ KEYBIND_NONE, nullptr, nullptr, nullptr, nullptr }
+};
+
 } // End of namespace Got
 
 const char *GotMetaEngine::getName() const {
@@ -62,6 +81,29 @@ bool GotMetaEngine::hasFeature(MetaEngineFeature f) const {
 		(f == kSupportsLoadingDuringStartup);
 }
 
+Common::Array<Common::Keymap *> GotMetaEngine::initKeymaps(const char *target) const {
+	Common::KeymapArray keymapArray;
+	Common::Keymap *keyMap;
+	Common::Action *act;
+
+	keyMap = new Common::Keymap(Common::Keymap::kKeymapTypeGame,
+		"got", _s("Game Keys"));
+	keymapArray.push_back(keyMap);
+
+	for (const Got::KeybindingRecord *r = Got::GAME_KEYS; r->_id; ++r) {
+		act = new Common::Action(r->_id, _(r->_desc));
+		act->setCustomEngineActionEvent(r->_action);
+		act->addDefaultInputMapping(r->_key);
+		if (r->_joy)
+			act->addDefaultInputMapping(r->_joy);
+
+		keyMap->addAction(act);
+	}
+
+	return keymapArray;
+}
+
+
 #if PLUGIN_ENABLED_DYNAMIC(GOT)
 REGISTER_PLUGIN_DYNAMIC(GOT, PLUGIN_TYPE_ENGINE, GotMetaEngine);
 #else
diff --git a/engines/got/metaengine.h b/engines/got/metaengine.h
index 8422c6527ff..cdc52bdc4a2 100644
--- a/engines/got/metaengine.h
+++ b/engines/got/metaengine.h
@@ -24,6 +24,15 @@
 
 #include "engines/advancedDetector.h"
 
+namespace Got {
+
+enum KeybindingAction {
+	KEYBIND_NONE, KEYBIND_UP, KEYBIND_DOWN, KEYBIND_LEFT, KEYBIND_RIGHT,
+	KEYBIND_SELECT
+};
+
+}
+
 class GotMetaEngine : public AdvancedMetaEngine<ADGameDescription> {
 public:
 	const char *getName() const override;
@@ -38,6 +47,8 @@ public:
 	bool hasFeature(MetaEngineFeature f) const override;
 
 	const ADExtraGuiOptionsMap *getAdvancedExtraGuiOptions() const override;
+
+	Common::Array<Common::Keymap *> initKeymaps(const char *target) const override;
 };
 
 #endif // GOT_METAENGINE_H
diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
index 29256e24a93..9376624a479 100644
--- a/engines/got/views/dialogs/dialog.cpp
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "got/views/dialogs/dialog.h"
+#include "got/metaengine.h"
 #include "got/vars.h"
 
 namespace Got {
@@ -58,15 +59,22 @@ Dialog::Dialog(const char *title, const char *options[]) :
 	_bounds.setBorderSize(16);
 }
 
-bool Dialog::msgFocus(const FocusMessage &msg) {
-	return true;
-}
+bool Dialog::msgAction(const ActionMessage &msg) {
+	switch (msg._action) {
+	case KEYBIND_UP:
+		if (--_selectedItem < 0)
+			_selectedItem = (int)_options.size() - 1;
+		break;
 
-bool Dialog::msgUnfocus(const UnfocusMessage &msg) {
-	return true;
-}
+	case KEYBIND_DOWN:
+		if (++_selectedItem >= (int)_options.size())
+			_selectedItem = 0;
+		break;
+
+	default:
+		break;
+	}
 
-bool Dialog::msgKeypress(const KeypressMessage &msg) {
 	return true;
 }
 
diff --git a/engines/got/views/dialogs/dialog.h b/engines/got/views/dialogs/dialog.h
index 4bc1ff1193b..984da5eeb4e 100644
--- a/engines/got/views/dialogs/dialog.h
+++ b/engines/got/views/dialogs/dialog.h
@@ -41,9 +41,7 @@ public:
 	virtual ~Dialog() {
 	}
 
-	bool msgFocus(const FocusMessage &msg) override;
-	bool msgUnfocus(const UnfocusMessage &msg) override;
-	bool msgKeypress(const KeypressMessage &msg) override;
+	bool msgAction(const ActionMessage &msg) override;
 	void draw() override;
 	bool tick() override;
 };


Commit: daff4e304cb890aa9c827a256c226d15b80bc94c
    https://github.com/scummvm/scummvm/commit/daff4e304cb890aa9c827a256c226d15b80bc94c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Animation for selecting a dialog item

Changed paths:
    engines/got/metaengine.cpp
    engines/got/metaengine.h
    engines/got/views/dialogs/dialog.cpp
    engines/got/views/dialogs/dialog.h


diff --git a/engines/got/metaengine.cpp b/engines/got/metaengine.cpp
index b7fc58cf80d..67c0ae73eb3 100644
--- a/engines/got/metaengine.cpp
+++ b/engines/got/metaengine.cpp
@@ -53,11 +53,13 @@ struct KeybindingRecord {
 };
 
 static const KeybindingRecord GAME_KEYS[] = {
-	{ KEYBIND_SELECT, "SELECT", _s("Select"), "RETURN", "JOY_A" },
 	{ KEYBIND_UP, "UP", _s("Up"), "UP", "JOY_UP"},
 	{ KEYBIND_DOWN, "DOWN", _s("Down"), "DOWN", "JOY_DOWN"},
 	{ KEYBIND_LEFT, "LEFT", _s("Left"), "LEFT", "JOY_LEFT"},
 	{ KEYBIND_RIGHT, "RIGHT", _s("Right"), "RIGHT", "JOY_RIGHT"},
+	{ KEYBIND_SELECT, "SELECT", _s("Select"), "RETURN", "JOY_A" },
+	// I18N: ESC key
+	{ KEYBIND_ESCAPE, "ESCAPE", _s("Escape"), "ESCAPE", nullptr },
 	{ KEYBIND_NONE, nullptr, nullptr, nullptr, nullptr }
 };
 
diff --git a/engines/got/metaengine.h b/engines/got/metaengine.h
index cdc52bdc4a2..100a25fd82f 100644
--- a/engines/got/metaengine.h
+++ b/engines/got/metaengine.h
@@ -28,10 +28,10 @@ namespace Got {
 
 enum KeybindingAction {
 	KEYBIND_NONE, KEYBIND_UP, KEYBIND_DOWN, KEYBIND_LEFT, KEYBIND_RIGHT,
-	KEYBIND_SELECT
+	KEYBIND_SELECT, KEYBIND_ESCAPE, KEYBIND_FIRE, KEYBIND_MAGIC
 };
 
-}
+} // namespace Got
 
 class GotMetaEngine : public AdvancedMetaEngine<ADGameDescription> {
 public:
diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
index 9376624a479..757074d3950 100644
--- a/engines/got/views/dialogs/dialog.cpp
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -59,25 +59,6 @@ Dialog::Dialog(const char *title, const char *options[]) :
 	_bounds.setBorderSize(16);
 }
 
-bool Dialog::msgAction(const ActionMessage &msg) {
-	switch (msg._action) {
-	case KEYBIND_UP:
-		if (--_selectedItem < 0)
-			_selectedItem = (int)_options.size() - 1;
-		break;
-
-	case KEYBIND_DOWN:
-		if (++_selectedItem >= (int)_options.size())
-			_selectedItem = 0;
-		break;
-
-	default:
-		break;
-	}
-
-	return true;
-}
-
 void Dialog::draw() {
 	GfxSurface s = getSurface();
 
@@ -111,14 +92,61 @@ void Dialog::draw() {
 		s.print(Common::Point(32, 28 + i * 16), _options[i], 14);
 
 	// Draw selection pointer
-	s.blitFrom(_G(hampic)[_hammerFrame],
-		Common::Point(8, 24 + (_selectedItem * 16)));
+	if (_smackCtr > 0) {
+		// Selecting an item
+		s.blitFrom(_G(hampic)[0], Common::Point(8 + 2 * _smackCtr,
+			24 + (_selectedItem * 16)));
+	} else {
+		// Normal animated cursor
+		s.blitFrom(_G(hampic)[_hammerFrame],
+			Common::Point(8, 24 + (_selectedItem * 16)));
+	}
+}
+
+bool Dialog::msgAction(const ActionMessage &msg) {
+	// Don't allow further actions if selection is in progress
+	if (_smackCtr != 0)
+		return true;
+
+	switch (msg._action) {
+	case KEYBIND_UP:
+		if (--_selectedItem < 0)
+			_selectedItem = (int)_options.size() - 1;
+		break;
+
+	case KEYBIND_DOWN:
+		if (++_selectedItem >= (int)_options.size())
+			_selectedItem = 0;
+		break;
+
+	case KEYBIND_SELECT:
+	case KEYBIND_FIRE:
+	case KEYBIND_MAGIC:
+		_smackCtr = 1;
+		break;
+
+	case KEYBIND_ESCAPE:
+		closed();
+
+	default:
+		break;
+	}
+
+	return true;
 }
 
 bool Dialog::tick() {
 	if (++_hammerFrame == 4)
 		_hammerFrame = 0;
 
+	// Handle animation when an item is selected
+	if (_smackCtr != 0) {
+		if (++_smackCtr == 4) {
+			_smackCtr = 0;
+			selected();
+		}	
+	}
+
 	redraw();
 	return true;
 }
diff --git a/engines/got/views/dialogs/dialog.h b/engines/got/views/dialogs/dialog.h
index 984da5eeb4e..95d7a16ff85 100644
--- a/engines/got/views/dialogs/dialog.h
+++ b/engines/got/views/dialogs/dialog.h
@@ -33,14 +33,27 @@ class Dialog : public View {
 private:
 	const char *_title;
 	Common::StringArray _options;
-	int _selectedItem = 0;
 	int _hammerFrame = 0;
+	int _smackCtr = 0;
+
+protected:
+	int _selectedItem = 0;
+
+	virtual void closed() {
+		close();
+	}
+	virtual void selected() {}
 
 public:
 	Dialog(const char *title, const char *options[]);
 	virtual ~Dialog() {
 	}
 
+	bool msgFocus(const FocusMessage &msg) override {
+		_selectedItem = 0;
+		_smackCtr = 0;
+		return true;
+	}
 	bool msgAction(const ActionMessage &msg) override;
 	void draw() override;
 	bool tick() override;


Commit: 939153819cb5bd8918d2af99de965b9c15b411cf
    https://github.com/scummvm/scummvm/commit/939153819cb5bd8918d2af99de965b9c15b411cf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Further selection animation, play_sound placeholder

Changed paths:
    engines/got/views/dialogs/dialog.cpp
    engines/got/views/view.cpp
    engines/got/views/view.h


diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
index 757074d3950..72bad954807 100644
--- a/engines/got/views/dialogs/dialog.cpp
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -94,8 +94,8 @@ void Dialog::draw() {
 	// Draw selection pointer
 	if (_smackCtr > 0) {
 		// Selecting an item
-		s.blitFrom(_G(hampic)[0], Common::Point(8 + 2 * _smackCtr,
-			24 + (_selectedItem * 16)));
+		int xp = 8 + 2 * (_smackCtr < 3 ? (_smackCtr + 1) : (6 - _smackCtr));
+		s.blitFrom(_G(hampic)[0], Common::Point(xp, 24 + (_selectedItem * 16)));
 	} else {
 		// Normal animated cursor
 		s.blitFrom(_G(hampic)[_hammerFrame],
@@ -141,7 +141,10 @@ bool Dialog::tick() {
 
 	// Handle animation when an item is selected
 	if (_smackCtr != 0) {
-		if (++_smackCtr == 4) {
+		++_smackCtr;
+		if (_smackCtr == 3)
+			play_sound(CLANG, 1);
+		if (_smackCtr == 6) {
 			_smackCtr = 0;
 			selected();
 		}	
diff --git a/engines/got/views/view.cpp b/engines/got/views/view.cpp
index 753f3a93d8e..19431c3aaad 100644
--- a/engines/got/views/view.cpp
+++ b/engines/got/views/view.cpp
@@ -91,6 +91,9 @@ void View::drawBackground() {
 	}
 }
 
+void View::play_sound(int index, int priority_override) {
+	warning("TODO: play_sound");
+}
 
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/view.h b/engines/got/views/view.h
index 6e630a11586..edf3db7e2db 100644
--- a/engines/got/views/view.h
+++ b/engines/got/views/view.h
@@ -70,6 +70,8 @@ public:
 	bool msgMouseMove(const MouseMoveMessage &msg) override;
 	bool msgMouseDown(const MouseDownMessage &msg) override;
 	bool msgMouseUp(const MouseUpMessage &msg) override;
+
+	void play_sound(int index, int priority_override);
 };
 
 } // namespace Views


Commit: aa6d5debc31f6e0cfe3df51c4c11c101039e1c11
    https://github.com/scummvm/scummvm/commit/aa6d5debc31f6e0cfe3df51c4c11c101039e1c11
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Implemented sound effects

Changed paths:
  A engines/got/sound.cpp
  A engines/got/sound.h
    engines/got/defines.h
    engines/got/module.mk
    engines/got/vars.cpp
    engines/got/vars.h
    engines/got/views/view.cpp
    engines/got/views/view.h


diff --git a/engines/got/defines.h b/engines/got/defines.h
index a54014cff6e..a6b4d667ea9 100644
--- a/engines/got/defines.h
+++ b/engines/got/defines.h
@@ -23,6 +23,7 @@
 #define GOT_DEFINES_H
 
 #include "common/scummsys.h"
+#include "common/stream.h"
 
 namespace Got {
 
@@ -130,7 +131,7 @@ struct ACTOR {                      //size=256
 	byte shot_actor = 0;
 	byte magic_hit = 0;
 	byte temp6 = 0;
-	int  i1, i2, i3, i4, i5, i6 = 0;
+	int  i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
 	byte init_health = 0;
 	byte talk_counter = 0;
 	byte etype = 0;
@@ -304,6 +305,11 @@ struct THOR_INFO {
 struct HEADER {
 	long offset = 0;
 	long length = 0;
+
+	void load(Common::SeekableReadStream *src) {
+		offset = src->readUint32LE();
+		length = src->readUint32LE();
+	}
 };
 
 //==========================================================================
@@ -423,36 +429,11 @@ enum {
 };
 #define	status_Reg1 0x3da
 
-enum {
-	OW,
-	GULP,
-	SWISH,
-	YAH,
-	ELECTRIC,
-	THUNDER,
-	DOOR,
-	FALL,
-	ANGEL,
-	WOOP,
-	DEAD,
-	BRAAPP,
-	WIND,
-	PUNCH1,
-	CLANG,
-	EXPLODE,
-	BOSS11,
-	BOSS12,
-	BOSS13,
-};
-
-#define	status_Reg1 0x3da
-
 #define GAME1 (_G(area)==1)
 #define GAME2 (_G(area)==2)
 #define GAME3 (_G(area)==3)
 #define BP    (_G(key_flag)[_B])
 
-#define NUM_SOUNDS  19
 #define NUM_OBJECTS 32
 
 #define APPLE_MAGIC     1
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 6c48eb98670..e850054612f 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS = \
 	events.o \
 	messages.o \
 	metaengine.o \
+	sound.o \
 	vars.o \
 	gfx/font.o \
 	gfx/gfx_chunks.o \
diff --git a/engines/got/sound.cpp b/engines/got/sound.cpp
new file mode 100644
index 00000000000..1924ac6ba02
--- /dev/null
+++ b/engines/got/sound.cpp
@@ -0,0 +1,69 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/memstream.h"
+#include "audio/decoders/raw.h"
+#include "audio/decoders/voc.h"
+#include "got/sound.h"
+#include "got/got.h"
+#include "got/utils/file.h"
+
+namespace Got {
+
+static const byte SOUND_PRIORITY[] = { 1,2,3,3,3,1,4,4,4,5,4,3,1,2,2,5,1,3,1 };
+
+void Sound::load() {
+	File f("DIGSOUND");
+
+	// Load index
+	for (int i = 0; i < 16; ++i)
+		_digiSounds[i].load(&f);
+
+	// Allocate memory and load sound data
+	_soundData = new byte[f.size() - 16 * 8];
+	f.read(_soundData, f.size() - 16 * 8);
+}
+
+void Sound::play_sound(int index, bool priority_override) {
+	if (index >= NUM_SOUNDS)
+		return;
+
+	// If a sound is playing, stop it unless there is a priority override
+	if (sound_playing()) {
+		if (!priority_override && _currentPriority < SOUND_PRIORITY[index])
+			return;
+
+		g_engine->_mixer->stopHandle(_soundHandle);
+	}
+
+	// Play the new sound
+	Common::MemoryReadStream *stream = new Common::MemoryReadStream(
+		_soundData + _digiSounds[index].offset, _digiSounds[index].length);
+	Audio::AudioStream *audioStream = Audio::makeVOCStream(stream, Audio::FLAG_UNSIGNED);
+	g_engine->_mixer->playStream(Audio::Mixer::kPlainSoundType,
+		&_soundHandle, audioStream);
+}
+
+bool Sound::sound_playing() const {
+	return g_engine->_mixer->isSoundHandleActive(_soundHandle);
+}
+
+} // namespace Got
diff --git a/engines/got/sound.h b/engines/got/sound.h
new file mode 100644
index 00000000000..bff846afdbb
--- /dev/null
+++ b/engines/got/sound.h
@@ -0,0 +1,74 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_SOUND_H
+#define GOT_SOUND_H
+
+#include "audio/mixer.h"
+#include "got/defines.h"
+
+namespace Got {
+
+enum {
+	OW,
+	GULP,
+	SWISH,
+	YAH,
+	ELECTRIC,
+	THUNDER,
+	DOOR,
+	FALL,
+	ANGEL,
+	WOOP,
+	DEAD,
+	BRAAPP,
+	WIND,
+	PUNCH1,
+	CLANG,
+	EXPLODE,
+	BOSS11,
+	BOSS12,
+	BOSS13,
+};
+
+#define NUM_SOUNDS  19
+
+class Sound {
+private:
+	byte *_soundData = nullptr;
+	HEADER _digiSounds[NUM_SOUNDS];
+	Audio::SoundHandle _soundHandle;
+	int _currentPriority = 0;
+
+public:
+	~Sound() {
+		delete[] _soundData;
+	}
+	void load();
+
+	void play_sound(int index, bool priority_override);
+
+	bool sound_playing() const;
+};
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 722f0ca0b90..5956c4bfd75 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -39,6 +39,7 @@ void Vars::load() {
 	_gfx.load();
 	_bgPics.load();
 	_hampic.load();
+	_sound.load();
 
 	_music_flag = !ConfMan.getBool("music_mute");
 	_sound_flag = _pcsound_flag = !ConfMan.getBool("sfx_mute");
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 06f4a0ecd35..d774e6bb924 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -25,6 +25,7 @@
 #include "common/events.h"
 #include "graphics/screen.h"
 #include "got/defines.h"
+#include "got/sound.h"
 #include "got/gfx/font.h"
 #include "got/gfx/gfx_chunks.h"
 #include "got/gfx/gfx_pics.h"
@@ -46,6 +47,7 @@ public:
 	Gfx::BgPics _bgPics;
 	Gfx::Font _font;
 	Gfx::Pics _hampic;
+	Sound _sound;
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
 	uint _display_page = 0, _draw_page = 0;
diff --git a/engines/got/views/view.cpp b/engines/got/views/view.cpp
index 19431c3aaad..ab03c8a1566 100644
--- a/engines/got/views/view.cpp
+++ b/engines/got/views/view.cpp
@@ -91,8 +91,8 @@ void View::drawBackground() {
 	}
 }
 
-void View::play_sound(int index, int priority_override) {
-	warning("TODO: play_sound");
+void View::play_sound(int index, bool priority_override) {
+	_G(sound).play_sound(index, priority_override);
 }
 
 } // namespace Views
diff --git a/engines/got/views/view.h b/engines/got/views/view.h
index edf3db7e2db..8fd86c77302 100644
--- a/engines/got/views/view.h
+++ b/engines/got/views/view.h
@@ -71,7 +71,7 @@ public:
 	bool msgMouseDown(const MouseDownMessage &msg) override;
 	bool msgMouseUp(const MouseUpMessage &msg) override;
 
-	void play_sound(int index, int priority_override);
+	void play_sound(int index, bool priority_override);
 };
 
 } // namespace Views


Commit: 9f4e657dee2faa9fa428c69c25b71b6c7707def2
    https://github.com/scummvm/scummvm/commit/9f4e657dee2faa9fa428c69c25b71b6c7707def2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Prototype sub-menu from Options Menu

Changed paths:
  A engines/got/views/dialogs/set_sound.cpp
  A engines/got/views/dialogs/set_sound.h
    engines/got/module.mk
    engines/got/views/dialogs/dialog.cpp
    engines/got/views/dialogs/dialog.h
    engines/got/views/dialogs/options_menu.cpp
    engines/got/views/dialogs/options_menu.h
    engines/got/views/views.h


diff --git a/engines/got/module.mk b/engines/got/module.mk
index e850054612f..8885bd106ae 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -20,7 +20,8 @@ MODULE_OBJS = \
 	views/view.o \
 	views/story.o \
 	views/dialogs/dialog.o \
-	views/dialogs/options_menu.o
+	views/dialogs/options_menu.o \
+	views/dialogs/set_sound.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_GOT), DYNAMIC_PLUGIN)
diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
index 72bad954807..7d5b2d6c792 100644
--- a/engines/got/views/dialogs/dialog.cpp
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -27,6 +27,9 @@ namespace Got {
 namespace Views {
 namespace Dialogs {
 
+const char *ON_OFF[] = { "On", "Off", nullptr };
+
+
 // Forms a class name for the view hierarchy from the dialog title
 static Common::String getDialogName(const char *title) {
 	Common::String result = title;
@@ -110,11 +113,13 @@ bool Dialog::msgAction(const ActionMessage &msg) {
 
 	switch (msg._action) {
 	case KEYBIND_UP:
+		play_sound(WOOP,1);
 		if (--_selectedItem < 0)
 			_selectedItem = (int)_options.size() - 1;
 		break;
 
 	case KEYBIND_DOWN:
+		play_sound(WOOP, 1);
 		if (++_selectedItem >= (int)_options.size())
 			_selectedItem = 0;
 		break;
diff --git a/engines/got/views/dialogs/dialog.h b/engines/got/views/dialogs/dialog.h
index 95d7a16ff85..ef9628be59c 100644
--- a/engines/got/views/dialogs/dialog.h
+++ b/engines/got/views/dialogs/dialog.h
@@ -29,6 +29,9 @@ namespace Got {
 namespace Views {
 namespace Dialogs {
 
+// On/Off is commonly used across multiple dialogs
+extern const char *ON_OFF[];
+
 class Dialog : public View {
 private:
 	const char *_title;
diff --git a/engines/got/views/dialogs/options_menu.cpp b/engines/got/views/dialogs/options_menu.cpp
index d56a81091fe..1974493d3ec 100644
--- a/engines/got/views/dialogs/options_menu.cpp
+++ b/engines/got/views/dialogs/options_menu.cpp
@@ -36,6 +36,16 @@ static const char *OPTIONS[] = {
 OptionsMenu::OptionsMenu() : Dialog("Options Menu", OPTIONS) {
 }
 
+void OptionsMenu::selected() {
+	switch (_selectedItem) {
+	case 0:
+		replaceView("SetSound");
+		break;
+	default:
+		break;
+	}
+}
+
 } // namespace Dialogs
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/dialogs/options_menu.h b/engines/got/views/dialogs/options_menu.h
index fbde1333828..fbe11e3bd04 100644
--- a/engines/got/views/dialogs/options_menu.h
+++ b/engines/got/views/dialogs/options_menu.h
@@ -34,6 +34,7 @@ public:
 	virtual ~OptionsMenu() {
 	}
 
+	void selected() override;
 };
 
 } // namespace Dialogs
diff --git a/engines/got/views/dialogs/set_sound.cpp b/engines/got/views/dialogs/set_sound.cpp
new file mode 100644
index 00000000000..7b72f9158cd
--- /dev/null
+++ b/engines/got/views/dialogs/set_sound.cpp
@@ -0,0 +1,41 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/set_sound.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+static const char *OPTIONS[] = {
+	"None", "Digitized", nullptr
+};
+
+SetSound::SetSound() : Dialog("Set Sound", OPTIONS) {
+}
+
+void SetSound::selected() {
+	// TODO
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/set_sound.h b/engines/got/views/dialogs/set_sound.h
new file mode 100644
index 00000000000..4638e831aa1
--- /dev/null
+++ b/engines/got/views/dialogs/set_sound.h
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_SET_SOUND_H
+#define GOT_VIEWS_DIALOGS_SET_SOUND_H
+
+#include "got/views/dialogs/dialog.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class SetSound : public Dialog {
+public:
+	SetSound();
+	virtual ~SetSound() {
+	}
+
+	void selected() override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index 384629a2322..323f3a24f3d 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -25,6 +25,7 @@
 #include "got/views/main_menu.h"
 #include "got/views/story.h"
 #include "got/views/dialogs/options_menu.h"
+#include "got/views/dialogs/set_sound.h"
 
 namespace Got {
 namespace Views {
@@ -34,6 +35,7 @@ struct Views {
 	Story _story;
 
 	Dialogs::OptionsMenu _optionsMenu;
+	Dialogs::SetSound _setSound;
 };
 
 } // namespace Views


Commit: 249f1e6563bd5fc6d5b4259162486e91b7d56e1a
    https://github.com/scummvm/scummvm/commit/249f1e6563bd5fc6d5b4259162486e91b7d56e1a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added Quit Game dialog

Changed paths:
  A engines/got/views/dialogs/quit_game.cpp
  A engines/got/views/dialogs/quit_game.h
    engines/got/module.mk
    engines/got/views/dialogs/dialog.cpp
    engines/got/views/dialogs/dialog.h
    engines/got/views/dialogs/options_menu.cpp
    engines/got/views/dialogs/set_sound.cpp
    engines/got/views/views.h


diff --git a/engines/got/module.mk b/engines/got/module.mk
index 8885bd106ae..bc6bddaa8e4 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -21,6 +21,7 @@ MODULE_OBJS = \
 	views/story.o \
 	views/dialogs/dialog.o \
 	views/dialogs/options_menu.o \
+	views/dialogs/quit_game.o \
 	views/dialogs/set_sound.o
 
 # This module can be built as a plugin
diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
index 7d5b2d6c792..f115201d57c 100644
--- a/engines/got/views/dialogs/dialog.cpp
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -30,17 +30,9 @@ namespace Dialogs {
 const char *ON_OFF[] = { "On", "Off", nullptr };
 
 
-// Forms a class name for the view hierarchy from the dialog title
-static Common::String getDialogName(const char *title) {
-	Common::String result = title;
-	size_t idx;
-	while ((idx = result.findFirstOf(' ')) != Common::String::npos)
-		result.deleteChar(idx);
-	return result;
-}
-
-Dialog::Dialog(const char *title, const char *options[]) :
-		View(getDialogName(title)), _title(title) {
+Dialog::Dialog(const Common::String &name, const char *title,
+		const char *options[]) :
+		View(name), _title(title) {
 	// Load the options list into the string array
 	for (const char **option = options; *option; ++option)
 		_options.push_back(*option);
@@ -87,7 +79,7 @@ void Dialog::draw() {
 
 	// Write the title
 	s = getSurface(true);
-	int titleStart = (s.w - strlen(_title) * 8) / 2;
+	int titleStart = (s.w - _title.size() * 8) / 2;
 	s.print(Common::Point(titleStart, 4), _title, 54);
 
 	// Write the options
diff --git a/engines/got/views/dialogs/dialog.h b/engines/got/views/dialogs/dialog.h
index ef9628be59c..b78cf7cf5d9 100644
--- a/engines/got/views/dialogs/dialog.h
+++ b/engines/got/views/dialogs/dialog.h
@@ -34,7 +34,7 @@ extern const char *ON_OFF[];
 
 class Dialog : public View {
 private:
-	const char *_title;
+	Common::String _title;
 	Common::StringArray _options;
 	int _hammerFrame = 0;
 	int _smackCtr = 0;
@@ -48,7 +48,8 @@ protected:
 	virtual void selected() {}
 
 public:
-	Dialog(const char *title, const char *options[]);
+	Dialog(const Common::String &name, const char *title,
+		const char *options[]);
 	virtual ~Dialog() {
 	}
 
diff --git a/engines/got/views/dialogs/options_menu.cpp b/engines/got/views/dialogs/options_menu.cpp
index 1974493d3ec..46965ecb160 100644
--- a/engines/got/views/dialogs/options_menu.cpp
+++ b/engines/got/views/dialogs/options_menu.cpp
@@ -33,7 +33,7 @@ static const char *OPTIONS[] = {
 		"Die", "Turbo Mode", "Help", "Quit", nullptr
 };
 
-OptionsMenu::OptionsMenu() : Dialog("Options Menu", OPTIONS) {
+OptionsMenu::OptionsMenu() : Dialog("OptionsMenu", "Options Menu", OPTIONS) {
 }
 
 void OptionsMenu::selected() {
@@ -41,6 +41,9 @@ void OptionsMenu::selected() {
 	case 0:
 		replaceView("SetSound");
 		break;
+	case 7:
+		replaceView("QuitGame");
+		break;
 	default:
 		break;
 	}
diff --git a/engines/got/views/dialogs/quit_game.cpp b/engines/got/views/dialogs/quit_game.cpp
new file mode 100644
index 00000000000..4f8774ace1f
--- /dev/null
+++ b/engines/got/views/dialogs/quit_game.cpp
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/quit_game.h"
+#include "got/got.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+static const char *OPTIONS[] = {
+	"Continue Game", "Quit to Opening Screen", "Quit to DOS", nullptr
+};
+
+QuitGame::QuitGame() : Dialog("QuitGame", "Quit Game?", OPTIONS) {
+}
+
+void QuitGame::selected() {
+	switch (_selectedItem) {
+	case 0:
+		close();
+		break;
+	case 1:
+		replaceView("Title", true);
+		break;
+	case 2:
+		g_engine->quitGame();
+		break;
+	default:
+		break;
+	}
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/quit_game.h b/engines/got/views/dialogs/quit_game.h
new file mode 100644
index 00000000000..1687f958a19
--- /dev/null
+++ b/engines/got/views/dialogs/quit_game.h
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_QUIT_GAME_H
+#define GOT_VIEWS_DIALOGS_QUIT_GAME_H
+
+#include "got/views/dialogs/dialog.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class QuitGame : public Dialog {
+public:
+	QuitGame();
+	virtual ~QuitGame() {
+	}
+
+	void selected() override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/dialogs/set_sound.cpp b/engines/got/views/dialogs/set_sound.cpp
index 7b72f9158cd..08e8deb2bd1 100644
--- a/engines/got/views/dialogs/set_sound.cpp
+++ b/engines/got/views/dialogs/set_sound.cpp
@@ -29,7 +29,7 @@ static const char *OPTIONS[] = {
 	"None", "Digitized", nullptr
 };
 
-SetSound::SetSound() : Dialog("Set Sound", OPTIONS) {
+SetSound::SetSound() : Dialog("SetSound", "Set Sound", OPTIONS) {
 }
 
 void SetSound::selected() {
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index 323f3a24f3d..c74e028edbb 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -25,6 +25,7 @@
 #include "got/views/main_menu.h"
 #include "got/views/story.h"
 #include "got/views/dialogs/options_menu.h"
+#include "got/views/dialogs/quit_game.h"
 #include "got/views/dialogs/set_sound.h"
 
 namespace Got {
@@ -35,6 +36,7 @@ struct Views {
 	Story _story;
 
 	Dialogs::OptionsMenu _optionsMenu;
+	Dialogs::QuitGame _quitGame;
 	Dialogs::SetSound _setSound;
 };
 


Commit: 13c1eab13edfe4b7106c47da381c4d5d3b58ae7d
    https://github.com/scummvm/scummvm/commit/13c1eab13edfe4b7106c47da381c4d5d3b58ae7d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added main menu display

Changed paths:
  A engines/got/views/dialogs/main_menu.cpp
  A engines/got/views/dialogs/main_menu.h
  A engines/got/views/title.cpp
  A engines/got/views/title.h
  R engines/got/views/main_menu.cpp
  R engines/got/views/main_menu.h
    engines/got/events.cpp
    engines/got/module.mk
    engines/got/views/dialogs/dialog.cpp
    engines/got/views/views.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 49c3aedef9f..4322ac2c75b 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -47,7 +47,7 @@ void Events::runGame() {
 	if (saveSlot != -1)
 		g_engine->loadGameState(saveSlot);
 
-	addView("OptionsMenu");
+	addView("Title");
 
 	Common::Event e;
 	while (!_views.empty() && !shouldQuit()) {
diff --git a/engines/got/module.mk b/engines/got/module.mk
index bc6bddaa8e4..0b87da02fe3 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -16,10 +16,11 @@ MODULE_OBJS = \
 	utils/compression.o \
 	utils/file.o \
 	utils/res_archive.o \
-	views/main_menu.o \
 	views/view.o \
 	views/story.o \
+	views/title.o \
 	views/dialogs/dialog.o \
+	views/dialogs/main_menu.o \
 	views/dialogs/options_menu.o \
 	views/dialogs/quit_game.o \
 	views/dialogs/set_sound.o
diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
index f115201d57c..d3d2000aff4 100644
--- a/engines/got/views/dialogs/dialog.cpp
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -55,11 +55,12 @@ Dialog::Dialog(const Common::String &name, const char *title,
 }
 
 void Dialog::draw() {
-	GfxSurface s = getSurface();
-
-	// Draw four corners
+	// Clear the inner content first
+	GfxSurface s = getSurface(true);
 	s.clear(215);
 
+	// Draw four corners
+	s = getSurface();
 	s.blitFrom(_G(bgPics)[192], Common::Point(0, 0));
 	s.blitFrom(_G(bgPics)[193], Common::Point(_bounds.width() - 16, 0));
 	s.blitFrom(_G(bgPics)[194], Common::Point(0, _bounds.height() - 16));
diff --git a/engines/got/views/dialogs/main_menu.cpp b/engines/got/views/dialogs/main_menu.cpp
new file mode 100644
index 00000000000..ff4f2b593b5
--- /dev/null
+++ b/engines/got/views/dialogs/main_menu.cpp
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/main_menu.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+static const char *OPTIONS[] = {
+	"Play Game", "High Scores", "Credits", "Demo", "Quit", nullptr
+};
+
+MainMenu::MainMenu() : Dialog("MainMenu", "God of Thunder Menu", OPTIONS) {
+}
+
+void MainMenu::closed() {
+	_selectedItem = 4; // Quit game
+	selected();
+}
+
+void MainMenu::selected() {
+	// TODO
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/main_menu.h b/engines/got/views/dialogs/main_menu.h
new file mode 100644
index 00000000000..2b04a357552
--- /dev/null
+++ b/engines/got/views/dialogs/main_menu.h
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_MAIN_MENU_H
+#define GOT_VIEWS_DIALOGS_MAIN_MENU_H
+
+#include "got/views/dialogs/dialog.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class MainMenu : public Dialog {
+public:
+	MainMenu();
+	virtual ~MainMenu() {
+	}
+
+	void closed() override;
+	void selected() override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/main_menu.cpp b/engines/got/views/title.cpp
similarity index 71%
rename from engines/got/views/main_menu.cpp
rename to engines/got/views/title.cpp
index 43280b1438b..b77acbacf39 100644
--- a/engines/got/views/main_menu.cpp
+++ b/engines/got/views/title.cpp
@@ -19,31 +19,29 @@
  *
  */
 
-#include "got/views/main_menu.h"
-#include "got/gfx/palette.h"
+#include "got/views/title.h"
 #include "got/vars.h"
 
 namespace Got {
 namespace Views {
 
-bool MainMenu::msgFocus(const FocusMessage &msg) {
-	xsetpal(_G(gfx)[0]._data);
-	return true;
-}
+void Title::draw() {
+	GfxSurface s = getSurface();
 
-bool MainMenu::msgUnfocus(const UnfocusMessage &msg) {
-	return true;
+	for (int col = 0, xp = 0; col < 10; ++col, xp += 32) {
+		for (int yp = 0; yp < 240; yp += 32)
+			s.blitFrom(_G(gfx)[26], Common::Point(xp, yp));
+	}
 }
 
-bool MainMenu::msgKeypress(const KeypressMessage &msg) {
-	// Any keypress to close the view
-	close();
-	return true;
-}
+bool Title::tick() {
+	if (isFocused()) {
+		// When the title screen is shown, show the main menu
+		draw();
+		addView("MainMenu");
+	}
 
-void MainMenu::draw() {
-	//GfxSurface s = getSurface();
-	drawBackground();
+	return true;
 }
 
 } // namespace Views
diff --git a/engines/got/views/main_menu.h b/engines/got/views/title.h
similarity index 77%
rename from engines/got/views/main_menu.h
rename to engines/got/views/title.h
index cdad84ddde3..c74b93a8629 100644
--- a/engines/got/views/main_menu.h
+++ b/engines/got/views/title.h
@@ -19,8 +19,8 @@
  *
  */
 
-#ifndef GOT_VIEWS_MAIN_MENU_H
-#define GOT_VIEWS_MAIN_MENU_H
+#ifndef GOT_VIEWS_TITLE_H
+#define GOT_VIEWS_TITLE_H
 
 #include "graphics/managed_surface.h"
 #include "got/views/view.h"
@@ -28,15 +28,17 @@
 namespace Got {
 namespace Views {
 
-class MainMenu : public View {
+/**
+ * This view provides the green background for the
+ * main menu and other dialogs on the title screen
+ */
+class Title : public View {
 public:
-	MainMenu() : View("MainMenu") {}
-	virtual ~MainMenu() {}
+	Title() : View("Title") {}
+	virtual ~Title() {}
 
-	bool msgFocus(const FocusMessage &msg) override;
-	bool msgUnfocus(const UnfocusMessage &msg) override;
-	bool msgKeypress(const KeypressMessage &msg) override;
 	void draw() override;
+	bool tick() override;
 };
 
 } // namespace Views
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index c74e028edbb..e78832bcd30 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -22,8 +22,9 @@
 #ifndef GOT_VIEWS_H
 #define GOT_VIEWS_H
 
-#include "got/views/main_menu.h"
 #include "got/views/story.h"
+#include "got/views/title.h"
+#include "got/views/dialogs/main_menu.h"
 #include "got/views/dialogs/options_menu.h"
 #include "got/views/dialogs/quit_game.h"
 #include "got/views/dialogs/set_sound.h"
@@ -32,9 +33,10 @@ namespace Got {
 namespace Views {
 
 struct Views {
-	MainMenu _mainMenu;
 	Story _story;
+	Title _title;
 
+	Dialogs::MainMenu _mainMenu;
 	Dialogs::OptionsMenu _optionsMenu;
 	Dialogs::QuitGame _quitGame;
 	Dialogs::SetSound _setSound;


Commit: 6e285a10752b9af1ab26c19b9c7353efed482a09
    https://github.com/scummvm/scummvm/commit/6e285a10752b9af1ab26c19b9c7353efed482a09
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix graphics having two transparency colors

Changed paths:
    engines/got/gfx/gfx_pics.cpp


diff --git a/engines/got/gfx/gfx_pics.cpp b/engines/got/gfx/gfx_pics.cpp
index 375ef23839a..775784b89c0 100644
--- a/engines/got/gfx/gfx_pics.cpp
+++ b/engines/got/gfx/gfx_pics.cpp
@@ -28,14 +28,20 @@ namespace Got {
 namespace Gfx {
 
 void convertPaneDataToSurface(const byte *src, Graphics::ManagedSurface &surf) {
+	surf.setTransparentColor(0);
+
 	// It's split into 4 panes per 4 pixels, so we need
 	// to juggle the pixels into their correct order
 	for (int plane = 0; plane < 4; ++plane) {
 		for (int y = 0; y < surf.h; ++y) {
 			byte *dest = (byte *)surf.getBasePtr(plane, y);
 
-			for (int x = 0; x < (surf.w / 4); ++x, dest += 4)
-				*dest = *src++;
+			for (int x = 0; x < (surf.w / 4); ++x, dest += 4, ++src) {
+				// For some reason, both '0' and '15' are both hard-coded
+				// as transparent colors in the graphics drawing. Simplify
+				// this for ScummVM by changing all 15's to 0
+				*dest = (*src == 15) ? 0 : *src;
+			}
 		}
 	}
 }
@@ -58,7 +64,6 @@ void GfxPics::load(const Common::String &name, int blockSize) {
 
 		Graphics::ManagedSurface &s = (*this)[idx];
 		s.create(w, h);
-		s.setTransparentColor(15);
 
 		convertPaneDataToSurface(buff, s);
 	}


Commit: 3943bc17a8157dc2618d1ddab5c032e52106bca9
    https://github.com/scummvm/scummvm/commit/3943bc17a8157dc2618d1ddab5c032e52106bca9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Split Dialog into SelectOption class, added Quit dialog

Changed paths:
  A engines/got/views/dialogs/quit.cpp
  A engines/got/views/dialogs/quit.h
  A engines/got/views/dialogs/select_option.cpp
  A engines/got/views/dialogs/select_option.h
    engines/got/module.mk
    engines/got/views/dialogs/dialog.cpp
    engines/got/views/dialogs/dialog.h
    engines/got/views/dialogs/main_menu.cpp
    engines/got/views/dialogs/main_menu.h
    engines/got/views/dialogs/options_menu.cpp
    engines/got/views/dialogs/options_menu.h
    engines/got/views/dialogs/quit_game.cpp
    engines/got/views/dialogs/quit_game.h
    engines/got/views/dialogs/set_sound.cpp
    engines/got/views/dialogs/set_sound.h
    engines/got/views/views.h


diff --git a/engines/got/module.mk b/engines/got/module.mk
index 0b87da02fe3..3e41f018d3a 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -20,8 +20,10 @@ MODULE_OBJS = \
 	views/story.o \
 	views/title.o \
 	views/dialogs/dialog.o \
+	views/dialogs/select_option.o \
 	views/dialogs/main_menu.o \
 	views/dialogs/options_menu.o \
+	views/dialogs/quit.o \
 	views/dialogs/quit_game.o \
 	views/dialogs/set_sound.o
 
diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
index d3d2000aff4..4033c1ad739 100644
--- a/engines/got/views/dialogs/dialog.cpp
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -20,40 +20,12 @@
  */
 
 #include "got/views/dialogs/dialog.h"
-#include "got/metaengine.h"
 #include "got/vars.h"
 
 namespace Got {
 namespace Views {
 namespace Dialogs {
 
-const char *ON_OFF[] = { "On", "Off", nullptr };
-
-
-Dialog::Dialog(const Common::String &name, const char *title,
-		const char *options[]) :
-		View(name), _title(title) {
-	// Load the options list into the string array
-	for (const char **option = options; *option; ++option)
-		_options.push_back(*option);
-
-	// Calculate the bounds for the dialog
-	int w, h, x1, y1, x2, y2;
-	w = strlen(title);
-	if (w & 1)
-		w++;
-	w = (w * 8) + 32;
-
-	h = (_options.size() * 16) + 32;
-	x1 = (320 - w) / 2;
-	x2 = (x1 + w);
-	y1 = (192 - h) / 2;
-	y2 = (y1 + h);
-
-	_bounds = Common::Rect(x1 - 16, y1 - 16, x2 + 16, y2 + 16);
-	_bounds.setBorderSize(16);
-}
-
 void Dialog::draw() {
 	// Clear the inner content first
 	GfxSurface s = getSurface(true);
@@ -77,79 +49,6 @@ void Dialog::draw() {
 		s.blitFrom(_G(bgPics)[198], Common::Point(0, y));
 		s.blitFrom(_G(bgPics)[199], Common::Point(_bounds.width() - 16, y));
 	}
-
-	// Write the title
-	s = getSurface(true);
-	int titleStart = (s.w - _title.size() * 8) / 2;
-	s.print(Common::Point(titleStart, 4), _title, 54);
-
-	// Write the options
-	for (uint i = 0; i < _options.size(); ++i)
-		s.print(Common::Point(32, 28 + i * 16), _options[i], 14);
-
-	// Draw selection pointer
-	if (_smackCtr > 0) {
-		// Selecting an item
-		int xp = 8 + 2 * (_smackCtr < 3 ? (_smackCtr + 1) : (6 - _smackCtr));
-		s.blitFrom(_G(hampic)[0], Common::Point(xp, 24 + (_selectedItem * 16)));
-	} else {
-		// Normal animated cursor
-		s.blitFrom(_G(hampic)[_hammerFrame],
-			Common::Point(8, 24 + (_selectedItem * 16)));
-	}
-}
-
-bool Dialog::msgAction(const ActionMessage &msg) {
-	// Don't allow further actions if selection is in progress
-	if (_smackCtr != 0)
-		return true;
-
-	switch (msg._action) {
-	case KEYBIND_UP:
-		play_sound(WOOP,1);
-		if (--_selectedItem < 0)
-			_selectedItem = (int)_options.size() - 1;
-		break;
-
-	case KEYBIND_DOWN:
-		play_sound(WOOP, 1);
-		if (++_selectedItem >= (int)_options.size())
-			_selectedItem = 0;
-		break;
-
-	case KEYBIND_SELECT:
-	case KEYBIND_FIRE:
-	case KEYBIND_MAGIC:
-		_smackCtr = 1;
-		break;
-
-	case KEYBIND_ESCAPE:
-		closed();
-
-	default:
-		break;
-	}
-
-	return true;
-}
-
-bool Dialog::tick() {
-	if (++_hammerFrame == 4)
-		_hammerFrame = 0;
-
-	// Handle animation when an item is selected
-	if (_smackCtr != 0) {
-		++_smackCtr;
-		if (_smackCtr == 3)
-			play_sound(CLANG, 1);
-		if (_smackCtr == 6) {
-			_smackCtr = 0;
-			selected();
-		}	
-	}
-
-	redraw();
-	return true;
 }
 
 } // namespace Dialogs
diff --git a/engines/got/views/dialogs/dialog.h b/engines/got/views/dialogs/dialog.h
index b78cf7cf5d9..13fa46c44ea 100644
--- a/engines/got/views/dialogs/dialog.h
+++ b/engines/got/views/dialogs/dialog.h
@@ -29,38 +29,14 @@ namespace Got {
 namespace Views {
 namespace Dialogs {
 
-// On/Off is commonly used across multiple dialogs
-extern const char *ON_OFF[];
-
 class Dialog : public View {
-private:
-	Common::String _title;
-	Common::StringArray _options;
-	int _hammerFrame = 0;
-	int _smackCtr = 0;
-
-protected:
-	int _selectedItem = 0;
-
-	virtual void closed() {
-		close();
-	}
-	virtual void selected() {}
-
 public:
-	Dialog(const Common::String &name, const char *title,
-		const char *options[]);
+	Dialog(const Common::String &name) : View(name) {
+	}
 	virtual ~Dialog() {
 	}
 
-	bool msgFocus(const FocusMessage &msg) override {
-		_selectedItem = 0;
-		_smackCtr = 0;
-		return true;
-	}
-	bool msgAction(const ActionMessage &msg) override;
 	void draw() override;
-	bool tick() override;
 };
 
 } // namespace Dialogs
diff --git a/engines/got/views/dialogs/main_menu.cpp b/engines/got/views/dialogs/main_menu.cpp
index ff4f2b593b5..055297a9659 100644
--- a/engines/got/views/dialogs/main_menu.cpp
+++ b/engines/got/views/dialogs/main_menu.cpp
@@ -29,7 +29,7 @@ static const char *OPTIONS[] = {
 	"Play Game", "High Scores", "Credits", "Demo", "Quit", nullptr
 };
 
-MainMenu::MainMenu() : Dialog("MainMenu", "God of Thunder Menu", OPTIONS) {
+MainMenu::MainMenu() : SelectOption("MainMenu", "God of Thunder Menu", OPTIONS) {
 }
 
 void MainMenu::closed() {
@@ -38,7 +38,14 @@ void MainMenu::closed() {
 }
 
 void MainMenu::selected() {
-	// TODO
+	switch (_selectedItem) {
+	case 4:
+		replaceView("Quit");
+		break;
+
+	default:
+		break;
+	}
 }
 
 } // namespace Dialogs
diff --git a/engines/got/views/dialogs/main_menu.h b/engines/got/views/dialogs/main_menu.h
index 2b04a357552..ff236533c7c 100644
--- a/engines/got/views/dialogs/main_menu.h
+++ b/engines/got/views/dialogs/main_menu.h
@@ -22,13 +22,13 @@
 #ifndef GOT_VIEWS_DIALOGS_MAIN_MENU_H
 #define GOT_VIEWS_DIALOGS_MAIN_MENU_H
 
-#include "got/views/dialogs/dialog.h"
+#include "got/views/dialogs/select_option.h"
 
 namespace Got {
 namespace Views {
 namespace Dialogs {
 
-class MainMenu : public Dialog {
+class MainMenu : public SelectOption {
 public:
 	MainMenu();
 	virtual ~MainMenu() {
diff --git a/engines/got/views/dialogs/options_menu.cpp b/engines/got/views/dialogs/options_menu.cpp
index 46965ecb160..89d1bc3077a 100644
--- a/engines/got/views/dialogs/options_menu.cpp
+++ b/engines/got/views/dialogs/options_menu.cpp
@@ -33,7 +33,7 @@ static const char *OPTIONS[] = {
 		"Die", "Turbo Mode", "Help", "Quit", nullptr
 };
 
-OptionsMenu::OptionsMenu() : Dialog("OptionsMenu", "Options Menu", OPTIONS) {
+OptionsMenu::OptionsMenu() : SelectOption("OptionsMenu", "Options Menu", OPTIONS) {
 }
 
 void OptionsMenu::selected() {
diff --git a/engines/got/views/dialogs/options_menu.h b/engines/got/views/dialogs/options_menu.h
index fbe11e3bd04..ed3229a21b5 100644
--- a/engines/got/views/dialogs/options_menu.h
+++ b/engines/got/views/dialogs/options_menu.h
@@ -22,13 +22,13 @@
 #ifndef GOT_VIEWS_DIALOGS_OPTIONS_MENU_H
 #define GOT_VIEWS_DIALOGS_OPTIONS_MENU_H
 
-#include "got/views/dialogs/dialog.h"
+#include "got/views/dialogs/select_option.h"
 
 namespace Got {
 namespace Views {
 namespace Dialogs {
 
-class OptionsMenu : public Dialog {
+class OptionsMenu : public SelectOption {
 public:
 	OptionsMenu();
 	virtual ~OptionsMenu() {
diff --git a/engines/got/views/dialogs/quit.cpp b/engines/got/views/dialogs/quit.cpp
new file mode 100644
index 00000000000..72a863eea16
--- /dev/null
+++ b/engines/got/views/dialogs/quit.cpp
@@ -0,0 +1,47 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/quit.h"
+#include "got/got.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+Quit::Quit() : SelectOption("Quit", "Quit Game?", YES_NO) {
+}
+
+void Quit::selected() {
+	switch (_selectedItem) {
+	case 0:
+		g_engine->quitGame();
+		break;
+	case 1:
+		close();
+		break;
+	default:
+		break;
+	}
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/quit.h b/engines/got/views/dialogs/quit.h
new file mode 100644
index 00000000000..5ec3965a5e9
--- /dev/null
+++ b/engines/got/views/dialogs/quit.h
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_QUIT_H
+#define GOT_VIEWS_DIALOGS_QUIT_H
+
+#include "got/views/dialogs/select_option.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class Quit : public SelectOption {
+public:
+	Quit();
+	virtual ~Quit() {
+	}
+
+	void selected() override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/dialogs/quit_game.cpp b/engines/got/views/dialogs/quit_game.cpp
index 4f8774ace1f..2143a361f1f 100644
--- a/engines/got/views/dialogs/quit_game.cpp
+++ b/engines/got/views/dialogs/quit_game.cpp
@@ -30,7 +30,7 @@ static const char *OPTIONS[] = {
 	"Continue Game", "Quit to Opening Screen", "Quit to DOS", nullptr
 };
 
-QuitGame::QuitGame() : Dialog("QuitGame", "Quit Game?", OPTIONS) {
+QuitGame::QuitGame() : SelectOption("QuitGame", "Quit Game?", OPTIONS) {
 }
 
 void QuitGame::selected() {
diff --git a/engines/got/views/dialogs/quit_game.h b/engines/got/views/dialogs/quit_game.h
index 1687f958a19..9326f502afc 100644
--- a/engines/got/views/dialogs/quit_game.h
+++ b/engines/got/views/dialogs/quit_game.h
@@ -22,13 +22,13 @@
 #ifndef GOT_VIEWS_DIALOGS_QUIT_GAME_H
 #define GOT_VIEWS_DIALOGS_QUIT_GAME_H
 
-#include "got/views/dialogs/dialog.h"
+#include "got/views/dialogs/select_option.h"
 
 namespace Got {
 namespace Views {
 namespace Dialogs {
 
-class QuitGame : public Dialog {
+class QuitGame : public SelectOption {
 public:
 	QuitGame();
 	virtual ~QuitGame() {
diff --git a/engines/got/views/dialogs/select_option.cpp b/engines/got/views/dialogs/select_option.cpp
new file mode 100644
index 00000000000..f5a50936047
--- /dev/null
+++ b/engines/got/views/dialogs/select_option.cpp
@@ -0,0 +1,157 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/select_option.h"
+#include "got/metaengine.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+const char *ON_OFF[] = { "On", "Off", nullptr };
+const char *YES_NO[] = { "Yes", "No", nullptr };
+
+SelectOption::SelectOption(const Common::String &name, const char *title,
+		const char *options[]) :
+		Dialog(name), _title(title) {
+	// Load the options list into the string array
+	for (const char **option = options; *option; ++option)
+		_options.push_back(*option);
+
+	// Calculate the bounds for the dialog
+	int w, h, x1, y1, x2, y2;
+	w = strlen(title);
+	if (w & 1)
+		w++;
+	w = (w * 8) + 32;
+
+	h = (_options.size() * 16) + 32;
+	x1 = (320 - w) / 2;
+	x2 = (x1 + w);
+	y1 = (192 - h) / 2;
+	y2 = (y1 + h);
+
+	_bounds = Common::Rect(x1 - 16, y1 - 16, x2 + 16, y2 + 16);
+	_bounds.setBorderSize(16);
+}
+
+void SelectOption::draw() {
+	// Clear the inner content first
+	GfxSurface s = getSurface(true);
+	s.clear(215);
+
+	// Draw four corners
+	s = getSurface();
+	s.blitFrom(_G(bgPics)[192], Common::Point(0, 0));
+	s.blitFrom(_G(bgPics)[193], Common::Point(_bounds.width() - 16, 0));
+	s.blitFrom(_G(bgPics)[194], Common::Point(0, _bounds.height() - 16));
+	s.blitFrom(_G(bgPics)[195], Common::Point(_bounds.width() - 16, _bounds.height() - 16));
+
+	// Draw top/bottom horizontal lines
+	for (int x = 16; x < _bounds.width() - 16; x += 16) {
+		s.blitFrom(_G(bgPics)[196], Common::Point(x, 0));
+		s.blitFrom(_G(bgPics)[197], Common::Point(x, _bounds.height() - 16));
+	}
+
+	// Draw left/right vertical lines
+	for (int y = 16; y < _bounds.height() - 16; y += 16) {
+		s.blitFrom(_G(bgPics)[198], Common::Point(0, y));
+		s.blitFrom(_G(bgPics)[199], Common::Point(_bounds.width() - 16, y));
+	}
+
+	// Write the title
+	s = getSurface(true);
+	int titleStart = (s.w - _title.size() * 8) / 2;
+	s.print(Common::Point(titleStart, 4), _title, 54);
+
+	// Write the options
+	for (uint i = 0; i < _options.size(); ++i)
+		s.print(Common::Point(32, 28 + i * 16), _options[i], 14);
+
+	// Draw selection pointer
+	if (_smackCtr > 0) {
+		// Selecting an item
+		int xp = 8 + 2 * (_smackCtr < 3 ? (_smackCtr + 1) : (6 - _smackCtr));
+		s.blitFrom(_G(hampic)[0], Common::Point(xp, 24 + (_selectedItem * 16)));
+	} else {
+		// Normal animated cursor
+		s.blitFrom(_G(hampic)[_hammerFrame],
+			Common::Point(8, 24 + (_selectedItem * 16)));
+	}
+}
+
+bool SelectOption::msgAction(const ActionMessage &msg) {
+	// Don't allow further actions if selection is in progress
+	if (_smackCtr != 0)
+		return true;
+
+	switch (msg._action) {
+	case KEYBIND_UP:
+		play_sound(WOOP,1);
+		if (--_selectedItem < 0)
+			_selectedItem = (int)_options.size() - 1;
+		break;
+
+	case KEYBIND_DOWN:
+		play_sound(WOOP, 1);
+		if (++_selectedItem >= (int)_options.size())
+			_selectedItem = 0;
+		break;
+
+	case KEYBIND_SELECT:
+	case KEYBIND_FIRE:
+	case KEYBIND_MAGIC:
+		_smackCtr = 1;
+		break;
+
+	case KEYBIND_ESCAPE:
+		closed();
+
+	default:
+		break;
+	}
+
+	return true;
+}
+
+bool SelectOption::tick() {
+	if (++_hammerFrame == 4)
+		_hammerFrame = 0;
+
+	// Handle animation when an item is selected
+	if (_smackCtr != 0) {
+		++_smackCtr;
+		if (_smackCtr == 3)
+			play_sound(CLANG, 1);
+		if (_smackCtr == 6) {
+			_smackCtr = 0;
+			selected();
+		}	
+	}
+
+	redraw();
+	return true;
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/select_option.h b/engines/got/views/dialogs/select_option.h
new file mode 100644
index 00000000000..a4d2cbd1f94
--- /dev/null
+++ b/engines/got/views/dialogs/select_option.h
@@ -0,0 +1,72 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_SELECT_OPTION_H
+#define GOT_VIEWS_DIALOGS_SELECT_OPTION_H
+
+#include "graphics/managed_surface.h"
+#include "got/views/dialogs/dialog.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+// Commonly used options across multiple dialogs
+extern const char *ON_OFF[];
+extern const char *YES_NO[];
+
+
+class SelectOption : public Dialog {
+private:
+	Common::String _title;
+	Common::StringArray _options;
+	int _hammerFrame = 0;
+	int _smackCtr = 0;
+
+protected:
+	int _selectedItem = 0;
+
+	virtual void closed() {
+		close();
+	}
+	virtual void selected() {}
+
+public:
+	SelectOption(const Common::String &name, const char *title,
+		const char *options[]);
+	virtual ~SelectOption() {
+	}
+
+	bool msgFocus(const FocusMessage &msg) override {
+		_selectedItem = 0;
+		_smackCtr = 0;
+		return true;
+	}
+	bool msgAction(const ActionMessage &msg) override;
+	void draw() override;
+	bool tick() override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/dialogs/set_sound.cpp b/engines/got/views/dialogs/set_sound.cpp
index 08e8deb2bd1..6cb7f1bdf60 100644
--- a/engines/got/views/dialogs/set_sound.cpp
+++ b/engines/got/views/dialogs/set_sound.cpp
@@ -29,7 +29,7 @@ static const char *OPTIONS[] = {
 	"None", "Digitized", nullptr
 };
 
-SetSound::SetSound() : Dialog("SetSound", "Set Sound", OPTIONS) {
+SetSound::SetSound() : SelectOption("SetSound", "Set Sound", OPTIONS) {
 }
 
 void SetSound::selected() {
diff --git a/engines/got/views/dialogs/set_sound.h b/engines/got/views/dialogs/set_sound.h
index 4638e831aa1..9f5c6f5a75f 100644
--- a/engines/got/views/dialogs/set_sound.h
+++ b/engines/got/views/dialogs/set_sound.h
@@ -22,13 +22,13 @@
 #ifndef GOT_VIEWS_DIALOGS_SET_SOUND_H
 #define GOT_VIEWS_DIALOGS_SET_SOUND_H
 
-#include "got/views/dialogs/dialog.h"
+#include "got/views/dialogs/select_option.h"
 
 namespace Got {
 namespace Views {
 namespace Dialogs {
 
-class SetSound : public Dialog {
+class SetSound : public SelectOption {
 public:
 	SetSound();
 	virtual ~SetSound() {
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index e78832bcd30..8d43b46f6a5 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -26,6 +26,7 @@
 #include "got/views/title.h"
 #include "got/views/dialogs/main_menu.h"
 #include "got/views/dialogs/options_menu.h"
+#include "got/views/dialogs/quit.h"
 #include "got/views/dialogs/quit_game.h"
 #include "got/views/dialogs/set_sound.h"
 
@@ -38,6 +39,7 @@ struct Views {
 
 	Dialogs::MainMenu _mainMenu;
 	Dialogs::OptionsMenu _optionsMenu;
+	Dialogs::Quit _quit;
 	Dialogs::QuitGame _quitGame;
 	Dialogs::SetSound _setSound;
 };


Commit: e10cdaba2382991698b54398ed58aa50ccc0ccc7
    https://github.com/scummvm/scummvm/commit/e10cdaba2382991698b54398ed58aa50ccc0ccc7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Redraw underlying views when switching between dialogs

Changed paths:
    engines/got/events.cpp


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 4322ac2c75b..f54666a3236 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -115,7 +115,15 @@ void Events::replaceView(UIElement *ui, bool replaceAllViews) {
 		_views.pop();
 	}
 
+	// Redraw any prior views to erase the removed view
+	for (uint i = 0; i < _views.size(); ++i) {
+		_views[i]->redraw();
+		_views[i]->draw();
+	}
+
+	// Add the new view
 	_views.push(ui);
+
 	ui->redraw();
 	ui->msgFocus(FocusMessage(priorView));
 }


Commit: 26d38f6d0dab14220d09cb3097c0d947382c0a72
    https://github.com/scummvm/scummvm/commit/26d38f6d0dab14220d09cb3097c0d947382c0a72
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Quit dialog shows on top of title menu

Changed paths:
    engines/got/views/dialogs/main_menu.cpp
    engines/got/views/dialogs/quit.cpp


diff --git a/engines/got/views/dialogs/main_menu.cpp b/engines/got/views/dialogs/main_menu.cpp
index 055297a9659..d50a544b011 100644
--- a/engines/got/views/dialogs/main_menu.cpp
+++ b/engines/got/views/dialogs/main_menu.cpp
@@ -40,7 +40,7 @@ void MainMenu::closed() {
 void MainMenu::selected() {
 	switch (_selectedItem) {
 	case 4:
-		replaceView("Quit");
+		addView("Quit");
 		break;
 
 	default:
diff --git a/engines/got/views/dialogs/quit.cpp b/engines/got/views/dialogs/quit.cpp
index 72a863eea16..31f1bc3e1f5 100644
--- a/engines/got/views/dialogs/quit.cpp
+++ b/engines/got/views/dialogs/quit.cpp
@@ -35,7 +35,7 @@ void Quit::selected() {
 		g_engine->quitGame();
 		break;
 	case 1:
-		close();
+		replaceView("Title", true);
 		break;
 	default:
 		break;


Commit: 805e821b3394250b2722e5fc3b05d584cfb7e3e4
    https://github.com/scummvm/scummvm/commit/805e821b3394250b2722e5fc3b05d584cfb7e3e4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Skeleton Play Game dialog class

Changed paths:
  A engines/got/views/dialogs/high_scores.cpp
  A engines/got/views/dialogs/high_scores.h
  A engines/got/views/dialogs/play_game.cpp
  A engines/got/views/dialogs/play_game.h
    engines/got/module.mk
    engines/got/views/dialogs/select_option.cpp


diff --git a/engines/got/module.mk b/engines/got/module.mk
index 3e41f018d3a..76c8d5259db 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -23,6 +23,7 @@ MODULE_OBJS = \
 	views/dialogs/select_option.o \
 	views/dialogs/main_menu.o \
 	views/dialogs/options_menu.o \
+	views/dialogs/play_game.o \
 	views/dialogs/quit.o \
 	views/dialogs/quit_game.o \
 	views/dialogs/set_sound.o
diff --git a/engines/got/views/dialogs/high_scores.cpp b/engines/got/views/dialogs/high_scores.cpp
new file mode 100644
index 00000000000..4033c1ad739
--- /dev/null
+++ b/engines/got/views/dialogs/high_scores.cpp
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/dialog.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+void Dialog::draw() {
+	// Clear the inner content first
+	GfxSurface s = getSurface(true);
+	s.clear(215);
+
+	// Draw four corners
+	s = getSurface();
+	s.blitFrom(_G(bgPics)[192], Common::Point(0, 0));
+	s.blitFrom(_G(bgPics)[193], Common::Point(_bounds.width() - 16, 0));
+	s.blitFrom(_G(bgPics)[194], Common::Point(0, _bounds.height() - 16));
+	s.blitFrom(_G(bgPics)[195], Common::Point(_bounds.width() - 16, _bounds.height() - 16));
+
+	// Draw top/bottom horizontal lines
+	for (int x = 16; x < _bounds.width() - 16; x += 16) {
+		s.blitFrom(_G(bgPics)[196], Common::Point(x, 0));
+		s.blitFrom(_G(bgPics)[197], Common::Point(x, _bounds.height() - 16));
+	}
+
+	// Draw left/right vertical lines
+	for (int y = 16; y < _bounds.height() - 16; y += 16) {
+		s.blitFrom(_G(bgPics)[198], Common::Point(0, y));
+		s.blitFrom(_G(bgPics)[199], Common::Point(_bounds.width() - 16, y));
+	}
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/high_scores.h b/engines/got/views/dialogs/high_scores.h
new file mode 100644
index 00000000000..13fa46c44ea
--- /dev/null
+++ b/engines/got/views/dialogs/high_scores.h
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_DIALOG_H
+#define GOT_VIEWS_DIALOGS_DIALOG_H
+
+#include "graphics/managed_surface.h"
+#include "got/views/view.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class Dialog : public View {
+public:
+	Dialog(const Common::String &name) : View(name) {
+	}
+	virtual ~Dialog() {
+	}
+
+	void draw() override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/dialogs/play_game.cpp b/engines/got/views/dialogs/play_game.cpp
new file mode 100644
index 00000000000..65eb13f59c1
--- /dev/null
+++ b/engines/got/views/dialogs/play_game.cpp
@@ -0,0 +1,74 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/play_game.h"
+#include "got/metaengine.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+void PlayGame::draw() {
+	Dialog::draw();
+#ifdef TODO
+	// Write the title
+	GfxSurface s = getSurface(true);
+	int titleStart = (s.w - _title.size() * 8) / 2;
+
+	s.print(Common::Point(titleStart, 4), _title, 54);
+#endif
+}
+
+bool PlayGame::msgAction(const ActionMessage &msg) {
+	// Don't allow further actions if selection is in progress
+
+	switch (msg._action) {
+	case KEYBIND_UP:
+		play_sound(WOOP,1);		
+		break;
+
+	case KEYBIND_DOWN:
+		play_sound(WOOP, 1);
+		break;
+
+	case KEYBIND_SELECT:
+	case KEYBIND_FIRE:
+	case KEYBIND_MAGIC:
+		break;
+
+	case KEYBIND_ESCAPE:
+		close();
+
+	default:
+		break;
+	}
+
+	return true;
+}
+
+bool PlayGame::tick() {
+	return true;
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/play_game.h b/engines/got/views/dialogs/play_game.h
new file mode 100644
index 00000000000..2cea74e65c4
--- /dev/null
+++ b/engines/got/views/dialogs/play_game.h
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_PLAY_GAME_H
+#define GOT_VIEWS_DIALOGS_PLAY_GAME_H
+
+#include "graphics/managed_surface.h"
+#include "got/views/dialogs/dialog.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class PlayGame : public Dialog {
+public:
+	PlayGame() : Dialog("PlayGame") {
+	}
+	virtual ~PlayGame() {
+	}
+
+	bool msgFocus(const FocusMessage &msg) override;
+	bool msgAction(const ActionMessage &msg) override;
+	void draw() override;
+	bool tick() override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/dialogs/select_option.cpp b/engines/got/views/dialogs/select_option.cpp
index f5a50936047..28c1f5a927a 100644
--- a/engines/got/views/dialogs/select_option.cpp
+++ b/engines/got/views/dialogs/select_option.cpp
@@ -55,31 +55,10 @@ SelectOption::SelectOption(const Common::String &name, const char *title,
 }
 
 void SelectOption::draw() {
-	// Clear the inner content first
-	GfxSurface s = getSurface(true);
-	s.clear(215);
-
-	// Draw four corners
-	s = getSurface();
-	s.blitFrom(_G(bgPics)[192], Common::Point(0, 0));
-	s.blitFrom(_G(bgPics)[193], Common::Point(_bounds.width() - 16, 0));
-	s.blitFrom(_G(bgPics)[194], Common::Point(0, _bounds.height() - 16));
-	s.blitFrom(_G(bgPics)[195], Common::Point(_bounds.width() - 16, _bounds.height() - 16));
-
-	// Draw top/bottom horizontal lines
-	for (int x = 16; x < _bounds.width() - 16; x += 16) {
-		s.blitFrom(_G(bgPics)[196], Common::Point(x, 0));
-		s.blitFrom(_G(bgPics)[197], Common::Point(x, _bounds.height() - 16));
-	}
-
-	// Draw left/right vertical lines
-	for (int y = 16; y < _bounds.height() - 16; y += 16) {
-		s.blitFrom(_G(bgPics)[198], Common::Point(0, y));
-		s.blitFrom(_G(bgPics)[199], Common::Point(_bounds.width() - 16, y));
-	}
+	Dialog::draw();
 
 	// Write the title
-	s = getSurface(true);
+	GfxSurface s = getSurface(true);
 	int titleStart = (s.w - _title.size() * 8) / 2;
 	s.print(Common::Point(titleStart, 4), _title, 54);
 


Commit: f046dffb92b0a9c48fe0c96852d307079836bbe3
    https://github.com/scummvm/scummvm/commit/f046dffb92b0a9c48fe0c96852d307079836bbe3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Work on Story view display

Changed paths:
    engines/got/console.cpp
    engines/got/console.h
    engines/got/events.cpp
    engines/got/gfx/gfx_pics.cpp
    engines/got/gfx/gfx_pics.h
    engines/got/gfx/gfx_surface.cpp
    engines/got/gfx/gfx_surface.h
    engines/got/gfx/palette.cpp
    engines/got/gfx/palette.h
    engines/got/views/story.cpp
    engines/got/views/story.h


diff --git a/engines/got/console.cpp b/engines/got/console.cpp
index d3fbc3652bd..454169829be 100644
--- a/engines/got/console.cpp
+++ b/engines/got/console.cpp
@@ -20,19 +20,25 @@
  */
 
 #include "got/console.h"
+#include "got/events.h"
 
 namespace Got {
 
 Console::Console() : GUI::Debugger() {
-	registerCmd("test",   WRAP_METHOD(Console, Cmd_test));
+	registerCmd("view",   WRAP_METHOD(Console, cmdView));
 }
 
 Console::~Console() {
 }
 
-bool Console::Cmd_test(int argc, const char **argv) {
-	debugPrintf("Test\n");
-	return true;
+bool Console::cmdView(int argc, const char **argv) {
+	if (argc != 2) {
+		debugPrintf("view <view name>\n");
+		return true;
+	} else {
+		g_events->replaceView(argv[1], true);
+		return false;
+	}
 }
 
-} // End of namespace Got
+} // namespace Got
diff --git a/engines/got/console.h b/engines/got/console.h
index 057c0ed5535..bf86679a2c7 100644
--- a/engines/got/console.h
+++ b/engines/got/console.h
@@ -29,7 +29,8 @@ namespace Got {
 
 class Console : public GUI::Debugger {
 private:
-	bool Cmd_test(int argc, const char **argv);
+	bool cmdView(int argc, const char **argv);
+
 public:
 	Console();
 	~Console() override;
diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index f54666a3236..e1b5232d5de 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -201,7 +201,7 @@ void Events::addKeypress(const Common::KeyCode kc) {
 /*------------------------------------------------------------------------*/
 
 Bounds::Bounds(Common::Rect &innerBounds) :
-		_bounds(0, 0, 320, 200),
+		_bounds(0, 0, 320, 240),
 		_innerBounds(innerBounds),
 		left(_bounds.left), top(_bounds.top),
 		right(_bounds.right), bottom(_bounds.bottom) {
diff --git a/engines/got/gfx/gfx_pics.cpp b/engines/got/gfx/gfx_pics.cpp
index 775784b89c0..5783a40f559 100644
--- a/engines/got/gfx/gfx_pics.cpp
+++ b/engines/got/gfx/gfx_pics.cpp
@@ -52,7 +52,13 @@ void GfxPics::load(const Common::String &name, int blockSize) {
 
 	// Set up array of images
 	clear();
-	resize(f.size() / blockSize);
+	if (blockSize == -1) {
+		// Only a single image
+		resize(1);
+		blockSize = f.size();
+	} else {
+		resize(f.size() / blockSize);
+	}
 
 	byte *buff = new byte[blockSize];
 
@@ -60,7 +66,7 @@ void GfxPics::load(const Common::String &name, int blockSize) {
 		int w = f.readUint16LE() * 4;
 		int h = f.readUint16LE();
 		f.skip(2);	// Unused transparent color. It's always 15
-		f.read(buff, 16 * 16);
+		f.read(buff, blockSize - 6);
 
 		Graphics::ManagedSurface &s = (*this)[idx];
 		s.create(w, h);
diff --git a/engines/got/gfx/gfx_pics.h b/engines/got/gfx/gfx_pics.h
index 315265ee2e1..6c092f593ce 100644
--- a/engines/got/gfx/gfx_pics.h
+++ b/engines/got/gfx/gfx_pics.h
@@ -58,11 +58,11 @@ public:
 
 class Pics : public GfxPics {
 private:
-	const char *_resName;
+	Common::String _resName;
 	int _blockSize;
 
 public:
-	Pics(const char *resName, int blockSize) :
+	Pics(const Common::String &resName, int blockSize = -1) :
 		_resName(resName), _blockSize(blockSize) {}
 
 	void load() {
diff --git a/engines/got/gfx/gfx_surface.cpp b/engines/got/gfx/gfx_surface.cpp
index ed18242461a..38c64179aeb 100644
--- a/engines/got/gfx/gfx_surface.cpp
+++ b/engines/got/gfx/gfx_surface.cpp
@@ -30,5 +30,9 @@ void GfxSurface::print(const Common::Point &pos,
 	_G(font).drawString(this, pos, text, color);
 }
 
+void GfxSurface::printChar(uint32 chr, int x, int y, uint32 color) {
+	_G(font).drawChar(this, chr, x, y, color);
+}
+
 } // namespace Gfx
 } // namespace Got
diff --git a/engines/got/gfx/gfx_surface.h b/engines/got/gfx/gfx_surface.h
index 3192a7b09b6..dc436cb9a13 100644
--- a/engines/got/gfx/gfx_surface.h
+++ b/engines/got/gfx/gfx_surface.h
@@ -29,6 +29,8 @@ namespace Gfx {
 
 class GfxSurface : public Graphics::ManagedSurface {
 public:
+	GfxSurface() : Graphics::ManagedSurface() {
+	}
 	GfxSurface(Graphics::ManagedSurface &surf, const Common::Rect &bounds) :
 		Graphics::ManagedSurface(surf, bounds) {
 	}
@@ -37,6 +39,7 @@ public:
 	 * Write some text to the surface
 	 */
 	void print(const Common::Point &pos, const Common::String &text, int color);
+	void printChar(uint32 chr, int x, int y, uint32 color);
 };
 
 } // namespace Gfx
diff --git a/engines/got/gfx/palette.cpp b/engines/got/gfx/palette.cpp
index f22620c901c..49072c2fefa 100644
--- a/engines/got/gfx/palette.cpp
+++ b/engines/got/gfx/palette.cpp
@@ -62,9 +62,4 @@ void xgetpal(byte *pal, int num_colrs, int start_index) {
 	g_system->getPaletteManager()->grabPalette(pal, start_index, num_colrs);
 }
 
-void set_palette() {
-	const byte *pal = _G(pbuff);
-	g_system->getPaletteManager()->setPalette(pal, 0, PALETTE_COUNT);
-}
-
 } // namespace Got
diff --git a/engines/got/gfx/palette.h b/engines/got/gfx/palette.h
index 1030b1d62db..daed723970d 100644
--- a/engines/got/gfx/palette.h
+++ b/engines/got/gfx/palette.h
@@ -31,7 +31,6 @@ extern void set_screen_pal();
 extern void xsetpal(byte color, byte R, byte G, byte B);
 extern void xsetpal(const byte *pal);
 extern void xgetpal(byte *pal, int num_colrs, int start_index);
-extern void set_palette();
 
 } // namespace Got
 
diff --git a/engines/got/views/story.cpp b/engines/got/views/story.cpp
index 7576ea2e8d2..3357bb6ad9c 100644
--- a/engines/got/views/story.cpp
+++ b/engines/got/views/story.cpp
@@ -31,51 +31,92 @@ bool Story::msgFocus(const FocusMessage &msg) {
 	char back[4][262];
 
 	res_read("OPENSONG", _G(song));
-	res_read("STORY1", _G(tmp_buff));
+	res_read(Common::String::format("STORY%d", _G(area)), _G(tmp_buff));
 	res_read("OPENBACK", back);
 	res_read("STORYPIC", back);
-#if 0
-	// Load the images
-	_image1.create(320, 240);
-	_image2.create(320, 240);
 
-	for (int i = 0; i < 12; i++) {
-		Graphics::ManagedSurface *s = (i < 6) ? &_image1 : &_image2;
-		byte *destP = (byte *)s->getBasePtr(0, (i % 6) * 40);
-		res_read(Common::String::format("OPENP%d", i + 1), destP);
-	}
-#endif
 	res_read("STORYPAL", _G(pbuff));
 	_G(pbuff)[2] = 0;
 	_G(pbuff)[1] = 0;
 	_G(pbuff)[0] = 0;
-	set_palette();
+
+	for (int i = 0; i < 768; ++i)
+		_G(pbuff)[i] = (_G(pbuff)[i] * 255 + 31) / 63;
+	xsetpal(_G(pbuff));
+
+	// Create story image and load in it's fragments
+	_surface.create(320, 240 * 2);
+
+	for (int i = 0; i < 12; i++) {
+		Gfx::Pics pics(Common::String::format("OPENP%d", i + 1));
+		pics.load();
+
+		_surface.blitFrom(pics[0], Common::Point(0, i * 40));
+	}
+
+	// Set up the story text
+	int i = 0;
+	int x = 8, y = 2;
+	byte color = 72;
+	char s[21];
+
+	const char *p = (const char *)_G(tmp_buff);
+
+	while (i < 46) {
+		if (*p == '\n') {
+			x = 8;
+			y += 10;
+			i++;
+
+			if (i == 23) {
+				// Move to start of of "second page" of the surface
+				y = 240 + 2;
+			}
+		} else if (*p == '/' && *(p + 4) == '/') {
+			p++;
+			s[0] = *p++;
+			s[1] = *p++;
+			s[2] = *p++;
+			s[3] = 0;
+			color = atoi(s);
+		} else if (*p != '\r') {
+			_surface.printChar(*p, x - 1, y - 1, 255);
+			_surface.printChar(*p, x + 1, y + 1, 255);
+			_surface.printChar(*p, x - 1, y + 1, 255);
+			_surface.printChar(*p, x + 1, y - 1, 255);
+			_surface.printChar(*p, x, y - 1, 255);
+			_surface.printChar(*p, x, y + 1, 255);
+			_surface.printChar(*p, x - 1, y, 255);
+			_surface.printChar(*p, x + 1, y, 255);
+			_surface.printChar(*p, x, y, color);
+			x += 8;
+		}
+
+		p++;
+	}
 
 	return true;
 }
 
 bool Story::msgUnfocus(const UnfocusMessage &msg) {
-	_image1.clear();
-	_image2.clear();
+	_surface.clear();
 	return true;
 }
 
+void Story::draw() {
+	GfxSurface s = getSurface();
+
+	// Draw the currently visible part of the surface
+	s.blitFrom(_surface, Common::Rect(0, _yp, 320, _yp + 240),
+		Common::Point(0, 0));
+}
+
 bool Story::msgKeypress(const KeypressMessage &msg) {
 	// Any keypress to close the view
 	close();
 	return true;
 }
 
-void Story::draw() {
-	GfxSurface s = getSurface();
-
-	//s.blitFrom(_image1);
-	for (int i = 0; i < 10 * 10; ++i) {
-		Graphics::ManagedSurface & img = _G(bgPics)[i];
-		s.blitFrom(img, Common::Point((i % 10) * 32, (i / 10) * 16));
-	}
-}
-
 bool Story::tick() {
 	return true;
 }
diff --git a/engines/got/views/story.h b/engines/got/views/story.h
index bd1fc090af8..17c88b86fb0 100644
--- a/engines/got/views/story.h
+++ b/engines/got/views/story.h
@@ -30,7 +30,8 @@ namespace Views {
 
 class Story : public View {
 private:
-	Graphics::ManagedSurface _image1, _image2;
+	Gfx::GfxSurface _surface;
+	int _yp = 0;
 
 public:
 	Story() : View("Story") {}


Commit: 1b6c84c7058b4d766cef652ad205e2f9fd0ad4b2
    https://github.com/scummvm/scummvm/commit/1b6c84c7058b4d766cef652ad205e2f9fd0ad4b2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Placeholder music code

Changed paths:
    engines/got/console.cpp
    engines/got/console.h
    engines/got/sound.cpp
    engines/got/sound.h
    engines/got/utils/file.cpp
    engines/got/utils/file.h
    engines/got/vars.cpp
    engines/got/vars.h
    engines/got/views/story.cpp
    engines/got/views/view.cpp
    engines/got/views/view.h


diff --git a/engines/got/console.cpp b/engines/got/console.cpp
index 454169829be..f7e077b8d9d 100644
--- a/engines/got/console.cpp
+++ b/engines/got/console.cpp
@@ -21,11 +21,14 @@
 
 #include "got/console.h"
 #include "got/events.h"
+#include "got/vars.h"
 
 namespace Got {
 
 Console::Console() : GUI::Debugger() {
 	registerCmd("view",   WRAP_METHOD(Console, cmdView));
+	registerCmd("sound", WRAP_METHOD(Console, cmdSound));
+	registerCmd("music", WRAP_METHOD(Console, cmdMusic));
 }
 
 Console::~Console() {
@@ -41,4 +44,16 @@ bool Console::cmdView(int argc, const char **argv) {
 	}
 }
 
+bool Console::cmdSound(int argc, const char **argv) {
+	if (argc == 2)
+		_G(sound).play_sound(atoi(argv[1]), true);
+	return false;
+}
+
+bool Console::cmdMusic(int argc, const char **argv) {
+	if (argc == 2)
+		_G(sound).music_play(atoi(argv[1]), true);
+	return false;
+}
+
 } // namespace Got
diff --git a/engines/got/console.h b/engines/got/console.h
index bf86679a2c7..0cb9eb8bc24 100644
--- a/engines/got/console.h
+++ b/engines/got/console.h
@@ -30,6 +30,8 @@ namespace Got {
 class Console : public GUI::Debugger {
 private:
 	bool cmdView(int argc, const char **argv);
+	bool cmdSound(int argc, const char **argv);
+	bool cmdMusic(int argc, const char **argv);
 
 public:
 	Console();
diff --git a/engines/got/sound.cpp b/engines/got/sound.cpp
index 1924ac6ba02..d2fcf3d9f63 100644
--- a/engines/got/sound.cpp
+++ b/engines/got/sound.cpp
@@ -66,4 +66,138 @@ bool Sound::sound_playing() const {
 	return g_engine->_mixer->isSoundHandleActive(_soundHandle);
 }
 
+void Sound::music_play(const char *name, bool override) {
+	if (name != _currentMusic || override) {
+		g_engine->_mixer->stopHandle(_musicHandle);
+		_currentMusic = name;
+
+#ifdef TODO
+		// FIXME: Completely wrong. Don't know music format yet
+		// Open it up for access
+		File file(name);
+
+		Common::SeekableReadStream *f = file.readStream(file.size());
+		Audio::AudioStream *audioStream = Audio::makeRawStream(
+			f, 11025, 0, DisposeAfterUse::YES);
+		g_engine->_mixer->playStream(Audio::Mixer::kPlainSoundType,
+			&_musicHandle, audioStream);
+#else
+		warning("TODO: play_music %s", name);
+#endif
+	}
+}
+
+void Sound::music_pause() {
+	g_engine->_mixer->pauseHandle(_musicHandle, true);
+}
+
+void Sound::music_resume() {
+	g_engine->_mixer->pauseHandle(_musicHandle, false);
+}
+
+bool Sound::music_is_on() const {
+	return g_engine->_mixer->isSoundHandleActive(_musicHandle);
+}
+
+const char *Sound::getMusicName(int num) const {
+	const char *name = nullptr;
+
+	switch (_G(area)) {
+	case 1:
+		switch (num) {
+		case 0:
+			name = "SONG1";
+			break;
+		case 1:
+			name = "SONG2";
+			break;
+		case 2:
+			name = "SONG3";
+			break;
+		case 3:
+			name = "SONG4";
+			break;
+		case 4:
+			name = "WINSONG";
+			break;
+		case 5:
+			name = "BOSSSONG";
+			break;
+		default:
+			break;
+		}
+		break;
+
+	case 2:
+		switch (num) {
+		case 0:
+			name = "SONG21";
+			break;
+		case 1:
+			name = "SONG22";
+			break;
+		case 2:
+			name = "SONG23";
+			break;
+		case 3:
+			name = "SONG24";
+			break;
+		case 4:
+			name = "SONG35";
+			break;
+		case 5:
+			name = "SONG25";
+			break;
+		case 6:
+			name = "WINSONG";
+			break;
+		case 7:
+			name = "BOSSSONG";
+			break;
+		default:
+			break;
+		}
+		break;
+
+	case 3:
+		switch (num) {
+		case 0:
+			name = "SONG31";
+			break;
+		case 1:
+			name = "SONG32";
+			break;
+		case 2:
+			name = "SONG33";
+			break;
+		case 3:
+			name = "SONG34";
+			break;
+		case 4:
+			name = "SONG35";
+			break;
+		case 5:
+			name = "SONG36";
+			break;
+		case 6:
+			name = "WINSONG";
+			break;
+		case 7:
+			name = "BOSSSONG";
+			break;
+		default:
+			break;
+		}
+		break;
+
+	default:
+		break;
+	}
+
+	if (!name)
+		error("Invalid music");
+
+	return name;
+}
+
 } // namespace Got
diff --git a/engines/got/sound.h b/engines/got/sound.h
index bff846afdbb..0dce4f5691b 100644
--- a/engines/got/sound.h
+++ b/engines/got/sound.h
@@ -58,6 +58,11 @@ private:
 	Audio::SoundHandle _soundHandle;
 	int _currentPriority = 0;
 
+	const char *_currentMusic = nullptr;
+	Audio::SoundHandle _musicHandle;
+
+	const char *getMusicName(int num) const;
+
 public:
 	~Sound() {
 		delete[] _soundData;
@@ -65,8 +70,15 @@ public:
 	void load();
 
 	void play_sound(int index, bool priority_override);
-
 	bool sound_playing() const;
+
+	void music_play(int num, bool override) {
+		music_play(getMusicName(num), override);
+	}
+	void music_play(const char *name, bool override);
+	void music_pause();
+	void music_resume();
+	bool music_is_on() const;
 };
 
 } // namespace Got
diff --git a/engines/got/utils/file.cpp b/engines/got/utils/file.cpp
index d5d59458e53..dba31301012 100644
--- a/engines/got/utils/file.cpp
+++ b/engines/got/utils/file.cpp
@@ -247,29 +247,4 @@ long res_read(const Common::String &name, void *buff) {
 	}
 }
 
-bool load_music(int num) {
-	switch (num) {
-	case 0:
-		res_read("SONG1", _G(song));
-		break;
-	case 1:
-		res_read("SONG2", _G(song));
-		break;
-	case 2:
-		res_read("SONG3", _G(song));
-		break;
-	case 3:
-		res_read("SONG4", _G(song));
-		break;
-	case 4:
-		res_read("WINSONG", _G(song));
-		break;
-	case 5:
-		res_read("BOSSSONG", _G(song));
-		break;
-	}
-
-	return _G(song) != nullptr;
-}
-
 } // End of namespace Got
diff --git a/engines/got/utils/file.h b/engines/got/utils/file.h
index 38121322ca0..45022aae14b 100644
--- a/engines/got/utils/file.h
+++ b/engines/got/utils/file.h
@@ -43,7 +43,6 @@ extern void save_game();
 extern bool load_game(int flag);
 extern void help();
 extern long res_read(const Common::String &name, void *buff);
-extern bool load_music(int num);
 
 class File : public Common::File {
 public:
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 5956c4bfd75..333924f030b 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -84,8 +84,6 @@ void Vars::load() {
 	res_read("ODINPIC", _odin);
 
 	load_palette();
-
-	_song = new byte[20000];
 }
 
 Vars::~Vars() {
@@ -93,7 +91,6 @@ Vars::~Vars() {
 
 	delete[] _tmp_buff;
 	delete[] _mask_buff;
-	delete[] _song;
 }
 
 } // namespace Got
diff --git a/engines/got/vars.h b/engines/got/vars.h
index d774e6bb924..3d789d7efea 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -80,7 +80,6 @@ public:
 	int8 _thor_icon1 = 0, _thor_icon2 = 0, _thor_icon3 = 0,
 		_thor_icon4 = 0;
 	int8 _level_type = 0;
-	byte *_song = nullptr;
 	int8 _music_current = 0;
 	int8 _boss_loaded = 0;
 	int8 _apple_drop = 0;
diff --git a/engines/got/views/story.cpp b/engines/got/views/story.cpp
index 3357bb6ad9c..625e55cb378 100644
--- a/engines/got/views/story.cpp
+++ b/engines/got/views/story.cpp
@@ -30,7 +30,6 @@ namespace Views {
 bool Story::msgFocus(const FocusMessage &msg) {
 	char back[4][262];
 
-	res_read("OPENSONG", _G(song));
 	res_read(Common::String::format("STORY%d", _G(area)), _G(tmp_buff));
 	res_read("OPENBACK", back);
 	res_read("STORYPIC", back);
@@ -95,11 +94,15 @@ bool Story::msgFocus(const FocusMessage &msg) {
 		p++;
 	}
 
+	music_play("OPENSONG", 1);
+
 	return true;
 }
 
 bool Story::msgUnfocus(const UnfocusMessage &msg) {
 	_surface.clear();
+	music_pause();
+
 	return true;
 }
 
diff --git a/engines/got/views/view.cpp b/engines/got/views/view.cpp
index ab03c8a1566..0cf8fe8e134 100644
--- a/engines/got/views/view.cpp
+++ b/engines/got/views/view.cpp
@@ -80,19 +80,28 @@ bool View::msgMouseUp(const MouseUpMessage &msg) {
 	return child ? child->send(msg) : false;
 }
 
-void View::drawBackground() {
-	GfxSurface s = getSurface();
+void View::play_sound(int index, bool priority_override) {
+	_G(sound).play_sound(index, priority_override);
+}
 
-	for (int col = 0, xp = 0; col < 10; ++col, xp += 32) {
-		for (int yp = 0; yp < 192; yp += 32)
-			s.blitFrom(_G(gfx)[26], Common::Point(xp, yp));
+void View::music_play(int num, bool override) {
+	_G(sound).music_play(num, override);
+}
 
-		s.blitFrom(_G(gfx)[27], Common::Point(xp, 192));
-	}
+void View::music_play(const char *name, bool override) {
+	_G(sound).music_play(name, override);
 }
 
-void View::play_sound(int index, bool priority_override) {
-	_G(sound).play_sound(index, priority_override);
+void View::music_pause() {
+	_G(sound).music_pause();
+}
+
+void View::music_resume() {
+	_G(sound).music_resume();
+}
+
+bool View::music_is_on() const {
+	return _G(sound).music_is_on();
 }
 
 } // namespace Views
diff --git a/engines/got/views/view.h b/engines/got/views/view.h
index 8fd86c77302..c570574799d 100644
--- a/engines/got/views/view.h
+++ b/engines/got/views/view.h
@@ -53,7 +53,13 @@ private:
 	UIElement *getElementAtPos(const Common::Point &pos) const;
 
 protected:
-	void drawBackground();
+	void play_sound(int index, bool priority_override);
+
+	void music_play(int num, bool override);
+	void music_play(const char *name, bool override);
+	void music_pause();
+	void music_resume();
+	bool music_is_on() const;
 
 public:
 	View(const Common::String &name, UIElement *uiParent) :
@@ -70,8 +76,6 @@ public:
 	bool msgMouseMove(const MouseMoveMessage &msg) override;
 	bool msgMouseDown(const MouseDownMessage &msg) override;
 	bool msgMouseUp(const MouseUpMessage &msg) override;
-
-	void play_sound(int index, bool priority_override);
 };
 
 } // namespace Views


Commit: 185b57eb781356bdcfbd3efb7e57792ba5e44eb9
    https://github.com/scummvm/scummvm/commit/185b57eb781356bdcfbd3efb7e57792ba5e44eb9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Add icons to story view

Changed paths:
    engines/got/gfx/gfx_pics.h
    engines/got/vars.cpp
    engines/got/views/story.cpp


diff --git a/engines/got/gfx/gfx_pics.h b/engines/got/gfx/gfx_pics.h
index 6c092f593ce..bdb7f01bd5f 100644
--- a/engines/got/gfx/gfx_pics.h
+++ b/engines/got/gfx/gfx_pics.h
@@ -62,8 +62,12 @@ private:
 	int _blockSize;
 
 public:
-	Pics(const Common::String &resName, int blockSize = -1) :
-		_resName(resName), _blockSize(blockSize) {}
+	Pics(const Common::String &resName, int blockSize = -1,
+			bool immediateLoad = true) :
+			_resName(resName), _blockSize(blockSize) {
+		if (immediateLoad)
+			load();
+	}
 
 	void load() {
 		GfxPics::load(_resName, _blockSize);
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 333924f030b..c4a57ea495c 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -30,7 +30,7 @@ namespace Got {
 
 Vars *g_vars;
 
-Vars::Vars() : _hampic("HAMPIC", 262) {
+Vars::Vars() : _hampic("HAMPIC", 262, false) {
 	g_vars = this;
 }
 
diff --git a/engines/got/views/story.cpp b/engines/got/views/story.cpp
index 625e55cb378..9616e1b7790 100644
--- a/engines/got/views/story.cpp
+++ b/engines/got/views/story.cpp
@@ -94,6 +94,16 @@ bool Story::msgFocus(const FocusMessage &msg) {
 		p++;
 	}
 
+	// Final two glyphs
+	Gfx::Pics bg1("STORYPIC");
+	_surface.blitFrom(bg1[0], Common::Point(146, 64));
+
+	if (_G(area) == 1) {
+		Gfx::Pics bg2("OPENBACK");
+		_surface.blitFrom(bg2[0], Common::Point(24, 88 + 240));
+	}
+
+	// Play the opening music
 	music_play("OPENSONG", 1);
 
 	return true;


Commit: 7261ea75d14de2e97ebe451ea7ecdfa47ef4f3cb
    https://github.com/scummvm/scummvm/commit/7261ea75d14de2e97ebe451ea7ecdfa47ef4f3cb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Vertical scrolling for Story view

Changed paths:
    engines/got/views/story.cpp
    engines/got/views/story.h


diff --git a/engines/got/views/story.cpp b/engines/got/views/story.cpp
index 9616e1b7790..c13f8fa6b15 100644
--- a/engines/got/views/story.cpp
+++ b/engines/got/views/story.cpp
@@ -22,6 +22,7 @@
 #include "got/views/story.h"
 #include "got/gfx/palette.h"
 #include "got/utils/file.h"
+#include "got/metaengine.h"
 #include "got/vars.h"
 
 namespace Got {
@@ -95,13 +96,10 @@ bool Story::msgFocus(const FocusMessage &msg) {
 	}
 
 	// Final two glyphs
-	Gfx::Pics bg1("STORYPIC");
-	_surface.blitFrom(bg1[0], Common::Point(146, 64));
-
-	if (_G(area) == 1) {
-		Gfx::Pics bg2("OPENBACK");
-		_surface.blitFrom(bg2[0], Common::Point(24, 88 + 240));
-	}
+	Gfx::Pics glyphs("STORYPIC", 262);
+	_surface.blitFrom(glyphs[0], Common::Point(146, 64));
+	if (_G(area) == 1)
+		_surface.blitFrom(glyphs[1], Common::Point(24, 88 + 240));
 
 	// Play the opening music
 	music_play("OPENSONG", 1);
@@ -124,15 +122,41 @@ void Story::draw() {
 		Common::Point(0, 0));
 }
 
+bool Story::msgAction(const ActionMessage &msg) {
+	if (msg._action == KEYBIND_ESCAPE || _yp == 240)
+		done();
+	else if (!_scrolling)
+		_scrolling = true;
+	else
+		_yp = 240;
+
+	return true;
+}
+
 bool Story::msgKeypress(const KeypressMessage &msg) {
-	// Any keypress to close the view
-	close();
+	if (_yp == 240)
+		done();
+	else if (!_scrolling)
+		_scrolling = true;
+	else
+		_yp = 240;
+
 	return true;
 }
 
 bool Story::tick() {
+	if (_scrolling && _yp < 240) {
+		_yp += 4;
+		redraw();
+	}
+
 	return true;
 }
 
+void Story::done() {
+	warning("TODO: Story::done");
+	load_palette();
+}
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/story.h b/engines/got/views/story.h
index 17c88b86fb0..5bfc4a95a15 100644
--- a/engines/got/views/story.h
+++ b/engines/got/views/story.h
@@ -32,6 +32,9 @@ class Story : public View {
 private:
 	Gfx::GfxSurface _surface;
 	int _yp = 0;
+	bool _scrolling = false;
+
+	void done();
 
 public:
 	Story() : View("Story") {}
@@ -39,6 +42,7 @@ public:
 
 	bool msgFocus(const FocusMessage &msg) override;
 	bool msgUnfocus(const UnfocusMessage &msg) override;
+	bool msgAction(const ActionMessage &msg) override;
 	bool msgKeypress(const KeypressMessage &msg) override;
 	void draw() override;
 	bool tick() override;


Commit: 6658a35c0244e962b00b360361255b7c05be148a
    https://github.com/scummvm/scummvm/commit/6658a35c0244e962b00b360361255b7c05be148a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added music_stop method

Changed paths:
    engines/got/sound.cpp
    engines/got/sound.h
    engines/got/views/story.cpp
    engines/got/views/view.cpp
    engines/got/views/view.h


diff --git a/engines/got/sound.cpp b/engines/got/sound.cpp
index d2fcf3d9f63..62bf66f6e4e 100644
--- a/engines/got/sound.cpp
+++ b/engines/got/sound.cpp
@@ -95,6 +95,11 @@ void Sound::music_resume() {
 	g_engine->_mixer->pauseHandle(_musicHandle, false);
 }
 
+void Sound::music_stop() {
+	music_pause();
+	_currentMusic = nullptr;
+}
+
 bool Sound::music_is_on() const {
 	return g_engine->_mixer->isSoundHandleActive(_musicHandle);
 }
diff --git a/engines/got/sound.h b/engines/got/sound.h
index 0dce4f5691b..0de08a95a26 100644
--- a/engines/got/sound.h
+++ b/engines/got/sound.h
@@ -78,6 +78,7 @@ public:
 	void music_play(const char *name, bool override);
 	void music_pause();
 	void music_resume();
+	void music_stop();
 	bool music_is_on() const;
 };
 
diff --git a/engines/got/views/story.cpp b/engines/got/views/story.cpp
index c13f8fa6b15..54daa062e86 100644
--- a/engines/got/views/story.cpp
+++ b/engines/got/views/story.cpp
@@ -155,6 +155,7 @@ bool Story::tick() {
 
 void Story::done() {
 	warning("TODO: Story::done");
+	music_stop();
 	load_palette();
 }
 
diff --git a/engines/got/views/view.cpp b/engines/got/views/view.cpp
index 0cf8fe8e134..f97e53c6f9e 100644
--- a/engines/got/views/view.cpp
+++ b/engines/got/views/view.cpp
@@ -100,6 +100,10 @@ void View::music_resume() {
 	_G(sound).music_resume();
 }
 
+void View::music_stop() {
+	_G(sound).music_stop();
+}
+
 bool View::music_is_on() const {
 	return _G(sound).music_is_on();
 }
diff --git a/engines/got/views/view.h b/engines/got/views/view.h
index c570574799d..8e24a821e92 100644
--- a/engines/got/views/view.h
+++ b/engines/got/views/view.h
@@ -59,6 +59,7 @@ protected:
 	void music_play(const char *name, bool override);
 	void music_pause();
 	void music_resume();
+	void music_stop();
 	bool music_is_on() const;
 
 public:


Commit: acbe124d238686032380ab067478c75b67262279
    https://github.com/scummvm/scummvm/commit/acbe124d238686032380ab067478c75b67262279
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Working on fading

Changed paths:
    engines/got/events.cpp
    engines/got/events.h
    engines/got/gfx/palette.cpp
    engines/got/gfx/palette.h
    engines/got/vars.cpp
    engines/got/views/dialogs/main_menu.cpp
    engines/got/views/story.cpp
    engines/got/views/view.cpp
    engines/got/views/view.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index e1b5232d5de..596df9a8660 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -23,6 +23,7 @@
 #include "graphics/screen.h"
 #include "got/events.h"
 #include "got/got.h"
+#include "got/gfx/palette.h"
 #include "got/views/views.h"
 
 namespace Got {
@@ -103,10 +104,13 @@ void Events::processEvent(Common::Event &ev) {
 	}
 }
 
-void Events::replaceView(UIElement *ui, bool replaceAllViews) {
+void Events::replaceView(UIElement *ui, bool replaceAllViews, bool fadeOutIn) {
 	assert(ui);
 	UIElement *priorView = focusedView();
 
+	if (fadeOutIn)
+		Gfx::fade_out();
+
 	if (replaceAllViews) {
 		clearViews();
 
@@ -126,10 +130,14 @@ void Events::replaceView(UIElement *ui, bool replaceAllViews) {
 
 	ui->redraw();
 	ui->msgFocus(FocusMessage(priorView));
+	ui->draw();
+
+	if (fadeOutIn)
+		Gfx::fade_in();
 }
 
-void Events::replaceView(const Common::String &name, bool replaceAllViews) {
-	replaceView(findView(name));
+void Events::replaceView(const Common::String &name, bool replaceAllViews, bool fadeOutIn) {
+	replaceView(findView(name), replaceAllViews, fadeOutIn);
 }
 
 void Events::addView(UIElement *ui) {
@@ -305,12 +313,12 @@ UIElement *UIElement::findView(const Common::String &name) {
 	return nullptr;
 }
 
-void UIElement::replaceView(UIElement *ui, bool replaceAllViews) {
-	g_events->replaceView(ui, replaceAllViews);
+void UIElement::replaceView(UIElement *ui, bool replaceAllViews, bool fadeOutIn) {
+	g_events->replaceView(ui, replaceAllViews, fadeOutIn);
 }
 
-void UIElement::replaceView(const Common::String &name, bool replaceAllViews) {
-	g_events->replaceView(name, replaceAllViews);
+void UIElement::replaceView(const Common::String &name, bool replaceAllViews, bool fadeOutIn) {
+	g_events->replaceView(name, replaceAllViews, fadeOutIn);
 }
 
 void UIElement::addView(UIElement *ui) {
diff --git a/engines/got/events.h b/engines/got/events.h
index f280de28aed..ca0f459f2c8 100644
--- a/engines/got/events.h
+++ b/engines/got/events.h
@@ -150,8 +150,8 @@ public:
 	/**
 	 * Sets the focus to a new view
 	 */
-	void replaceView(UIElement *ui, bool replaceAllViews = false);
-	void replaceView(const Common::String &name, bool replaceAllViews = false);
+	void replaceView(UIElement *ui, bool replaceAllViews = false, bool fadeOutIn = false);
+	void replaceView(const Common::String &name, bool replaceAllViews = false, bool fadeOutIn = false);
 
 	/**
 	 * Adds a focused view to the view stack without replacing current one
@@ -298,8 +298,8 @@ public:
 	/**
 	 * Sets the focus to a new view
 	 */
-	void replaceView(UIElement *ui, bool replaceAllViews = false);
-	void replaceView(const Common::String &name, bool replaceAllViews = false);
+	void replaceView(UIElement *ui, bool replaceAllViews = false, bool fadeOutIn = false);
+	void replaceView(const Common::String &name, bool replaceAllViews = false, bool fadeOutIn = false);
 
 	/**
 	 * Adds a focused view to the view stack without replacing current one
diff --git a/engines/got/gfx/palette.cpp b/engines/got/gfx/palette.cpp
index 49072c2fefa..c94bdd501ab 100644
--- a/engines/got/gfx/palette.cpp
+++ b/engines/got/gfx/palette.cpp
@@ -20,20 +20,23 @@
  */
 
 #include "common/system.h"
+#include "common/events.h"
 #include "graphics/paletteman.h"
 #include "got/gfx/palette.h"
 #include "got/utils/file.h"
+#include "got/got.h"
 #include "got/vars.h"
 
 namespace Got {
+namespace Gfx {
 
-void load_palette() {
-	byte buff[256 * 3];
+static byte saved_palette[PALETTE_SIZE];
 
-	if (res_read("PALETTE", buff) < 0)
+void load_palette() {
+	if (res_read("PALETTE", saved_palette) < 0)
 		error("Cannot Read PALETTE");
 
-	g_system->getPaletteManager()->setPalette(buff, 0, 256);
+	g_system->getPaletteManager()->setPalette(saved_palette, 0, 256);
 
 	set_screen_pal();
 }
@@ -62,4 +65,74 @@ void xgetpal(byte *pal, int num_colrs, int start_index) {
 	g_system->getPaletteManager()->grabPalette(pal, start_index, num_colrs);
 }
 
+void fade_out() {
+	const int FADE_AMOUNT = 2;
+	byte tempPal[PALETTE_SIZE];
+	bool repeatFlag;
+	byte *srcP;
+	int count;
+	Common::Event evt;
+
+	xgetpal(saved_palette, PALETTE_COUNT, 0);
+	Common::copy(saved_palette, saved_palette + PALETTE_SIZE, tempPal);
+
+	do {
+		repeatFlag = false;
+		for (srcP = &tempPal[0], count = 0; count < PALETTE_SIZE; ++count, ++srcP) {
+			int v = *srcP;
+			if (v) {
+				repeatFlag = true;
+				*srcP = MAX((int)*srcP - FADE_AMOUNT, 0);
+			}
+		}
+
+		xsetpal(tempPal);
+
+		while (g_system->getEventManager()->pollEvent(evt)) {
+			if (evt.type == Common::EVENT_QUIT)
+				return;
+		}
+
+		g_events->getScreen()->update();
+		g_system->delayMillis(10);
+
+	} while (repeatFlag);
+}
+
+void fade_in() {
+	const int FADE_AMOUNT = 10;
+	byte tempPal[PALETTE_SIZE];
+	bool repeatFlag;
+	byte *srcP, *destP;
+	int count;
+	Common::Event evt;
+
+	Common::fill(tempPal, tempPal + PALETTE_SIZE, 0);
+
+	do {
+		repeatFlag = false;
+		for (srcP = &tempPal[0], destP = &saved_palette[0], count = 0;
+			count < PALETTE_SIZE; ++count, ++srcP, ++destP) {
+			int v = *srcP;
+
+			if (v != *destP) {
+				repeatFlag = true;
+				*srcP = MIN((int)*srcP + FADE_AMOUNT, (int)*destP);
+			}
+		}
+
+		xsetpal(tempPal);
+
+		while (g_system->getEventManager()->pollEvent(evt)) {
+			if (evt.type == Common::EVENT_QUIT)
+				return;
+		}
+
+		g_events->getScreen()->update();
+		g_system->delayMillis(10);
+
+	} while (repeatFlag);
+}
+
+} // namespace Gfx
 } // namespace Got
diff --git a/engines/got/gfx/palette.h b/engines/got/gfx/palette.h
index daed723970d..ff3c9d195ee 100644
--- a/engines/got/gfx/palette.h
+++ b/engines/got/gfx/palette.h
@@ -25,13 +25,17 @@
 #include "graphics/paletteman.h"
 
 namespace Got {
+namespace Gfx {
 
 extern void load_palette();
 extern void set_screen_pal();
 extern void xsetpal(byte color, byte R, byte G, byte B);
 extern void xsetpal(const byte *pal);
 extern void xgetpal(byte *pal, int num_colrs, int start_index);
+extern void fade_out();
+extern void fade_in();
 
+} // namespace Gfx
 } // namespace Got
 
 #endif
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index c4a57ea495c..4bef83164af 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -83,7 +83,7 @@ void Vars::load() {
 	res_read("DEMO", _demo_key);
 	res_read("ODINPIC", _odin);
 
-	load_palette();
+	Gfx::load_palette();
 }
 
 Vars::~Vars() {
diff --git a/engines/got/views/dialogs/main_menu.cpp b/engines/got/views/dialogs/main_menu.cpp
index d50a544b011..01ad211ce31 100644
--- a/engines/got/views/dialogs/main_menu.cpp
+++ b/engines/got/views/dialogs/main_menu.cpp
@@ -39,6 +39,11 @@ void MainMenu::closed() {
 
 void MainMenu::selected() {
 	switch (_selectedItem) {
+	case 0:
+		// FIXME: Dummy test of fading code
+		replaceView("QuitGame", true, true);
+		break;
+
 	case 4:
 		addView("Quit");
 		break;
diff --git a/engines/got/views/story.cpp b/engines/got/views/story.cpp
index 54daa062e86..2beb76f4d57 100644
--- a/engines/got/views/story.cpp
+++ b/engines/got/views/story.cpp
@@ -42,7 +42,7 @@ bool Story::msgFocus(const FocusMessage &msg) {
 
 	for (int i = 0; i < 768; ++i)
 		_G(pbuff)[i] = (_G(pbuff)[i] * 255 + 31) / 63;
-	xsetpal(_G(pbuff));
+	Gfx::xsetpal(_G(pbuff));
 
 	// Create story image and load in it's fragments
 	_surface.create(320, 240 * 2);
@@ -156,7 +156,7 @@ bool Story::tick() {
 void Story::done() {
 	warning("TODO: Story::done");
 	music_stop();
-	load_palette();
+	Gfx::load_palette();
 }
 
 } // namespace Views
diff --git a/engines/got/views/view.cpp b/engines/got/views/view.cpp
index f97e53c6f9e..2ba02700de8 100644
--- a/engines/got/views/view.cpp
+++ b/engines/got/views/view.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "got/views/view.h"
+#include "got/gfx/palette.h"
 #include "got/vars.h"
 
 namespace Got {
@@ -108,5 +109,13 @@ bool View::music_is_on() const {
 	return _G(sound).music_is_on();
 }
 
+void View::fadeOut() {
+	Gfx::fade_out();
+}
+
+void View::fadeIn() {
+	Gfx::fade_in();
+}
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/view.h b/engines/got/views/view.h
index 8e24a821e92..abb61705c31 100644
--- a/engines/got/views/view.h
+++ b/engines/got/views/view.h
@@ -62,6 +62,9 @@ protected:
 	void music_stop();
 	bool music_is_on() const;
 
+	void fadeOut();
+	void fadeIn();
+
 public:
 	View(const Common::String &name, UIElement *uiParent) :
 		UIElement(name, uiParent) {


Commit: ae0274bf30f8c6ebefc6267cd14cdd8f31ca35de
    https://github.com/scummvm/scummvm/commit/ae0274bf30f8c6ebefc6267cd14cdd8f31ca35de
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Make screen fades faster

Changed paths:
    engines/got/gfx/palette.cpp


diff --git a/engines/got/gfx/palette.cpp b/engines/got/gfx/palette.cpp
index c94bdd501ab..840caaec030 100644
--- a/engines/got/gfx/palette.cpp
+++ b/engines/got/gfx/palette.cpp
@@ -30,6 +30,8 @@
 namespace Got {
 namespace Gfx {
 
+#define FADE_STEPS 10
+
 static byte saved_palette[PALETTE_SIZE];
 
 void load_palette() {
@@ -66,28 +68,25 @@ void xgetpal(byte *pal, int num_colrs, int start_index) {
 }
 
 void fade_out() {
-	const int FADE_AMOUNT = 2;
 	byte tempPal[PALETTE_SIZE];
-	bool repeatFlag;
-	byte *srcP;
+	const byte *srcP;
+	byte *destP;
 	int count;
 	Common::Event evt;
 
 	xgetpal(saved_palette, PALETTE_COUNT, 0);
-	Common::copy(saved_palette, saved_palette + PALETTE_SIZE, tempPal);
-
-	do {
-		repeatFlag = false;
-		for (srcP = &tempPal[0], count = 0; count < PALETTE_SIZE; ++count, ++srcP) {
-			int v = *srcP;
-			if (v) {
-				repeatFlag = true;
-				*srcP = MAX((int)*srcP - FADE_AMOUNT, 0);
-			}
+
+	for (int step = FADE_STEPS - 1; step >= 0; --step) {
+		// Set each palette RGB proportionately
+		for (srcP = &saved_palette[0], destP = &tempPal[0], count = 0;
+				count < PALETTE_SIZE; ++count, ++srcP, ++destP) {
+			*destP = *srcP * step / FADE_STEPS;
 		}
 
+		// Set new palette
 		xsetpal(tempPal);
 
+		// Use up any pending events and update the screen
 		while (g_system->getEventManager()->pollEvent(evt)) {
 			if (evt.type == Common::EVENT_QUIT)
 				return;
@@ -95,34 +94,27 @@ void fade_out() {
 
 		g_events->getScreen()->update();
 		g_system->delayMillis(10);
-
-	} while (repeatFlag);
+	}
 }
 
 void fade_in() {
-	const int FADE_AMOUNT = 10;
 	byte tempPal[PALETTE_SIZE];
-	bool repeatFlag;
-	byte *srcP, *destP;
+	const byte *srcP;
+	byte *destP;
 	int count;
 	Common::Event evt;
 
-	Common::fill(tempPal, tempPal + PALETTE_SIZE, 0);
-
-	do {
-		repeatFlag = false;
-		for (srcP = &tempPal[0], destP = &saved_palette[0], count = 0;
+	for (int step = 1; step <= FADE_STEPS; ++step) {
+		// Set each palette RGB proportionately
+		for (srcP = &saved_palette[0], destP = &tempPal[0], count = 0;
 			count < PALETTE_SIZE; ++count, ++srcP, ++destP) {
-			int v = *srcP;
-
-			if (v != *destP) {
-				repeatFlag = true;
-				*srcP = MIN((int)*srcP + FADE_AMOUNT, (int)*destP);
-			}
+			*destP = *srcP * step / FADE_STEPS;
 		}
 
+		// Set new palette
 		xsetpal(tempPal);
 
+		// Use up any pending events and update the screen
 		while (g_system->getEventManager()->pollEvent(evt)) {
 			if (evt.type == Common::EVENT_QUIT)
 				return;
@@ -130,8 +122,7 @@ void fade_in() {
 
 		g_events->getScreen()->update();
 		g_system->delayMillis(10);
-
-	} while (repeatFlag);
+	}
 }
 
 } // namespace Gfx


Commit: 192904476d63c4d3bafe829ee2e7f6adcc2ebdb3
    https://github.com/scummvm/scummvm/commit/192904476d63c4d3bafe829ee2e7f6adcc2ebdb3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Dialog widths should account for options as well as title

Changed paths:
    engines/got/views/dialogs/select_option.cpp


diff --git a/engines/got/views/dialogs/select_option.cpp b/engines/got/views/dialogs/select_option.cpp
index 28c1f5a927a..bb30b8a2487 100644
--- a/engines/got/views/dialogs/select_option.cpp
+++ b/engines/got/views/dialogs/select_option.cpp
@@ -39,7 +39,11 @@ SelectOption::SelectOption(const Common::String &name, const char *title,
 
 	// Calculate the bounds for the dialog
 	int w, h, x1, y1, x2, y2;
+
 	w = strlen(title);
+	for (uint i = 0; i < _options.size(); ++i)
+		w = MAX(w, (int)_options[i].size());
+
 	if (w & 1)
 		w++;
 	w = (w * 8) + 32;


Commit: 8ed24cd4983871c1a92ed064d94aa40db729cec2
    https://github.com/scummvm/scummvm/commit/8ed24cd4983871c1a92ed064d94aa40db729cec2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added view for the part title card

Changed paths:
  A engines/got/views/part_title.cpp
  A engines/got/views/part_title.h
    engines/got/module.mk
    engines/got/views/story.cpp
    engines/got/views/views.h


diff --git a/engines/got/module.mk b/engines/got/module.mk
index 76c8d5259db..ca5be6f972f 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -17,6 +17,7 @@ MODULE_OBJS = \
 	utils/file.o \
 	utils/res_archive.o \
 	views/view.o \
+	views/part_title.o \
 	views/story.o \
 	views/title.o \
 	views/dialogs/dialog.o \
diff --git a/engines/got/views/part_title.cpp b/engines/got/views/part_title.cpp
new file mode 100644
index 00000000000..1ae5a6ff927
--- /dev/null
+++ b/engines/got/views/part_title.cpp
@@ -0,0 +1,70 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/part_title.h"
+#include "got/metaengine.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+
+void PartTitle::draw() {
+	GfxSurface s = getSurface();
+	s.clear();
+	s.print(Common::Point(13 * 8, 13 * 8), "God of Thunder", 14);
+
+	switch (_G(area)) {
+	case 1:
+		s.print(Common::Point(8 * 8, 15 * 8), "Part I: Serpent Surprise", 32);
+		break;
+	case 2:
+		s.print(Common::Point(7 * 8, 15 * 8), "Part II: Non-Stick Nognir", 32);
+		break;
+	case 3:
+		s.print(Common::Point(7 * 8, 15 * 8), "Part III: Lookin' for Loki", 32);
+		break;
+	default:
+		break;
+	}
+}
+
+bool PartTitle::msgAction(const ActionMessage &msg) {
+	if (msg._action == KEYBIND_ESCAPE)
+		done();
+
+	return true;
+}
+
+bool PartTitle::tick() {
+	if (++_timeoutCtr == 50) {
+		_timeoutCtr = 0;
+		done();
+	}
+
+	return true;
+}
+
+void PartTitle::done() {
+	replaceView("Game", true, true);
+}
+
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/part_title.h b/engines/got/views/part_title.h
new file mode 100644
index 00000000000..12cdea230b4
--- /dev/null
+++ b/engines/got/views/part_title.h
@@ -0,0 +1,48 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_PART_TITLE_H
+#define GOT_VIEWS_PART_TITLE_H
+
+#include "got/views/view.h"
+
+namespace Got {
+namespace Views {
+
+class PartTitle : public View {
+private:
+	int _timeoutCtr = 0;
+
+	void done();
+
+public:
+	PartTitle() : View("PartTitle") {}
+	virtual ~PartTitle() {}
+
+	bool msgAction(const ActionMessage &msg) override;
+	void draw() override;
+	bool tick() override;
+};
+
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/story.cpp b/engines/got/views/story.cpp
index 2beb76f4d57..d077f83a683 100644
--- a/engines/got/views/story.cpp
+++ b/engines/got/views/story.cpp
@@ -154,9 +154,12 @@ bool Story::tick() {
 }
 
 void Story::done() {
-	warning("TODO: Story::done");
 	music_stop();
+
+	fadeOut();
 	Gfx::load_palette();
+	replaceView("PartTitle");
+	fadeIn();
 }
 
 } // namespace Views
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index 8d43b46f6a5..76c69c54171 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -22,6 +22,7 @@
 #ifndef GOT_VIEWS_H
 #define GOT_VIEWS_H
 
+#include "got/views/part_title.h"
 #include "got/views/story.h"
 #include "got/views/title.h"
 #include "got/views/dialogs/main_menu.h"
@@ -34,6 +35,7 @@ namespace Got {
 namespace Views {
 
 struct Views {
+	PartTitle _partTitle;
 	Story _story;
 	Title _title;
 


Commit: 2d1510eb214aa053998260140ed151fd4dc1030e
    https://github.com/scummvm/scummvm/commit/2d1510eb214aa053998260140ed151fd4dc1030e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Skeleton Game view

Changed paths:
  A engines/got/views/game.cpp
  A engines/got/views/game.h
    engines/got/module.mk
    engines/got/vars.cpp
    engines/got/vars.h
    engines/got/views/part_title.cpp
    engines/got/views/views.h


diff --git a/engines/got/module.mk b/engines/got/module.mk
index ca5be6f972f..4dc97b86adf 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -17,6 +17,7 @@ MODULE_OBJS = \
 	utils/file.o \
 	utils/res_archive.o \
 	views/view.o \
+	views/game.o \
 	views/part_title.o \
 	views/story.o \
 	views/title.o \
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 4bef83164af..30b320e0f89 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -30,7 +30,9 @@ namespace Got {
 
 Vars *g_vars;
 
-Vars::Vars() : _hampic("HAMPIC", 262, false) {
+Vars::Vars() :
+		_hampic("HAMPIC", 262, false),
+		_status("STATUS", -1, false) {
 	g_vars = this;
 }
 
@@ -39,6 +41,7 @@ void Vars::load() {
 	_gfx.load();
 	_bgPics.load();
 	_hampic.load();
+	_status.load();
 	_sound.load();
 
 	_music_flag = !ConfMan.getBool("music_mute");
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 3d789d7efea..af9c755189e 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -47,6 +47,7 @@ public:
 	Gfx::BgPics _bgPics;
 	Gfx::Font _font;
 	Gfx::Pics _hampic;
+	Gfx::Pics _status;
 	Sound _sound;
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
new file mode 100644
index 00000000000..fa5c2102d9a
--- /dev/null
+++ b/engines/got/views/game.cpp
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/game.h"
+#include "got/metaengine.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+
+bool Game::msgFocus(const FocusMessage &msg) {
+	return true;
+}
+
+bool Game::msgUnfocus(const UnfocusMessage &msg) {
+	return true;
+}
+
+void Game::draw() {
+	GfxSurface s = getSurface();
+
+	// Status area
+	const Graphics::ManagedSurface &status = _G(status)[0];
+	s.blitFrom(status, Common::Point(0, 240 - status.h));
+}
+
+bool Game::msgAction(const ActionMessage &msg) {
+	return true;
+}
+
+bool Game::tick() {
+	return true;
+}
+
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/game.h b/engines/got/views/game.h
new file mode 100644
index 00000000000..78605b32200
--- /dev/null
+++ b/engines/got/views/game.h
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_GAME_H
+#define GOT_VIEWS_GAME_H
+
+#include "got/views/view.h"
+
+namespace Got {
+namespace Views {
+
+class Game : public View {
+public:
+	Game() : View("Game") {}
+	virtual ~Game() {}
+
+	bool msgFocus(const FocusMessage &msg) override;
+	bool msgUnfocus(const UnfocusMessage &msg) override;
+	bool msgAction(const ActionMessage &msg) override;
+	void draw() override;
+	bool tick() override;
+};
+
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/part_title.cpp b/engines/got/views/part_title.cpp
index 1ae5a6ff927..b5275318711 100644
--- a/engines/got/views/part_title.cpp
+++ b/engines/got/views/part_title.cpp
@@ -54,7 +54,7 @@ bool PartTitle::msgAction(const ActionMessage &msg) {
 }
 
 bool PartTitle::tick() {
-	if (++_timeoutCtr == 50) {
+	if (++_timeoutCtr == 40) {
 		_timeoutCtr = 0;
 		done();
 	}
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index 76c69c54171..22a7301b05d 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -22,6 +22,7 @@
 #ifndef GOT_VIEWS_H
 #define GOT_VIEWS_H
 
+#include "got/views/game.h"
 #include "got/views/part_title.h"
 #include "got/views/story.h"
 #include "got/views/title.h"
@@ -35,6 +36,7 @@ namespace Got {
 namespace Views {
 
 struct Views {
+	Game _game;
 	PartTitle _partTitle;
 	Story _story;
 	Title _title;


Commit: 2a0b44c87401fe72a9b1cbe779a03f3e5b27bbe0
    https://github.com/scummvm/scummvm/commit/2a0b44c87401fe72a9b1cbe779a03f3e5b27bbe0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added status methods

Changed paths:
  A engines/got/game/status.cpp
  A engines/got/game/status.h
    engines/got/module.mk
    engines/got/prototypes.h


diff --git a/engines/got/game/status.cpp b/engines/got/game/status.cpp
new file mode 100644
index 00000000000..f7b4694cc23
--- /dev/null
+++ b/engines/got/game/status.cpp
@@ -0,0 +1,98 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/game/status.h"
+#include "got/events.h"
+#include "got/vars.h"
+
+namespace Got {
+
+void add_jewels(int num) {
+	_G(thor_info).jewels = CLIP(_G(thor_info).jewels + num, 0, 999);
+}
+
+void add_score(int num) {
+	_G(thor_info).score = CLIP(_G(thor_info).score + num, 0l, 999999l);
+}
+
+void add_magic(int num) {
+	_G(thor_info).magic = CLIP(_G(thor_info).magic + num, 0, 150);
+}
+
+void add_health(int num) {
+	_G(thor)->health = CLIP(_G(thor)->health + num, 0, 150);
+
+	if (_G(thor)->health < 1)
+		g_events->replaceView("ThorDies");
+}
+
+void add_keys(int num) {
+	_G(thor_info).keys = CLIP(_G(thor_info).keys + num, 0, 99);
+}
+
+void fill_health() {
+	add_health(150);
+}
+
+void fill_magic() {
+	add_magic(150);
+}
+
+void fill_score(int num) {
+#ifndef TODO
+	error("TODO: fill_score");
+#else
+	while (num) {
+		num--;
+		_G(sound).play_sound(WOOP, 1);
+		add_score(1000);
+		g_events->delay(8);
+	}
+#endif
+}
+
+void score_for_inv() {
+#ifdef TODO
+	while (_G(thor)->health) {
+		_G(thor)->health--;
+		play_sound(WOOP, 1);
+		add_health(-1);
+		add_score(10);
+		pause(8);
+	}
+	while (_G(thor_info).magic) {
+		_G(thor_info).magic--;
+		play_sound(WOOP, 1);
+		add_magic(-1);
+		add_score(10);
+		pause(8);
+	}
+	while (_G(thor_info).jewels) {
+		_G(thor_info).jewels--;
+		play_sound(WOOP, 1);
+		add_jewels(-1);
+		add_score(10);
+		pause(8);
+	}
+#endif
+}
+
+} // namespace Got
diff --git a/engines/got/game/status.h b/engines/got/game/status.h
new file mode 100644
index 00000000000..74c3deaf2a8
--- /dev/null
+++ b/engines/got/game/status.h
@@ -0,0 +1,41 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_DATA_STATUS_H
+#define GOT_DATA_STATUS_H
+
+#include "got/defines.h"
+
+namespace Got {
+
+extern void add_jewels(int num);
+extern void add_score(int num);
+extern void add_magic(int num);
+extern void add_health(int num);
+extern void add_keys(int num);
+extern void fill_health();
+extern void fill_magic();
+extern void fill_score(int num);
+extern void score_for_inv();
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 4dc97b86adf..2739b07b3ed 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -8,6 +8,7 @@ MODULE_OBJS = \
 	metaengine.o \
 	sound.o \
 	vars.o \
+	game/status.o \
 	gfx/font.o \
 	gfx/gfx_chunks.o \
 	gfx/gfx_pics.o \
diff --git a/engines/got/prototypes.h b/engines/got/prototypes.h
index c1813211724..5d2223e7ec1 100644
--- a/engines/got/prototypes.h
+++ b/engines/got/prototypes.h
@@ -118,23 +118,6 @@ void story(void);
 
 
 //G_PANEL.C
-void status_panel(void);
-void display_health(void);
-void display_magic(void);
-void display_jewels(void);
-void display_score(void);
-void display_keys(void);
-void display_item(void);
-int  init_status_panel(void);
-void add_jewels(int num);
-void add_score(int num);
-void add_magic(int num);
-void add_health(int num);
-void add_keys(int num);
-void fill_health(void);
-void fill_magic(void);
-void fill_score(int num);
-void score_for_inv(void);
 void boss_status(int health);
 int  select_option(const char *option[], const char *title, int ipos);
 int  option_menu(void);


Commit: 0075ebc5e033fb6d8d987a4f2526a0f0a1588c24
    https://github.com/scummvm/scummvm/commit/0075ebc5e033fb6d8d987a4f2526a0f0a1588c24
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Split status area into it's own subclass

Changed paths:
  A engines/got/views/game_status.cpp
  A engines/got/views/game_status.h
    engines/got/module.mk
    engines/got/views/game.cpp
    engines/got/views/game.h


diff --git a/engines/got/module.mk b/engines/got/module.mk
index 2739b07b3ed..f1c36e9b198 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -19,6 +19,7 @@ MODULE_OBJS = \
 	utils/res_archive.o \
 	views/view.o \
 	views/game.o \
+	views/game_status.o \
 	views/part_title.o \
 	views/story.o \
 	views/title.o \
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index fa5c2102d9a..264d01b6cdc 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -26,6 +26,11 @@
 namespace Got {
 namespace Views {
 
+Game::Game() : View("Game") {
+	_children.push_back(&_status);
+	_status.setBounds(Common::Rect(0, 240 - 48, 320, 240));
+}
+
 bool Game::msgFocus(const FocusMessage &msg) {
 	return true;
 }
@@ -36,10 +41,7 @@ bool Game::msgUnfocus(const UnfocusMessage &msg) {
 
 void Game::draw() {
 	GfxSurface s = getSurface();
-
-	// Status area
-	const Graphics::ManagedSurface &status = _G(status)[0];
-	s.blitFrom(status, Common::Point(0, 240 - status.h));
+	s.clear();
 }
 
 bool Game::msgAction(const ActionMessage &msg) {
diff --git a/engines/got/views/game.h b/engines/got/views/game.h
index 78605b32200..4355ee4905a 100644
--- a/engines/got/views/game.h
+++ b/engines/got/views/game.h
@@ -23,13 +23,17 @@
 #define GOT_VIEWS_GAME_H
 
 #include "got/views/view.h"
+#include "got/views/game_status.h"
 
 namespace Got {
 namespace Views {
 
 class Game : public View {
+private:
+	GameStatus _status;
+
 public:
-	Game() : View("Game") {}
+	Game();
 	virtual ~Game() {}
 
 	bool msgFocus(const FocusMessage &msg) override;
diff --git a/engines/got/views/game_status.cpp b/engines/got/views/game_status.cpp
new file mode 100644
index 00000000000..b88817070cf
--- /dev/null
+++ b/engines/got/views/game_status.cpp
@@ -0,0 +1,103 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/game_status.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+
+#define STAT_COLOR 206
+
+void GameStatus::draw() {
+	GfxSurface s = getSurface();
+
+	// Draw the status background
+	const Graphics::ManagedSurface &status = _G(status)[0];
+	s.blitFrom(status);
+
+	// Draw the elements
+	displayHealth();
+	displayMagic();
+	displayJewels();
+	displayScore();
+	displayKeys();
+}
+
+void GameStatus::displayHealth() {
+	int b = 59 + _G(thor)->health;
+
+	GfxSurface s = getSurface();
+	s.fillRect(Common::Rect(59, 8, b, 12), 32);
+	s.fillRect(Common::Rect(b, 8, 209, 12), STAT_COLOR);
+}
+
+void GameStatus::displayMagic() {
+	int b = 59 + _G(thor_info).magic;
+
+	GfxSurface s = getSurface();
+	s.fillRect(Common::Rect(59, 20, b, 24), 96);
+	s.fillRect(Common::Rect(b, 20, 209, 24), STAT_COLOR);
+}
+
+void GameStatus::displayJewels() {
+	Common::String str = Common::String::format("%d", _G(thor_info).jewels);
+	int x;
+	if (str.size() == 1)
+		x = 70;
+	else if (str.size() == 2)
+		x = 66;
+	else
+		x = 62;
+
+	GfxSurface s = getSurface();
+	s.fillRect(Common::Rect(59, 32, 85, 42), STAT_COLOR);
+	s.print(Common::Point(x, 32), str, 14);
+}
+
+void GameStatus::displayScore() {
+	Common::String str = Common::String::format("%d", _G(thor_info).score);
+	int x = 276 - (str.size() * 8);
+
+	GfxSurface s = getSurface();
+	s.fillRect(Common::Rect(223, 32, 279, 42), STAT_COLOR);
+	s.print(Common::Point(x, 32), str, 14);
+}
+
+void GameStatus::displayKeys() {
+	Common::String str = Common::String::format("%d", _G(thor_info).keys);
+
+	int x;
+	if (str.size() == 1)
+		x = 150;
+	else if (str.size() == 2)
+		x = 146;
+	else
+		x = 142;
+
+	GfxSurface s = getSurface();
+	s.fillRect(Common::Rect(139, 32, 164, 42), STAT_COLOR);
+	s.print(Common::Point(x, 32), str, 14);
+}
+
+
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/game_status.h b/engines/got/views/game_status.h
new file mode 100644
index 00000000000..9a4ef0c7b76
--- /dev/null
+++ b/engines/got/views/game_status.h
@@ -0,0 +1,48 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_GAME_STATUS_H
+#define GOT_VIEWS_GAME_STATUS_H
+
+#include "got/views/view.h"
+
+namespace Got {
+namespace Views {
+
+class GameStatus : public View {
+private:
+	void displayHealth();
+	void displayMagic();
+	void displayJewels();
+	void displayScore();
+	void displayKeys();
+
+public:
+	GameStatus() : View("GameStatus") {}
+	virtual ~GameStatus() {}
+
+	void draw() override;
+};
+
+} // namespace Views
+} // namespace Got
+
+#endif


Commit: 500f71d8c84e67993bc65e27f13708e8e9dce5c1
    https://github.com/scummvm/scummvm/commit/500f71d8c84e67993bc65e27f13708e8e9dce5c1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Adding image setup methods

Changed paths:
  A engines/got/game/image.cpp
  A engines/got/game/image.h
    engines/got/defines.h
    engines/got/game/status.h
    engines/got/module.mk
    engines/got/prototypes.h
    engines/got/vars.h
    engines/got/views/game.cpp
    engines/got/views/game.h


diff --git a/engines/got/defines.h b/engines/got/defines.h
index a6b4d667ea9..4d004608b32 100644
--- a/engines/got/defines.h
+++ b/engines/got/defines.h
@@ -33,7 +33,7 @@ namespace Got {
 struct ALIGNED_MASK_IMAGE {
 	int image_width = 0;		// Image width in addresses in display memory
 	uint image_ptr = 0;			// Offset of image bitmap in display mem
-	const byte *mask_ptr = nullptr;   // Pointer to mask bitmap
+	byte *mask_ptr = nullptr;   // Pointer to mask bitmap
 };
 
 struct MASK_IMAGE {
diff --git a/engines/got/game/image.cpp b/engines/got/game/image.cpp
new file mode 100644
index 00000000000..0f383922433
--- /dev/null
+++ b/engines/got/game/image.cpp
@@ -0,0 +1,369 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/game/image.h"
+#include "got/events.h"
+#include "got/utils/file.h"
+#include "got/got.h"
+#include "got/vars.h"
+
+namespace Got {
+
+void xcopys2d(int SourceStartX, int SourceStartY,
+		int SourceEndX, int SourceEndY, int DestStartX,
+		int DestStartY, byte *SourcePtr, unsigned int DestPageBase,
+		int SourceBitmapWidth, int DestBitmapWidth) {
+	error("TODO: Refactor this to use surfaces");
+}
+
+
+uint make_mask(MASK_IMAGE *new_image, uint page_start, byte *Image,
+		int image_width, int image_height) {
+	uint page_offset, size;
+	int align, set;
+	ALIGNED_MASK_IMAGE *work_ami;
+	int scan_line, bit_num, temp_image_width;
+	unsigned char mask_temp;
+	byte *new_mask_ptr;
+	byte *old_mask_ptr;
+
+	page_offset = page_start;
+	set = 0;
+
+	for (align = 0; align < 3; align += 2) {
+		work_ami = new_image->alignments[set++] = (ALIGNED_MASK_IMAGE *)_G(ami_buff);
+		_G(ami_buff) += sizeof(ALIGNED_MASK_IMAGE);
+
+		work_ami->image_width = (image_width + align + 3) / 4;
+		work_ami->image_ptr = page_offset; /* image dest */
+
+		/* Download this alignment of the image */
+		xcopys2d(0, 0, image_width, image_height, align, 0,
+			Image, page_offset, image_width,
+			work_ami->image_width * 4);
+
+		/* Calculate the number of bytes needed to store the mask in
+		   nibble (Map Mask-ready) form, then allocate that space */
+		size = work_ami->image_width * image_height;
+		work_ami->mask_ptr = (byte *)_G(mask_buff);
+		_G(mask_buff) += size;
+
+		/* Generate this nibble oriented (Map Mask-ready) alignment of
+		   the mask, one scan line at a time */
+		old_mask_ptr = Image;
+		new_mask_ptr = work_ami->mask_ptr;
+		for (scan_line = 0; scan_line < image_height; scan_line++) {
+			bit_num = align;
+			mask_temp = 0;
+			temp_image_width = image_width;
+			do {
+
+				/* Set the mask bit for next pixel according to its alignment */
+				mask_temp |= (*old_mask_ptr != 15 && *old_mask_ptr != 0) << bit_num;
+				old_mask_ptr++;
+				if (++bit_num > 3) {
+					*new_mask_ptr = mask_temp;
+					new_mask_ptr++;
+					mask_temp = bit_num = 0;
+				}
+			} while (--temp_image_width);
+
+
+			/* Set any partial final mask on this scan line */
+			if (bit_num != 0) {
+				*new_mask_ptr = mask_temp;
+				new_mask_ptr++;
+			}
+		}
+		page_offset += size; /* mark off the space we just used */
+	}
+	return page_offset - page_start;
+}
+
+void setup_actor(ACTOR *actr, char num, char dir, int x, int y) {
+
+	actr->next = 0;                    //next frame to be shown
+	actr->frame_count = actr->frame_speed;
+	actr->dir = dir;                   //direction of travel
+	actr->last_dir = dir;              //last direction of travel
+	if (actr->directions == 1) actr->dir = 0;
+	if (actr->directions == 2) actr->dir &= 1;
+	if (actr->directions == 4 && actr->frames == 1) {
+		actr->dir = 0;
+		actr->next = dir;
+	}
+
+	actr->x = x;                       //actual X coor
+	actr->y = y;                       //actual Y coor
+	actr->width = 16;                  //actual X coor
+	actr->height = 16;                  //actual Y coor
+	actr->center = 0;                        //center of object
+	actr->last_x[0] = x;               //last X coor on each page
+	actr->last_x[1] = x;
+	actr->last_y[0] = y;               //last Y coor on each page
+	actr->last_y[1] = y;
+	actr->used = 1;                    //1=active, 0=not active
+	actr->speed_count = 8;             //count down to movement
+	actr->vunerable = STAMINA;         //count down to vunerability
+	actr->shot_cnt = 20;               //count down to another shot
+	actr->num_shots = 0;               //# of shots currently on screen
+	actr->creator = 0;                 //which actor # created this actor
+	actr->pause = 0;                   //pause must be 0 to move
+	actr->show = 0;
+	actr->actor_num = num;
+	actr->counter = 0;
+	actr->move_counter = 0;
+	actr->edge_counter = 20;
+	actr->hit_thor = 0;
+	actr->rand = g_engine->getRandomNumber(99);
+	actr->temp1 = 0;
+	actr->init_health = actr->health;
+}
+
+void make_actor_mask(ACTOR *actr) {
+	int d, f;
+
+	for (d = 0; d < actr->directions; d++) {
+		for (f = 0; f < actr->frames; f++) {
+			make_mask(&actr->pic[d][f], _G(latch_mem), &_G(tmp_buff)[256 * ((d * 4) + f)], 16, 16);
+			_G(latch_mem) += 144;
+			if (_G(latch_mem) > 65421u) {
+				error("Too Many Actor Frames=");
+			}
+		}
+	}
+}
+
+int load_standard_actors(void) {
+
+	_G(latch_mem) = 50160u;
+	_G(mask_buff) = _G(mask_buff_start);
+	_G(ami_buff) = _G(abuff);
+
+	load_actor(0, 100 + _G(thor_info).armor);   // Load thor
+	memcpy(&_G(actor)[0], (_G(tmp_buff) + 5120), 40);
+	setup_actor(&_G(actor)[0], 0, 0, 100, 100);
+	_G(thor) = &_G(actor)[0];
+
+	_G(ami_store1) = _G(ami_buff);
+	_G(mask_store1) = _G(mask_buff);
+	make_actor_mask(&_G(actor)[0]);
+
+	_G(thor_x1) = _G(thor)->x + 2;
+	_G(thor_y1) = _G(thor)->y + 2;
+	_G(thor_x2) = _G(thor)->x + 14;
+	_G(thor_y2) = _G(thor)->y + 14;
+
+	load_actor(0, 103 + _G(thor_info).armor);   //load hammer
+	memcpy(&_G(actor)[1], (_G(tmp_buff) + 5120), 40);
+	setup_actor(&_G(actor)[1], 1, 0, 100, 100);
+	_G(actor)[1].used = 0;
+	_G(hammer) = &_G(actor)[1];
+
+	_G(ami_store2) = _G(ami_buff);
+	_G(mask_store2) = _G(mask_buff);
+	make_actor_mask(&_G(actor)[1]);
+
+	load_actor(0, 106);   // Load sparkle
+	memcpy(&_G(sparkle), (_G(tmp_buff) + 5120), 40);
+	setup_actor(&_G(sparkle), 20, 0, 100, 100);
+	_G(sparkle).used = 0;
+	make_actor_mask(&_G(sparkle));
+
+	load_actor(0, 107);   // Load explosion
+	memcpy(&_G(explosion), (_G(tmp_buff) + 5120), 40);
+	setup_actor(&_G(explosion), 21, 0, 100, 100);
+	_G(explosion).used = 0;
+	make_actor_mask(&_G(explosion));
+
+	load_actor(0, 108);   //load tornado
+	memcpy(&_G(magic_item)[0], (_G(tmp_buff) + 5120), 40);
+	memcpy(&_G(magic_pic)[0], _G(tmp_buff), 1024);
+	setup_actor(&_G(magic_item)[0], 20, 0, 0, 0);
+	_G(magic_item)[0].used = 0;
+
+	load_actor(0, 1099);   //load shield
+	memcpy(&_G(magic_item)[1], (_G(tmp_buff) + 5120), 40);
+	memcpy(&_G(magic_pic)[1], _G(tmp_buff), 1024);
+	setup_actor(&_G(magic_item)[1], 20, 0, 0, 0);
+	_G(magic_item)[1].used = 0;
+
+	_G(actor)[2].used = 0;
+	_G(magic_ami) = _G(ami_buff);
+	_G(magic_mask_buff) = _G(mask_buff);
+
+	make_actor_mask(&_G(magic_item)[0]);  //to fool next lines
+
+	_G(enemy_mb) = _G(mask_buff);
+	_G(enemy_ami) = _G(ami_buff);
+	_G(enemy_lm) = _G(latch_mem);
+	return 1;
+}
+
+void show_enemies(void) {
+	int i, d, r;
+
+	for (i = 3; i < MAX_ACTORS; i++)
+		_G(actor)[i].used = 0;
+	for (i = 0; i < MAX_ENEMIES; i++)
+		_G(enemy_type)[i] = 0;
+
+	_G(latch_mem) = _G(enemy_lm);
+	_G(mask_buff) = _G(enemy_mb);
+	_G(ami_buff) = _G(enemy_ami);
+
+	for (i = 0; i < MAX_ENEMIES; i++) {
+		if (_G(scrn).actor_type[i] > 0) {
+			r = load_enemy(_G(scrn).actor_type[i]);
+			if (r >= 0) {
+				memcpy(&_G(actor)[i + 3], &_G(enemy)[r], sizeof(ACTOR));
+				d = _G(scrn).actor_dir[i];
+				//       _G(scrn).actor_type[i] &= 0x3f;
+				setup_actor(&_G(actor)[i + 3], i + 3, d, (_G(scrn).actor_loc[i] % 20) * 16,
+					(_G(scrn).actor_loc[i] / 20) * 16);
+				_G(actor)[i + 3].init_dir = _G(scrn).actor_dir[i];
+				_G(actor)[i + 3].pass_value = _G(scrn).actor_value[i];
+				if (_G(actor)[i + 3].move == 23) {  //spinball
+					if (_G(actor)[i + 3].pass_value & 1) _G(actor)[i + 3].move = 24;
+				}
+				if (_G(scrn).actor_invis[i]) _G(actor)[i + 3].used = 0;
+			}
+
+			_G(etype)[i] = r;
+		}
+	}
+}
+
+int load_enemy(int type) {
+	int i, f, d, e;
+	ACTOR *enm;
+
+	for (i = 0; i < MAX_ENEMIES; i++) if (_G(enemy_type)[i] == type) return i;
+
+	if (!load_actor(1, type)) {
+		return -1;
+	}
+	enm = (ACTOR *)(_G(tmp_buff) + 5120);
+
+	e = -1;
+	for (i = 0; i < MAX_ENEMIES; i++) {
+		if (!_G(enemy_type)[i]) {
+			e = i;
+			break;
+		}
+	}
+	if (e == -1) return -1;
+
+	memcpy(&_G(enemy)[e], enm, sizeof(ACTOR_NFO));
+
+	make_actor_mask(&_G(enemy)[e]);
+	_G(enemy_type)[e] = type;
+	_G(enemy)[e].shot_type = 0;
+
+	if (_G(enemy)[e].shots_allowed) {
+		_G(enemy)[e].shot_type = e + 1;
+		enm = (ACTOR *)(_G(tmp_buff) + 5160);
+		memcpy(&_G(shot)[e], enm, sizeof(ACTOR_NFO));
+		for (d = 0; d < _G(shot)[e].directions; d++) {
+			for (f = 0; f < _G(shot)[e].frames; f++) {
+				if (_G(shot)[e].directions < _G(shot)[e].frames)
+					make_mask(&_G(shot)[e].pic[d][f], _G(latch_mem),
+						&_G(tmp_buff)[4096 + (256 * ((d * 4) + f))], 16, 16);
+				else
+					make_mask(&_G(shot)[e].pic[f][d], _G(latch_mem),
+						&_G(tmp_buff)[4096 + (256 * ((f * 4) + d))], 16, 16);
+
+				_G(latch_mem) += 144;
+				if (_G(latch_mem) > 65421u)
+					error("Too Many Actor Frames");
+			}
+		}
+	}
+	return e;
+}
+
+int actor_visible(int invis_num) {
+	int i, d;
+
+	for (i = 0; i < MAX_ENEMIES; i++) {
+		if (_G(scrn).actor_invis[i] == invis_num) {
+			if (_G(etype)[i] >= 0 && !_G(actor)[i + 3].used) {
+				memcpy(&_G(actor)[i + 3], &_G(enemy)[_G(etype)[i]], sizeof(ACTOR));
+				d = _G(scrn).actor_dir[i];
+				//       _G(scrn).actor_type[i] &= 0x3f;
+				setup_actor(&_G(actor)[i + 3], i + 3, d, (_G(scrn).actor_loc[i] % 20) * 16,
+					(_G(scrn).actor_loc[i] / 20) * 16);
+				_G(actor)[i + 3].init_dir = _G(scrn).actor_dir[i];
+				_G(actor)[i + 3].pass_value = _G(scrn).actor_value[i];
+				return i;
+			} else return -1;
+		}
+	}
+	return -1;
+}
+
+void setup_magic_item(int item) {
+	int i;
+	byte *ami;
+	byte *mb;
+
+
+	mb = _G(mask_buff);
+	_G(mask_buff) = _G(magic_mask_buff);
+
+	ami = _G(ami_buff);
+	_G(ami_buff) = _G(magic_ami);
+
+	for (i = 0; i < 4; i++) {
+		make_mask(&_G(magic_item)[item].pic[i / 4][i % 4], 55200u + (144 * i), &_G(magic_pic)[item][256 * i], 16, 16);
+	}
+	_G(ami_buff) = ami;
+	_G(mask_buff) = mb;
+}
+
+void load_new_thor(void) {
+	int rep;
+	byte *ami;
+	byte *mb;
+
+
+	mb = _G(mask_buff);
+	ami = _G(ami_buff);
+
+	_G(mask_buff) = _G(mask_store1);
+	_G(ami_buff) = _G(ami_store1);
+
+	load_actor(0, 100 + _G(thor_info).armor);   //load thor
+	for (rep = 0; rep < 16; rep++) {
+		make_mask(&_G(actor)[0].pic[rep / 4][rep % 4], PAGE3 + (144 * rep), &_G(tmp_buff)[256 * rep], 16, 16);
+	}
+	_G(mask_buff) = _G(mask_store2);
+	_G(ami_buff) = _G(ami_store2);
+	load_actor(0, 103 + _G(thor_info).armor);   //load hammer
+	for (rep = 0; rep < 16; rep++) {
+		make_mask(&_G(actor)[1].pic[rep / 4][rep % 4], 52464u + (144 * rep), &_G(tmp_buff)[256 * rep], 16, 16);
+	}
+
+	_G(ami_buff) = ami;
+	_G(mask_buff) = mb;
+}
+
+} // namespace Got
diff --git a/engines/got/game/image.h b/engines/got/game/image.h
new file mode 100644
index 00000000000..ed3f67384f6
--- /dev/null
+++ b/engines/got/game/image.h
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GAME_IMAGE_H
+#define GOT_GAME_IMAGE_H
+
+#include "got/defines.h"
+
+namespace Got {
+
+extern uint make_mask(MASK_IMAGE *new_image, uint page_start,
+	byte *Image, int image_width, int image_height);
+extern void setup_actor(ACTOR *actr, char num, char dir, int x, int y);
+extern void make_actor_mask(ACTOR *actr);
+extern int load_standard_actors();
+extern void show_enemies();
+extern int load_enemy(int type);
+extern int actor_visible(int invis_num);
+extern void setup_magic_item(int item);
+extern void load_new_thor();
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/game/status.h b/engines/got/game/status.h
index 74c3deaf2a8..79afc7ef9dd 100644
--- a/engines/got/game/status.h
+++ b/engines/got/game/status.h
@@ -19,8 +19,8 @@
  *
  */
 
-#ifndef GOT_DATA_STATUS_H
-#define GOT_DATA_STATUS_H
+#ifndef GOT_GAME_STATUS_H
+#define GOT_GAME_STATUS_H
 
 #include "got/defines.h"
 
diff --git a/engines/got/module.mk b/engines/got/module.mk
index f1c36e9b198..f9615881e8a 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -8,6 +8,7 @@ MODULE_OBJS = \
 	metaengine.o \
 	sound.o \
 	vars.o \
+	game/image.o \
 	game/status.o \
 	gfx/font.o \
 	gfx/gfx_chunks.o \
diff --git a/engines/got/prototypes.h b/engines/got/prototypes.h
index 5d2223e7ec1..6b8f47dd670 100644
--- a/engines/got/prototypes.h
+++ b/engines/got/prototypes.h
@@ -55,7 +55,7 @@ void xcopyd2dmasked2(
 	unsigned int DestPageBase);
 void xcopys2d(int SourceStartX, int SourceStartY,
 	int SourceEndX, int SourceEndY, int DestStartX,
-	int DestStartY, char *SourcePtr, unsigned int DestPageBase,
+	int DestStartY, byte *SourcePtr, unsigned int DestPageBase,
 	int SourceBitmapWidth, int DestBitmapWidth);
 void xcopyd2d(int SourceStartX, int SourceStartY,
 	int SourceEndX, int SourceEndY, int DestStartX,
diff --git a/engines/got/vars.h b/engines/got/vars.h
index af9c755189e..886fab76faf 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -54,7 +54,6 @@ public:
 	uint _display_page = 0, _draw_page = 0;
 	uint _page3_offset = 0;
 	int8 _pge = 0;
-	int _exit_flag = 0;
 
 	byte _key_flag[100] = {};
 	byte _joy_flag[100] = {};
@@ -92,8 +91,6 @@ public:
 	byte *_scrnp = nullptr;
 
 	byte *_sd_data = nullptr;
-	int _current_level = 23;
-	int _new_level = 0, _new_level_tile = 0, _current_area = 0;
 
 	SETUP _setup;
 	byte *_tmp_buff = nullptr;
@@ -107,6 +104,7 @@ public:
 	ACTOR _enemy[MAX_ENEMIES] = {};  //current enemies
 	ACTOR _shot[MAX_ENEMIES] = {};   //current shots
 	int8 _enemy_type[MAX_ENEMIES] = {};
+	int _etype[MAX_ENEMIES] = {};
 
 	ACTOR _magic_item[2] = {};
 	byte _magic_pic[2][1024] = {};
@@ -173,8 +171,19 @@ public:
 	int8 _ide_run = 0, _fast_exit = 0, _nojoy = 0, _gr = 0, _xdos = 0;
 	int8 _main_loop = 0;
 	int8 _end_tile = 0;
-
 	byte _pbuff[PALETTE_SIZE] = {};
+	int _current_level, _new_level;
+	int _new_level_tile = 0, _current_area = 0;
+	uint _latch_mem = 0;
+	byte *_enemy_mb = nullptr;
+	uint _enemy_lm = 0;
+	byte *_enemy_ami = nullptr;
+	char _sd_header[128] = {};
+	char _play_speed = 0;
+	byte *_magic_ami = nullptr;
+	byte *_magic_mask_buff = nullptr;
+	byte *_ami_store1 = nullptr, *_ami_store2 = nullptr;
+	byte *_mask_store1 = nullptr, *_mask_store2 = nullptr;
 };
 
 #define _G(X) (g_vars->_##X)
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 264d01b6cdc..ed50b547ccc 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "got/views/game.h"
+#include "got/game/image.h"
 #include "got/metaengine.h"
 #include "got/vars.h"
 
@@ -31,7 +32,16 @@ Game::Game() : View("Game") {
 	_status.setBounds(Common::Rect(0, 240 - 48, 320, 240));
 }
 
+void Game::initialize() {
+	load_standard_actors();
+}
+
 bool Game::msgFocus(const FocusMessage &msg) {
+	if (_firstTime) {
+		initialize();
+		_firstTime = false;
+	}
+
 	return true;
 }
 
diff --git a/engines/got/views/game.h b/engines/got/views/game.h
index 4355ee4905a..46b1e62041e 100644
--- a/engines/got/views/game.h
+++ b/engines/got/views/game.h
@@ -31,6 +31,12 @@ namespace Views {
 class Game : public View {
 private:
 	GameStatus _status;
+	bool _firstTime = true;
+
+	/**
+	 * Handles in-game initialization the first time
+	 */
+	void initialize();
 
 public:
 	Game();


Commit: 5789b2978bb0e08687cb252374553ff80fef83d7
    https://github.com/scummvm/scummvm/commit/5789b2978bb0e08687cb252374553ff80fef83d7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: image.cpp cleanups

Changed paths:
    engines/got/game/image.cpp


diff --git a/engines/got/game/image.cpp b/engines/got/game/image.cpp
index 0f383922433..da435af73c5 100644
--- a/engines/got/game/image.cpp
+++ b/engines/got/game/image.cpp
@@ -53,15 +53,15 @@ uint make_mask(MASK_IMAGE *new_image, uint page_start, byte *Image,
 		_G(ami_buff) += sizeof(ALIGNED_MASK_IMAGE);
 
 		work_ami->image_width = (image_width + align + 3) / 4;
-		work_ami->image_ptr = page_offset; /* image dest */
+		work_ami->image_ptr = page_offset;	// Image dest
 
-		/* Download this alignment of the image */
+		// Download this alignment of the image
 		xcopys2d(0, 0, image_width, image_height, align, 0,
 			Image, page_offset, image_width,
 			work_ami->image_width * 4);
 
-		/* Calculate the number of bytes needed to store the mask in
-		   nibble (Map Mask-ready) form, then allocate that space */
+		// Calculate the number of bytes needed to store the mask in
+		// nibble (Map Mask-ready) form, then allocate that space */
 		size = work_ami->image_width * image_height;
 		work_ami->mask_ptr = (byte *)_G(mask_buff);
 		_G(mask_buff) += size;
@@ -75,8 +75,7 @@ uint make_mask(MASK_IMAGE *new_image, uint page_start, byte *Image,
 			mask_temp = 0;
 			temp_image_width = image_width;
 			do {
-
-				/* Set the mask bit for next pixel according to its alignment */
+				// Set the mask bit for next pixel according to its alignment
 				mask_temp |= (*old_mask_ptr != 15 && *old_mask_ptr != 0) << bit_num;
 				old_mask_ptr++;
 				if (++bit_num > 3) {
@@ -87,23 +86,23 @@ uint make_mask(MASK_IMAGE *new_image, uint page_start, byte *Image,
 			} while (--temp_image_width);
 
 
-			/* Set any partial final mask on this scan line */
+			// Set any partial final mask on this scan line
 			if (bit_num != 0) {
 				*new_mask_ptr = mask_temp;
 				new_mask_ptr++;
 			}
 		}
-		page_offset += size; /* mark off the space we just used */
+		page_offset += size; // Mark off the space we just used
 	}
 	return page_offset - page_start;
 }
 
 void setup_actor(ACTOR *actr, char num, char dir, int x, int y) {
 
-	actr->next = 0;                    //next frame to be shown
+	actr->next = 0;                    // Next frame to be shown
 	actr->frame_count = actr->frame_speed;
-	actr->dir = dir;                   //direction of travel
-	actr->last_dir = dir;              //last direction of travel
+	actr->dir = dir;                   // Direction of travel
+	actr->last_dir = dir;              // Last direction of travel
 	if (actr->directions == 1) actr->dir = 0;
 	if (actr->directions == 2) actr->dir &= 1;
 	if (actr->directions == 4 && actr->frames == 1) {
@@ -111,22 +110,22 @@ void setup_actor(ACTOR *actr, char num, char dir, int x, int y) {
 		actr->next = dir;
 	}
 
-	actr->x = x;                       //actual X coor
-	actr->y = y;                       //actual Y coor
-	actr->width = 16;                  //actual X coor
-	actr->height = 16;                  //actual Y coor
-	actr->center = 0;                        //center of object
-	actr->last_x[0] = x;               //last X coor on each page
+	actr->x = x;                       // Actual X coor
+	actr->y = y;                       // Actual Y coor
+	actr->width = 16;                  // Actual X coor
+	actr->height = 16;                 // Actual Y coor
+	actr->center = 0;                  // Center of object
+	actr->last_x[0] = x;               // Last X coor on each page
 	actr->last_x[1] = x;
-	actr->last_y[0] = y;               //last Y coor on each page
+	actr->last_y[0] = y;               // Last Y coor on each page
 	actr->last_y[1] = y;
-	actr->used = 1;                    //1=active, 0=not active
-	actr->speed_count = 8;             //count down to movement
-	actr->vunerable = STAMINA;         //count down to vunerability
-	actr->shot_cnt = 20;               //count down to another shot
-	actr->num_shots = 0;               //# of shots currently on screen
-	actr->creator = 0;                 //which actor # created this actor
-	actr->pause = 0;                   //pause must be 0 to move
+	actr->used = 1;                    // 1=active, 0=not active
+	actr->speed_count = 8;             // Count down to movement
+	actr->vunerable = STAMINA;         // Count down to vunerability
+	actr->shot_cnt = 20;               // Count down to another shot
+	actr->num_shots = 0;               // # of shots currently on screen
+	actr->creator = 0;                 // which actor # created this actor
+	actr->pause = 0;                   // Pause must be 0 to move
 	actr->show = 0;
 	actr->actor_num = num;
 	actr->counter = 0;
@@ -152,8 +151,7 @@ void make_actor_mask(ACTOR *actr) {
 	}
 }
 
-int load_standard_actors(void) {
-
+int load_standard_actors() {
 	_G(latch_mem) = 50160u;
 	_G(mask_buff) = _G(mask_buff_start);
 	_G(ami_buff) = _G(abuff);
@@ -172,7 +170,7 @@ int load_standard_actors(void) {
 	_G(thor_x2) = _G(thor)->x + 14;
 	_G(thor_y2) = _G(thor)->y + 14;
 
-	load_actor(0, 103 + _G(thor_info).armor);   //load hammer
+	load_actor(0, 103 + _G(thor_info).armor);   // Load hammer
 	memcpy(&_G(actor)[1], (_G(tmp_buff) + 5120), 40);
 	setup_actor(&_G(actor)[1], 1, 0, 100, 100);
 	_G(actor)[1].used = 0;
@@ -194,13 +192,13 @@ int load_standard_actors(void) {
 	_G(explosion).used = 0;
 	make_actor_mask(&_G(explosion));
 
-	load_actor(0, 108);   //load tornado
+	load_actor(0, 108);   // Load tornado
 	memcpy(&_G(magic_item)[0], (_G(tmp_buff) + 5120), 40);
 	memcpy(&_G(magic_pic)[0], _G(tmp_buff), 1024);
 	setup_actor(&_G(magic_item)[0], 20, 0, 0, 0);
 	_G(magic_item)[0].used = 0;
 
-	load_actor(0, 1099);   //load shield
+	load_actor(0, 1099);   // Load shield
 	memcpy(&_G(magic_item)[1], (_G(tmp_buff) + 5120), 40);
 	memcpy(&_G(magic_pic)[1], _G(tmp_buff), 1024);
 	setup_actor(&_G(magic_item)[1], 20, 0, 0, 0);
@@ -210,15 +208,16 @@ int load_standard_actors(void) {
 	_G(magic_ami) = _G(ami_buff);
 	_G(magic_mask_buff) = _G(mask_buff);
 
-	make_actor_mask(&_G(magic_item)[0]);  //to fool next lines
+	make_actor_mask(&_G(magic_item)[0]);  // To fool next lines
 
 	_G(enemy_mb) = _G(mask_buff);
 	_G(enemy_ami) = _G(ami_buff);
 	_G(enemy_lm) = _G(latch_mem);
+
 	return 1;
 }
 
-void show_enemies(void) {
+void show_enemies() {
 	int i, d, r;
 
 	for (i = 3; i < MAX_ACTORS; i++)
@@ -241,8 +240,10 @@ void show_enemies(void) {
 					(_G(scrn).actor_loc[i] / 20) * 16);
 				_G(actor)[i + 3].init_dir = _G(scrn).actor_dir[i];
 				_G(actor)[i + 3].pass_value = _G(scrn).actor_value[i];
-				if (_G(actor)[i + 3].move == 23) {  //spinball
-					if (_G(actor)[i + 3].pass_value & 1) _G(actor)[i + 3].move = 24;
+				if (_G(actor)[i + 3].move == 23) {
+					// Spinball
+					if (_G(actor)[i + 3].pass_value & 1)
+						_G(actor)[i + 3].move = 24;
 				}
 				if (_G(scrn).actor_invis[i]) _G(actor)[i + 3].used = 0;
 			}
@@ -297,6 +298,7 @@ int load_enemy(int type) {
 			}
 		}
 	}
+
 	return e;
 }
 
@@ -339,7 +341,7 @@ void setup_magic_item(int item) {
 	_G(mask_buff) = mb;
 }
 
-void load_new_thor(void) {
+void load_new_thor() {
 	int rep;
 	byte *ami;
 	byte *mb;
@@ -351,13 +353,13 @@ void load_new_thor(void) {
 	_G(mask_buff) = _G(mask_store1);
 	_G(ami_buff) = _G(ami_store1);
 
-	load_actor(0, 100 + _G(thor_info).armor);   //load thor
+	load_actor(0, 100 + _G(thor_info).armor);   // Load thor
 	for (rep = 0; rep < 16; rep++) {
 		make_mask(&_G(actor)[0].pic[rep / 4][rep % 4], PAGE3 + (144 * rep), &_G(tmp_buff)[256 * rep], 16, 16);
 	}
 	_G(mask_buff) = _G(mask_store2);
 	_G(ami_buff) = _G(ami_store2);
-	load_actor(0, 103 + _G(thor_info).armor);   //load hammer
+	load_actor(0, 103 + _G(thor_info).armor);   // Load hammer
 	for (rep = 0; rep < 16; rep++) {
 		make_mask(&_G(actor)[1].pic[rep / 4][rep % 4], 52464u + (144 * rep), &_G(tmp_buff)[256 * rep], 16, 16);
 	}


Commit: bf0a15c45e473c1e9022573db3087dd8cfda21e9
    https://github.com/scummvm/scummvm/commit/bf0a15c45e473c1e9022573db3087dd8cfda21e9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Move image.cpp to gfx/, temporarily disable some init code

Changed paths:
  A engines/got/gfx/image.cpp
  A engines/got/gfx/image.h
  R engines/got/game/image.cpp
  R engines/got/game/image.h
    engines/got/events.cpp
    engines/got/module.mk
    engines/got/views/game.cpp


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 596df9a8660..c97b603dd6f 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -48,7 +48,7 @@ void Events::runGame() {
 	if (saveSlot != -1)
 		g_engine->loadGameState(saveSlot);
 
-	addView("Title");
+	addView("Game");
 
 	Common::Event e;
 	while (!_views.empty() && !shouldQuit()) {
diff --git a/engines/got/game/image.cpp b/engines/got/gfx/image.cpp
similarity index 99%
rename from engines/got/game/image.cpp
rename to engines/got/gfx/image.cpp
index da435af73c5..ebea19e1850 100644
--- a/engines/got/game/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -19,7 +19,7 @@
  *
  */
 
-#include "got/game/image.h"
+#include "got/gfx/image.h"
 #include "got/events.h"
 #include "got/utils/file.h"
 #include "got/got.h"
@@ -160,7 +160,7 @@ int load_standard_actors() {
 	memcpy(&_G(actor)[0], (_G(tmp_buff) + 5120), 40);
 	setup_actor(&_G(actor)[0], 0, 0, 100, 100);
 	_G(thor) = &_G(actor)[0];
-
+#ifdef TODO
 	_G(ami_store1) = _G(ami_buff);
 	_G(mask_store1) = _G(mask_buff);
 	make_actor_mask(&_G(actor)[0]);
@@ -213,7 +213,7 @@ int load_standard_actors() {
 	_G(enemy_mb) = _G(mask_buff);
 	_G(enemy_ami) = _G(ami_buff);
 	_G(enemy_lm) = _G(latch_mem);
-
+#endif
 	return 1;
 }
 
diff --git a/engines/got/game/image.h b/engines/got/gfx/image.h
similarity index 96%
rename from engines/got/game/image.h
rename to engines/got/gfx/image.h
index ed3f67384f6..f0b7b92dcbb 100644
--- a/engines/got/game/image.h
+++ b/engines/got/gfx/image.h
@@ -19,8 +19,8 @@
  *
  */
 
-#ifndef GOT_GAME_IMAGE_H
-#define GOT_GAME_IMAGE_H
+#ifndef GOT_GFX_IMAGE_H
+#define GOT_GFX_IMAGE_H
 
 #include "got/defines.h"
 
diff --git a/engines/got/module.mk b/engines/got/module.mk
index f9615881e8a..b66205c074a 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -8,12 +8,12 @@ MODULE_OBJS = \
 	metaengine.o \
 	sound.o \
 	vars.o \
-	game/image.o \
 	game/status.o \
 	gfx/font.o \
 	gfx/gfx_chunks.o \
 	gfx/gfx_pics.o \
 	gfx/gfx_surface.o \
+	gfx/image.o \
 	gfx/palette.o \
 	utils/compression.o \
 	utils/file.o \
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index ed50b547ccc..6fd77e17bc9 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -20,7 +20,7 @@
  */
 
 #include "got/views/game.h"
-#include "got/game/image.h"
+#include "got/gfx/image.h"
 #include "got/metaengine.h"
 #include "got/vars.h"
 


Commit: 269df0f92b284066794dfa9ad2488414599f5343
    https://github.com/scummvm/scummvm/commit/269df0f92b284066794dfa9ad2488414599f5343
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Add item display to status area

Changed paths:
    engines/got/utils/file.cpp
    engines/got/utils/file.h
    engines/got/vars.cpp
    engines/got/vars.h
    engines/got/views/game_status.cpp
    engines/got/views/game_status.h


diff --git a/engines/got/utils/file.cpp b/engines/got/utils/file.cpp
index dba31301012..959306b4338 100644
--- a/engines/got/utils/file.cpp
+++ b/engines/got/utils/file.cpp
@@ -51,10 +51,6 @@ bool load_sd_data() {
 	return res_read(fname, _G(sd_data)) > 0;
 }
 
-bool load_objects() {
-	return res_read("OBJECTS", _G(objects)) > 0;
-}
-
 bool load_actor(int file, int num) {
 	Common::String fname = Common::String::format("ACTOR%d", num);
 
diff --git a/engines/got/utils/file.h b/engines/got/utils/file.h
index 45022aae14b..3450a365e62 100644
--- a/engines/got/utils/file.h
+++ b/engines/got/utils/file.h
@@ -32,7 +32,6 @@ extern unsigned int read_file(const char *filename, const char *buff,
 	long offset, unsigned int amount, int key);
 
 extern bool load_sd_data();
-extern bool load_objects();
 extern bool load_actor(int file, int num);
 extern bool load_picture(int index, char *buff);
 extern void setup_filenames(int level);
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 30b320e0f89..31a15f35aec 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -32,6 +32,7 @@ Vars *g_vars;
 
 Vars::Vars() :
 		_hampic("HAMPIC", 262, false),
+		_objects("OBJECTS", 262, false),
 		_status("STATUS", -1, false) {
 	g_vars = this;
 }
@@ -41,6 +42,7 @@ void Vars::load() {
 	_gfx.load();
 	_bgPics.load();
 	_hampic.load();
+	_objects.load();
 	_status.load();
 	_sound.load();
 
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 886fab76faf..6a4c992b3b1 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -47,6 +47,8 @@ public:
 	Gfx::BgPics _bgPics;
 	Gfx::Font _font;
 	Gfx::Pics _hampic;
+	Gfx::Pics _objects;
+
 	Gfx::Pics _status;
 	Sound _sound;
 
@@ -72,7 +74,6 @@ public:
 
 	//union REGS in, out = 0;
 	//struct SREGS seg = 0;
-	byte _objects[NUM_OBJECTS][262] = {};
 	int _ox = 0, _oy = 0, _of = 0;
 	byte _object_map[240] = {};
 	byte _object_index[240] = {};
diff --git a/engines/got/views/game_status.cpp b/engines/got/views/game_status.cpp
index b88817070cf..f81cbcc3c0d 100644
--- a/engines/got/views/game_status.cpp
+++ b/engines/got/views/game_status.cpp
@@ -35,30 +35,29 @@ void GameStatus::draw() {
 	s.blitFrom(status);
 
 	// Draw the elements
-	displayHealth();
-	displayMagic();
-	displayJewels();
-	displayScore();
-	displayKeys();
+	displayHealth(s);
+	displayMagic(s);
+	displayJewels(s);
+	displayScore(s);
+	displayKeys(s);
+	displayItem(s);
 }
 
-void GameStatus::displayHealth() {
+void GameStatus::displayHealth(GfxSurface &s) {
 	int b = 59 + _G(thor)->health;
 
-	GfxSurface s = getSurface();
 	s.fillRect(Common::Rect(59, 8, b, 12), 32);
 	s.fillRect(Common::Rect(b, 8, 209, 12), STAT_COLOR);
 }
 
-void GameStatus::displayMagic() {
+void GameStatus::displayMagic(GfxSurface &s) {
 	int b = 59 + _G(thor_info).magic;
 
-	GfxSurface s = getSurface();
 	s.fillRect(Common::Rect(59, 20, b, 24), 96);
 	s.fillRect(Common::Rect(b, 20, 209, 24), STAT_COLOR);
 }
 
-void GameStatus::displayJewels() {
+void GameStatus::displayJewels(GfxSurface &s) {
 	Common::String str = Common::String::format("%d", _G(thor_info).jewels);
 	int x;
 	if (str.size() == 1)
@@ -68,21 +67,19 @@ void GameStatus::displayJewels() {
 	else
 		x = 62;
 
-	GfxSurface s = getSurface();
 	s.fillRect(Common::Rect(59, 32, 85, 42), STAT_COLOR);
 	s.print(Common::Point(x, 32), str, 14);
 }
 
-void GameStatus::displayScore() {
+void GameStatus::displayScore(GfxSurface &s) {
 	Common::String str = Common::String::format("%d", _G(thor_info).score);
 	int x = 276 - (str.size() * 8);
 
-	GfxSurface s = getSurface();
 	s.fillRect(Common::Rect(223, 32, 279, 42), STAT_COLOR);
 	s.print(Common::Point(x, 32), str, 14);
 }
 
-void GameStatus::displayKeys() {
+void GameStatus::displayKeys(GfxSurface &s) {
 	Common::String str = Common::String::format("%d", _G(thor_info).keys);
 
 	int x;
@@ -93,11 +90,20 @@ void GameStatus::displayKeys() {
 	else
 		x = 142;
 
-	GfxSurface s = getSurface();
 	s.fillRect(Common::Rect(139, 32, 164, 42), STAT_COLOR);
 	s.print(Common::Point(x, 32), str, 14);
 }
 
+void GameStatus::displayItem(GfxSurface &s) {
+	s.fillRect(Common::Rect(280, 8, 296, 24), STAT_COLOR);
+
+	if (_G(thor_info).item) {
+		if (_G(thor_info).item == 7)
+			s.blitFrom(_G(objects)[_G(thor_info).object + 10], Common::Point(282, 8));
+		else
+			s.blitFrom(_G(objects)[_G(thor_info).item + 25], Common::Point(282, 8));
+	}
+}
 
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/game_status.h b/engines/got/views/game_status.h
index 9a4ef0c7b76..ecb8b8c245d 100644
--- a/engines/got/views/game_status.h
+++ b/engines/got/views/game_status.h
@@ -29,11 +29,12 @@ namespace Views {
 
 class GameStatus : public View {
 private:
-	void displayHealth();
-	void displayMagic();
-	void displayJewels();
-	void displayScore();
-	void displayKeys();
+	void displayHealth(GfxSurface &s);
+	void displayMagic(GfxSurface &s);
+	void displayJewels(GfxSurface &s);
+	void displayScore(GfxSurface &s);
+	void displayKeys(GfxSurface &s);
+	void displayItem(GfxSurface &s);
 
 public:
 	GameStatus() : View("GameStatus") {}


Commit: 02acac8a2dcf57701770176ab374ff5d4e6817d8
    https://github.com/scummvm/scummvm/commit/02acac8a2dcf57701770176ab374ff5d4e6817d8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added setup_player, setup_level methods

Changed paths:
  A engines/got/game/init.cpp
  A engines/got/game/init.h
    engines/got/module.mk
    engines/got/prototypes.h
    engines/got/views/game.cpp


diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
new file mode 100644
index 00000000000..1fa3e4ffca8
--- /dev/null
+++ b/engines/got/game/init.cpp
@@ -0,0 +1,67 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/game/init.h"
+#include "got/utils/file.h"
+#include "got/events.h"
+#include "got/vars.h"
+
+namespace Got {
+
+int setup_level() {
+	_G(bgPics).setArea(_G(area));
+
+	if (_G(load_game_flag) != 1) {
+		if (!load_sd_data())
+			return 0;
+	}
+
+	return 1;
+}
+
+int setup_player() {
+	memset(&_G(thor_info), 0, sizeof(_G(thor_info)));
+	_G(thor_info).inventory = 0;
+	if (_G(area) > 1) _G(thor_info).inventory |= APPLE_MAGIC + LIGHTNING_MAGIC;
+	if (_G(area) > 2) _G(thor_info).inventory |= BOOTS_MAGIC + WIND_MAGIC;
+
+	_G(thor)->health = 150;
+	_G(thor_info).magic = 0;
+	_G(thor_info).jewels = 0;
+	_G(thor_info).score = 0;
+	_G(thor_info).keys = 0;
+	_G(thor_info).last_item = 0;
+	_G(thor_info).object = 0;
+	_G(thor_info).object_name = nullptr;
+	_G(thor)->x = 152;
+	_G(thor)->y = 96;
+	_G(thor)->last_x[0] = _G(thor)->x;
+	_G(thor)->last_x[1] = _G(thor)->x;
+	_G(thor)->last_y[0] = _G(thor)->y;
+	_G(thor)->last_y[1] = _G(thor)->y;
+	_G(thor_info).last_icon = (6 * 20) + 8;
+	_G(thor_info).last_screen = 23;
+	_G(thor)->dir = 1;
+
+	return 1;
+}
+
+} // namespace Got
diff --git a/engines/got/game/init.h b/engines/got/game/init.h
new file mode 100644
index 00000000000..e0b05877b2f
--- /dev/null
+++ b/engines/got/game/init.h
@@ -0,0 +1,34 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GAME_INIT_H
+#define GOT_GAME_INIT_H
+
+#include "got/defines.h"
+
+namespace Got {
+
+extern int setup_level();
+extern int setup_player();
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/module.mk b/engines/got/module.mk
index b66205c074a..d1040429588 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -8,6 +8,7 @@ MODULE_OBJS = \
 	metaengine.o \
 	sound.o \
 	vars.o \
+	game/init.o \
 	game/status.o \
 	gfx/font.o \
 	gfx/gfx_chunks.o \
diff --git a/engines/got/prototypes.h b/engines/got/prototypes.h
index 6b8f47dd670..20b489e33ac 100644
--- a/engines/got/prototypes.h
+++ b/engines/got/prototypes.h
@@ -158,18 +158,6 @@ void remove_objects(int y, int x);
 void place_tile(int x, int y, int tile);
 int  bgtile(int x, int y);
 
-//G_IMAGE.C
-unsigned int make_mask(MASK_IMAGE *image,
-	unsigned int page_start, char *Image, int image_width,
-	int image_height);
-int  load_standard_actors(void);
-void setup_actor(ACTOR *actr, char num, char dir, int x, int y);
-void show_enemies(void);
-int  load_enemy(int type);
-int actor_visible(int invis_num);
-void setup_magic_item(int item);
-void load_new_thor(void);
-
 //G_MOVE.C
 void next_frame(ACTOR *actr);
 int  point_within(int x, int y, int x1, int y1, int x2, int y2);
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 6fd77e17bc9..a1df7118b85 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "got/views/game.h"
+#include "got/game/init.h"
 #include "got/gfx/image.h"
 #include "got/metaengine.h"
 #include "got/vars.h"
@@ -34,6 +35,11 @@ Game::Game() : View("Game") {
 
 void Game::initialize() {
 	load_standard_actors();
+	if (!setup_player())
+		error("setup_player failed");
+	if (!setup_level())
+		error("setup_level failed");
+	// TODO
 }
 
 bool Game::msgFocus(const FocusMessage &msg) {


Commit: 715615d3bd46a623fb4d46294ddfc942457402b0
    https://github.com/scummvm/scummvm/commit/715615d3bd46a623fb4d46294ddfc942457402b0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: More initialization code

Changed paths:
    engines/got/game/init.cpp
    engines/got/game/init.h
    engines/got/views/game.cpp
    engines/got/views/game.h


diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index 1fa3e4ffca8..c3df9a042db 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -19,7 +19,9 @@
  *
  */
 
+#include "common/textconsole.h"
 #include "got/game/init.h"
+#include "got/gfx/image.h"
 #include "got/utils/file.h"
 #include "got/events.h"
 #include "got/vars.h"
@@ -64,4 +66,35 @@ int setup_player() {
 	return 1;
 }
 
+void initialize() {
+	load_standard_actors();
+	if (!setup_player())
+		error("setup_player failed");
+	if (!setup_level())
+		error("setup_level failed");
+
+	// Handle loading demo key
+	if (_G(rdemo)) {
+		Common::File f;
+		if (f.open("demo.got"))
+			f.read(_G(demo_key), DEMO_LEN);
+	}
+
+	if (_G(record))
+		Common::fill(_G(demo_key), _G(demo_key) + DEMO_LEN, 0);
+
+	if (_G(demo) || _G(record)) {
+		_G(thor)->health = 100;
+		_G(thor_info).magic = 100;
+		_G(thor_info).jewels = 463;
+		_G(thor_info).score = 12455;
+		_G(setup).skill = 0;
+		_G(thor_info).inventory = 1 + 2;
+		_G(current_level) = 54;
+		_G(thor_info).item = 2;
+	}
+
+	_G(new_level) = _G(current_level);
+}
+
 } // namespace Got
diff --git a/engines/got/game/init.h b/engines/got/game/init.h
index e0b05877b2f..934cf31707c 100644
--- a/engines/got/game/init.h
+++ b/engines/got/game/init.h
@@ -26,8 +26,10 @@
 
 namespace Got {
 
-extern int setup_level();
-extern int setup_player();
+/**
+ * Handles in-game initialization the first time
+ */
+extern void initialize();
 
 } // namespace Got
 
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index a1df7118b85..32960e74f3e 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -21,7 +21,6 @@
 
 #include "got/views/game.h"
 #include "got/game/init.h"
-#include "got/gfx/image.h"
 #include "got/metaengine.h"
 #include "got/vars.h"
 
@@ -33,15 +32,6 @@ Game::Game() : View("Game") {
 	_status.setBounds(Common::Rect(0, 240 - 48, 320, 240));
 }
 
-void Game::initialize() {
-	load_standard_actors();
-	if (!setup_player())
-		error("setup_player failed");
-	if (!setup_level())
-		error("setup_level failed");
-	// TODO
-}
-
 bool Game::msgFocus(const FocusMessage &msg) {
 	if (_firstTime) {
 		initialize();
diff --git a/engines/got/views/game.h b/engines/got/views/game.h
index 46b1e62041e..edb867c0e1b 100644
--- a/engines/got/views/game.h
+++ b/engines/got/views/game.h
@@ -33,11 +33,6 @@ private:
 	GameStatus _status;
 	bool _firstTime = true;
 
-	/**
-	 * Handles in-game initialization the first time
-	 */
-	void initialize();
-
 public:
 	Game();
 	virtual ~Game() {}


Commit: 550eae1f38ca0a21c9e9fdd17fc987a2f298202f
    https://github.com/scummvm/scummvm/commit/550eae1f38ca0a21c9e9fdd17fc987a2f298202f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix demo detection entry not working

Changed paths:
    engines/got/detection_tables.h


diff --git a/engines/got/detection_tables.h b/engines/got/detection_tables.h
index 58f1ca5c75f..95dae2c0cae 100644
--- a/engines/got/detection_tables.h
+++ b/engines/got/detection_tables.h
@@ -23,6 +23,7 @@ namespace Got {
 
 const PlainGameDescriptor gotGames[] = {
 	{ "got", "God of Thunder" },
+	{ "gotdemo", "God of Thunder" },
 	{ 0, 0 }
 };
 
@@ -38,7 +39,7 @@ const ADGameDescription gameDescriptions[] = {
 	},
 
 {
-		"got",
+		"gotdemo",
 		"Demo",
 		AD_ENTRY1s("gotres.dat", "747ed508ffa3808156a4eb080e9859f8", 739710),
 		Common::EN_ANY,


Commit: c0bfd761f4d844cddfd4174d5838cf3b76704ee7
    https://github.com/scummvm/scummvm/commit/c0bfd761f4d844cddfd4174d5838cf3b76704ee7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix alignment of item display

Changed paths:
    engines/got/views/game_status.cpp


diff --git a/engines/got/views/game_status.cpp b/engines/got/views/game_status.cpp
index f81cbcc3c0d..1622e86b3ac 100644
--- a/engines/got/views/game_status.cpp
+++ b/engines/got/views/game_status.cpp
@@ -99,9 +99,9 @@ void GameStatus::displayItem(GfxSurface &s) {
 
 	if (_G(thor_info).item) {
 		if (_G(thor_info).item == 7)
-			s.blitFrom(_G(objects)[_G(thor_info).object + 10], Common::Point(282, 8));
+			s.blitFrom(_G(objects)[_G(thor_info).object + 10], Common::Point(280, 8));
 		else
-			s.blitFrom(_G(objects)[_G(thor_info).item + 25], Common::Point(282, 8));
+			s.blitFrom(_G(objects)[_G(thor_info).item + 25], Common::Point(280, 8));
 	}
 }
 


Commit: 6b0176fc5ace77908893fd7a8e3ac652a62eada5
    https://github.com/scummvm/scummvm/commit/6b0176fc5ace77908893fd7a8e3ac652a62eada5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Add LEVEL structure loading

Changed paths:
  A engines/got/data/defines.cpp
  A engines/got/data/defines.h
  R engines/got/defines.h
    engines/got/game/init.cpp
    engines/got/game/init.h
    engines/got/game/status.h
    engines/got/gfx/image.h
    engines/got/module.mk
    engines/got/sound.h
    engines/got/utils/file.h
    engines/got/vars.h


diff --git a/engines/got/data/defines.cpp b/engines/got/data/defines.cpp
new file mode 100644
index 00000000000..e578f5ec5d1
--- /dev/null
+++ b/engines/got/data/defines.cpp
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/data/defines.h"
+
+namespace Got {
+
+void LEVEL::load(Common::SeekableReadStream *src) {
+	for (int i = 0; i < 12; ++i)
+		src->read(icon[i], 20);
+
+	bg_color = src->readByte();
+	type = src->readByte();
+
+	src->read(actor_type, 16);
+	src->read(actor_loc, 16);
+	src->read(actor_value, 16);
+	src->read(pal_colors, 3);
+	src->read(actor_invis, 16);
+	src->read(extra, 13);
+	src->read(static_obj, 30);
+
+	for (int i = 0; i < 30; ++i)
+		static_x[i] = src->readSint16LE();
+	for (int i = 0; i < 30; ++i)
+		static_y[i] = src->readSint16LE();
+
+	src->read(new_level, 10);
+	src->read(new_level_loc, 10);
+
+	area = src->readByte();
+	src->read(actor_dir, 16);
+	src->read(future, 3);
+}
+
+} // namespace Got
diff --git a/engines/got/defines.h b/engines/got/data/defines.h
similarity index 99%
rename from engines/got/defines.h
rename to engines/got/data/defines.h
index 4d004608b32..cf070f0f334 100644
--- a/engines/got/defines.h
+++ b/engines/got/data/defines.h
@@ -61,6 +61,8 @@ struct LEVEL {                    // size=512
 	byte area = 0;                // 472 game area (1=forest,etc)
 	byte actor_dir[16] = {};      // initial dir
 	byte future[3] = {};          // 473
+
+	void load(Common::SeekableReadStream *src);
 };
 
 struct ACTOR {                      //size=256
diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index c3df9a042db..5b67682968e 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "common/memstream.h"
 #include "common/textconsole.h"
 #include "got/game/init.h"
 #include "got/gfx/image.h"
@@ -95,6 +96,11 @@ void initialize() {
 	}
 
 	_G(new_level) = _G(current_level);
+
+	// Load level data
+	Common::MemoryReadStream levelStream(
+		_G(sd_data) + _G(new_level) * 512, 512);
+	_G(scrn).load(&levelStream);
 }
 
 } // namespace Got
diff --git a/engines/got/game/init.h b/engines/got/game/init.h
index 934cf31707c..193db774608 100644
--- a/engines/got/game/init.h
+++ b/engines/got/game/init.h
@@ -22,7 +22,7 @@
 #ifndef GOT_GAME_INIT_H
 #define GOT_GAME_INIT_H
 
-#include "got/defines.h"
+#include "got/data/defines.h"
 
 namespace Got {
 
diff --git a/engines/got/game/status.h b/engines/got/game/status.h
index 79afc7ef9dd..66d20b80d09 100644
--- a/engines/got/game/status.h
+++ b/engines/got/game/status.h
@@ -22,7 +22,7 @@
 #ifndef GOT_GAME_STATUS_H
 #define GOT_GAME_STATUS_H
 
-#include "got/defines.h"
+#include "got/data/defines.h"
 
 namespace Got {
 
diff --git a/engines/got/gfx/image.h b/engines/got/gfx/image.h
index f0b7b92dcbb..ac88f12d9e3 100644
--- a/engines/got/gfx/image.h
+++ b/engines/got/gfx/image.h
@@ -22,7 +22,7 @@
 #ifndef GOT_GFX_IMAGE_H
 #define GOT_GFX_IMAGE_H
 
-#include "got/defines.h"
+#include "got/data/defines.h"
 
 namespace Got {
 
diff --git a/engines/got/module.mk b/engines/got/module.mk
index d1040429588..9e96101278f 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -8,6 +8,7 @@ MODULE_OBJS = \
 	metaengine.o \
 	sound.o \
 	vars.o \
+	data/defines.o \
 	game/init.o \
 	game/status.o \
 	gfx/font.o \
diff --git a/engines/got/sound.h b/engines/got/sound.h
index 0de08a95a26..b17a61215f8 100644
--- a/engines/got/sound.h
+++ b/engines/got/sound.h
@@ -23,7 +23,7 @@
 #define GOT_SOUND_H
 
 #include "audio/mixer.h"
-#include "got/defines.h"
+#include "got/data/defines.h"
 
 namespace Got {
 
diff --git a/engines/got/utils/file.h b/engines/got/utils/file.h
index 3450a365e62..3ff97d7458e 100644
--- a/engines/got/utils/file.h
+++ b/engines/got/utils/file.h
@@ -23,7 +23,7 @@
 #define GOT_UTILS_FILE_H
 
 #include "common/file.h"
-#include "got/defines.h"
+#include "got/data/defines.h"
 
 namespace Got {
 
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 6a4c992b3b1..dff2a767e87 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -24,7 +24,7 @@
 
 #include "common/events.h"
 #include "graphics/screen.h"
-#include "got/defines.h"
+#include "got/data/defines.h"
 #include "got/sound.h"
 #include "got/gfx/font.h"
 #include "got/gfx/gfx_chunks.h"


Commit: 36f0d5455b8b714bd4654f64e1f0e8a76b726eeb
    https://github.com/scummvm/scummvm/commit/36f0d5455b8b714bd4654f64e1f0e8a76b726eeb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: OPENBACK and STORYPIC aren't used by story view

Changed paths:
    engines/got/views/story.cpp


diff --git a/engines/got/views/story.cpp b/engines/got/views/story.cpp
index d077f83a683..60394dd259b 100644
--- a/engines/got/views/story.cpp
+++ b/engines/got/views/story.cpp
@@ -29,11 +29,7 @@ namespace Got {
 namespace Views {
 
 bool Story::msgFocus(const FocusMessage &msg) {
-	char back[4][262];
-
 	res_read(Common::String::format("STORY%d", _G(area)), _G(tmp_buff));
-	res_read("OPENBACK", back);
-	res_read("STORYPIC", back);
 
 	res_read("STORYPAL", _G(pbuff));
 	_G(pbuff)[2] = 0;


Commit: c477386c96dd127053622c414713bf1b70f7a69b
    https://github.com/scummvm/scummvm/commit/c477386c96dd127053622c414713bf1b70f7a69b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Level background is now rendering

Changed paths:
  A engines/got/views/game_content.cpp
  A engines/got/views/game_content.h
    engines/got/module.mk
    engines/got/views/game.cpp
    engines/got/views/game.h


diff --git a/engines/got/module.mk b/engines/got/module.mk
index 9e96101278f..27acc6273d4 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -22,6 +22,7 @@ MODULE_OBJS = \
 	utils/res_archive.o \
 	views/view.o \
 	views/game.o \
+	views/game_content.o \
 	views/game_status.o \
 	views/part_title.o \
 	views/story.o \
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 32960e74f3e..d79d679b058 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -28,7 +28,9 @@ namespace Got {
 namespace Views {
 
 Game::Game() : View("Game") {
+	_children.push_back(&_content);
 	_children.push_back(&_status);
+	_content.setBounds(Common::Rect(0, 0, 320, 240 - 48));
 	_status.setBounds(Common::Rect(0, 240 - 48, 320, 240));
 }
 
diff --git a/engines/got/views/game.h b/engines/got/views/game.h
index edb867c0e1b..df7ee18f9b3 100644
--- a/engines/got/views/game.h
+++ b/engines/got/views/game.h
@@ -23,6 +23,7 @@
 #define GOT_VIEWS_GAME_H
 
 #include "got/views/view.h"
+#include "got/views/game_content.h"
 #include "got/views/game_status.h"
 
 namespace Got {
@@ -30,6 +31,7 @@ namespace Views {
 
 class Game : public View {
 private:
+	GameContent _content;
 	GameStatus _status;
 	bool _firstTime = true;
 
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
new file mode 100644
index 00000000000..449c3147331
--- /dev/null
+++ b/engines/got/views/game_content.cpp
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/game_content.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+
+#define TILE_SIZE 16
+
+void GameContent::draw() {
+	GfxSurface s = getSurface();
+	s.clear();
+
+	for (int y = 0; y < (s.h / TILE_SIZE); y++) {
+		for (int x = 0; x < (s.w / TILE_SIZE); x++) {
+			if (_G(scrn).icon[y][x] != 0) {
+				const Common::Point pt(x * TILE_SIZE, y * TILE_SIZE);
+				s.blitFrom(_G(bgPics)[_G(scrn).bg_color], pt);
+				s.blitFrom(_G(bgPics)[_G(scrn).icon[y][x]], pt);
+			}
+		}
+	}
+}
+
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
new file mode 100644
index 00000000000..af4368d748e
--- /dev/null
+++ b/engines/got/views/game_content.h
@@ -0,0 +1,41 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_GAME_CONTENT_H
+#define GOT_VIEWS_GAME_CONTENT_H
+
+#include "got/views/view.h"
+
+namespace Got {
+namespace Views {
+
+class GameContent : public View {
+public:
+	GameContent() : View("GameContent") {}
+	virtual ~GameContent() {}
+
+	void draw() override;
+};
+
+} // namespace Views
+} // namespace Got
+
+#endif


Commit: 9f298f5d91e37c08d9febef283628084fd23a3c7
    https://github.com/scummvm/scummvm/commit/9f298f5d91e37c08d9febef283628084fd23a3c7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Add rendering of static objects

Changed paths:
    engines/got/data/defines.h
    engines/got/vars.h
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index cf070f0f334..ae894a73bc6 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -43,6 +43,8 @@ struct MASK_IMAGE {
 	ALIGNED_MASK_IMAGE *alignments[4] = { nullptr, nullptr, nullptr, nullptr };
 };
 
+#define OBJECTS_COUNT 30
+
 struct LEVEL {                    // size=512
 	byte icon[12][20] = {};       // 0   grid of icons
 	byte bg_color = 0;            // 240 background color
@@ -53,9 +55,9 @@ struct LEVEL {                    // size=512
 	byte pal_colors[3] = {};      // change 251,253,254 to these three
 	byte actor_invis[16] = {};
 	byte extra[13] = {};
-	byte static_obj[30] = {};     // 302 static objects (treasure, keys,etc)
-	int  static_x[30] = {};       // 332 X coor of static objects
-	int  static_y[30] = {};       // 392 Y coor of static objects
+	byte static_obj[OBJECTS_COUNT] = {};     // 302 static objects (treasure, keys,etc)
+	int  static_x[OBJECTS_COUNT] = {};       // 332 X coor of static objects
+	int  static_y[OBJECTS_COUNT] = {};       // 392 Y coor of static objects
 	byte new_level[10] = {};      // 452 level jump for icon 200-204
 	byte new_level_loc[10] = {};  // 462 grid location to jump in to
 	byte area = 0;                // 472 game area (1=forest,etc)
diff --git a/engines/got/vars.h b/engines/got/vars.h
index dff2a767e87..4d8353013eb 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -32,6 +32,11 @@
 
 namespace Got {
 
+#define TILE_SIZE 16
+#define TILES_X (320 / TILE_SIZE)
+#define TILES_Y (192 / TILE_SIZE)
+#define TILES_COUNT (TILES_X * TILES_Y)
+
 class Vars;
 
 extern Vars *g_vars;
@@ -75,8 +80,8 @@ public:
 	//union REGS in, out = 0;
 	//struct SREGS seg = 0;
 	int _ox = 0, _oy = 0, _of = 0;
-	byte _object_map[240] = {};
-	byte _object_index[240] = {};
+	byte _object_map[TILES_COUNT] = {};
+	byte _object_index[TILES_COUNT] = {};
 	byte *_bleep = nullptr;
 	int8 _thor_icon1 = 0, _thor_icon2 = 0, _thor_icon3 = 0,
 		_thor_icon4 = 0;
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 449c3147331..b4cbefe07ee 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -25,14 +25,28 @@
 namespace Got {
 namespace Views {
 
-#define TILE_SIZE 16
-
 void GameContent::draw() {
 	GfxSurface s = getSurface();
 	s.clear();
 
-	for (int y = 0; y < (s.h / TILE_SIZE); y++) {
-		for (int x = 0; x < (s.w / TILE_SIZE); x++) {
+	int save_d;
+
+	_G(boss_active) = 0;
+	if (!_G(shield_on))
+		_G(actor)[2].used = 0;
+	_G(bomb_flag) = 0;
+
+	save_d = _G(thor)->dir;
+	if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154)
+		_G(thor)->dir = 0;
+
+	drawBackground(s);
+	drawObjects(s);
+}
+
+void GameContent::drawBackground(GfxSurface &s) {
+	for (int y = 0; y < TILES_Y; y++) {
+		for (int x = 0; x < TILES_X; x++) {
 			if (_G(scrn).icon[y][x] != 0) {
 				const Common::Point pt(x * TILE_SIZE, y * TILE_SIZE);
 				s.blitFrom(_G(bgPics)[_G(scrn).bg_color], pt);
@@ -42,5 +56,24 @@ void GameContent::draw() {
 	}
 }
 
+void GameContent::drawObjects(GfxSurface &s) {
+	int i, p;
+
+	Common::fill(_G(object_map), _G(object_map) + TILES_COUNT, 0);
+	Common::fill(_G(object_index), _G(object_index) + TILES_COUNT, 0);
+
+	for (i = 0; i < OBJECTS_COUNT; i++) {
+		if (_G(scrn).static_obj[i]) {
+			s.blitFrom(_G(objects)[_G(scrn).static_obj[i] - 1],
+				Common::Point(_G(scrn).static_x[i] * TILE_SIZE,
+					_G(scrn).static_y[i] * TILE_SIZE));
+
+			p = _G(scrn).static_x[i] + (_G(scrn).static_y[i] * TILES_X);
+			_G(object_index)[p] = i;
+			_G(object_map)[p] = _G(scrn).static_obj[i];
+		}
+	}
+}
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index af4368d748e..5250be08894 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -28,6 +28,10 @@ namespace Got {
 namespace Views {
 
 class GameContent : public View {
+private:
+	void drawBackground(GfxSurface &s);
+	void drawObjects(GfxSurface &s);
+
 public:
 	GameContent() : View("GameContent") {}
 	virtual ~GameContent() {}


Commit: 6fa83a28f91cc6ba26aa060723faa14beb1254e2
    https://github.com/scummvm/scummvm/commit/6fa83a28f91cc6ba26aa060723faa14beb1254e2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: In progress enemies loading

Changed paths:
  A engines/got/game/back.cpp
  A engines/got/game/back.h
    engines/got/data/defines.h
    engines/got/gfx/image.cpp
    engines/got/gfx/image.h
    engines/got/module.mk
    engines/got/prototypes.h
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index ae894a73bc6..6b2fe5b5439 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -24,9 +24,11 @@
 
 #include "common/scummsys.h"
 #include "common/stream.h"
+#include "graphics/managed_surface.h"
 
 namespace Got {
 
+#ifdef DEPRECATED
 /**
  * Describes one alignment of a mask - image pair
  */
@@ -40,8 +42,9 @@ struct MASK_IMAGE {
 	// ptrs to AlignedMaskedImage
 	// structs for four possible destination
 	// image alignments
-	ALIGNED_MASK_IMAGE *alignments[4] = { nullptr, nullptr, nullptr, nullptr };
+	ALIGNED_MASK_IMAGE *alignments[4] = {};
 };
+#endif
 
 #define OBJECTS_COUNT 30
 
@@ -67,59 +70,64 @@ struct LEVEL {                    // size=512
 	void load(Common::SeekableReadStream *src);
 };
 
-struct ACTOR {                      //size=256
-	// first part loaded from disk  (size=40)
-	byte move = 0;                  //movement pattern (0=none)
-	byte width = 0;                 //physical width
-	byte height = 0;                //physical height
-	byte directions = 0;            //1,2 or 4 (1=uni-directional)
-	byte frames = 0;                //# frames per direction
-	byte frame_speed = 0;           //# cycles between frame changes
-	byte frame_sequence[4] = {};    //sequence
-	byte speed = 0;                 //move every Nth cycle
-	byte size_x = 0;                //non-physical padding on X coor
-	byte size_y = 0;                //non-phsyical padding on Y coor
-	byte strength = 0;              //hit strength
-	byte health = 0;                //
-	byte num_moves = 0;             //# of moves every <speed> cycles
-	byte shot_type = 0;             //actor # of shot
-	byte shot_pattern = 0;          //func number to decide to shoot
-	byte shots_allowed = 0;         //# shots allowed on screen
-	byte solid = 0;                 //1=solid (not ghost,etc)
-	byte flying = 0;                //
-	byte rating = 0;                //rnd(100) < rating = jewel
-	byte type = 0;                  //actor (0=thor,1=hammer,2=enemy,3=shot)
-	byte name[9] = {};              //actors name
-	byte func_num = 0;              //special function when thor touches
-	byte func_pass = 0;             //value to pass to func
-	int  magic_hurts = 0;           //bitwise magic hurts flags
+#define DIRECTION_COUNT 4
+#define FRAME_COUNT 4
+
+struct ACTOR {                      // Size=256
+	// First part loaded from disk  (size=40)
+	byte move = 0;                  // Movement pattern (0=none)
+	byte width = 0;                 // Physical width
+	byte height = 0;                // Physical height
+	byte directions = 0;            // 1,2 or 4 (1=uni-directional)
+	byte frames = 0;                // # frames per direction
+	byte frame_speed = 0;           // # cycles between frame changes
+	byte frame_sequence[4] = {};    // Sequence
+	byte speed = 0;                 // Move every Nth cycle
+	byte size_x = 0;                // Non-physical padding on X coor
+	byte size_y = 0;                // Non-phsyical padding on Y coor
+	byte strength = 0;              // Hit strength
+	byte health = 0;                // 
+	byte num_moves = 0;             // # of moves every <speed> cycles
+	byte shot_type = 0;             // Actor # of shot
+	byte shot_pattern = 0;          // Func number to decide to shoot
+	byte shots_allowed = 0;         // # shots allowed on screen
+	byte solid = 0;                 // 1=solid (not ghost,etc)
+	byte flying = 0;                // 
+	byte rating = 0;                // rnd(100) < rating = jewel
+	byte type = 0;                  // Actor (0=thor,1=hammer,2=enemy,3=shot)
+	byte name[9] = {};              // Actors name
+	byte func_num = 0;              // Special function when thor touches
+	byte func_pass = 0;             // Value to pass to func
+	int  magic_hurts = 0;           // Bitwise magic hurts flags
 	byte future1[4] = {};
 
-	//the rest is dynamic    //size=216
-	MASK_IMAGE pic[4][4] = {};      //mask image pointers
-	byte frame_count = 0;           //count to switch frames
-	byte dir = 0;                   //direction of travel
-	byte last_dir = 0;              //last direction of travel
-	int  x = 0;                     //actual X coor
-	int  y = 0;                     //actual Y coor
-	int  center = 0;                //center of object
-	int  last_x[2] = {};            //last X coor on each page
-	int  last_y[2] = {};            //last Y coor on each page
-	byte used = 0;                  //1=active, 0=not active
-	byte next = 0;                  //next frame to be shown
-	byte speed_count = 0;           //count down to movement
-	byte vunerable = 0;             //count down to vunerability
-	byte shot_cnt = 0;              //count down to another shot
-	byte num_shots = 0;             //# of shots currently on screen
-	byte creator = 0;               //which actor # created this actor
-	byte pause = 0;                 //pause must be 0 to move
+	// The rest is dynamic    //size=216
+	// Direction/frame surfaces
+	Graphics::ManagedSurface pic[DIRECTION_COUNT][FRAME_COUNT];
+
+	byte frame_count = 0;           // Count to switch frames
+	byte dir = 0;                   // Direction of travel
+	byte last_dir = 0;              // Last direction of travel
+	int  x = 0;                     // Actual X coor
+	int  y = 0;                     // Actual Y coor
+	int  center = 0;                // Center of object
+	int  last_x[2] = {};            // Last X coor on each page
+	int  last_y[2] = {};            // Last Y coor on each page
+	byte used = 0;                  // 1=active, 0=not active
+	byte next = 0;                  // Next frame to be shown
+	byte speed_count = 0;           // Count down to movement
+	byte vunerable = 0;             // Count down to vunerability
+	byte shot_cnt = 0;              // Count down to another shot
+	byte num_shots = 0;             // # of shots currently on screen
+	byte creator = 0;               // Which actor # created this actor
+	byte pause = 0;                 // Pause must be 0 to move
 	byte actor_num = 0;
 	byte move_count = 0;
 	byte dead = 0;
 	byte toggle = 0;
 	byte center_x = 0;
 	byte center_y = 0;
-	byte show = 0;                  //display or not (for blinking)
+	byte show = 0;                  // Display or not (for blinking)
 	byte temp1 = 0;
 	byte temp2 = 0;
 	byte counter = 0;
diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
new file mode 100644
index 00000000000..d384cb8519d
--- /dev/null
+++ b/engines/got/game/back.cpp
@@ -0,0 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/game/back.h"
+
+namespace Got {
+
+
+} // namespace Got
diff --git a/engines/got/game/back.h b/engines/got/game/back.h
new file mode 100644
index 00000000000..203cbad7875
--- /dev/null
+++ b/engines/got/game/back.h
@@ -0,0 +1,32 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GAME_BACK_H
+#define GOT_GAME_BACK_H
+
+#include "got/data/defines.h"
+
+namespace Got {
+
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index ebea19e1850..0a85890a164 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -27,76 +27,6 @@
 
 namespace Got {
 
-void xcopys2d(int SourceStartX, int SourceStartY,
-		int SourceEndX, int SourceEndY, int DestStartX,
-		int DestStartY, byte *SourcePtr, unsigned int DestPageBase,
-		int SourceBitmapWidth, int DestBitmapWidth) {
-	error("TODO: Refactor this to use surfaces");
-}
-
-
-uint make_mask(MASK_IMAGE *new_image, uint page_start, byte *Image,
-		int image_width, int image_height) {
-	uint page_offset, size;
-	int align, set;
-	ALIGNED_MASK_IMAGE *work_ami;
-	int scan_line, bit_num, temp_image_width;
-	unsigned char mask_temp;
-	byte *new_mask_ptr;
-	byte *old_mask_ptr;
-
-	page_offset = page_start;
-	set = 0;
-
-	for (align = 0; align < 3; align += 2) {
-		work_ami = new_image->alignments[set++] = (ALIGNED_MASK_IMAGE *)_G(ami_buff);
-		_G(ami_buff) += sizeof(ALIGNED_MASK_IMAGE);
-
-		work_ami->image_width = (image_width + align + 3) / 4;
-		work_ami->image_ptr = page_offset;	// Image dest
-
-		// Download this alignment of the image
-		xcopys2d(0, 0, image_width, image_height, align, 0,
-			Image, page_offset, image_width,
-			work_ami->image_width * 4);
-
-		// Calculate the number of bytes needed to store the mask in
-		// nibble (Map Mask-ready) form, then allocate that space */
-		size = work_ami->image_width * image_height;
-		work_ami->mask_ptr = (byte *)_G(mask_buff);
-		_G(mask_buff) += size;
-
-		/* Generate this nibble oriented (Map Mask-ready) alignment of
-		   the mask, one scan line at a time */
-		old_mask_ptr = Image;
-		new_mask_ptr = work_ami->mask_ptr;
-		for (scan_line = 0; scan_line < image_height; scan_line++) {
-			bit_num = align;
-			mask_temp = 0;
-			temp_image_width = image_width;
-			do {
-				// Set the mask bit for next pixel according to its alignment
-				mask_temp |= (*old_mask_ptr != 15 && *old_mask_ptr != 0) << bit_num;
-				old_mask_ptr++;
-				if (++bit_num > 3) {
-					*new_mask_ptr = mask_temp;
-					new_mask_ptr++;
-					mask_temp = bit_num = 0;
-				}
-			} while (--temp_image_width);
-
-
-			// Set any partial final mask on this scan line
-			if (bit_num != 0) {
-				*new_mask_ptr = mask_temp;
-				new_mask_ptr++;
-			}
-		}
-		page_offset += size; // Mark off the space we just used
-	}
-	return page_offset - page_start;
-}
-
 void setup_actor(ACTOR *actr, char num, char dir, int x, int y) {
 
 	actr->next = 0;                    // Next frame to be shown
@@ -137,12 +67,18 @@ void setup_actor(ACTOR *actr, char num, char dir, int x, int y) {
 	actr->init_health = actr->health;
 }
 
-void make_actor_mask(ACTOR *actr) {
+void make_actor_surface(ACTOR *actr) {
 	int d, f;
 
+	assert(actr->directions <= 4 && actr->frames <= 4);
 	for (d = 0; d < actr->directions; d++) {
 		for (f = 0; f < actr->frames; f++) {
-			make_mask(&actr->pic[d][f], _G(latch_mem), &_G(tmp_buff)[256 * ((d * 4) + f)], 16, 16);
+			Graphics::ManagedSurface &s = actr->pic[d][f];
+			if (s.empty())
+				s.create(16, 16);
+			const byte *src = &_G(tmp_buff)[256 * ((d * 4) + f)];
+			Common::copy(src, src + 16 * 16, (byte *)s.getPixels());
+
 			_G(latch_mem) += 144;
 			if (_G(latch_mem) > 65421u) {
 				error("Too Many Actor Frames=");
@@ -156,14 +92,14 @@ int load_standard_actors() {
 	_G(mask_buff) = _G(mask_buff_start);
 	_G(ami_buff) = _G(abuff);
 
-	load_actor(0, 100 + _G(thor_info).armor);   // Load thor
+	load_actor(0, 100 + _G(thor_info).armor);   // Load Thor
 	memcpy(&_G(actor)[0], (_G(tmp_buff) + 5120), 40);
 	setup_actor(&_G(actor)[0], 0, 0, 100, 100);
 	_G(thor) = &_G(actor)[0];
-#ifdef TODO
+
 	_G(ami_store1) = _G(ami_buff);
 	_G(mask_store1) = _G(mask_buff);
-	make_actor_mask(&_G(actor)[0]);
+	make_actor_surface(&_G(actor)[0]);
 
 	_G(thor_x1) = _G(thor)->x + 2;
 	_G(thor_y1) = _G(thor)->y + 2;
@@ -178,19 +114,19 @@ int load_standard_actors() {
 
 	_G(ami_store2) = _G(ami_buff);
 	_G(mask_store2) = _G(mask_buff);
-	make_actor_mask(&_G(actor)[1]);
+	make_actor_surface(&_G(actor)[1]);
 
 	load_actor(0, 106);   // Load sparkle
 	memcpy(&_G(sparkle), (_G(tmp_buff) + 5120), 40);
 	setup_actor(&_G(sparkle), 20, 0, 100, 100);
 	_G(sparkle).used = 0;
-	make_actor_mask(&_G(sparkle));
+	make_actor_surface(&_G(sparkle));
 
 	load_actor(0, 107);   // Load explosion
 	memcpy(&_G(explosion), (_G(tmp_buff) + 5120), 40);
 	setup_actor(&_G(explosion), 21, 0, 100, 100);
 	_G(explosion).used = 0;
-	make_actor_mask(&_G(explosion));
+	make_actor_surface(&_G(explosion));
 
 	load_actor(0, 108);   // Load tornado
 	memcpy(&_G(magic_item)[0], (_G(tmp_buff) + 5120), 40);
@@ -208,12 +144,12 @@ int load_standard_actors() {
 	_G(magic_ami) = _G(ami_buff);
 	_G(magic_mask_buff) = _G(mask_buff);
 
-	make_actor_mask(&_G(magic_item)[0]);  // To fool next lines
+	make_actor_surface(&_G(magic_item)[0]);  // To fool next lines
 
 	_G(enemy_mb) = _G(mask_buff);
 	_G(enemy_ami) = _G(ami_buff);
 	_G(enemy_lm) = _G(latch_mem);
-#endif
+
 	return 1;
 }
 
@@ -275,10 +211,10 @@ int load_enemy(int type) {
 
 	memcpy(&_G(enemy)[e], enm, sizeof(ACTOR_NFO));
 
-	make_actor_mask(&_G(enemy)[e]);
+	make_actor_surface(&_G(enemy)[e]);
 	_G(enemy_type)[e] = type;
 	_G(enemy)[e].shot_type = 0;
-
+#ifdef TODO
 	if (_G(enemy)[e].shots_allowed) {
 		_G(enemy)[e].shot_type = e + 1;
 		enm = (ACTOR *)(_G(tmp_buff) + 5160);
@@ -298,7 +234,7 @@ int load_enemy(int type) {
 			}
 		}
 	}
-
+#endif
 	return e;
 }
 
@@ -323,6 +259,7 @@ int actor_visible(int invis_num) {
 }
 
 void setup_magic_item(int item) {
+#ifdef TODO
 	int i;
 	byte *ami;
 	byte *mb;
@@ -339,9 +276,13 @@ void setup_magic_item(int item) {
 	}
 	_G(ami_buff) = ami;
 	_G(mask_buff) = mb;
+#else
+	error("TODO: setup_magic_item");
+#endif
 }
 
 void load_new_thor() {
+#ifdef TODO
 	int rep;
 	byte *ami;
 	byte *mb;
@@ -366,6 +307,9 @@ void load_new_thor() {
 
 	_G(ami_buff) = ami;
 	_G(mask_buff) = mb;
+#else
+	error("TODO: load_new_thor");
+#endif
 }
 
 } // namespace Got
diff --git a/engines/got/gfx/image.h b/engines/got/gfx/image.h
index ac88f12d9e3..fa7af7943fc 100644
--- a/engines/got/gfx/image.h
+++ b/engines/got/gfx/image.h
@@ -26,8 +26,8 @@
 
 namespace Got {
 
-extern uint make_mask(MASK_IMAGE *new_image, uint page_start,
-	byte *Image, int image_width, int image_height);
+//extern uint make_mask(MASK_IMAGE *new_image, uint page_start,
+//	byte *Image, int image_width, int image_height);
 extern void setup_actor(ACTOR *actr, char num, char dir, int x, int y);
 extern void make_actor_mask(ACTOR *actr);
 extern int load_standard_actors();
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 27acc6273d4..6ff6f6b6d8b 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -9,6 +9,7 @@ MODULE_OBJS = \
 	sound.o \
 	vars.o \
 	data/defines.o \
+	game/back.o \
 	game/init.o \
 	game/status.o \
 	gfx/font.o \
diff --git a/engines/got/prototypes.h b/engines/got/prototypes.h
index 20b489e33ac..9e62bdd4d4c 100644
--- a/engines/got/prototypes.h
+++ b/engines/got/prototypes.h
@@ -28,6 +28,7 @@ namespace Got {
 
 //G_LIB.LIB
 
+#ifdef DEPRECATED
 void xsetmode(void);
 void xshowpage(unsigned page);
 void xline(int x0, int y0, int x1, int y1, int page, int color);
@@ -74,6 +75,7 @@ void xddfast(int source_x, int source_y, int width, int height,
 	unsigned int source_page, unsigned int dest_page);
 void xsetpal(unsigned char color, unsigned char R, unsigned char G, unsigned char B);
 void xgetpal(char *pal, int num_colrs, int start_index);
+#endif
 
 //G_MAIN.C
 void run_gotm(void);
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index b4cbefe07ee..91ed408a959 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "got/views/game_content.h"
+#include "got/gfx/image.h"
 #include "got/vars.h"
 
 namespace Got {
@@ -37,11 +38,17 @@ void GameContent::draw() {
 	_G(bomb_flag) = 0;
 
 	save_d = _G(thor)->dir;
+	_G(thor)->next = 0;
 	if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154)
 		_G(thor)->dir = 0;
 
 	drawBackground(s);
 	drawObjects(s);
+#ifdef TODO
+	setupEnemies();
+	drawEnemies(s, &_G(actor)[MAX_ACTORS - 1]);
+#endif
+	_G(thor)->dir = save_d;
 }
 
 void GameContent::drawBackground(GfxSurface &s) {
@@ -75,5 +82,73 @@ void GameContent::drawObjects(GfxSurface &s) {
 	}
 }
 
+void GameContent::setupEnemies() {
+	int i, d, r;
+
+	for (i = 3; i < MAX_ACTORS; i++)
+		_G(actor)[i].used = 0;
+	for (i = 0; i < MAX_ENEMIES; i++)
+		_G(enemy_type)[i] = 0;
+
+	_G(latch_mem) = _G(enemy_lm);
+	_G(mask_buff) = _G(enemy_mb);
+	_G(ami_buff) = _G(enemy_ami);
+
+	for (i = 0; i < MAX_ENEMIES; i++) {
+		if (_G(scrn).actor_type[i] > 0) {
+			r = load_enemy(_G(scrn).actor_type[i]);
+
+			if (r >= 0) {
+				memcpy(&_G(actor)[i + 3], &_G(enemy)[r], sizeof(ACTOR));
+				d = _G(scrn).actor_dir[i];
+
+				setup_actor(&_G(actor)[i + 3], i + 3, d, (_G(scrn).actor_loc[i] % 20) * 16,
+					(_G(scrn).actor_loc[i] / 20) * 16);
+				_G(actor)[i + 3].init_dir = _G(scrn).actor_dir[i];
+				_G(actor)[i + 3].pass_value = _G(scrn).actor_value[i];
+
+				if (_G(actor)[i + 3].move == 23) {
+					// Spinball
+					if (_G(actor)[i + 3].pass_value & 1)
+						_G(actor)[i + 3].move = 24;
+				}
+
+				if (_G(scrn).actor_invis[i])
+					_G(actor)[i + 3].used = 0;
+			}
+
+			_G(etype)[i] = r;
+		}
+	}
+}
+
+void GameContent::drawEnemies(GfxSurface &s, ACTOR *lastActor) {
+	ACTOR *actor_ptr = lastActor;
+	ACTOR *actor2_storage = nullptr;
+
+	for (int actor_num = 0; actor_num <= MAX_ACTORS; ) {
+		// Check for blinking flag
+		if (!(actor_ptr->show & 2)) {
+			actor_ptr->last_x[0] = actor_ptr->x;
+			actor_ptr->last_y[0] = actor_ptr->y;
+
+			const Graphics::ManagedSurface &frame = actor_ptr->pic[actor_ptr->dir]
+				[actor_ptr->frame_sequence[actor_ptr->next]];
+			s.blitFrom(frame, Common::Point(actor_ptr->x, actor_ptr->y));
+		}
+
+		// Move to the next actor
+		do {
+			--actor_ptr;
+			++actor_num;
+
+			if (actor_num == MAX_ACTORS)
+				actor_ptr = actor2_storage;
+			else if (actor_num == (MAX_ACTORS - 3))
+				actor2_storage = actor_ptr;
+		} while (actor_num == (MAX_ACTORS - 3));
+	}
+}
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index 5250be08894..fdf76364df0 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -23,6 +23,7 @@
 #define GOT_VIEWS_GAME_CONTENT_H
 
 #include "got/views/view.h"
+#include "got/data/defines.h"
 
 namespace Got {
 namespace Views {
@@ -31,6 +32,8 @@ class GameContent : public View {
 private:
 	void drawBackground(GfxSurface &s);
 	void drawObjects(GfxSurface &s);
+	void setupEnemies();
+	void drawEnemies(GfxSurface &s, ACTOR *lastActor);
 
 public:
 	GameContent() : View("GameContent") {}


Commit: 6b4ecbf61eca8dfc4e5c5b9f0924881b8d9da320
    https://github.com/scummvm/scummvm/commit/6b4ecbf61eca8dfc4e5c5b9f0924881b8d9da320
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: More level setup

Changed paths:
  A engines/got/game/main.cpp
  A engines/got/game/main.h
    engines/got/data/defines.cpp
    engines/got/data/defines.h
    engines/got/game/back.cpp
    engines/got/game/back.h
    engines/got/game/init.cpp
    engines/got/gfx/image.cpp
    engines/got/module.mk
    engines/got/prototypes.h
    engines/got/vars.h
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/data/defines.cpp b/engines/got/data/defines.cpp
index e578f5ec5d1..38a3648a3da 100644
--- a/engines/got/data/defines.cpp
+++ b/engines/got/data/defines.cpp
@@ -23,32 +23,32 @@
 
 namespace Got {
 
-void LEVEL::load(Common::SeekableReadStream *src) {
+void LEVEL::sync(Common::Serializer &s) {
 	for (int i = 0; i < 12; ++i)
-		src->read(icon[i], 20);
+		s.syncBytes(icon[i], 20);
 
-	bg_color = src->readByte();
-	type = src->readByte();
+	s.syncAsByte(bg_color);
+	s.syncAsByte(type);
 
-	src->read(actor_type, 16);
-	src->read(actor_loc, 16);
-	src->read(actor_value, 16);
-	src->read(pal_colors, 3);
-	src->read(actor_invis, 16);
-	src->read(extra, 13);
-	src->read(static_obj, 30);
+	s.syncBytes(actor_type, 16);
+	s.syncBytes(actor_loc, 16);
+	s.syncBytes(actor_value, 16);
+	s.syncBytes(pal_colors, 3);
+	s.syncBytes(actor_invis, 16);
+	s.syncBytes(extra, 13);
+	s.syncBytes(static_obj, 30);
 
 	for (int i = 0; i < 30; ++i)
-		static_x[i] = src->readSint16LE();
+		s.syncAsSint16LE(static_x[i]);
 	for (int i = 0; i < 30; ++i)
-		static_y[i] = src->readSint16LE();
+		s.syncAsSint16LE(static_y[i]);
 
-	src->read(new_level, 10);
-	src->read(new_level_loc, 10);
+	s.syncBytes(new_level, 10);
+	s.syncBytes(new_level_loc, 10);
 
-	area = src->readByte();
-	src->read(actor_dir, 16);
-	src->read(future, 3);
+	s.syncAsByte(area);
+	s.syncBytes(actor_dir, 16);
+	s.syncBytes(future, 3);
 }
 
 } // namespace Got
diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index 6b2fe5b5439..2909e9194a5 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -23,7 +23,7 @@
 #define GOT_DEFINES_H
 
 #include "common/scummsys.h"
-#include "common/stream.h"
+#include "common/serializer.h"
 #include "graphics/managed_surface.h"
 
 namespace Got {
@@ -58,6 +58,7 @@ struct LEVEL {                    // size=512
 	byte pal_colors[3] = {};      // change 251,253,254 to these three
 	byte actor_invis[16] = {};
 	byte extra[13] = {};
+
 	byte static_obj[OBJECTS_COUNT] = {};     // 302 static objects (treasure, keys,etc)
 	int  static_x[OBJECTS_COUNT] = {};       // 332 X coor of static objects
 	int  static_y[OBJECTS_COUNT] = {};       // 392 Y coor of static objects
@@ -67,7 +68,15 @@ struct LEVEL {                    // size=512
 	byte actor_dir[16] = {};      // initial dir
 	byte future[3] = {};          // 473
 
-	void load(Common::SeekableReadStream *src);
+	void sync(Common::Serializer &s);
+	void load(Common::SeekableReadStream *src) {
+		Common::Serializer s(src, nullptr);
+		sync(s);
+	}
+	void save(Common::WriteStream *dest) {
+		Common::Serializer s(nullptr, dest);
+		sync(s);
+	}
 };
 
 #define DIRECTION_COUNT 4
diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index d384cb8519d..cf2e538367b 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -19,9 +19,124 @@
  *
  */
 
+#include "common/memstream.h"
 #include "got/game/back.h"
+#include "got/gfx/image.h"
+#include "got/vars.h"
 
 namespace Got {
 
+void show_level(int new_level) {
+	int save_d;
+
+	_G(boss_active) = 0;
+	if (!_G(shield_on))
+		_G(actor)[2].used = 0;
+	_G(bomb_flag) = 0;
+
+	save_d = _G(thor)->dir;
+	if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154)
+		_G(thor)->dir = 0;
+
+	// The original copied 130 bytes from scrn.static_object onwards into sd_data.
+	// This doesn't make sense, because that would put the ending in the middle of static_y.
+	// Plus, it follows with an entire copy of scrn into sd_data anyway, so the first
+	// move seems entirely redundant.
+	Common::MemoryWriteStream outStream(_G(sd_data) + (_G(current_level) * 512), 512);
+	_G(scrn).save(&outStream);
+	Common::MemoryReadStream inStream(_G(sd_data) + (_G(current_level) * 512), 512);
+	_G(scrn).load(&inStream);
+
+	_G(scrnp) = (byte *)&_G(scrn);
+	_G(level_type) = _G(scrn).type;
+
+	_G(thor)->next = 0;
+	//xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], PAGE2);
+
+	//build_screen(draw_page);
+	//show_objects(new_level, draw_page);
+	show_enemies();
+
+	if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154) _G(thor)->dir = 0;
+	//xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], draw_page);
+	_G(thor)->dir = save_d;
+
+	if (_G(warp_flag))
+		_G(current_level) = new_level - 5;   //force phase
+
+	_G(warp_flag) = 0;
+	if (_G(warp_scroll)) {
+		_G(warp_scroll) = 0;
+		if (_G(thor)->dir == 0)
+			_G(current_level) = new_level + 10;
+		else if (_G(thor)->dir == 1)
+			_G(current_level) = new_level - 10;
+		else if (_G(thor)->dir == 2)
+			_G(current_level) = new_level + 1;
+		else if (_G(thor)->dir == 3)
+			_G(current_level) = new_level - 1;
+	}
+
+	if (!_G(setup).scroll_flag)
+		_G(current_level) = new_level; //force no scroll
+
+	if (_G(music_current) != _G(level_type))
+		_G(sound).music_pause();
+
+#ifdef TODO
+	switch (new_level - _G(current_level)) {
+	case 0:
+		xshowpage(draw_page);
+		xcopyd2d(0, 0, 320, 192, 0, 0, draw_page, display_page, 320, 320);
+		break;
+	case 1:
+	{
+		scroll_level_right(); break;
+	}
+	case 10:
+	{
+		scroll_level_down(); break;
+	}
+	case -1:
+	{
+		scroll_level_left(); break;
+	}
+	case -10:
+	{
+		scroll_level_up(); break;
+	}
+	default:
+		phase_level();
+	}
+	build_screen(PAGE2);
+	show_objects(new_level, PAGE2);
+
+	_G(current_level) = new_level;
+	thor_info.last_health = _G(thor)->health;
+	thor_info.last_magic = thor_info.magic;
+	thor_info.last_jewels = thor_info.jewels;
+	thor_info.last_keys = thor_info.keys;
+	thor_info.last_score = thor_info.score;
+	thor_info.last_item = thor_info.item;
+	thor_info.last_screen = _G(current_level);
+	thor_info.last_icon = ((_G(thor)->x + 8) / 16) + (((_G(thor)->y + 14) / 16) * 20);
+	thor_info.last_dir = _G(thor)->dir;
+	thor_info.last_inventory = thor_info.inventory;
+	thor_info.last_object = thor_info.object;
+	thor_info.last_object_name = thor_info.object_name;
+
+	_G(last_setup) = _G(setup);
+
+	f = 1;
+	if (GAME1 && new_level == BOSS_LEVEL1) {
+		if (!_G(setup).boss_dead[0]) {
+			if (!auto_load) boss_level1();
+			f = 0;
+		}
+	}
+	if (startup) f = 0;
+	if (f) music_play(_G(level_type), 0);
+#endif
+}
 
 } // namespace Got
diff --git a/engines/got/game/back.h b/engines/got/game/back.h
index 203cbad7875..e74e7ffa020 100644
--- a/engines/got/game/back.h
+++ b/engines/got/game/back.h
@@ -26,6 +26,13 @@
 
 namespace Got {
 
+/**
+ * Shows a new level
+ * In the original this did some initial actors setup and rendering.
+ * Now in ScummVM, it only does the setup portions, since the
+ * GameContent view takes care of the scene rendering.
+*/
+extern void show_level(int new_level);
 
 } // namespace Got
 
diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index 5b67682968e..d3decd0a52a 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -22,9 +22,12 @@
 #include "common/memstream.h"
 #include "common/textconsole.h"
 #include "got/game/init.h"
+#include "got/game/back.h"
+#include "got/game/main.h"
 #include "got/gfx/image.h"
 #include "got/utils/file.h"
 #include "got/events.h"
+#include "got/sound.h"
 #include "got/vars.h"
 
 namespace Got {
@@ -95,12 +98,44 @@ void initialize() {
 		_G(thor_info).item = 2;
 	}
 
+	_G(thor)->speed_count = 6;
+
 	_G(new_level) = _G(current_level);
 
 	// Load level data
 	Common::MemoryReadStream levelStream(
 		_G(sd_data) + _G(new_level) * 512, 512);
 	_G(scrn).load(&levelStream);
+
+	show_level(_G(current_level));
+
+	if (_G(auto_load)) {
+		if (load_game(0)) {
+			setup_load();
+		}
+		_G(auto_load) = 0;
+		if (GAME1 && _G(current_area) == 59 && !_G(setup).game_over) {
+			_G(auto_load) = 1;
+#ifdef TODO
+			fade_in();
+			boss_level1();
+#else
+			error("TODO: boss_level1");
+#endif
+		}
+	} else if (!_G(cheat)) {
+//		key_flag[ESC] = 1;
+	}
+
+	if (!_G(auto_load)) {
+//		fade_in();
+		_G(sound).music_play(_G(level_type), 1);
+	}
+	_G(auto_load) = 0;
+
+	_G(startup) = false;
+	if (_G(record))
+		memset(_G(demo_key), 0, DEMO_LEN);
 }
 
 } // namespace Got
diff --git a/engines/got/game/main.cpp b/engines/got/game/main.cpp
new file mode 100644
index 00000000000..5b4de8a7bd8
--- /dev/null
+++ b/engines/got/game/main.cpp
@@ -0,0 +1,72 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/memstream.h"
+#include "got/game/back.h"
+#include "got/vars.h"
+
+namespace Got {
+
+void setup_load() {
+
+	_G(thor)->used = 1;
+	_G(new_level) = _G(thor_info).last_screen;
+	_G(thor)->x = (_G(thor_info).last_icon % 20) * 16;
+	_G(thor)->y = ((_G(thor_info).last_icon / 20) * 16) - 1;
+	if (_G(thor)->x < 1) _G(thor)->x = 1;
+	if (_G(thor)->y < 0) _G(thor)->y = 0;
+	_G(thor)->last_x[0] = _G(thor)->x;
+	_G(thor)->last_x[1] = _G(thor)->x;
+	_G(thor)->last_y[0] = _G(thor)->y;
+	_G(thor)->last_y[1] = _G(thor)->y;
+	_G(thor)->dir = _G(thor_info).last_dir;
+	_G(thor)->last_dir = _G(thor_info).last_dir;
+	_G(thor)->health = _G(thor_info).last_health;
+	_G(thor_info).magic = _G(thor_info).last_magic;
+	_G(thor_info).jewels = _G(thor_info).last_jewels;
+	_G(thor_info).keys = _G(thor_info).last_keys;
+	_G(thor_info).score = _G(thor_info).last_score;
+	_G(thor_info).item = _G(thor_info).last_item;
+	_G(thor_info).inventory = _G(thor_info).last_inventory;
+	_G(thor_info).object = _G(thor_info).last_object;
+	_G(thor_info).object_name = _G(thor_info).last_object_name;
+	_G(thor)->num_moves = 1;
+	_G(thor)->vunerable = 60;
+	_G(thor)->show = 60;
+	_G(hourglass_flag) = 0;
+	_G(apple_flag) = 0;
+	_G(bomb_flag) = 0;
+	_G(thunder_flag) = 0;
+	_G(lightning_used) = 0;
+	_G(tornado_used) = 0;
+	_G(shield_on) = 0;
+	_G(actor)[1].used = 0;
+	_G(actor)[2].used = 0;
+	_G(thor)->speed_count = 6;
+
+	Common::MemoryReadStream stream(_G(sd_data) + (_G(new_level) * 512), 512);
+	_G(scrn).load(&stream);
+
+	_G(current_level) = _G(new_level);
+	show_level(_G(new_level));
+}
+
+} // namespace Got
diff --git a/engines/got/game/main.h b/engines/got/game/main.h
new file mode 100644
index 00000000000..4891d57a374
--- /dev/null
+++ b/engines/got/game/main.h
@@ -0,0 +1,33 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GAME_MAIN_H
+#define GOT_GAME_MAIN_H
+
+#include "got/data/defines.h"
+
+namespace Got {
+
+extern void setup_load();
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index 0a85890a164..9f107ada885 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -190,7 +190,7 @@ void show_enemies() {
 }
 
 int load_enemy(int type) {
-	int i, f, d, e;
+	int i, d, e;
 	ACTOR *enm;
 
 	for (i = 0; i < MAX_ENEMIES; i++) if (_G(enemy_type)[i] == type) return i;
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 6ff6f6b6d8b..0e699fc6db2 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -11,6 +11,7 @@ MODULE_OBJS = \
 	data/defines.o \
 	game/back.o \
 	game/init.o \
+	game/main.o \
 	game/status.o \
 	gfx/font.o \
 	gfx/gfx_chunks.o \
diff --git a/engines/got/prototypes.h b/engines/got/prototypes.h
index 9e62bdd4d4c..71bee0f650f 100644
--- a/engines/got/prototypes.h
+++ b/engines/got/prototypes.h
@@ -136,7 +136,6 @@ void show_scr(void);
 
 //G_BACK.C
 void build_screen(unsigned int pg);
-void show_level(int new_level);
 void scroll_level_left(void);
 void scroll_level_up(void);
 void scroll_level_right(void);
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 4d8353013eb..8a06ae953a8 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -68,7 +68,7 @@ public:
 	int8 _break_code = 0;
 	int8 _scan_code = 0, _last_scan_code = 0;
 	int8 _diag = 0;
-	int8 _slow_mode = 0, _startup = 0;
+	bool _slow_mode = false, _startup = true;
 	int8 _shot_ok = 0;
 	int _thor_x1 = 0, _thor_y1 = 0, _thor_x2 = 0, _thor_y2 = 0,
 		_thor_real_y1 = 0;
@@ -86,12 +86,11 @@ public:
 	int8 _thor_icon1 = 0, _thor_icon2 = 0, _thor_icon3 = 0,
 		_thor_icon4 = 0;
 	int8 _level_type = 0;
-	int8 _music_current = 0;
+	int8 _music_current = -1;
 	int8 _boss_loaded = 0;
 	int8 _apple_drop = 0;
 	bool _cheat = false;
 	int8 _area = 1;
-	byte _last_setup[32] = {};
 
 	LEVEL _scrn;
 	byte *_scrnp = nullptr;
@@ -99,6 +98,7 @@ public:
 	byte *_sd_data = nullptr;
 
 	SETUP _setup;
+	SETUP _last_setup;
 	byte *_tmp_buff = nullptr;
 	int _reps = 0;
 
@@ -164,7 +164,7 @@ public:
 	char _demo_key[DEMO_LEN] = {};
 	int  _demo_cnt = 0;
 	bool _demo = false, _record = false;
-	int8 _demo_enable = 0;
+	int8 _demo_enable = 1;
 	int  _rnd_index = 0;
 	int  _rnd_array[100] = {};
 	int8 _rdemo = 0;
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 91ed408a959..a6474c314e8 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "got/views/game_content.h"
+#include "got/game/back.h"
 #include "got/gfx/image.h"
 #include "got/vars.h"
 
@@ -30,25 +31,18 @@ void GameContent::draw() {
 	GfxSurface s = getSurface();
 	s.clear();
 
-	int save_d;
-
-	_G(boss_active) = 0;
-	if (!_G(shield_on))
-		_G(actor)[2].used = 0;
-	_G(bomb_flag) = 0;
-
-	save_d = _G(thor)->dir;
-	_G(thor)->next = 0;
-	if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154)
-		_G(thor)->dir = 0;
-
 	drawBackground(s);
 	drawObjects(s);
-#ifdef TODO
-	setupEnemies();
 	drawEnemies(s, &_G(actor)[MAX_ACTORS - 1]);
-#endif
-	_G(thor)->dir = save_d;
+}
+
+bool GameContent::msgGame(const GameMessage &msg) {
+	if (msg._name == "SHOW_LEVEL") {
+		show_level(msg._value);
+		return true;
+	}
+
+	return false;
 }
 
 void GameContent::drawBackground(GfxSurface &s) {
@@ -82,46 +76,6 @@ void GameContent::drawObjects(GfxSurface &s) {
 	}
 }
 
-void GameContent::setupEnemies() {
-	int i, d, r;
-
-	for (i = 3; i < MAX_ACTORS; i++)
-		_G(actor)[i].used = 0;
-	for (i = 0; i < MAX_ENEMIES; i++)
-		_G(enemy_type)[i] = 0;
-
-	_G(latch_mem) = _G(enemy_lm);
-	_G(mask_buff) = _G(enemy_mb);
-	_G(ami_buff) = _G(enemy_ami);
-
-	for (i = 0; i < MAX_ENEMIES; i++) {
-		if (_G(scrn).actor_type[i] > 0) {
-			r = load_enemy(_G(scrn).actor_type[i]);
-
-			if (r >= 0) {
-				memcpy(&_G(actor)[i + 3], &_G(enemy)[r], sizeof(ACTOR));
-				d = _G(scrn).actor_dir[i];
-
-				setup_actor(&_G(actor)[i + 3], i + 3, d, (_G(scrn).actor_loc[i] % 20) * 16,
-					(_G(scrn).actor_loc[i] / 20) * 16);
-				_G(actor)[i + 3].init_dir = _G(scrn).actor_dir[i];
-				_G(actor)[i + 3].pass_value = _G(scrn).actor_value[i];
-
-				if (_G(actor)[i + 3].move == 23) {
-					// Spinball
-					if (_G(actor)[i + 3].pass_value & 1)
-						_G(actor)[i + 3].move = 24;
-				}
-
-				if (_G(scrn).actor_invis[i])
-					_G(actor)[i + 3].used = 0;
-			}
-
-			_G(etype)[i] = r;
-		}
-	}
-}
-
 void GameContent::drawEnemies(GfxSurface &s, ACTOR *lastActor) {
 	ACTOR *actor_ptr = lastActor;
 	ACTOR *actor2_storage = nullptr;
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index fdf76364df0..07a58e355da 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -32,7 +32,6 @@ class GameContent : public View {
 private:
 	void drawBackground(GfxSurface &s);
 	void drawObjects(GfxSurface &s);
-	void setupEnemies();
 	void drawEnemies(GfxSurface &s, ACTOR *lastActor);
 
 public:
@@ -40,6 +39,7 @@ public:
 	virtual ~GameContent() {}
 
 	void draw() override;
+	bool msgGame(const GameMessage &msg) override;
 };
 
 } // namespace Views


Commit: b6ea50837cd999f84f1f341b7aa3df7be148b688
    https://github.com/scummvm/scummvm/commit/b6ea50837cd999f84f1f341b7aa3df7be148b688
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Allow res_read calls to fail without error

Changed paths:
    engines/got/utils/file.cpp
    engines/got/utils/file.h


diff --git a/engines/got/utils/file.cpp b/engines/got/utils/file.cpp
index 959306b4338..693f705dac6 100644
--- a/engines/got/utils/file.cpp
+++ b/engines/got/utils/file.cpp
@@ -51,10 +51,10 @@ bool load_sd_data() {
 	return res_read(fname, _G(sd_data)) > 0;
 }
 
-bool load_actor(int file, int num) {
+bool load_actor(int /*file*/, int num) {
 	Common::String fname = Common::String::format("ACTOR%d", num);
 
-	if (res_read(fname, _G(tmp_buff)) < 0)
+	if (res_read(fname, _G(tmp_buff), true) < 0)
 		return false;
 
 	//file = file;
@@ -233,12 +233,13 @@ bool load_game(int flag) {
 	return true;
 }
 
-long res_read(const Common::String &name, void *buff) {
+long res_read(const Common::String &name, void *buff, bool failAllowed) {
 	Common::File f;
 	if (f.open(Common::Path(name))) {
 		return f.read(buff, f.size());
 	} else {
-		error("Could not load - %s", name.c_str());
+		if (!failAllowed)
+			error("Could not load - %s", name.c_str());
 		return -1;
 	}
 }
diff --git a/engines/got/utils/file.h b/engines/got/utils/file.h
index 3ff97d7458e..153f2505330 100644
--- a/engines/got/utils/file.h
+++ b/engines/got/utils/file.h
@@ -32,7 +32,7 @@ extern unsigned int read_file(const char *filename, const char *buff,
 	long offset, unsigned int amount, int key);
 
 extern bool load_sd_data();
-extern bool load_actor(int file, int num);
+extern bool load_actor(int, int num);
 extern bool load_picture(int index, char *buff);
 extern void setup_filenames(int level);
 extern bool  load_speech(int index);
@@ -41,7 +41,8 @@ extern void *get_file(const char *filename, int key);
 extern void save_game();
 extern bool load_game(int flag);
 extern void help();
-extern long res_read(const Common::String &name, void *buff);
+extern long res_read(const Common::String &name, void *buff,
+	bool failAllowed = false);
 
 class File : public Common::File {
 public:


Commit: 75cf1fa6cf9b4b8eefc062cb7da66a2aed8e9781
    https://github.com/scummvm/scummvm/commit/75cf1fa6cf9b4b8eefc062cb7da66a2aed8e9781
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Startup fixes

Changed paths:
    engines/got/data/defines.cpp
    engines/got/data/defines.h
    engines/got/gfx/image.cpp


diff --git a/engines/got/data/defines.cpp b/engines/got/data/defines.cpp
index 38a3648a3da..3b76795a7f5 100644
--- a/engines/got/data/defines.cpp
+++ b/engines/got/data/defines.cpp
@@ -51,4 +51,32 @@ void LEVEL::sync(Common::Serializer &s) {
 	s.syncBytes(future, 3);
 }
 
+void ACTOR::loadFixed(Common::SeekableReadStream *src) {
+	move = src->readByte();
+	width = src->readByte();
+	height = src->readByte();
+	directions = src->readByte();
+	frames = src->readByte();
+	frame_speed = src->readByte();
+	src->read(frame_sequence, 4);
+	speed = src->readByte();
+	size_x = src->readByte();
+	size_y = src->readByte();
+	strength = src->readByte();
+	health = src->readByte();
+	num_moves = src->readByte();
+	shot_type = src->readByte();
+	shot_pattern = src->readByte();
+	shots_allowed = src->readByte();
+	solid = src->readByte();
+	flying = src->readByte();
+	rating = src->readByte();
+	type = src->readByte();
+	src->read(name, 9);
+	func_num = src->readByte();
+	func_pass = src->readByte();
+	magic_hurts = src->readSint16LE();
+	src->read(future1, 4);
+}
+
 } // namespace Got
diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index 2909e9194a5..292457de587 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -107,7 +107,7 @@ struct ACTOR {                      // Size=256
 	byte name[9] = {};              // Actors name
 	byte func_num = 0;              // Special function when thor touches
 	byte func_pass = 0;             // Value to pass to func
-	int  magic_hurts = 0;           // Bitwise magic hurts flags
+	uint16  magic_hurts = 0;           // Bitwise magic hurts flags
 	byte future1[4] = {};
 
 	// The rest is dynamic    //size=216
@@ -157,6 +157,8 @@ struct ACTOR {                      // Size=256
 	byte talk_counter = 0;
 	byte etype = 0;
 	byte future2[25] = {};
+
+	void loadFixed(Common::SeekableReadStream *src);
 };
 
 struct ACTOR_NFO {				//size=40
diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index 9f107ada885..c46c1be8465 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "common/memstream.h"
 #include "got/gfx/image.h"
 #include "got/events.h"
 #include "got/utils/file.h"
@@ -129,14 +130,20 @@ int load_standard_actors() {
 	make_actor_surface(&_G(explosion));
 
 	load_actor(0, 108);   // Load tornado
-	memcpy(&_G(magic_item)[0], (_G(tmp_buff) + 5120), 40);
-	memcpy(&_G(magic_pic)[0], _G(tmp_buff), 1024);
+
+	Common::MemoryReadStream mi((const byte *)_G(tmp_buff) + 5120, 40);
+	_G(magic_item)[0].loadFixed(&mi);
+	Common::copy(_G(tmp_buff), _G(tmp_buff) + 1024, _G(magic_pic)[0]);
+
 	setup_actor(&_G(magic_item)[0], 20, 0, 0, 0);
 	_G(magic_item)[0].used = 0;
 
 	load_actor(0, 1099);   // Load shield
-	memcpy(&_G(magic_item)[1], (_G(tmp_buff) + 5120), 40);
-	memcpy(&_G(magic_pic)[1], _G(tmp_buff), 1024);
+
+	mi.seek(0);
+	_G(magic_item)[1].loadFixed(&mi);
+	Common::copy(_G(tmp_buff), _G(tmp_buff) + 1024, _G(magic_pic)[1]);
+
 	setup_actor(&_G(magic_item)[1], 20, 0, 0, 0);
 	_G(magic_item)[1].used = 0;
 
@@ -169,19 +176,23 @@ void show_enemies() {
 		if (_G(scrn).actor_type[i] > 0) {
 			r = load_enemy(_G(scrn).actor_type[i]);
 			if (r >= 0) {
-				memcpy(&_G(actor)[i + 3], &_G(enemy)[r], sizeof(ACTOR));
+				_G(actor)[i + 3] = _G(enemy)[r];
+
 				d = _G(scrn).actor_dir[i];
-				//       _G(scrn).actor_type[i] &= 0x3f;
+
 				setup_actor(&_G(actor)[i + 3], i + 3, d, (_G(scrn).actor_loc[i] % 20) * 16,
 					(_G(scrn).actor_loc[i] / 20) * 16);
 				_G(actor)[i + 3].init_dir = _G(scrn).actor_dir[i];
 				_G(actor)[i + 3].pass_value = _G(scrn).actor_value[i];
+
 				if (_G(actor)[i + 3].move == 23) {
 					// Spinball
 					if (_G(actor)[i + 3].pass_value & 1)
 						_G(actor)[i + 3].move = 24;
 				}
-				if (_G(scrn).actor_invis[i]) _G(actor)[i + 3].used = 0;
+
+				if (_G(scrn).actor_invis[i])
+					_G(actor)[i + 3].used = 0;
 			}
 
 			_G(etype)[i] = r;
@@ -190,15 +201,16 @@ void show_enemies() {
 }
 
 int load_enemy(int type) {
-	int i, d, e;
-	ACTOR *enm;
+	int i, e;
 
-	for (i = 0; i < MAX_ENEMIES; i++) if (_G(enemy_type)[i] == type) return i;
+	for (i = 0; i < MAX_ENEMIES; i++) {
+		if (_G(enemy_type)[i] == type)
+			return i;
+	}
 
 	if (!load_actor(1, type)) {
 		return -1;
 	}
-	enm = (ACTOR *)(_G(tmp_buff) + 5120);
 
 	e = -1;
 	for (i = 0; i < MAX_ENEMIES; i++) {
@@ -207,9 +219,11 @@ int load_enemy(int type) {
 			break;
 		}
 	}
-	if (e == -1) return -1;
+	if (e == -1)
+		return -1;
 
-	memcpy(&_G(enemy)[e], enm, sizeof(ACTOR_NFO));
+	Common::MemoryReadStream inf(_G(tmp_buff) + 5120, 40);
+	_G(enemy)[e].loadFixed(&inf);
 
 	make_actor_surface(&_G(enemy)[e]);
 	_G(enemy_type)[e] = type;
@@ -219,6 +233,7 @@ int load_enemy(int type) {
 		_G(enemy)[e].shot_type = e + 1;
 		enm = (ACTOR *)(_G(tmp_buff) + 5160);
 		memcpy(&_G(shot)[e], enm, sizeof(ACTOR_NFO));
+
 		for (d = 0; d < _G(shot)[e].directions; d++) {
 			for (f = 0; f < _G(shot)[e].frames; f++) {
 				if (_G(shot)[e].directions < _G(shot)[e].frames)


Commit: 3d5a5448fd328488eb6e59208f17f7fb8a4f1a06
    https://github.com/scummvm/scummvm/commit/3d5a5448fd328488eb6e59208f17f7fb8a4f1a06
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Use the top-left corner of enemy frames as trans color

The original uses a highly complicated set of methods creating
"masks" based on the frames. However, this is tied into the
screen having four planes, so I'm honestly not sure what parts
of the code are for that, and if any of it is legitimately a
mask used for controlling which pixels are drawn. For now,
I'm simply using the top-left corner pixel as the transparency
color. That seems to work with the sprites I'm drawing so far.

Changed paths:
    engines/got/gfx/image.cpp


diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index c46c1be8465..9ac831478cc 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -80,10 +80,8 @@ void make_actor_surface(ACTOR *actr) {
 			const byte *src = &_G(tmp_buff)[256 * ((d * 4) + f)];
 			Common::copy(src, src + 16 * 16, (byte *)s.getPixels());
 
-			_G(latch_mem) += 144;
-			if (_G(latch_mem) > 65421u) {
-				error("Too Many Actor Frames=");
-			}
+			// Use the top-left corner pixel as the transparency color
+			s.setTransparentColor(*src);
 		}
 	}
 }


Commit: c8701c98d5202a8980ee92de88dfa83d52ebb5a5
    https://github.com/scummvm/scummvm/commit/c8701c98d5202a8980ee92de88dfa83d52ebb5a5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added lots of files

Changed paths:
  A engines/got/data/flags.h
  A engines/got/game/boss1.cpp
  A engines/got/game/boss1.h
  A engines/got/game/move.cpp
  A engines/got/game/move.h
  A engines/got/game/move_patterns.cpp
  A engines/got/game/move_patterns.h
  A engines/got/game/object.cpp
  A engines/got/game/object.h
  A engines/got/game/panel.cpp
  A engines/got/game/panel.h
  A engines/got/game/script.cpp
  A engines/got/game/script.h
  A engines/got/game/shot_movement.cpp
  A engines/got/game/shot_movement.h
  A engines/got/game/shot_pattern.cpp
  A engines/got/game/shot_pattern.h
  A engines/got/game/special_tile.cpp
  A engines/got/game/special_tile.h
  R engines/got/prototypes.h
    engines/got/data/defines.h
    engines/got/game/back.cpp
    engines/got/game/back.h
    engines/got/game/init.cpp
    engines/got/game/init.h
    engines/got/module.mk
    engines/got/sound.cpp
    engines/got/sound.h
    engines/got/utils/file.cpp
    engines/got/utils/file.h
    engines/got/vars.cpp
    engines/got/vars.h
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index 292457de587..1f1e464c6c7 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -19,8 +19,8 @@
  *
  */
 
-#ifndef GOT_DEFINES_H
-#define GOT_DEFINES_H
+#ifndef GOT_DATA_DEFINES_H
+#define GOT_DATA_DEFINES_H
 
 #include "common/scummsys.h"
 #include "common/serializer.h"
@@ -28,23 +28,8 @@
 
 namespace Got {
 
-#ifdef DEPRECATED
-/**
- * Describes one alignment of a mask - image pair
- */
-struct ALIGNED_MASK_IMAGE {
-	int image_width = 0;		// Image width in addresses in display memory
-	uint image_ptr = 0;			// Offset of image bitmap in display mem
-	byte *mask_ptr = nullptr;   // Pointer to mask bitmap
-};
-
-struct MASK_IMAGE {
-	// ptrs to AlignedMaskedImage
-	// structs for four possible destination
-	// image alignments
-	ALIGNED_MASK_IMAGE *alignments[4] = {};
-};
-#endif
+#define REPEAT(a) for(rep=0;rep<a;rep++)
+#define IN_RANGE(v,l,h) (v>=l && v<=h)
 
 #define OBJECTS_COUNT 30
 
@@ -104,7 +89,7 @@ struct ACTOR {                      // Size=256
 	byte flying = 0;                // 
 	byte rating = 0;                // rnd(100) < rating = jewel
 	byte type = 0;                  // Actor (0=thor,1=hammer,2=enemy,3=shot)
-	byte name[9] = {};              // Actors name
+	char name[9] = {};              // Actors name
 	byte func_num = 0;              // Special function when thor touches
 	byte func_pass = 0;             // Value to pass to func
 	uint16  magic_hurts = 0;           // Bitwise magic hurts flags
@@ -318,9 +303,9 @@ struct THOR_INFO {
 	long score = 0;
 	long last_score = 0;
 	byte object = 0;
-	byte *object_name = 0;
+	const char *object_name = nullptr;
 	byte last_object = 0;
-	byte *last_object_name = 0;
+	const char *last_object_name = nullptr;
 	byte armor = 0;
 	byte future[65] = {};
 };
diff --git a/engines/got/data/flags.h b/engines/got/data/flags.h
new file mode 100644
index 00000000000..9d4c59ceac1
--- /dev/null
+++ b/engines/got/data/flags.h
@@ -0,0 +1,33 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_DATA_FLAGS_H
+#define GOT_DATA_FLAGS_H
+
+#include "got/data/defines.h"
+
+namespace Got {
+
+#define HERMIT_HAS_DOLL _G(setup).f04
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index cf2e538367b..ff5078eb8a1 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -19,13 +19,29 @@
  *
  */
 
+#include "common/file.h"
 #include "common/memstream.h"
 #include "got/game/back.h"
+#include "got/game/move.h"
+#include "got/game/panel.h"
+#include "got/game/script.h"
 #include "got/gfx/image.h"
 #include "got/vars.h"
 
 namespace Got {
 
+const char *object_names[] = {
+	"Shrub","Child's Doll","UNUSED","FUTURE",
+	"FUTURE","FUTURE","FUTURE","FUTURE","FUTURE",
+	"FUTURE","FUTURE","FUTURE","FUTURE","FUTURE",
+	"FUTURE"
+};
+const char *item_name[] = {
+	"Enchanted Apple","Lightning Power",
+	"Winged Boots","Wind Power",
+	"Amulet of Protection","Thunder Power"
+};
+
 void show_level(int new_level) {
 	int save_d;
 
@@ -38,7 +54,7 @@ void show_level(int new_level) {
 	if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154)
 		_G(thor)->dir = 0;
 
-	// The original copied 130 bytes from scrn.static_object onwards into sd_data.
+	// The original copied 130 bytes from _G(scrn).static_object onwards into sd_data.
 	// This doesn't make sense, because that would put the ending in the middle of static_y.
 	// Plus, it follows with an entire copy of scrn into sd_data anyway, so the first
 	// move seems entirely redundant.
@@ -139,4 +155,183 @@ void show_level(int new_level) {
 #endif
 }
 
+int odin_speaks(int index, int item) {
+	execute_script((long)index, &_G(odin)[0]);
+	if (!_G(thor)->health) {
+		_G(thor)->show = 0;
+		_G(exit_flag) = 2;
+	}
+
+	item = item;
+	return 1;
+}
+
+
+int switch_icons() {
+	int x, y, ix, iy;
+
+	play_sound(WOOP, 0);
+
+	for (y = 0; y < 12; y++) {
+		for (x = 0; x < 20; x++) {
+			ix = x * 16;
+			iy = y * 16;
+			if (_G(scrn).icon[y][x] == 93) {
+				place_tile(x, y, 144);
+			} else if (_G(scrn).icon[y][x] == 144) {
+				place_tile(x, y, 93);
+				kill_enemies(iy, ix);
+			}
+			if (_G(scrn).icon[y][x] == 94) {
+				place_tile(x, y, 146);
+			} else if (_G(scrn).icon[y][x] == 146) {
+				place_tile(x, y, 94);
+				kill_enemies(iy, ix);
+			}
+		}
+	}
+
+	return 0;
+}
+
+int rotate_arrows() {
+	int x, y;
+
+	play_sound(WOOP, 0);
+
+	for (y = 0; y < 12; y++) {
+		for (x = 0; x < 20; x++) {
+			if (_G(scrn).icon[y][x] == 205)
+				place_tile(x, y, 208);
+			else if (_G(scrn).icon[y][x] == 206)
+				place_tile(x, y, 207);
+			else if (_G(scrn).icon[y][x] == 207)
+				place_tile(x, y, 205);
+			else if (_G(scrn).icon[y][x] == 208)
+				place_tile(x, y, 206);
+		}
+	}
+
+	return 0;
+}
+
+void kill_enemies(int iy, int ix) {
+	int i, x1, y1, x2, y2;
+
+	for (i = 3; i < MAX_ACTORS; i++) {
+		if (_G(actor)[i].used) {
+			x1 = _G(actor)[i].x;
+			y1 = _G(actor)[i].y + _G(actor)[i].size_y - 2;
+			x2 = (_G(actor)[i].x + _G(actor)[i].size_x);
+			y2 = _G(actor)[i].y + _G(actor)[i].size_y - 1;
+
+			if (point_within(x1, y1, ix, iy, ix + 15, iy + 15))
+				actor_destroyed(&_G(actor)[i]);
+			else if (point_within(x2, y1, ix, iy, ix + 15, iy + 15))
+				actor_destroyed(&_G(actor)[i]);
+			else if (point_within(x1, y2, ix, iy, ix + 15, iy + 15))
+				actor_destroyed(&_G(actor)[i]);
+			else if (point_within(x2, y2, ix, iy, ix + 15, iy + 15))
+				actor_destroyed(&_G(actor)[i]);
+		}
+	}
+
+	x1 = _G(thor)->x;
+	y1 = _G(thor)->y + 11;
+	x2 = x1 + 13;
+	y2 = y1 + 5;
+
+	if (point_within(x1, y1, ix, iy, ix + 15, iy + 15)) goto dead;
+	if (point_within(x2, y1, ix, iy, ix + 15, iy + 15)) goto dead;
+	if (point_within(x1, y2, ix, iy, ix + 15, iy + 15)) goto dead;
+	if (point_within(x2, y2, ix, iy, ix + 15, iy + 15)) goto dead;
+	return;
+
+dead:
+	_G(thor)->health = 0;
+	//display_health();
+	_G(exit_flag) = 2;
+}
+
+void remove_objects(int y, int x) {
+	int p, ix, iy;
+
+	p = (y * 20) + x;
+	ix = x * 16;
+	iy = y * 16;
+
+	if (_G(object_map)[p] > 0) {
+		//xfput(ix, iy, PAGE2, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
+		//xfput(ix, iy, PAGE2, (char far *) (bg_pics + (_G(scrn).icon[y][x] * 262)));
+		//xcopyd2d(ix, iy, ix + 16, iy + 16, ix, iy, PAGE2, draw_page, 320, 320);
+		_G(object_map)[p] = 0;
+		_G(object_index)[p] = 0;
+	}
+}
+
+void place_tile(int x, int y, int tile) {
+	int ix, iy;
+
+	ix = x * 16;
+	iy = y * 16;
+
+	//xfput(ix, iy, PAGE2, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
+	//xfput(ix, iy, PAGE2, (char far *) (bg_pics + (tile * 262)));
+	//xcopyd2d(ix, iy, ix + 16, iy + 16, ix, iy, PAGE2, draw_page, 320, 320);
+	//xcopyd2d(ix, iy, ix + 16, iy + 16, ix, iy, PAGE2, display_page, 320, 320);
+	_G(scrn).icon[y][x] = tile;
+	remove_objects(y, x);
+}
+
+int bgtile(int x, int y) {
+	if (x < 0 || x>319 || y < 0 || y>191) return 0;  //303 , 175
+
+	x = (x + 1) >> 4;
+	y = (y + 1) >> 4;
+
+	return _G(scrn).icon[y][x];
+}
+
+void select_item() {
+	error("TODO: select_item");
+}
+
+int actor_speaks(ACTOR *actr, int index, int item) {
+	Common::String str;
+	int v;
+	long lind;
+	Graphics::ManagedSurface *pic;
+
+	if (actr->type != 4)
+		return 0;
+	v = atoi(actr->name);
+	if (v < 1 || v>20)
+		return 0;
+
+	str = Common::String::format("FACE%d", v);
+
+	Gfx::Pics pics(str, -1, false);
+	if (Common::File::exists(Common::Path(str))) {
+		pics.load();
+		pic = &pics[0];
+	} else {
+		pic = &_G(odin)[0];
+	}
+
+	lind = (long)_G(current_level);
+	lind = lind * 1000;
+	lind += (long)actr->actor_num;
+	execute_script(lind, pic);
+	if (!_G(thor)->health) {
+		_G(thor)->show = 0;
+		_G(exit_flag) = 2;
+	}
+
+	d_restore();
+	index = index;
+	item = item;
+
+	return 1;
+}
+
 } // namespace Got
diff --git a/engines/got/game/back.h b/engines/got/game/back.h
index e74e7ffa020..6223ad0a543 100644
--- a/engines/got/game/back.h
+++ b/engines/got/game/back.h
@@ -26,6 +26,10 @@
 
 namespace Got {
 
+extern const char *object_names[];
+extern const char *item_name[];
+
+
 /**
  * Shows a new level
  * In the original this did some initial actors setup and rendering.
@@ -33,6 +37,15 @@ namespace Got {
  * GameContent view takes care of the scene rendering.
 */
 extern void show_level(int new_level);
+extern int odin_speaks(int index, int item);
+extern int switch_icons();
+extern int rotate_arrows();
+extern void kill_enemies(int iy, int ix);
+extern void remove_objects(int y, int x);
+extern void place_tile(int x, int y, int tile);
+extern int bgtile(int x, int y);
+extern void select_item();
+extern int actor_speaks(ACTOR *actr, int index, int item);
 
 } // namespace Got
 
diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
new file mode 100644
index 00000000000..b46838ec37e
--- /dev/null
+++ b/engines/got/game/boss1.cpp
@@ -0,0 +1,301 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/game/boss1.h"
+#include "got/game/move.h"
+#include "got/game/move_patterns.h"
+#include "got/game/panel.h"
+#include "got/vars.h"
+#include "got/events.h"
+#include "got/sound.h"
+
+namespace Got {
+
+// boss - snake
+int boss1_movement(ACTOR *actr) {
+	int d, x1, y1, f;
+
+	if (_G(boss_dead))
+		return boss_dead1();
+
+	d = actr->last_dir;
+	if (actr->edge_counter) {
+		actr->edge_counter--;
+		goto done;
+	}
+	x1 = actr->x;
+	y1 = actr->y;
+
+	if (overlap(actr->x + 2, actr->y + 8, actr->x + 30, actr->y + 30,
+		_G(thor)->x, _G(thor)->y + 8, _G(thor)->x + 15, _G(thor)->y + 15)) {
+		thor_damaged(actr);
+	}
+	if (actr->temp3) {  //start striking
+		actr->temp3--;
+		if (!actr->temp3) play_sound(BOSS11, 0);
+		if (_G(hourglass_flag))
+			actr->num_moves = 3;
+		else
+			actr->num_moves = 6;
+
+		goto done0;
+	}
+
+	// Strike
+	if (actr->temp1) {  
+		actr->temp1--;
+		if (actr->x < (_G(thor_x1) + 12))
+			actr->temp1 = 0;
+		actr->temp2 = 1;
+		d = 2;
+		actr->x -= 2;
+
+		if (overlap(actr->x + 2, actr->y + 8, actr->x + 32, actr->y + 30,
+			_G(thor)->x, _G(thor)->y + 8, _G(thor)->x + 15, _G(thor)->y + 15)) {
+			actr->temp1 = 0;
+			goto done1;
+		}
+
+		actr->next = 3;
+		actr->num_moves = _G(setup).skill + 2;
+		goto done1;
+	}
+	if (actr->temp2) {          //retreating
+		if (actr->x < 256) {
+			d = 3;
+			actr->x += 2;
+			if (overlap(actr->x + 2, actr->y + 8, actr->x + 32, actr->y + 30,
+				_G(thor)->x, _G(thor)->y + 8, _G(thor)->x + 15, _G(thor)->y + 15)) {
+				goto done1;
+			}
+			actr->num_moves = _G(setup).skill + 1;
+			goto done0;
+		} else actr->temp2 = 0;
+	}
+	if (ABS((_G(thor_y1))-(actr->y + 20)) < 8) {
+		if (!actr->temp1) {
+			if (actr->x > _G(thor_x1)) {
+				actr->temp3 = 75;
+				actr->temp1 = 130;
+				actr->temp2 = 0;
+			}
+		}
+	}
+	f = 0;
+	if (actr->counter) {
+		actr->counter--;
+		switch (d) {
+		case 1:
+			x1 = _G(actor)[5].x;
+			y1 = _G(actor)[5].y;
+			y1 += 2;
+
+			if (!check_move2(x1, y1, &_G(actor)[5]))
+				f = 1;
+			else {
+				actr->x = _G(actor)[5].x;
+				actr->y = _G(actor)[5].y - 16;
+			}
+			break;
+		case 0:
+			y1 -= 2;
+			if (!check_move2(x1, y1, actr)) f = 1;
+			break;
+		case 3:
+			x1 = _G(actor)[5].x;
+			y1 = _G(actor)[5].y;
+			y1 += 2;
+			if (!check_move2(x1, y1, &_G(actor)[5])) f = 1;
+			else {
+				actr->x = _G(actor)[5].x;
+				actr->y = _G(actor)[5].y - 16;
+			}
+			break;
+		case 2:
+			y1 -= 2;
+			if (!check_move2(x1, y1, actr)) f = 1;
+			break;
+		}
+	} else f = 1;
+
+	if (f == 1) {
+		actr->counter = g_events->getRandomNumber(10, 99);
+		d = g_events->getRandomNumber(1);
+		actr->edge_counter = 20;
+	}
+
+done:
+	if (d > 1) d -= 2;
+
+done0:
+	next_frame(actr);
+	if (actr->next == 3) actr->next = 0;
+
+done1:
+	actr->last_dir = d;
+
+	_G(actor)[4].next = actr->next;
+	_G(actor)[5].next = actr->next;
+	_G(actor)[6].next = actr->next;
+
+	_G(actor)[4].last_dir = d;
+	_G(actor)[5].last_dir = d;
+	_G(actor)[6].last_dir = d;
+
+	_G(actor)[4].x = actr->x + 16;
+	_G(actor)[4].y = actr->y;
+	_G(actor)[5].x = actr->x;
+	_G(actor)[5].y = actr->y + 16;
+	_G(actor)[6].x = actr->x + 16;
+	_G(actor)[6].y = actr->y + 16;
+	_G(actor)[4].num_moves = actr->num_moves;
+	_G(actor)[5].num_moves = actr->num_moves;
+	_G(actor)[6].num_moves = actr->num_moves;
+
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+void check_boss1_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
+	int rep;
+
+	if (actr->move == 15 && act_num == 4) {
+		if ((!_G(actor)[3].vunerable) && (_G(actor)[3].next != 3) &&
+			overlap(x1, y1, x2, y2, actr->x + 6, actr->y + 4, actr->x + 14, actr->y + 20)) {
+			actor_damaged(&_G(actor)[3], _G(hammer)->strength);
+			if (_G(cheat) && _G(key_flag)[_Z])
+				_G(actor)[3].health = 0;
+			else
+				_G(actor)[3].health -= 10;
+
+			_G(actor)[3].speed_count = 50;
+			boss_status(_G(actor)[3].health);
+			_G(actor)[3].vunerable = 100;
+			play_sound(BOSS13, 1);
+			_G(actor)[3].next = 1;
+
+			for (rep = 4; rep < 7; rep++) {
+				_G(actor)[rep].next = 1;
+				_G(actor)[rep].speed_count = 50;
+			}
+
+			if (_G(actor)[3].health == 0)
+				_G(boss_dead) = 1;
+		}
+	}
+}
+
+void boss_level1() {
+#ifdef TODO
+	setup_boss(1);
+	_G(boss_active) = 1;
+	boss_status(-1);
+	music_pause();
+	play_sound(BOSS11, 1);
+	pause(120);
+	music_play(5, 1);
+#else
+	error("boss_level1");
+#endif
+}
+
+int boss_dead1(void) {
+	int rep, n, x, y, r, x1, y1;
+
+	_G(hourglass_flag) = 0;
+	if (_G(boss_dead) == 1) {
+		REPEAT(4) {
+			x1 = _G(actor)[3 + rep].last_x[_G(pge)];
+			y1 = _G(actor)[3 + rep].last_y[_G(pge)];
+			x = _G(actor)[3 + rep].x;
+			y = _G(actor)[3 + rep].y;
+			n = _G(actor)[3 + rep].actor_num;
+			r = _G(actor)[3 + rep].rating;
+
+			_G(actor)[3 + rep] = _G(explosion);
+			_G(actor)[3 + rep].actor_num = n;
+			_G(actor)[3 + rep].rating = r;
+			_G(actor)[3 + rep].x = x;
+			_G(actor)[3 + rep].y = y;
+			_G(actor)[3 + rep].last_x[_G(pge)] = x1;
+			_G(actor)[3 + rep].last_x[_G(pge) ^ 1] = x;
+			_G(actor)[3 + rep].last_y[_G(pge)] = y1;
+			_G(actor)[3 + rep].last_y[_G(pge) ^ 1] = y;
+			_G(actor)[3 + rep].used = 1;
+			_G(actor)[3 + rep].vunerable = 255;
+			_G(actor)[3 + rep].move = 6;
+			_G(actor)[3 + rep].next = rep;
+			_G(actor)[3 + rep].speed = g_events->getRandomNumber(6, 8);
+			_G(actor)[3 + rep].num_shots = (10 - _G(actor)[3 + rep].speed) * 10;
+			_G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
+		}
+		play_sound(EXPLODE, 1);
+		_G(boss_dead)++;
+		for (rep = 7; rep < MAX_ACTORS; rep++)
+			if (_G(actor)[rep].used) actor_destroyed(&_G(actor)[rep]);
+	}
+	return _G(actor)[3].last_dir;
+}
+
+void closing_sequence1() {
+#ifdef TODO
+	LEVEL far *lvl;
+	int rep;
+
+	music_play(4, 1);
+	odin_speaks(1001, 13);
+	thor_info.armor = 1;
+	load_new_thor();
+	_G(thor)->dir = 1;
+	_G(thor)->next = 0;
+	xerase_actors(actor, display_page);
+	xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], display_page);
+	fill_score(20);
+	score_for_inv();
+
+	fill_health();
+	fill_magic();
+	odin_speaks(1002, 0);
+
+	REPEAT(16) scrn.actor_type[rep] = 0;
+	_G(boss_dead) = 0;
+	_G(setup)._G(boss_dead)[0] = 1;
+	game_over = 1;
+	_G(boss_active) = 0;
+	scrn.type = 4;
+	show_level(BOSS_LEVEL1);
+
+	play_sound(ANGEL, 1);
+	place_tile(18, 6, 148);
+	place_tile(19, 6, 202);
+	actor_visible(1);
+	actor_visible(2);
+
+	lvl = (LEVEL far *) (sd_data + (59 * 512));
+	lvl->icon[6][18] = 148;
+	lvl->icon[6][19] = 202;
+	exit_flag = 0;
+#else
+	error("closing_sequence1");
+#endif
+}
+
+} // namespace Got
diff --git a/engines/got/game/boss1.h b/engines/got/game/boss1.h
new file mode 100644
index 00000000000..cb4c0e49b4e
--- /dev/null
+++ b/engines/got/game/boss1.h
@@ -0,0 +1,37 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GAME_BOSS1_H
+#define GOT_GAME_BOSS1_H
+
+#include "got/data/defines.h"
+
+namespace Got {
+
+extern int boss1_movement(ACTOR *actr);
+extern void check_boss1_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num);
+extern void boss_level1();
+extern int boss_dead1();
+extern void closing_sequence1();
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index d3decd0a52a..29f811377b4 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -138,4 +138,79 @@ void initialize() {
 		memset(_G(demo_key), 0, DEMO_LEN);
 }
 
+int setup_boss(int num) {
+	int rep;
+	Common::String ress, prefix;
+	Common::File f;
+
+	if (_G(boss_loaded) == num)
+		return 1;
+
+	if (_G(boss_loaded)) {
+		REPEAT(3) {
+			if (_G(boss_sound)[rep])
+				free(_G(boss_sound)[rep]);
+			if (_G(boss_pcsound)[rep])
+				free(_G(boss_pcsound)[rep]);
+		}
+	}
+
+	ress = Common::String::format("BOSSV%d1", num);
+	_G(boss_sound)[0] = (byte *)res_falloc_read(ress);
+	if (!_G(boss_sound)[0]) return 0;
+	_G(dig_sound)[NUM_SOUNDS - 3] = _G(boss_sound)[0];
+
+	ress = Common::String::format("BOSSV%d2", num);
+	_G(boss_sound)[1] = (byte *)res_falloc_read(ress);
+	if (!_G(boss_sound)[1]) return 0;
+	_G(dig_sound)[NUM_SOUNDS - 2] = _G(boss_sound)[1];
+
+	ress = Common::String::format("BOSSV%d3", num);
+	_G(boss_sound)[2] = (byte *)res_falloc_read(ress);
+	if (!_G(boss_sound)[2]) return 0;
+	_G(dig_sound)[NUM_SOUNDS - 1] = _G(boss_sound)[2];
+
+	prefix = (num == 2) ? "BOSSP1" : Common::String::format("BOSSP%d", num);
+	ress = prefix + "1";
+	_G(boss_pcsound)[0] = (byte *)res_falloc_read(ress);
+	if (!_G(boss_pcsound)[0]) return 0;
+
+	_G(pc_sound)[NUM_SOUNDS - 3] = _G(boss_pcsound)[0];
+	_G(pc_sound)[NUM_SOUNDS - 3][0] = 0;
+	_G(pc_sound)[NUM_SOUNDS - 3][1] = 0;
+
+	if (!f.open(Common::Path(ress)))
+		return 0;
+	_G(pcsound_length)[NUM_SOUNDS - 3] = f.size();
+	f.close();
+
+	ress = prefix + "2";
+	_G(boss_pcsound)[1] = (byte *)res_falloc_read(ress);
+	if (!_G(boss_pcsound)[1]) return 0;
+
+	_G(pc_sound)[NUM_SOUNDS - 2] = _G(boss_pcsound)[1];
+	_G(pc_sound)[NUM_SOUNDS - 2][0] = 0;
+	_G(pc_sound)[NUM_SOUNDS - 2][1] = 0;
+
+	if (!f.open(Common::Path(ress)))
+		return 0;
+	_G(pcsound_length)[NUM_SOUNDS - 2] = f.size();
+	f.close();
+
+	ress = prefix + "3";
+	_G(boss_pcsound)[2] = (byte *)res_falloc_read(ress);
+	if (!_G(boss_pcsound)[2]) return 0;
+	_G(pc_sound)[NUM_SOUNDS - 1] = _G(boss_pcsound)[2];
+	_G(pc_sound)[NUM_SOUNDS - 1][0] = 0;
+	_G(pc_sound)[NUM_SOUNDS - 1][1] = 0;
+
+	if (!f.open(Common::Path(ress)))
+		return 0;
+	_G(pcsound_length)[NUM_SOUNDS - 1] = f.size();
+	f.close();
+
+	_G(boss_loaded) = num;
+	return 1;
+}
+
 } // namespace Got
diff --git a/engines/got/game/init.h b/engines/got/game/init.h
index 193db774608..3ce3867a818 100644
--- a/engines/got/game/init.h
+++ b/engines/got/game/init.h
@@ -30,6 +30,7 @@ namespace Got {
  * Handles in-game initialization the first time
  */
 extern void initialize();
+extern int setup_boss(int num);
 
 } // namespace Got
 
diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
new file mode 100644
index 00000000000..365ba97ef46
--- /dev/null
+++ b/engines/got/game/move.cpp
@@ -0,0 +1,320 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/game/move.h"
+#include "got/game/back.h"
+#include "got/game/move_patterns.h"
+#include "got/game/shot_movement.h"
+#include "got/game/shot_pattern.h"
+#include "got/game/status.h"
+#include "got/vars.h"
+
+namespace Got {
+
+void next_frame(ACTOR *actr) {
+	actr->frame_count--;
+
+	if (actr->frame_count <= 0) {
+		actr->next++;
+
+		if (actr->next > 3)
+			actr->next = 0;
+
+		actr->frame_count = actr->frame_speed;
+	}
+}
+
+bool point_within(int x, int y, int x1, int y1, int x2, int y2) {
+	return ((x >= x1) && (x <= x2) && (y >= y1) && (y <= y2));
+}
+
+bool overlap(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
+	if ((x1 >= x3) && (x1 <= x4) && (y1 >= y3) && (y1 <= y4)) return true;
+	if ((x2 >= x3) && (x2 <= x4) && (y2 >= y3) && (y2 <= y4)) return true;
+	if ((x1 >= x3) && (x1 <= x4) && (y2 >= y3) && (y2 <= y4)) return true;
+	if ((x2 >= x3) && (x2 <= x4) && (y1 >= y3) && (y1 <= y4)) return true;
+	if ((x3 >= x1) && (x3 <= x2) && (y3 >= y1) && (y3 <= y2)) return true;
+	if ((x4 >= x1) && (x4 <= x2) && (y4 >= y1) && (y4 <= y2)) return true;
+	if ((x3 >= x1) && (x3 <= x2) && (y4 >= y1) && (y4 <= y2)) return true;
+	if ((x4 >= x1) && (x4 <= x2) && (y3 >= y1) && (y3 <= y2)) return true;
+	return false;
+}
+
+int reverse_direction(ACTOR *actr) {
+	if (actr->dir == 1) return 0;
+	if (actr->dir == 2) return 3;
+	if (actr->dir == 3) return 2;
+	return 1;
+}
+
+void thor_shoots(void) {
+	if ((_G(hammer)->used != 1) && (!_G(hammer)->dead) && (!_G(thor)->shot_cnt)) {
+		play_sound(SWISH, 0);
+		_G(thor)->shot_cnt = 20;
+		_G(hammer)->used = 1;
+		_G(hammer)->dir = _G(thor)->dir;
+		_G(hammer)->last_dir = _G(thor)->dir;
+		_G(hammer)->x = _G(thor)->x;
+		_G(hammer)->y = _G(thor)->y + 2;
+		_G(hammer)->move = 2;
+		_G(hammer)->next = 0;
+		_G(hammer)->last_x[0] = _G(hammer)->x;
+		_G(hammer)->last_x[1] = _G(hammer)->x;
+		_G(hammer)->last_y[0] = _G(hammer)->y;
+		_G(hammer)->last_y[1] = _G(hammer)->y;
+	}
+}
+
+int kill_good_guy(void) {
+	if (!_G(killgg_inform) && !_G(thunder_flag)) {
+		odin_speaks(2010, 0);
+		_G(killgg_inform) = 1;
+	}
+
+	add_score(-1000);
+	return 0;
+}
+
+void actor_damaged(ACTOR *actr, int damage) {
+	if (!_G(setup).skill)
+		damage *= 2;
+	else if (_G(setup).skill == 2)
+		damage /= 2;
+
+	if (!actr->vunerable && actr->type != 3 && (actr->solid & 0x7f) != 2) {
+		actr->vunerable = STAMINA;
+		if (damage >= actr->health) {
+			if (actr->type != 4) {
+				add_score(actr->init_health * 10);
+//				display_score();
+			} else {
+				kill_good_guy();
+			}
+
+			actor_destroyed(actr);
+		} else {
+			actr->show = 10;
+			actr->health -= damage;
+			actr->speed_count += 8;
+		}
+	} else if (!actr->vunerable) {
+		actr->vunerable = STAMINA;
+
+		if (actr->func_num == 4) {
+			switch_icons();
+		}
+		if (actr->func_num == 7) {
+			rotate_arrows();
+		}
+	}
+
+}
+
+void thor_damaged(ACTOR *actr) {
+	int damage;
+
+	actr->hit_thor = 1;
+//	if (cheat) if (key_flag[_FOUR]) return;
+	damage = actr->strength;
+	if (damage != 255) {
+		if (!_G(setup).skill) damage /= 2;
+		else if (_G(setup).skill == 2) damage *= 2;
+	}
+	if ((!_G(thor)->vunerable && !_G(shield_on)) || damage == 255) {
+		if (damage >= _G(thor)->health) {
+			_G(thor)->vunerable = 40;
+			_G(thor)->show = 0;
+			_G(thor)->health = 0;
+			//display_health();
+			_G(exit_flag) = 2;
+		} else if (damage) {
+			_G(thor)->vunerable = 40;
+			_G(sound).play_sound(OW, 0);
+			_G(thor)->show = 10;
+			_G(thor)->health -= damage;
+			//display_health();
+		}
+	}
+}
+
+void actor_destroyed(ACTOR *actr) {
+	int x, y, x1, y1, r, n, t;
+	int pge = 0;
+
+	if (actr->actor_num > 2) {
+		x = actr->last_x[pge ^ 1];
+		y = actr->last_y[pge ^ 1];
+		x1 = actr->last_x[pge];
+		y1 = actr->last_y[pge];
+		r = actr->rating;
+		n = actr->actor_num;
+		t = actr->type;
+
+		if (actr->func_num == 255)
+			*actr = _G(explosion);
+		else
+			*actr = _G(sparkle);
+
+		actr->type = t;
+		actr->actor_num = n;
+		actr->rating = r;
+		actr->x = x;
+		actr->y = y;
+		actr->last_x[pge] = x1;
+		actr->last_x[pge ^ 1] = x;
+		actr->last_y[pge] = y1;
+		actr->last_y[pge ^ 1] = y;
+		actr->speed_count = actr->speed;
+		actr->used = 1;
+		actr->num_shots = 3;  // used to reverse explosion
+		actr->vunerable = 255;
+	} else {
+		actr->dead = 2;
+		actr->used = 0;
+	}
+}
+
+int _actor_shoots(ACTOR *actr, int dir) {
+	int t, i, cx, cy;
+	ACTOR *act;
+
+	t = actr->shot_type - 1;
+	for (i = MAX_ENEMIES + 3; i < MAX_ACTORS; i++) {
+		if ((!_G(actor)[i].used) && (!_G(actor)[i].dead)) {
+			act = &_G(actor)[i];
+			memcpy(act, &_G(shot)[t], sizeof(ACTOR));
+			if (actr->size_y < act->size_y) cy = actr->y - ((act->size_y - actr->size_y) / 2);
+			else cy = actr->y + ((actr->size_y - act->size_y) / 2);
+			if (actr->size_x < act->size_x) cx = actr->x - ((act->size_x - actr->size_x) / 2);
+			else cx = actr->x + ((actr->size_x - act->size_x) / 2);
+			if (cy > 174) cy = 174;
+			if (cx > 304) cx = 304;
+			act->x = cx;
+			act->y = cy;
+			act->last_dir = dir;
+			act->next = 0;
+			act->dir = dir;
+			if (act->directions == 1) act->dir = 0;
+			else if (act->directions == 4 && act->frames == 1) {
+				act->next = dir;
+				act->dir = 0;
+			}
+			act->frame_count = act->frame_speed;
+			act->speed_count = act->speed;
+			act->last_x[0] = cx;
+			act->last_x[1] = cx;
+			act->last_x[0] = actr->x;
+			act->last_x[1] = actr->x;
+			act->last_y[0] = cy;
+			act->last_y[1] = cy;
+			act->used = 1;
+			act->creator = actr->actor_num;
+			act->move_count = act->num_moves;
+			act->dead = 0;
+			actr->shot_actor = i;
+			actr->num_shots++;
+			actr->shot_cnt = 20;
+			_G(shot_ok) = 0;
+			return 1;
+		}
+	}
+	return 0;
+}
+
+void actor_always_shoots(ACTOR *actr, int dir) {
+
+
+	_actor_shoots(actr, dir);
+}
+
+int actor_shoots(ACTOR *actr, int dir) {
+	int i, cx, cy, tx, ty;
+	int icn;
+
+	cx = (actr->x + (actr->size_x / 2)) >> 4;
+	cy = ((actr->y + actr->size_y) - 2) >> 4;
+
+	tx = _G(thor)->center_x;
+	ty = _G(thor)->center_y;
+
+	icn = 140;
+	if (_G(shot)[actr->shot_type - 1].flying == 1) icn = 80;
+
+	switch (dir) {
+	case 0:
+		for (i = ty + 1; i <= cy; i++)
+			if (_G(scrn).icon[i][cx] < icn) return 0;
+		break;
+	case 1:
+		for (i = cy; i <= ty; i++)
+			if (_G(scrn).icon[i][cx] < icn) return 0;
+		break;
+	case 2:
+		for (i = tx; i < cx; i++)
+			if (_G(scrn).icon[cy][i] < icn) return 0;
+		break;
+	case 3:
+		for (i = cx; i < tx; i++)
+			if (_G(scrn).icon[cy][i] < icn) return 0;
+		break;
+	}
+	return _actor_shoots(actr, dir);
+}
+
+void move_actor(ACTOR *actr) {
+	int i;
+
+	if (actr->vunerable != 0) actr->vunerable--;
+	if (actr->shot_cnt != 0) actr->shot_cnt--;
+	if (actr->show != 0) actr->show--;
+
+	if (!actr->shot_cnt && _G(shot_ok)) {
+		if (actr->shots_allowed) {
+			if (actr->num_shots < actr->shots_allowed) {
+				shot_pattern_func[actr->shot_pattern](actr);
+			}
+		}
+	}
+
+	actr->speed_count--;
+	if (actr->speed_count <= 0) {
+		if (!actr->move_counter) actr->speed_count = actr->speed;
+		else actr->speed_count = (actr->speed << 1);
+		if (actr->type == 3) i = shot_movement_func[actr->move](actr);
+		else i = movement_func[actr->move](actr);
+		if (actr->directions == 2) i &= 1;
+		if (i != actr->dir) actr->dir = i;
+
+		if (actr->move == 0 && _G(current_level) != _G(new_level) && _G(shield_on)) {
+			_G(actor)[2].x = actr->x - 2;
+			if (_G(actor)[2].x < 0) _G(actor)[2].x = 0;
+			_G(actor)[2].y = actr->y;
+			_G(actor)[2].last_x[0] = _G(actor)[2].x;
+			_G(actor)[2].last_x[1] = _G(actor)[2].x;
+			_G(actor)[2].last_y[0] = _G(actor)[2].y;
+			_G(actor)[2].last_y[1] = _G(actor)[2].y;
+		}
+	} else i = actr->dir;
+
+	actr->x &= 0xfffe;
+}
+
+} // namespace Got
diff --git a/engines/got/game/move.h b/engines/got/game/move.h
new file mode 100644
index 00000000000..c3b071b93b0
--- /dev/null
+++ b/engines/got/game/move.h
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GAME_MOVE_H
+#define GOT_GAME_MOVE_H
+
+#include "got/data/defines.h"
+
+namespace Got {
+
+extern void next_frame(ACTOR *actr);
+extern bool point_within(int x, int y, int x1, int y1, int x2, int y2);
+extern bool overlap(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
+extern int  reverse_direction(ACTOR *actr);
+extern void thor_shoots(void);
+extern void thor_damaged(ACTOR *actr);
+extern void actor_destroyed(ACTOR *actr);
+extern int  actor_shoots(ACTOR *actr, int dir);
+extern void actor_always_shoots(ACTOR *actr, int dir);
+extern void actor_damaged(ACTOR *actr, int damage);
+extern void move_actor(ACTOR *actr);
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
new file mode 100644
index 00000000000..8441f8af4b5
--- /dev/null
+++ b/engines/got/game/move_patterns.cpp
@@ -0,0 +1,2264 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/game/move_patterns.h"
+#include "got/game/back.h"
+#include "got/game/boss1.h"
+#include "got/game/move.h"
+#include "got/game/object.h"
+#include "got/game/panel.h"
+#include "got/game/script.h"
+#include "got/game/special_tile.h"
+#include "got/events.h"
+#include "got/vars.h"
+
+namespace Got {
+
+#define TILE_SOLID   80
+#define TILE_FLY     140
+#define TILE_SPECIAL 200
+
+static const int bomb_x[] = { 0,-16,32,-32,32,-16,-16, 32,-16 };
+static const int bomb_y[] = { 0,-16,16,  0,16,-32, 32,-32, 32 };
+static const int8 rotate_pat[] = { 0,3,1,2 };
+
+extern int (*dialog_func[]) (ACTOR *actr);
+
+int check_special_move1(int x, int y, ACTOR *actr);
+
+int  check_move0(int x, int y, ACTOR *actr);
+int  check_move1(int x, int y, ACTOR *actr);
+int  check_move2(int x, int y, ACTOR *actr);
+int  check_move3(int x, int y, ACTOR *actr);
+int  check_move4(int x, int y, ACTOR *actr);
+
+int movement_zero(ACTOR *actr);
+int movement_one(ACTOR *actr);
+int movement_two(ACTOR *actr);
+int movement_three(ACTOR *actr);
+int movement_four(ACTOR *actr);
+int movement_five(ACTOR *actr);
+int movement_six(ACTOR *actr);
+int movement_seven(ACTOR *actr);
+int movement_eight(ACTOR *actr);
+int movement_nine(ACTOR *actr);
+int movement_ten(ACTOR *actr);
+int movement_eleven(ACTOR *actr);
+int movement_twelve(ACTOR *actr);         // horz straight until bump
+int movement_thirteen(ACTOR *actr);       // pause-seek (mushroom)
+int movement_fourteen(ACTOR *actr);       // move-bump-stop (boulder)
+int movement_fifteen(ACTOR *actr);        // no move, no frame cycle
+int movement_sixteen(ACTOR *actr);        // tornado 1
+int movement_seventeen(ACTOR *actr);      // tornado 2
+int movement_eighteen(ACTOR *actr);       // random-seek-bite-run
+int movement_nineteen(ACTOR *actr);       // tornado 2
+int movement_twenty(ACTOR *actr);         // tornado 2
+int movement_twentyone(ACTOR *actr);      // eyeball
+int movement_twentytwo(ACTOR *actr);      // spear
+int movement_twentythree(ACTOR *actr);    // spinball cw
+int movement_twentyfour(ACTOR *actr);     // spinball ccw
+int movement_twentyfive(ACTOR *actr);     //
+int movement_twentysix(ACTOR *actr);      //
+int movement_twentyseven(ACTOR *actr);    //
+int movement_twentyeight(ACTOR *actr);    // tree boss
+int movement_twentynine(ACTOR *actr);     // horz or vert (pass_val)
+int movement_thirty(ACTOR *actr);         // vert straight
+int movement_thirtyone(ACTOR *actr);      // drop (stalagtite)
+int movement_thirtytwo(ACTOR *actr);      // bomb 1
+int movement_thirtythree(ACTOR *actr);    // bomb 2
+int movement_thirtyfour(ACTOR *actr);     // gun (4-dir)
+int movement_thirtyfive(ACTOR *actr);     // gun (4-dir)
+int movement_thirtysix(ACTOR *actr);      // acid drop
+int movement_thirtyseven(ACTOR *actr);    // 4-way rnd,rnd len
+int movement_thirtyeight(ACTOR *actr);    // timed darting
+int movement_thirtynine(ACTOR *actr);     // troll 1
+int movement_forty(ACTOR *actr);          // troll 2
+
+int (*const movement_func[]) (ACTOR *actr) = {
+	movement_zero,
+	movement_one,
+	movement_two,
+	movement_three,
+	movement_four,
+	movement_five,
+	movement_six,
+	movement_seven,
+	movement_eight,
+	movement_nine,
+	movement_ten,
+	movement_eleven,
+	movement_twelve,
+	movement_thirteen,
+	movement_fourteen,
+	movement_fifteen,
+	movement_sixteen,
+	movement_seventeen,
+	movement_eighteen,
+	movement_nineteen,
+	movement_twenty,
+	movement_twentyone,
+	movement_twentytwo,
+	movement_twentythree,
+	movement_twentyfour,
+	movement_twentyfive,
+	movement_twentysix,
+	movement_twentyseven,
+	movement_twentyeight,
+	movement_twentynine,
+	movement_thirty,
+	movement_thirtyone,
+	movement_thirtytwo,
+	movement_thirtythree,
+	movement_thirtyfour,
+	movement_thirtyfive,
+	movement_thirtysix,
+	movement_thirtyseven,
+	movement_thirtyeight,
+	movement_thirtynine,
+	movement_forty
+};
+
+int special_movement_one(ACTOR *actr);
+int special_movement_two(ACTOR *actr);
+int special_movement_three(ACTOR *actr);
+int special_movement_four(ACTOR *actr);
+int special_movement_five(ACTOR *actr);
+int special_movement_six(ACTOR *actr);
+int special_movement_seven(ACTOR *actr);
+int special_movement_eight(ACTOR *actr);
+int special_movement_nine(ACTOR *actr);
+int special_movement_ten(ACTOR *actr);
+
+int (*special_movement_func[])(ACTOR *actr) = {
+	NULL,
+	special_movement_one,
+	special_movement_two,
+	special_movement_three,
+	special_movement_four,
+	special_movement_five,
+	special_movement_six,
+	special_movement_seven,
+	special_movement_eight,
+	special_movement_nine,
+	special_movement_ten
+};
+
+
+// check thor move
+int check_move0(int x, int y, ACTOR *actr) {
+	int x1, x2, y1, y2;
+	int x3, x4, y3, y4;
+	int i, ti;
+	ACTOR *act;
+	char icn1, icn2, icn3, icn4;
+
+	_G(thor_icon1) = 0;
+	_G(thor_icon2) = 0;
+	_G(thor_icon3) = 0;
+	_G(thor_icon4) = 0;
+
+	if (x < 0) {
+		if (_G(current_level) > 0) {
+			_G(new_level) = _G(current_level) - 1;
+			actr->x = 304;
+			actr->last_x[0] = 304;
+			actr->last_x[1] = 304;
+			actr->show = 0;
+			actr->move_count = 0;
+			set_thor_vars();
+			return 1;
+		} else return 0;
+	}
+	if (x > 306) {
+		if (_G(current_level) < 119) {
+			_G(new_level) = _G(current_level) + 1;
+			actr->x = 0;
+			actr->last_x[0] = 0;
+			actr->last_x[1] = 0;
+			actr->show = 0;
+			actr->move_count = 0;
+			set_thor_vars();
+			return 1;
+		} else return 0;
+	}
+	if (y < 0) {
+		if (_G(current_level) > 9) {
+			_G(new_level) = _G(current_level) - 10;
+			actr->y = 175;
+			actr->last_y[0] = 175;
+			actr->show = 0;
+			actr->last_y[1] = 175;
+			actr->move_count = 0;
+			set_thor_vars();
+			return 1;
+		} else return 0;
+	}
+	if (y > 175) {
+		if (_G(current_level) < 110) {
+			_G(new_level) = _G(current_level) + 10;
+			actr->y = 0;
+			actr->last_y[0] = 0;
+			actr->last_y[1] = 0;
+			actr->show = 0;
+			actr->move_count = 0;
+			set_thor_vars();
+			return 1;
+		} else return 0;
+	}
+	x1 = (x + 1) >> 4;
+	y1 = (y + 8) >> 4;
+	if (_G(thor)->dir > 1) x2 = (x + 12) >> 4;
+	else x2 = (x + 10) >> 4;
+	y2 = (y + 15) >> 4;
+
+	// check for solid or fly over
+	if ((_G(cheat) + _G(key_flag)[_ONE]) < 2) {
+		icn1 = _G(scrn).icon[y1][x1];
+		icn2 = _G(scrn).icon[y2][x1];
+		icn3 = _G(scrn).icon[y1][x2];
+		icn4 = _G(scrn).icon[y2][x2];
+		ti = 0;
+
+		if (icn1 < TILE_FLY) {
+			_G(thor_icon1) = 1; ti = 1;
+		}
+		if (icn2 < TILE_FLY) {
+			_G(thor_icon2) = 1; ti = 1;
+		}
+		if (icn3 < TILE_FLY) {
+			_G(thor_icon3) = 1; ti = 1;
+		}
+		if (icn4 < TILE_FLY) {
+			_G(thor_icon4) = 1; ti = 1;
+		}
+		if (ti) return 0;
+
+		if (icn1 > TILE_SPECIAL) {
+			if (!special_tile_thor(y1, x1, icn1)) return 0;
+			icn2 = _G(scrn).icon[y2][x1];
+			icn3 = _G(scrn).icon[y1][x2];
+			icn4 = _G(scrn).icon[y2][x2];
+		}
+		if (icn2 > TILE_SPECIAL) {
+			if (!special_tile_thor(y2, x1, icn2)) return 0;
+			icn3 = _G(scrn).icon[y1][x2];
+			icn4 = _G(scrn).icon[y2][x2];
+		}
+		if (icn3 > TILE_SPECIAL) {
+			if (!special_tile_thor(y1, x2, icn3)) return 0;
+			icn4 = _G(scrn).icon[y2][x2];
+		}
+		if (icn4 > TILE_SPECIAL) if (!special_tile_thor(y2, x2, icn4)) return 0;
+	}
+
+	x1 = x + 1;
+	y1 = y + 8;
+	if (_G(thor)->dir > 1) x2 = x + 12;
+	else x2 = x + 12;
+	y2 = y + 15;
+
+	_G(thor_special_flag) = 0;
+	for (i = 3; i < MAX_ACTORS; i++) {   //max_actors
+		act = &_G(actor)[i];
+		if (act->solid & 128) continue;
+		if (!act->used) continue;
+		x3 = act->x + 1;
+		if ((ABS(x3 - x1)) > 16) continue;
+		y3 = act->y + 1;
+		if ((ABS(y3 - y1)) > 16) continue;
+		x4 = act->x + act->size_x - 1;
+		y4 = act->y + act->size_y - 1;
+		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
+			if (act->func_num > 0) { //255=explosion
+				if (act->func_num == 255) return 0;
+				act->temp1 = x;
+				act->temp2 = y;
+				_G(thor_special_flag) = 1;
+				return special_movement_func[act->func_num](act);
+			} else {
+				_G(thor_special_flag) = 0;
+				thor_damaged(act);
+				if (act->solid < 2) {
+					if (!act->vunerable && (!(act->type & 1))) play_sound(PUNCH1, 0);
+					if (!_G(hammer)->used && _G(key_flag)[_G(key_fire)])
+						actor_damaged(act, _G(hammer)->strength);
+					else
+						actor_damaged(act, _G(thor)->strength);
+				}
+			}
+			return 1;
+		}
+	}
+	actr->x = x;
+	actr->y = y;
+	return 1;
+}
+
+int check_move1(int x, int y, ACTOR *actr) {   //check hammer move
+	int  x1, x2, y1, y2, i;
+	int  x3, y3, x4, y4;
+	int  icn, f;
+	char icn1, icn2, icn3, icn4;
+
+	ACTOR *act;
+
+	if (x < 0 || x>306 || y < 0 || y>177) return 0;
+
+	x1 = (x + 1) >> 4;
+	y1 = (y + 6) >> 4;
+	x2 = (x + 10) >> 4;
+	y2 = (y + 10) >> 4;
+
+	//check for solid or fly over
+	icn = TILE_FLY;
+	if (actr->flying) icn = TILE_SOLID;
+
+	icn1 = _G(scrn).icon[y1][x1];
+	icn2 = _G(scrn).icon[y2][x1];
+	icn3 = _G(scrn).icon[y1][x2];
+	icn4 = _G(scrn).icon[y2][x2];
+	if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) {
+		if (actr->actor_num == 1 && actr->move == 2) play_sound(CLANG, 0);
+		return 0;
+	}
+
+	if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
+	if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
+	if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
+	if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
+
+	x1 = x + 1;
+	y1 = y + 1;
+	x2 = x + 10;
+	y2 = y + 10;
+
+	f = 0;
+	for (i = 3; i < MAX_ACTORS; i++) {       //max_actors
+		act = &_G(actor)[i];
+		if (!act->used) continue;
+		if (act->type == 3) continue;  //continue
+		x3 = act->x;
+		if ((ABS(x3 - x1)) > 16) continue;
+		y3 = act->y;
+		if ((ABS(y3 - y1)) > 16) continue;
+		x4 = act->x + act->size_x - 1;
+		y4 = act->y + act->size_y - 1;
+
+		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
+			if (_G(boss_active)) {
+				switch (_G(boss_active)) {
+				case 1:
+					check_boss1_hit(act, x1, y1, x2, y2, i);
+					break;
+				}
+			} else {
+				if (act->solid == 2 && (actr->move == 16 || actr->move == 17)) return 0;
+				actor_damaged(act, actr->strength);
+			}
+			f++;
+		}
+	}
+	if (f && actr->move == 2) return 0;
+	actr->x = x;
+	actr->y = y;
+	return 1;
+}
+
+int check_move2(int x, int y, ACTOR *actr) {   //check enemy move
+	int x1, x2, y1, y2, i;
+	int x3, y3, x4, y4;
+	int icn;
+	char icn1, icn2, icn3, icn4;
+
+	ACTOR *act;
+
+	if (actr->actor_num < 3) return check_move1(x, y, actr);
+
+	if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175) return 0;
+
+	x1 = (x + 1) >> 4;
+	if (!actr->func_num) y1 = (y + (actr->size_y / 2)) >> 4;
+	else y1 = (y + 1) >> 4;
+	x2 = ((x + actr->size_x) - 1) >> 4;
+	y2 = ((y + actr->size_y) - 1) >> 4;
+
+	//check for solid or fly over
+
+	icn = TILE_FLY;
+	if (actr->flying) icn = TILE_SOLID;
+
+
+	icn1 = _G(scrn).icon[y1][x1];
+	icn2 = _G(scrn).icon[y2][x1];
+	icn3 = _G(scrn).icon[y1][x2];
+	icn4 = _G(scrn).icon[y2][x2];
+	if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) return 0;
+
+	if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
+	if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
+	if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
+	if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
+
+	x1 = x + 1;
+	y1 = y + 1;
+	x2 = (x + actr->size_x) - 1;
+	y2 = (y + actr->size_y) - 1;
+
+	for (i = 0; i < MAX_ACTORS; i++) {   //max_actors
+		act = &_G(actor)[i];
+		if (act->actor_num == actr->actor_num) continue;
+		if (act->actor_num == 1) continue;
+		if (!act->used) continue;
+		if (act->type == 3) continue;   //shot
+		if (i == 0) {
+			if (overlap(x1, y1, x2, y2, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
+				thor_damaged(actr);
+				return 0;
+			}
+		} else {
+			x3 = act->x;
+			if ((ABS(x3 - x1)) > 16) continue;
+			y3 = act->y;
+			if ((ABS(y3 - y1)) > 16) continue;
+			x4 = act->x + act->size_x;
+			y4 = act->y + act->size_y;
+			if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
+				if (actr->move == 38) {
+					if (act->func_num == 4)
+						_G(switch_flag) = 1;
+					else if (act->func_num == 7)
+						_G(switch_flag) = 2;
+				}
+				return 0;
+			}
+		}
+	}
+	actr->x = x;
+	actr->y = y;
+	return 1;
+}
+
+int check_move3(int x, int y, ACTOR *actr) {   //check enemy shot move
+	int x1, x2, y1, y2;
+	int x3, x4, y3, y4, i;
+	char icn1, icn2, icn3, icn4;
+	ACTOR *act;
+
+	int icn;
+
+	if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175) return 0;
+
+	x1 = (x + 1) >> 4;
+	y1 = (y + (actr->size_y / 2)) >> 4;
+	x2 = ((x + actr->size_x) - 1) >> 4;
+	y2 = ((y + actr->size_y) - 1) >> 4;
+
+	//check for solid or fly over
+
+	icn = TILE_FLY;
+	if (actr->flying) icn = TILE_SOLID;
+
+	icn1 = _G(scrn).icon[y1][x1];
+	icn2 = _G(scrn).icon[y2][x1];
+	icn3 = _G(scrn).icon[y1][x2];
+	icn4 = _G(scrn).icon[y2][x2];
+	if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) return 0;
+
+	if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
+	if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
+	if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
+	if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
+
+	//check for solid or fly over
+	x1 = x + 1;
+	y1 = y + 1;
+	x2 = (x + actr->size_x) - 1;
+	y2 = (y + actr->size_y) - 1;
+
+	if (overlap(x1, y1, x2, y2, _G(thor_x1), _G(thor_real_y1), _G(thor_x2), _G(thor_y2))) {
+		thor_damaged(actr);
+		return 0;
+	}
+	for (i = 3; i < MAX_ACTORS; i++) {   //max_actors
+		if (i == actr->actor_num) continue;
+		act = &_G(actor)[i];
+		if (!act->used) continue;
+		if (act->solid < 2) continue;
+		if (act->type == 3) continue;   //shot
+		if (act->actor_num == actr->creator) continue;
+		x3 = act->x;
+		if ((ABS(x3 - x1)) > 16) continue;
+		y3 = act->y;
+		if ((ABS(y3 - y1)) > 16) continue;
+		x4 = x3 + 15;
+		y4 = y3 + 15;
+		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) return 0;
+	}
+	actr->x = x;
+	actr->y = y;
+	return 1;
+}
+
+int check_move4(int x, int y, ACTOR *actr) {   //flying enemies
+
+	if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175) return 0;
+	if (overlap(x, y, x + actr->size_x - 1, y + actr->size_y - 1,
+		_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
+		if (actr->type == 3) thor_damaged(actr);
+		return 0;
+	}
+	actr->x = x;
+	actr->y = y;
+	return 1;
+}
+
+#define THOR_PAD1 2
+#define THOR_PAD2 4
+int  check_thor_move(int x, int y, ACTOR *actr) {
+
+	if (check_move0(x, y, actr)) return 1;
+	if (_G(diag_flag) || _G(thor_special_flag)) return 0;
+	if ((_G(thor_icon1) + _G(thor_icon2) + _G(thor_icon3) + _G(thor_icon4)) > 1) return 0;
+	switch (actr->dir) {
+	case 0:
+		if (_G(thor_icon1)) {
+			actr->dir = 3;
+			if (check_move0(x + THOR_PAD1, y + 2, actr)) {
+				actr->dir = 0;
+				return 1;
+			}
+		} else if (_G(thor_icon3)) {
+			actr->dir = 2;
+			if (check_move0(x - THOR_PAD1, y + 2, actr)) {
+				actr->dir = 0;
+				return 1;
+			}
+		}
+		actr->dir = 0;
+		break;
+	case 1:
+		if (_G(thor_icon2)) {
+			actr->dir = 3;
+			if (check_move0(x + THOR_PAD1, y - 2, actr)) {
+				actr->dir = 1;
+				return 1;
+			}
+		} else if (_G(thor_icon4)) {
+			actr->dir = 2;
+			if (check_move0(x - THOR_PAD1, y - 2, actr)) {
+				actr->dir = 1;
+				return 1;
+			}
+		}
+		actr->dir = 1;
+		break;
+	case 2:
+		if (_G(thor_icon1)) {
+			if (check_move0(x + 2, y + THOR_PAD1, actr)) return 1;
+		} else if (_G(thor_icon2)) {
+			if (check_move0(x + 2, y - THOR_PAD1, actr)) return 1;
+		}
+		break;
+	case 3:
+		if (_G(thor_icon3)) {
+			if (check_move0(x - 2, y + THOR_PAD1, actr)) return 1;
+		} else if (_G(thor_icon4)) {
+			if (check_move0(x - 2, y - THOR_PAD1, actr)) return 1;
+		}
+		break;
+	}
+	return 0;
+}
+
+int movement_zero(ACTOR *actr) {       //player control
+	int d, x, y, od;
+	d = actr->dir;
+	od = d;
+
+	set_thor_vars();
+
+	if (_G(key_flag)[_G(key_fire)])
+		thor_shoots();
+	if (_G(key_flag)[_G(key_select)])
+		select_item();
+
+	if ((_G(hammer)->used) && (_G(hammer)->move == 5)) {
+		if (overlap(_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2),
+			_G(hammer)->x, _G(hammer)->y, _G(hammer)->x + 13, _G(hammer)->y + 13)) {
+			actor_destroyed(_G(hammer));
+		}
+	}
+	x = actr->x;
+	y = actr->y;
+	_G(diag_flag) = 0;
+	if (actr->move_counter) actr->move_counter--;
+	if (_G(key_flag)[_G(key_up)] && _G(key_flag)[_G(key_left)]) {
+		d = 2;
+		actr->dir = d;
+		_G(diag) = 1;
+		_G(diag_flag) = 1;
+		if (check_thor_move(x - 2, y - 2, actr)) {
+			next_frame(actr);
+			return d;
+		}
+	} else if (_G(key_flag)[_G(key_up)] && _G(key_flag)[_G(key_right)]) {
+		d = 3;
+		actr->dir = d;
+		_G(diag) = 2;
+		_G(diag_flag) = 1;
+		if (check_thor_move(x + 2, y - 2, actr)) {
+			next_frame(actr);
+			return d;
+		}
+	} else if (_G(key_flag)[_G(key_down)] && _G(key_flag)[_G(key_left)]) {
+		d = 2;
+		actr->dir = d;
+		_G(diag) = 4;
+		_G(diag_flag) = 1;
+		if (check_thor_move(x - 2, y + 2, actr)) {
+			next_frame(actr);
+			return d;
+		}
+	} else if (_G(key_flag)[_G(key_down)] && _G(key_flag)[_G(key_right)]) {
+		d = 3;
+		actr->dir = d;
+		_G(diag) = 3;
+		_G(diag_flag) = 1;
+		if (check_thor_move(x + 2, y + 2, actr)) {
+			next_frame(actr);
+			return d;
+		}
+	}
+	_G(diag) = 0;
+	if (_G(key_flag)[_G(key_right)]) {
+		if (!_G(key_flag)[_G(key_left)]) {
+			d = 3;
+			actr->dir = d;
+			if (check_thor_move(x + 2, y, actr)) {
+				next_frame(actr);
+				return d;
+			}
+		}
+	}
+	if (_G(key_flag)[_G(key_left)]) {
+		if (!_G(key_flag)[_G(key_right)]) {
+			d = 2;
+			actr->dir = d;
+			if (check_thor_move(x - 2, y, actr)) {
+				next_frame(actr);
+				return d;
+			}
+		}
+	}
+	if (_G(key_flag)[_G(key_down)]) {
+		if (!_G(key_flag)[_G(key_up)]) {
+			d = 1;
+			actr->dir = d;
+			if (check_thor_move(x, y + 2, actr)) {
+				next_frame(actr);
+				return d;
+			}
+		}
+	}
+	if (_G(key_flag)[_G(key_up)]) {
+		if (!_G(key_flag)[_G(key_down)]) {
+			d = 0;
+			actr->dir = d;
+			if (check_thor_move(x, y - 2, actr)) {
+				next_frame(actr);
+				return d;
+			}
+		}
+	}
+	actr->move_counter = 5;
+	actr->next = 0;
+	actr->dir = od;
+	return d;
+}
+
+int check_special_move1(int x, int y, ACTOR *actr) {
+	int x1, x2, y1, y2, i;
+	int x3, y3, x4, y4;
+	int icn;
+	char icn1, icn2, icn3, icn4;
+
+	ACTOR *act;
+
+	if (actr->actor_num < 3) return check_move1(x, y, actr);
+
+	if (x < 0 || x>304 || y < 0 || y>176) return 0;
+
+	x1 = x >> 4;
+	y1 = y >> 4;
+	x2 = (x + 15) >> 4;
+	y2 = (y + 15) >> 4;
+
+	//check for solid or fly over
+
+	icn = TILE_FLY;
+	if (actr->flying) icn = TILE_SOLID;
+
+	icn1 = _G(scrn).icon[y1][x1];
+	icn2 = _G(scrn).icon[y2][x1];
+	icn3 = _G(scrn).icon[y1][x2];
+	icn4 = _G(scrn).icon[y2][x2];
+	if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) return 0;
+
+	if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
+	if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
+	if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
+	if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
+
+	x1 = x;
+	y1 = y;
+	x2 = (x + 15);
+	y2 = (y + 15);
+
+	for (i = 3; i < MAX_ACTORS; i++) {   //max_actors
+		act = &_G(actor)[i];
+		if (act->actor_num == actr->actor_num) continue;
+		if (!act->used) continue;
+		if (act->type == 3) continue;   //shot
+		x3 = act->x;
+		if ((ABS(x3 - x1)) > 16) continue;
+		y3 = act->y;
+		if ((ABS(y3 - y1)) > 16) continue;
+		x4 = act->x + act->size_x;
+		y4 = act->y + 15;
+		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) return 0;
+	}
+	for (i = 3; i < MAX_ACTORS; i++) {   //max_actors
+		act = &_G(actor)[i];
+		if (act->actor_num == actr->actor_num) continue;
+		if (!act->used) continue;
+		if (act->type == 3) continue;   //shot
+		x3 = act->x;
+		if ((ABS(x3 - x1)) > 16) continue;
+		y3 = act->y;
+		if ((ABS(y3 - y1)) > 16) continue;
+		x4 = act->x + act->size_x;
+		y4 = act->y + act->size_y;
+		if (overlap(_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2), x3, y3, x4, y4)) return 0;
+	}
+	actr->x = x;
+	actr->y = y;
+	return 1;
+}
+
+//*==========================================================================
+
+int special_movement_one(ACTOR *actr) {   //block
+	int d, x1, y1, sd;
+
+	if (_G(diag_flag)) return 0;
+	d = _G(thor)->dir;
+	x1 = actr->x;
+	y1 = actr->y;
+	sd = actr->last_dir;
+	actr->last_dir = d;
+
+	switch (d) {
+	case 0:
+		y1 -= 2;
+		if (!check_special_move1(x1, y1, actr)) {
+			actr->last_dir = sd;
+			return 0;
+		}
+		break;
+	case 1:
+		y1 += 2;
+		if (!check_special_move1(x1, y1, actr)) {
+			actr->last_dir = sd;
+			return 0;
+		}
+		break;
+	case 2:
+		x1 -= 2;
+		if (!check_special_move1(x1, y1, actr)) {
+			actr->last_dir = sd;
+			return 0;
+		}
+		break;
+	case 3:
+		x1 += 2;
+		if (!check_special_move1(x1, y1, actr)) {
+			actr->last_dir = sd;
+			return 0;
+		}
+		break;
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	return 1;
+}
+
+int special_movement_two(ACTOR *actr) {   //angle
+	int x1, y1, x2, y2, i;
+	int x3, y3, x4, y4;
+	ACTOR *act;
+
+	x1 = actr->temp1;       //calc thor pos
+	y1 = actr->temp2;
+	x2 = x1 + 13;
+	y2 = y1 + 14;
+
+	for (i = 3; i < MAX_ACTORS; i++) {   //max_actors
+		act = &_G(actor)[i];
+		if (actr->actor_num == act->actor_num) continue;
+		if (!act->used) continue;
+		x3 = act->x;
+		if ((ABS(x3 - x1)) > 16) continue;
+		y3 = act->y;
+		if ((ABS(y3 - y1)) > 16) continue;
+		x4 = act->x + act->size_x;
+		y4 = act->y + act->size_y;
+		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) return 0;
+	}
+	if (!actr->func_pass) {
+		if (_G(thor)->health < 150) {
+			if (!sound_playing()) play_sound(ANGEL, 0);
+			_G(thor)->health += 1;
+			display_health();
+		}
+	} else {
+		if (_G(thor_info).magic < 150) {
+			if (!sound_playing()) play_sound(ANGEL, 0);
+			_G(thor_info).magic += 1;
+			display_magic();
+		}
+	}
+	return 1;
+}
+
+int special_movement_three(ACTOR *actr) {  //yellow globe
+	long lind;
+
+	if (_G(thunder_flag)) return 0;
+
+	lind = (long)_G(current_level);
+	lind = lind * 1000;
+	lind += (long)actr->actor_num;
+	execute_script(lind, &_G(odin)[0]);
+
+	return 0;
+}
+
+int special_movement_four(ACTOR *actr) {   //peg switch
+
+	if (actr->shot_cnt != 0) return 0;
+	actr->shot_cnt = 30;
+	actr = actr;
+	_G(switch_flag) = 1;
+	return 0;
+}
+void kill_enemies(int ix, int iy);
+void remove_objects(int iy, int ix);
+
+int special_movement_five(ACTOR *actr) {    //boulder roll
+	int d;
+
+	d = _G(thor)->dir;
+
+	if (_G(diag_flag)) {
+		switch (_G(diag)) {
+		case 1:
+			if (_G(thor_x1) < (actr->x + 15)) d = 0;
+			else d = 2;
+			break;
+		case 2:
+			if (_G(thor_x2) < actr->x) d = 3;
+			else d = 0;
+			break;
+		case 3:
+			if (_G(thor_x2) > (actr->x)) d = 1;
+			else d = 3;
+			break;
+		case 4:
+			if (_G(thor_x1) > (actr->x + 15)) d = 2;
+			else d = 1;
+			break;
+		}
+	}
+
+	actr->last_dir = d;
+	actr->move = 14;
+	return 0;
+}
+
+int special_movement_six(ACTOR *actr) {
+
+	thor_damaged(actr);
+	return 0;
+}
+
+int special_movement_seven(ACTOR *actr) {
+
+	if (actr->shot_cnt != 0) return 0;
+	actr->shot_cnt = 30;
+	actr = actr;
+	_G(switch_flag) = 2;
+	return 0;
+}
+
+int special_movement_eight(ACTOR *actr) {
+
+	if (_G(thor)->dir < 2 || _G(diag_flag)) return 0;
+	actr->last_dir = _G(thor)->dir;
+	actr->move = 14;
+	return 0;
+}
+
+int special_movement_nine(ACTOR *actr) {
+
+	if (_G(thor)->dir > 1 || _G(diag_flag)) return 0;
+	actr->last_dir = _G(thor)->dir;
+	actr->move = 14;
+	return 0;
+}
+
+int special_movement_ten(ACTOR *actr) {
+
+	if (actr->temp6) {
+		actr->temp6--;
+		return 0;
+	}
+	if (_G(thunder_flag)) return 0;
+	if (!actr->temp6) {
+		actr->temp6 = 10;
+		actor_speaks(actr, 0 - actr->pass_value, 0);
+	}
+	return 0;
+}
+
+int movement_one(ACTOR *actr) {    //no movement - frame cycle
+
+	next_frame(actr);
+	return actr->dir;
+}
+
+int movement_two(ACTOR *actr) {     //hammer only
+	int d, x1, y1;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	switch (d) {
+	case 0:
+		y1 -= 2;
+		break;
+	case 1:
+		y1 += 2;
+		break;
+	case 2:
+		x1 -= 2;
+		break;
+	case 3:
+		x1 += 2;
+		break;
+	}
+	if (!check_move2(x1, y1, actr)) {
+		if (actr->actor_num == 1) {
+			_G(hammer)->move = 5;
+			d = reverse_direction(_G(hammer));
+			_G(hammer)->dir = d;
+		}
+		if (actr->actor_num == 2) {
+			actr->used = 0;
+			actr->dead = 2;
+			_G(lightning_used) = 0;
+			_G(tornado_used) = 0;
+		}
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_three(ACTOR *actr) {         //walk-bump-random turn
+	int d, x1, y1;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	switch (d) {
+	case 0:
+		y1 -= 2;
+		if (!check_move2(x1, y1, actr)) {
+			d = g_events->getRandomNumber(3);
+		}
+		break;
+	case 1:
+		y1 += 2;
+		if (!check_move2(x1, y1, actr)) {
+			d = g_events->getRandomNumber(3);
+		}
+		break;
+	case 2:
+		x1 -= 2;
+		if (!check_move2(x1, y1, actr)) {
+			d = g_events->getRandomNumber(3);
+		}
+		break;
+	case 3:
+		x1 += 2;
+		if (!check_move2(x1, y1, actr)) {
+			d = g_events->getRandomNumber(3);
+		}
+		break;
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_four(ACTOR *actr) {         //simple tracking
+	int d, x1, y1, f;
+
+	d = actr->last_dir;
+
+	x1 = actr->x;
+	y1 = actr->y;
+
+	f = 0;
+	if (x1 > _G(thor_x1) - 1) {
+		x1 -= 2; d = 2; f = 1;
+	} else if (x1 < _G(thor_x1) - 1) {
+		x1 += 2; d = 3; f = 1;
+	}
+
+	if (f) f = check_move2(x1, y1, actr);
+
+	if (!f) {
+		if (y1 < (_G(thor_real_y1))) {
+			d = (_G(thor_real_y1))-y1;
+			if (d > 2) d = 2;
+			y1 += d;
+			d = 1;
+			f = 1;
+		} else if (y1 > (_G(thor_real_y1))) {
+			d = y1 - (_G(thor_real_y1));
+			if (d > 2) d = 2;
+			y1 -= d;
+			d = 0;
+			f = 1;
+		}
+		if (f) f = check_move2(actr->x, y1, actr);
+		if (!f) check_move2(actr->x, actr->y, actr);
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_five(ACTOR *actr) {
+	int x1, y1, xd, yd, d;
+
+	x1 = actr->x;
+	y1 = actr->y;
+	xd = yd = 0;
+	d = actr->last_dir;
+
+	if (x1 > (_G(thor)->x + 1)) xd = -2;  //+1
+	else if (x1 < (_G(thor)->x - 1)) xd = 2;
+
+	if (actr->actor_num == 1) {
+		if (y1 < (_G(thor_y1) - 6)) yd = 2;
+		else if (y1 > (_G(thor_y1) - 6)) yd = -2;
+	} else {
+		if (y1 < (_G(thor_real_y1) - 1)) yd = 2;
+		else if (y1 > (_G(thor_real_y1) + 1)) yd = -2;
+	}
+
+	if (xd && yd) {
+		if (xd == -2 && yd == -2) d = 2;
+		else if (xd == -2 && yd == 2) d = 2;
+		else if (xd == 2 && yd == -2) d = 3;
+		else if (xd == 2 && yd == 2) d = 3;
+		x1 += xd;
+		y1 += yd;
+		if (check_move2(x1, y1, actr)) {
+			next_frame(actr);
+			actr->last_dir = d;
+			if (actr->directions == 1) return 0;
+			return d;
+		}
+	} else {
+		if (xd == 0 && yd == 2) d = 1;
+		else if (xd == 0 && yd == -2) d = 0;
+		else if (xd == 2 && yd == 0) d = 3;
+		else if (xd == -2 && yd == 0) d = 2;
+	}
+	x1 = actr->x;
+	y1 = actr->y;
+	actr->toggle ^= 1;
+
+	if (actr->toggle) {
+		if (xd) {
+			x1 += xd;
+			if (check_move2(x1, y1, actr)) {
+				if (xd > 0) d = 3;
+				else d = 2;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1) return 0;
+				return d;
+			}
+			x1 = actr->x;
+		}
+		if (yd) {
+			y1 += yd;
+			if (check_move2(x1, y1, actr)) {
+				if (yd > 0) d = 1;
+				else d = 0;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1) return 0;
+				return d;
+			}
+		}
+		y1 = actr->y;
+	} else {
+		if (yd) {
+			y1 += yd;
+			if (check_move2(x1, y1, actr)) {
+				if (yd > 0) d = 1;
+				else d = 0;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1) return 0;
+				return d;
+			}
+			y1 = actr->y;
+		}
+		if (xd) {
+			x1 += xd;
+			if (check_move2(x1, y1, actr)) {
+				if (xd > 0) d = 3;
+				else d = 2;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1) return 0;
+				return d;
+			}
+		}
+	}
+	check_move2(actr->x, actr->y, actr);
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_six(ACTOR *actr) {   //explosion only
+
+	if (actr->num_shots > 0) {
+		actr->next++;
+		if (actr->next > 2) {
+			actr->next = 0;
+			if (_G(boss_dead)) play_sound(EXPLODE, 0);
+		}
+		actr->num_shots--;
+	} else {
+		actr->dead = 2;
+		actr->used = 0;
+		if (!_G(boss_dead)) if (actr->type == 2)
+			drop_object(actr);
+
+	}
+	next_frame(actr);
+	return 0;
+}
+
+int movement_seven(ACTOR *actr) {         //walk-bump-random turn (pause also)
+
+	if (actr->next == 0 && actr->frame_count == actr->frame_speed) {
+		actr->speed_count = 12;
+		actr->last_dir = g_events->getRandomNumber(3);
+	}
+	return movement_three(actr);
+}
+
+int movement_eight(ACTOR *actr) {         //follow thor
+
+	if (_G(thor)->x > 0) actr->x = _G(thor)->x - 1;
+	else actr->x = _G(thor)->x;
+	actr->y = _G(thor)->y;
+	next_frame(actr);
+	return 0;
+}
+
+int movement_nine(ACTOR *actr) {         //4-way straight (random length) change
+	int d, x1, y1, f;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	f = 0;
+	if (actr->counter) {
+		actr->counter--;
+		switch (d) {
+		case 0:
+			y1 -= 2;
+			if (!check_move4(x1, y1, actr)) f = 1;
+			break;
+		case 1:
+			y1 += 2;
+			if (!check_move4(x1, y1, actr)) f = 1;
+			break;
+		case 2:
+			x1 -= 2;
+			if (!check_move4(x1, y1, actr)) f = 1;
+			break;
+		case 3:
+			x1 += 2;
+			if (!check_move4(x1, y1, actr)) f = 1;
+			break;
+		}
+	} else f = 1;
+
+	if (f == 1) {
+		actr->counter = g_events->getRandomNumber(10, 99);
+		d = g_events->getRandomNumber(3);
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_ten(ACTOR *actr) {         //vert straight (random length) change
+	int d, x1, y1, f;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	f = 0;
+	if (actr->counter) {
+		if (actr->pass_value != 1) actr->counter--;
+		switch (d) {
+		case 0:
+			y1 -= 2;
+			if (!check_move2(x1, y1, actr)) f = 1;
+			break;
+		case 1:
+			y1 += 2;
+			if (!check_move2(x1, y1, actr)) f = 1;
+			break;
+		case 2:
+			y1 -= 2;
+			if (!check_move2(x1, y1, actr)) f = 1;
+			break;
+		case 3:
+			y1 += 2;
+			if (!check_move2(x1, y1, actr)) f = 1;
+			break;
+		}
+	} else f = 1;
+
+	if (f == 1) {
+		actr->counter = g_events->getRandomNumber(10, 99);
+		d = g_events->getRandomNumber(1);
+	}
+
+	if (d > 1)
+		d -= 2;
+
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_eleven(ACTOR *actr) {         //horz only (bats)
+	int d;
+
+	d = actr->last_dir;
+
+	switch (d) {
+	case 0:
+		if (check_move2(actr->x - 2, actr->y - 2, actr)) break;
+		d = 1;
+		if (check_move2(actr->x - 2, actr->y + 2, actr)) break;
+		d = 2;
+		break;
+	case 1:
+		if (check_move2(actr->x - 2, actr->y + 2, actr)) break;
+		d = 0;
+		if (check_move2(actr->x - 2, actr->y - 2, actr)) break;
+		d = 3;
+		break;
+	case 2:
+		if (check_move2(actr->x + 2, actr->y - 2, actr)) break;
+		d = 3;
+		if (check_move2(actr->x + 2, actr->y + 2, actr)) break;
+		d = 0;
+		break;
+	case 3:
+		if (check_move2(actr->x + 2, actr->y + 2, actr)) break;
+		d = 2;
+		if (check_move2(actr->x + 2, actr->y - 2, actr)) break;
+		d = 1;
+		break;
+	}
+
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_twelve(ACTOR *actr) {         //horz straight until bump
+	int d;
+
+	d = actr->last_dir;
+
+	switch (d) {
+	case 0:
+	case 2:
+		if (check_move2(actr->x - 2, actr->y, actr)) break;
+		d = 3;
+		break;
+	case 1:
+	case 3:
+		if (check_move2(actr->x + 2, actr->y, actr)) break;
+		d = 2;
+		break;
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_thirteen(ACTOR *actr) {         //pause-seek (mushroom)
+	int d;
+
+	d = actr->last_dir;
+
+	if (actr->counter == 0 && actr->pause == 0) {
+		actr->pause = 60;
+		return d;
+	}
+	if (actr->pause > 0) {
+		actr->pause--;
+		if (!actr->pause) actr->counter = 60;
+		actr->vunerable = 5;
+		actr->strength = 0;
+		return d;
+	}
+	if (actr->counter > 0) {
+		actr->counter--;
+		if (!actr->counter) actr->pause = 60;
+		actr->strength = 10;
+		return movement_five(actr);
+	}
+	return d;
+}
+
+int movement_fourteen(ACTOR *actr) {         //move-bump-stop (boulder)
+	int d, x1, y1;
+
+	d = actr->last_dir;
+	actr->dir = d;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	switch (d) {
+	case 0:
+		y1 -= 2;
+		if (!check_move2(x1, y1, actr)) {
+			actr->move = 15;
+			return 0;
+		}
+		break;
+	case 1:
+		y1 += 2;
+		if (!check_move2(x1, y1, actr)) {
+			actr->move = 15;
+			return 0;
+		}
+		break;
+	case 2:
+		x1 -= 2;
+		if (!check_move2(x1, y1, actr)) {
+			actr->move = 15;
+			return 0;
+		}
+		break;
+	case 3:
+		x1 += 2;
+		if (!check_move2(x1, y1, actr)) {
+			actr->move = 15;
+			return 0;
+		}
+		break;
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_fifteen(ACTOR *actr) {    //no movement - no frame cycle
+
+	return actr->dir;
+}
+
+int movement_sixteen(ACTOR *actr) {     //tornado 1
+	int d, x1, y1;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	switch (d) {
+	case 0:
+		y1 -= 2;
+		break;
+	case 1:
+		y1 += 2;
+		break;
+	case 2:
+		x1 -= 2;
+		break;
+	case 3:
+		x1 += 2;
+		break;
+	}
+	if (!check_move1(x1, y1, actr)) {
+		actr->move = 17;
+		d = g_events->getRandomNumber(3);
+	}
+
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_seventeen(ACTOR *actr) {         //tornado 2
+	int d;
+
+	d = actr->last_dir;
+
+	switch (d) {
+	case 0:
+		if (check_move1(actr->x - 2, actr->y - 2, actr)) break;
+		d = 1;
+		if (check_move1(actr->x - 2, actr->y + 2, actr)) break;
+		d = 2;
+		break;
+	case 1:
+		if (check_move1(actr->x - 2, actr->y + 2, actr)) break;
+		d = 0;
+		if (check_move1(actr->x - 2, actr->y - 2, actr)) break;
+		d = 3;
+		break;
+	case 2:
+		if (check_move1(actr->x + 2, actr->y - 2, actr)) break;
+		d = 3;
+		if (check_move1(actr->x + 2, actr->y + 2, actr)) break;
+		d = 0;
+		break;
+	case 3:
+		if (check_move1(actr->x + 2, actr->y + 2, actr)) break;
+		d = 2;
+		if (check_move1(actr->x + 2, actr->y - 2, actr)) break;
+		d = 1;
+		break;
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_eighteen(ACTOR *actr) {    //no movement - frame cycle
+	int d;
+
+	if (actr->temp5) {
+		actr->temp5--;
+		if (!actr->temp5) actr->num_moves = 1;
+	}
+	if (actr->temp1) {
+		d = movement_five(actr);
+		actr->rand--;
+		if (actr->hit_thor || !actr->rand) {
+			if (actr->hit_thor) {
+				actr->temp5 = 50;
+				actr->num_moves = 2;
+				actr->hit_thor = 0;
+				actr->dir = d;
+				d = reverse_direction(actr);
+			}
+			actr->temp1 = 0;
+			actr->rand = g_events->getRandomNumber(50, 149);
+		}
+	} else {
+		d = movement_three(actr);
+		actr->rand--;
+		if (!actr->rand) {
+			actr->temp5 = 0;
+			actr->temp1 = 1;
+			actr->rand = g_events->getRandomNumber(50, 149);
+		}
+		if (actr->hit_thor) {
+			actr->temp5 = 50;
+			actr->num_moves = 2;
+			actr->hit_thor = 0;
+			actr->dir = d;
+			d = reverse_direction(actr);
+		}
+	}
+	next_frame(actr);
+	return d;
+}
+
+int movement_nineteen(ACTOR *actr) {    //no movement - frame cycle
+
+	return movement_seven(actr);
+}
+
+int movement_twenty(ACTOR *actr) {    //boss - snake
+
+	return boss1_movement(actr);
+}
+
+int movement_twentyone(ACTOR *actr) {    //no movement - frame cycle
+
+	return movement_three(actr);
+}
+
+int movement_twentytwo(ACTOR *actr) {    //spear
+	int d;
+
+	d = actr->last_dir;
+	if (actr->directions == 1) d = 0;
+
+redo:
+
+	switch (actr->temp2) {
+	case 0:
+		if (bgtile(actr->x, actr->y) >= TILE_SOLID) actr->next = 1;
+		else {
+			actr->temp2 = 6;
+			actr->temp1 = 1;
+			goto redo;
+		}
+		actr->temp2++;
+		break;
+	case 1:
+		actr->next = 2;
+		actr->temp2++;
+		break;
+	case 2:
+		actr->next = 3;
+		actr->strength = 255;
+		actr->temp2++;
+		actr->temp1 = 10;
+		break;
+	case 3:
+		check_move2(actr->x, actr->y, actr);
+		actr->temp1--;
+		if (actr->temp1) break;
+		actr->temp2++;
+		actr->next = 2;
+		break;
+	case 4:
+		actr->strength = 0;
+		actr->temp2++;
+		actr->next = 1;
+		break;
+	case 5:
+		actr->temp2++;
+		actr->next = 0;
+		actr->temp1 = 10;
+		break;
+	case 6:
+		actr->temp1--;
+		if (actr->temp1) break;
+		actr->temp2 = 0;
+		actr->next = 0;
+		switch (d) {
+		case 0:
+			actr->x += 16;
+			actr->y += 16;
+			d = 3;
+			if (bgtile(actr->x, actr->y) < TILE_SOLID) goto redo;
+			break;
+		case 1:
+			actr->x -= 16;
+			actr->y -= 16;
+			d = 2;
+			if (bgtile(actr->x, actr->y) < TILE_SOLID) goto redo;
+			break;
+		case 2:
+			actr->x += 16;
+			actr->y -= 16;
+			d = 0;
+			if (bgtile(actr->x, actr->y) < TILE_SOLID) goto redo;
+			break;
+		case 3:
+			actr->x -= 16;
+			actr->y += 16;
+			d = 1;
+			if (bgtile(actr->x, actr->y) < TILE_SOLID) goto redo;
+			break;
+		}
+		actr->dir = d;
+		actr->last_dir = d;
+		break;
+	}
+	return d;
+}
+
+int movement_twentythree(ACTOR *actr) {    //spinball counter-clockwise
+	int d;
+
+	d = actr->last_dir;
+	next_frame(actr);
+	if (actr->pass_value & 2) actr->num_moves = 2;
+
+	switch (d) {
+	case 0:
+		if (bgtile(actr->x - 2, actr->y) >= TILE_FLY &&
+			bgtile(actr->x - 2, actr->y + actr->size_y - 1) >= TILE_FLY) {
+			d = 2;
+			actr->x -= 2;
+		} else {
+			if (bgtile(actr->x, actr->y - 2) < TILE_FLY ||
+				bgtile(actr->x + actr->size_x - 1, actr->y - 2) < TILE_FLY) {
+				if (bgtile(actr->x + actr->size_x + 1, actr->y) >= TILE_FLY &&
+					bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) >= TILE_FLY) {
+					d = 3;
+					actr->x += 2;
+				} else {
+					d = 1;
+					break;
+				}
+			} else actr->y -= 2;
+		}
+		break;
+	case 1:
+		if (bgtile(actr->x + actr->size_x + 1, actr->y) >= TILE_FLY &&
+			bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) >= TILE_FLY) {
+			d = 3;
+			actr->x += 2;
+		} else {
+			if (bgtile(actr->x, actr->y + actr->size_y + 1) < TILE_FLY ||
+				bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) < TILE_FLY) {
+				if (bgtile(actr->x - 2, actr->y) >= TILE_FLY &&
+					bgtile(actr->x - 2, actr->y + actr->size_y - 1) >= TILE_FLY) {
+					d = 2;
+					actr->x -= 2;
+				} else {
+					d = 0;
+					break;
+				}
+			} else actr->y += 2;
+		}
+		break;
+	case 2:
+		if (bgtile(actr->x, actr->y + actr->size_y + 1) >= TILE_FLY &&
+			bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) >= TILE_FLY) {
+			d = 1;
+			actr->y += 2;
+		} else {
+			if (bgtile(actr->x - 2, actr->y) < TILE_FLY ||
+				bgtile(actr->x - 2, actr->y + actr->size_y - 1) < TILE_FLY) {
+				if (bgtile(actr->x, actr->y - 2) >= TILE_FLY &&
+					bgtile(actr->x + actr->size_x - 1, actr->y - 2) >= TILE_FLY) {
+					d = 0;
+					actr->y -= 2;
+				} else {
+					d = 3;
+					break;
+				}
+			} else actr->x -= 2;
+		}
+		break;
+	case 3:
+		if (bgtile(actr->x, actr->y - 2) >= TILE_FLY &&
+			bgtile(actr->x + actr->size_x - 1, actr->y - 2) >= TILE_FLY) {
+			d = 0;
+			actr->y -= 2;
+		} else {
+			if (bgtile(actr->x + actr->size_x + 1, actr->y) < TILE_FLY ||
+				bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) < TILE_FLY) {
+				if (bgtile(actr->x, actr->y + actr->size_y + 1) >= TILE_FLY &&
+					bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) >= TILE_FLY) {
+					d = 1;
+					actr->y += 2;
+				} else {
+					d = 2;
+					break;
+				}
+			} else actr->x += 2;
+		}
+		break;
+	}
+	check_move2(actr->x, actr->y, actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_twentyfour(ACTOR *actr) {    //spinball  clockwise
+	int d;
+
+	d = actr->last_dir;
+	next_frame(actr);
+	if (actr->pass_value & 2) actr->num_moves = 2;
+
+	switch (d) {
+	case 0:
+		if (bgtile(actr->x + actr->size_x + 1, actr->y) >= TILE_FLY &&
+			bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) >= TILE_FLY) {
+			d = 3;
+			actr->x += 2;
+		} else {
+			if (bgtile(actr->x, actr->y - 2) < TILE_FLY ||
+				bgtile(actr->x + actr->size_x - 1, actr->y - 2) < TILE_FLY) {
+				if (bgtile(actr->x - 2, actr->y) >= TILE_FLY &&
+					bgtile(actr->x - 2, actr->y + actr->size_y - 1) >= TILE_FLY) {
+					d = 2;
+					actr->x -= 2;
+				} else {
+					d = 1;
+					break;
+				}
+			} else actr->y -= 2;
+		}
+		break;
+	case 1:
+		if (bgtile(actr->x - 2, actr->y) >= TILE_FLY &&
+			bgtile(actr->x - 2, actr->y + actr->size_y - 1) >= TILE_FLY) {
+			d = 2;
+			actr->x -= 2;
+		} else {
+			if (bgtile(actr->x, actr->y + actr->size_y + 1) < TILE_FLY ||
+				bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) < TILE_FLY) {
+				if (bgtile(actr->x + actr->size_x + 1, actr->y) >= TILE_FLY &&
+					bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) >= TILE_FLY) {
+					d = 3;
+					actr->x += 2;
+				} else {
+					d = 0;
+					break;
+				}
+			} else actr->y += 2;
+		}
+		break;
+	case 2:
+		if (bgtile(actr->x, actr->y - 2) >= TILE_FLY &&
+			bgtile(actr->x + actr->size_x - 1, actr->y - 2) >= TILE_FLY) {
+			d = 0;
+			actr->y -= 2;
+		} else {
+			if (bgtile(actr->x - 2, actr->y) < TILE_FLY ||
+				bgtile(actr->x - 2, actr->y + actr->size_y - 1) < TILE_FLY) {
+				if (bgtile(actr->x, actr->y + actr->size_y + 1) >= TILE_FLY &&
+					bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) >= TILE_FLY) {
+					d = 1;
+					actr->y += 2;
+				} else {
+					d = 3;
+					break;
+				}
+			} else actr->x -= 2;
+		}
+		break;
+	case 3:
+		if (bgtile(actr->x, actr->y + actr->size_y + 1) >= TILE_FLY &&
+			bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) >= TILE_FLY) {
+			d = 1;
+			actr->y += 2;
+		} else {
+			if (bgtile(actr->x + actr->size_x + 1, actr->y) < TILE_FLY ||
+				bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) < TILE_FLY) {
+				if (bgtile(actr->x, actr->y - 2) >= TILE_FLY &&
+					bgtile(actr->x + actr->size_x - 1, actr->y - 2) >= TILE_FLY) {
+					d = 0;
+					actr->y -= 2;
+				} else {
+					d = 2;
+					break;
+				}
+			} else actr->x += 2;
+		}
+		break;
+	}
+	check_move2(actr->x, actr->y, actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_twentyfive(ACTOR *actr) {         //acid puddle
+	int i, ret;
+
+	if (actr->temp2) {
+		actr->temp2--;
+		return movement_one(actr);
+	}
+	if (!actr->temp1) {
+		//  actr->temp2=12;
+		actr->last_dir = g_events->getRandomNumber(3);
+		i = 4;
+		while (i--) {
+			ret = movement_three(actr);
+			if (ret) return ret;
+			actr->last_dir++;
+			if (actr->last_dir > 3) actr->last_dir = 0;
+		}
+		actr->temp1 = 16;
+	}
+	actr->temp1--;
+	return movement_three(actr);
+}
+
+int movement_twentysix(ACTOR *actr) {         //
+
+	return movement_one(actr);
+}
+
+int movement_twentyseven(ACTOR *actr) {         //
+
+	return movement_one(actr);
+}
+
+void set_thor_vars() {
+	_G(thor_x1) = _G(thor)->x + 1;
+	_G(thor_y1) = _G(thor)->y + 8;
+	_G(thor_real_y1) = _G(thor)->y;
+	if (_G(thor)->dir > 1)
+		_G(thor_x2) = (_G(thor)->x + 12);
+	else
+		_G(thor_x2) = (_G(thor)->x + 12);
+
+	_G(thor_y2) = _G(thor)->y + 15;
+}
+
+int movement_twentyeight(ACTOR *actr) {         //fish
+	int d, x1, y1, ret;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	if (actr->i1) actr->i1--;
+	else {
+		if (!actr->temp3) {
+			if (!actr->next) {
+				actr->frame_count = 1;
+				actr->frame_speed = 4;
+			}
+
+			next_frame(actr);
+			if (actr->next == 3) {
+				if (actr->num_shots < actr->shots_allowed)
+					actor_shoots(actr, 0);
+				actr->temp3 = 1;
+			}
+		} else {
+			actr->frame_count--;
+			if (actr->frame_count <= 0) {
+				actr->next--;
+				actr->frame_count = actr->frame_speed;
+				if (!actr->next) {
+					actr->temp3 = 0;
+					actr->frame_speed = 4;
+					actr->i1 = g_events->getRandomNumber(60, 159);
+				}
+				//      else actr->solid=1;
+			}
+		}
+		goto done;
+	}
+	switch (actr->temp2) {
+	case 0:
+		y1 -= 2;
+		break;
+	case 1:
+		y1 += 2;
+		break;
+	case 2:
+		x1 -= 2;
+		break;
+	case 3:
+		x1 += 2;
+		break;
+	}
+	ret = bgtile(x1, y1);
+	if (ret != 100 && ret != 106 && ret != 110 && ret != 111 && ret != 113) goto chg_dir;
+	ret = bgtile((x1 + actr->size_x) - 1, y1);
+	if (ret != 100 && ret != 106 && ret != 110 && ret != 111 && ret != 113) goto chg_dir;
+	ret = bgtile(x1, (y1 + actr->size_y) - 1);
+	if (ret != 100 && ret != 106 && ret != 110 && ret != 111 && ret != 113) goto chg_dir;
+	ret = bgtile((x1 + actr->size_x) - 1, (y1 + actr->size_y) - 1);
+	if (ret != 100 && ret != 106 && ret != 110 && ret != 111 && ret != 113) goto chg_dir;
+
+	actr->x = x1;
+	actr->y = y1;
+
+	goto done;
+
+chg_dir:
+	actr->temp2 = _G(rand1) % 4;
+
+done:
+	if (actr->next) {
+		x1 = actr->x;
+		y1 = actr->y;
+		actr->solid = 1;
+		check_move2(x1, y1, actr);
+		actr->x = x1;
+		actr->y = y1;
+	} else actr->solid = 2;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_twentynine(ACTOR *actr) {  //horz or vert (pass_val)
+	if (!actr->pass_value) return movement_thirty(actr);
+	else return movement_twelve(actr);
+}
+
+int movement_thirty(ACTOR *actr) {         //vert straight
+	int d, x1, y1;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	switch (d) {
+	case 0:
+		y1 -= 2;
+		break;
+	case 1:
+		y1 += 2;
+		break;
+	}
+	if (!check_move2(x1, y1, actr)) d ^= 1;
+
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_thirtyone(ACTOR *actr) {         //drop (stalagtite)
+	int d, x1, y1, cx, cy, ty, i;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	if (actr->temp1) {
+		y1 += 2;
+		if (!check_move2(x1, y1, actr)) actor_destroyed(actr);
+	} else {
+		if (_G(thor_y1) > y1) {
+			if (ABS(x1 - _G(thor_x1)) < 16) {
+				cx = (actr->x + (actr->size_x / 2)) >> 4;
+				cy = ((actr->y + actr->size_y) - 2) >> 4;
+				ty = _G(thor)->center_y;
+				for (i = cy; i <= ty; i++) if (_G(scrn).icon[i][cx] < TILE_SOLID) goto done;
+				actr->num_moves = actr->pass_value + 1;
+				actr->temp1 = 1;
+			}
+		}
+	}
+
+done:
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_thirtytwo(ACTOR *actr) {      //unused
+
+	actr = actr;
+	return 0;
+}
+
+int movement_thirtythree(ACTOR *actr) {    //unused
+
+	actr = actr;
+	return 0;
+}
+
+int movement_thirtyfour(ACTOR *actr) {    //unused
+
+	actr = actr;
+	return 0;
+}
+
+int movement_thirtyfive(ACTOR *actr) {    //gun (single)
+
+	actr->next = actr->last_dir;
+	return actr->dir;
+}
+
+int movement_thirtysix(ACTOR *actr) {    //acid drop
+
+	actr->speed = actr->pass_value;
+	next_frame(actr);
+	if (actr->next == 0 && actr->frame_count == actr->frame_speed) {
+		actor_always_shoots(actr, 1);
+		_G(actor)[actr->shot_actor].x -= 2;
+	}
+	return 0;
+}
+
+//4-way straight (random length) change
+int movement_thirtyseven(ACTOR *actr) {
+	int d, x1, y1, f;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	f = 0;
+	if (actr->counter) {
+		actr->counter--;
+		switch (d) {
+		case 0:
+			y1 -= 2;
+			if (!check_move2(x1, y1, actr)) f = 1;
+			break;
+		case 1:
+			y1 += 2;
+			if (!check_move2(x1, y1, actr)) f = 1;
+			break;
+		case 2:
+			x1 -= 2;
+			if (!check_move2(x1, y1, actr)) f = 1;
+			break;
+		case 3:
+			x1 += 2;
+			if (!check_move2(x1, y1, actr)) f = 1;
+			break;
+		}
+	} else f = 1;
+
+	if (f == 1) {
+		actr->counter = g_events->getRandomNumber(10, 99);
+		d = g_events->getRandomNumber(3);
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+//timed darting
+#define TIMER     actr->i1
+#define INIT_DIR  actr->temp1
+#define OTHER_DIR actr->temp2
+#define FLAG      actr->temp3
+#define OX        actr->i2
+#define OY        actr->i3
+#define CNT       actr->i4
+int movement_thirtyeight(ACTOR *actr) {
+	int d, x1, y1;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+
+	if (!FLAG) {
+		FLAG = 1;
+		if (actr->pass_value) TIMER = actr->pass_value * 15;
+		else TIMER = g_events->getRandomNumber(5, 364);
+		INIT_DIR = actr->last_dir;
+		OX = x1;
+		OY = y1;
+		CNT = 0;
+		switch (INIT_DIR) {
+		case 0:
+			OTHER_DIR = 1;
+			break;
+		case 1:
+			OTHER_DIR = 0;
+			break;
+		case 2:
+			OTHER_DIR = 3;
+			break;
+		case 3:
+			OTHER_DIR = 2;
+			break;
+		}
+	}
+	if (TIMER) {
+		TIMER--; goto done;
+	}
+
+	switch (d) {
+	case 0:
+		y1 -= 2;
+		break;
+	case 1:
+		y1 += 2;
+		break;
+	case 2:
+		x1 -= 2;
+		break;
+	case 3:
+		x1 += 2;
+		break;
+	}
+
+	switch (FLAG) {
+	case 1:
+		if (!check_move2(x1, y1, actr)) {
+			if (CNT) {
+				d = OTHER_DIR;
+				actr->last_dir = d;
+				FLAG = 2;
+			} else {
+				actr->next = 0;
+				FLAG = 0;
+				goto done;
+			}
+		} else CNT++;
+		break;
+	case 2:
+		check_move2(x1, y1, actr);
+		if (x1 == OX && y1 == OY) {
+			FLAG = 0;
+			d = INIT_DIR;
+			actr->last_dir = d;
+			actr->next = 0;
+			goto done;
+		}
+	}
+	next_frame(actr);
+
+done:
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int movement_thirtynine(ACTOR *actr) {    //troll 1
+
+	if (_G(setup).skill == 0) {
+		actr->speed = 3; actr->num_moves = 1;
+	} else if (_G(setup).skill == 1) {
+		actr->speed = 2; actr->num_moves = 1;
+	} else if (_G(setup).skill == 2) {
+		actr->speed = 1; actr->num_moves = 1;
+	}
+
+
+	if (actr->pass_value < 5) return movement_forty(actr);
+	if (actr->pass_value == 10) {
+		if (overlap(actr->x + 1, actr->y + 1, actr->x + actr->size_x - 1,
+			actr->y + actr->size_y - 1, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
+			actr->strength = 255;
+			thor_damaged(actr);
+		}
+		return actr->dir;
+	}
+	if (actr->actor_num != 3) return actr->dir;
+
+	if (actr->i1) {
+		actr->i1--;
+		actr->x -= 2;
+		check_move2(actr->x, actr->y, actr);
+		_G(actor)[4].x -= 2;
+		_G(actor)[5].x -= 2;
+		_G(actor)[6].x -= 2;
+	}
+	next_frame(actr);
+	if (actr->next == 3) actr->next = 0;
+	_G(actor)[4].next = _G(actor)[3].next;
+	_G(actor)[5].next = 0;
+	_G(actor)[6].next = 0;
+	return actr->dir;
+}
+
+int movement_forty(ACTOR *actr) {    //troll 2
+	int x1, x2, a, d, f;
+
+	if (overlap(actr->x + 1, actr->y + 1, actr->x + actr->size_x + 3,
+		actr->y + actr->size_y - 1, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
+		actr->strength = 150;
+		thor_damaged(actr);
+	}
+	a = 5 + (actr->pass_value * 4);
+	x1 = actr->x;
+	x2 = _G(actor)[a + 1].x;
+	d = actr->last_dir;
+
+	if (actr->last_dir == 2) {
+		f = 1;
+		if (bgtile(x1 - 2, actr->y) >= TILE_SOLID) {
+			_G(actor)[a].x -= 2;
+			_G(actor)[a - 1].x -= 2;
+			_G(actor)[a - 2].x -= 2;
+			_G(actor)[a + 1].x -= 2;
+		} else f = 0;
+		if (!f)
+			d = 3;
+	} else {
+		f = 1;
+		if (bgtile(_G(actor)[a + 1].x + 14, _G(actor)[a + 1].y) >= TILE_SOLID) {
+			_G(actor)[a].x += 2;
+			_G(actor)[a - 1].x += 2;
+			_G(actor)[a - 2].x += 2;
+			_G(actor)[a + 1].x += 2;
+		} else f = 0;
+		if (!f) d = 2;
+	}
+	if (!f) {
+		actr->x = x1;
+		_G(actor)[a + 1].x = x2;
+	}
+
+	if (actr->next == 3 && !actr->num_shots && actr->frame_count == actr->frame_speed) {
+		actor_always_shoots(actr, 1);
+		_G(actor)[actr->shot_actor].x += 6;
+	}
+
+	next_frame(actr);
+	_G(actor)[a - 2].next = actr->next;
+	_G(actor)[a - 1].next = actr->next;
+	_G(actor)[a + 1].next = actr->next;
+	_G(actor)[a - 2].last_dir = d;
+	_G(actor)[a - 1].last_dir = d;
+	_G(actor)[a + 1].last_dir = d;
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+} // namespace Got
diff --git a/engines/got/game/move_patterns.h b/engines/got/game/move_patterns.h
new file mode 100644
index 00000000000..a6154316fe6
--- /dev/null
+++ b/engines/got/game/move_patterns.h
@@ -0,0 +1,37 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GAME_MOVE_PATTERNS_H
+#define GOT_GAME_MOVE_PATTERNS_H
+
+#include "got/data/defines.h"
+
+namespace Got {
+
+extern int (*const movement_func[]) (ACTOR *actr);
+extern int check_move2(int x, int y, ACTOR *actr);
+extern int check_move3(int x, int y, ACTOR *actr);
+extern int check_move4(int x, int y, ACTOR *actr);
+extern void set_thor_vars();
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
new file mode 100644
index 00000000000..c7f2f7a93f7
--- /dev/null
+++ b/engines/got/game/object.cpp
@@ -0,0 +1,602 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property _G(of) its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms _G(of) the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 _G(of) the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty _G(of)
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy _G(of) the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/game/object.h"
+#include "got/game/back.h"
+#include "got/game/move.h"
+#include "got/game/panel.h"
+#include "got/game/status.h"
+#include "got/data/flags.h"
+#include "got/gfx/image.h"
+#include "got/events.h"
+#include "got/vars.h"
+
+namespace Got {
+
+void throw_lightning();
+void not_enough_magic();
+void cannot_carry_more();
+
+void pick_up_object(int p) {
+	int r, x, y, s;
+
+	switch (_G(object_map)[p]) {
+	case 1:           //red jewel
+		if (_G(thor_info).jewels >= 999) {
+			cannot_carry_more();
+			return;
+		}
+		add_jewels(10);
+		break;
+	case 2:           //blue jewel
+		if (_G(thor_info).jewels >= 999) {
+			cannot_carry_more();
+			return;
+		}
+		add_jewels(1);
+		break;
+	case 3:           //red potion
+		if (_G(thor_info).magic >= 150) {
+			cannot_carry_more();
+			return;
+		}
+		add_magic(10);
+		break;
+	case 4:           //blue potion
+		if (_G(thor_info).magic >= 150) {
+			cannot_carry_more();
+			return;
+		}
+		add_magic(3);
+		break;
+	case 5:          //good apple
+		if (_G(thor)->health >= 150) {
+			cannot_carry_more();
+			return;
+		}
+		play_sound(GULP, 0);
+		s = 1;
+		add_health(5);
+		break;
+	case 6:           //bad apple
+		play_sound(OW, 0);
+		s = 1;
+		add_health(-10);
+		break;
+	case 7:           //key (reset on exit)
+		//           if(_G(scrn).reset) r=0;
+		add_keys(1);
+		break;
+	case 8:          //treasure
+		if (_G(thor_info).jewels >= 999) {
+			cannot_carry_more();
+			return;
+		}
+		add_jewels(50);
+		break;
+	case 9:          //trophy
+		add_score(100);
+		break;
+	case 10:         //crown
+		add_score(1000);
+		break;
+	case 12:
+	case 13:
+	case 14:
+	case 15:
+	case 16:
+	case 17:
+	case 18:
+	case 19:
+	case 20:
+	case 21:
+	case 22:
+	case 23:
+	case 24:
+	case 25:
+	case 26:
+		if (_G(object_map)[p] == 13 && HERMIT_HAS_DOLL) return;
+		_G(thor)->num_moves = 1;
+		_G(hammer)->num_moves = 2;
+		_G(actor)[2].used = 0;
+		_G(shield_on) = 0;
+		_G(tornado_used) = 0;
+		_G(thor_info).inventory |= 64;
+		_G(thor_info).item = 7;
+		_G(thor_info).object = _G(object_map)[p] - 11;
+		display_item();
+		_G(thor_info).object_name = object_names[_G(thor_info).object - 1];
+		odin_speaks((_G(object_map)[p] - 12) + 501, _G(object_map)[p] - 1);
+		break;
+	case 27:
+	case 28:
+	case 29:
+	case 30:
+	case 31:
+	case 32:
+		_G(hourglass_flag) = 0;
+		_G(thunder_flag) = 0;
+		_G(shield_on) = 0;
+		_G(lightning_used) = 0;
+		_G(tornado_used) = 0;
+		_G(hammer)->num_moves = 2;
+		_G(thor)->num_moves = 1;
+		_G(actor)[2].used = 0;
+		s = 1 << (_G(object_map)[p] - 27);
+		_G(thor_info).inventory |= s;
+		odin_speaks((_G(object_map)[p] - 27) + 516, _G(object_map)[p] - 1);
+		s = 1;
+		_G(thor_info).item = _G(object_map)[p] - 26;
+		display_item();
+		add_magic(150);
+		fill_score(5);
+		break;
+	}
+	x = p % 20;
+	y = p / 20;
+
+	_G(ox) = x * 16;
+	_G(oy) = y * 16;
+	_G(of) = 1;
+
+	//xfput(_G(ox), _G(oy), PAGE2, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
+	//xfput(_G(ox), _G(oy), PAGE2, (char far *) (bg_pics + (_G(scrn).icon[y][x] * 262)));
+	//xcopyd2d(_G(ox), _G(oy), _G(ox) + 16, _G(oy) + 16, _G(ox), _G(oy), PAGE2, draw_page, 320, 320);
+
+	r = 1;
+	s = 0;
+	if (!s)
+		play_sound(YAH, 0);
+	_G(object_map)[p] = 0;
+
+	if (r) {
+		// reset so it doesn't reappear on reentry to screen
+		if (_G(object_index)[p] < 30)
+			_G(scrn).static_obj[_G(object_index)[p]] = 0;
+		_G(object_index)[p] = 0;
+	}
+}
+
+int drop_object(ACTOR *actr) {
+	int o, rnd1, rnd2;
+
+	rnd1 = g_events->getRandomNumber(99);
+	rnd2 = g_events->getRandomNumber(99);
+
+	if (rnd1 < 25) o = 5;      //apple
+	else if (rnd1 & 1) {    //jewels
+		if (rnd2 < 10) o = 1;      //red
+		else o = 2;           //blue
+	} else {                 //potion
+		if (rnd2 < 10) o = 3;    //red
+		else o = 4;           //blue
+	}
+	_drop_obj(actr, o);
+	return 1;
+}
+
+int _drop_obj(ACTOR *actr, int o) {
+	int x, y, p;
+
+	p = (actr->x + (actr->size_x / 2)) / 16 + (((actr->y + (actr->size_y / 2)) / 16) * 20);
+	if (!_G(object_map)[p] && _G(scrn).icon[p / 20][p % 20] >= 140) {  //nothing there and solid
+		_G(object_map)[p] = o;
+		_G(object_index)[p] = 27 + actr->actor_num;  //actor is 3-15
+		x = (p % 20) * 16;
+		y = (p / 20) * 16;
+		//xfput(x, y, PAGE2, (char far *) objects[o - 1]);
+		//xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, draw_page, 320, 320);
+		//xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, display_page, 320, 320);
+		return 1;
+	}
+
+	return 0;
+}
+
+int use_apple(int flag) {
+	if (_G(thor)->health == 150)
+		return 0;
+
+	if (flag && _G(thor_info).magic > 0) {
+		if (!_G(apple_flag)) {
+			_G(magic_cnt) = 0;
+			add_magic(-2);
+			add_health(1);
+			play_sound(ANGEL, 0);
+		} else if (_G(magic_cnt) > 8) {
+			_G(magic_cnt) = 0;
+			add_magic(-2);
+			add_health(1);
+			if (!sound_playing()) play_sound(ANGEL, 0);
+		}
+		_G(apple_flag) = 1;
+		return 1;
+	} else {
+		_G(apple_flag) = 0;
+		if (flag) not_enough_magic();
+	}
+	return 0;
+}
+
+int use_thunder(int flag) {
+
+	if (flag && _G(thor_info).magic > 29) {
+		if (!_G(thunder_flag)) {
+			add_magic(-30);
+			play_sound(THUNDER, 0);
+			_G(thunder_flag) = 60;
+		}
+		return 1;
+	} else if (flag && !_G(thunder_flag)) not_enough_magic();
+
+	if (_G(thunder_flag)) return 1;
+	return 0;
+}
+
+int use_hourglass(int flag) {
+	int hour_time[] = { 0,60,120,180,240,300,360,420,480,
+					 510,540,570,600,630,660,690 };
+
+	if (_G(hourglass_flag)) {
+		if (_G(magic_cnt) > hour_time[_G(hourglass_flag)]) {
+			_G(hourglass_flag)++;
+			if (_G(hourglass_flag) == 16) {
+				_G(hourglass_flag) = 0;
+				music_resume();
+			}
+			play_sound(WOOP, 1);
+		}
+		return 1;
+	}
+
+	if (flag && _G(thor_info).magic > 29) {
+		if (!_G(hourglass_flag)) {
+			_G(magic_cnt) = 0;
+			add_magic(-30);
+			music_pause();
+			play_sound(WOOP, 1);
+			_G(hourglass_flag) = 1;
+			return 1;
+		}
+	} else {
+		_G(hourglass_flag) = 0;
+		if (flag) not_enough_magic();
+	}
+	return 0;
+}
+
+int use_boots(int flag) {
+
+	if (flag) {
+		if (_G(thor_info).magic > 0) {
+			if (_G(thor)->num_moves == 1) {
+				_G(magic_cnt) = 0;
+				add_magic(-1);
+			} else if (_G(magic_cnt) > 8) {
+				_G(magic_cnt) = 0;
+				add_magic(-1);
+			}
+			_G(thor)->num_moves = 2;
+			_G(hammer)->num_moves = 3;
+			return 1;
+		} else {
+			not_enough_magic();
+			_G(thor)->num_moves = 1;
+			_G(hammer)->num_moves = 2;
+		}
+	} else {
+		_G(thor)->num_moves = 1;
+		_G(hammer)->num_moves = 2;
+	}
+	return 0;
+}
+
+int use_shield(int flag) {
+	int f;
+
+	f = 0;
+	if (flag) {
+		if (_G(thor_info).magic) {
+			if (!_G(shield_on)) {
+				_G(magic_cnt) = 0;
+				add_magic(-1);
+				setup_magic_item(1);
+
+				_G(actor)[2] = _G(magic_item)[1];
+
+				setup_actor(&_G(actor)[2], 2, 0, _G(thor)->x, _G(thor)->y);
+				_G(actor)[2].speed_count = 1;
+				_G(actor)[2].speed = 1;
+				_G(shield_on) = 1;
+			} else if (_G(magic_cnt) > 8) {
+				_G(magic_cnt) = 0;
+				add_magic(-1);
+			}
+			return 1;
+		} else {
+			f = 1;
+			not_enough_magic();
+		}
+
+	} else f = 1;
+	if (f == 1) {
+		if (_G(shield_on)) {
+			_G(actor)[2].dead = 2;
+			_G(actor)[2].used = 0;
+			_G(shield_on) = 0;
+		}
+	}
+	return 0;
+}
+
+int use_lightning(int flag) {
+
+	if (flag) {
+		if (_G(thor_info).magic > 14) {
+			add_magic(-15);
+			throw_lightning();
+		} else {
+			not_enough_magic();
+			return 0;
+		}
+	}
+	return 1;
+}
+
+int use_tornado(int flag) {
+
+	if (flag) {
+		if (_G(thor_info).magic > 10) {
+			if (!_G(tornado_used) && !_G(actor)[2].dead && _G(magic_cnt) > 20) {
+				_G(magic_cnt) = 0;
+				add_magic(-10);
+				setup_magic_item(0);
+				memcpy(&_G(actor)[2], &_G(magic_item)[0], sizeof(ACTOR));
+				setup_actor(&_G(actor)[2], 2, 0, _G(thor)->x, _G(thor)->y);
+				_G(actor)[2].last_dir = _G(thor)->dir;
+				_G(actor)[2].move = 16;
+				_G(tornado_used) = 1;
+				play_sound(WIND, 0);
+			}
+		} else if (_G(tornado_used) == 0) {
+			not_enough_magic();
+			return 0;
+		}
+		if (_G(magic_cnt) > 8) {
+			if (_G(tornado_used)) {
+				_G(magic_cnt) = 0;
+				add_magic(-1);
+			}
+		}
+		if (_G(thor_info).magic < 1) {
+			actor_destroyed(&_G(actor)[2]);
+			_G(tornado_used) = 0;
+			not_enough_magic();
+			return 0;
+		}
+		return 1;
+	}
+	return 0;
+}
+
+int use_object(int flag) {
+	if (!flag) return 0;
+	if (!_G(thor_info).inventory & 64) return 0;
+
+	//xshowpage(draw_page);
+	//xerase_actors(actor, display_page);
+	//xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], display_page);
+	//xshowpage(display_page);
+
+	odin_speaks((_G(thor_info).object - 1) + 5501, _G(thor_info).object - 1);
+	//xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], draw_page);
+	return 1;
+}
+
+void use_item() {
+	static int flag = 0;
+	int kf, ret = 0, mf;
+
+	kf = _G(key_flag)[_G(key_magic)];
+
+	if (!kf && _G(tornado_used)) {
+		actor_destroyed(&_G(actor)[2]);
+		_G(tornado_used) = 0;
+	}
+
+	mf = _G(magic_inform);
+	switch (_G(thor_info).item) {
+	case 1:
+		ret = use_apple(kf);
+		break;
+	case 2:
+		ret = use_lightning(kf);
+		break;
+	case 3:
+		ret = use_boots(kf);
+		break;
+	case 4:
+		ret = use_tornado(kf);
+		break;
+	case 5:
+		ret = use_shield(kf);
+		break;
+	case 6:
+		ret = use_thunder(kf);
+		break;
+	case 7:
+		ret = use_object(kf);
+		break;
+
+	}
+	if (kf) {
+		if ((!ret) && (!flag)) {
+			if (mf) play_sound(BRAAPP, 0);
+			flag = 1;
+		}
+	} else flag = 0;
+}
+
+void place_pixel(int dir, int num) {
+#ifdef TODO
+	switch (dir) {
+	case 0:
+		_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] - 1;
+		_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] +
+			(1 - (g_events->getRandomNumber(2)));
+		break;
+	case 1:
+		if (g_events->getRandomNumber(1)) {
+			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + 1;
+			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
+		} else {
+			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] - 1;
+			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
+		}
+		break;
+	case 2:
+		_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + 1;
+		_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + (1 - (g_events->getRandomNumber(2)));
+		break;
+	case 3:
+		if (g_events->getRandomNumber(1)) {
+			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + 1;
+			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
+		} else {
+			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + 1;
+			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
+		}
+		break;
+	case 4:
+		_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + 1;
+		_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + (1 - (g_events->getRandomNumber(2)));
+		break;
+	case 5:
+		if (g_events->getRandomNumber(1)) {
+			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] - 1;
+			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
+		} else {
+			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + 1;
+			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
+		}
+		break;
+	case 6:
+		_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] - 1;
+		_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + (1 - (g_events->getRandomNumber(2)));
+		break;
+	case 7:
+		if (g_events->getRandomNumber(1)) {
+			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] - 1;
+			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
+		} else {
+			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] - 1;
+			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
+		}
+		break;
+	default:
+		return;
+	}
+	if (point_within(_G(pixel_x)[dir][num], _G(pixel_y)[dir][num], 0, 0, 319, 191)) {
+		_G(pixel_p)[dir][num] = xpoint(_G(pixel_x)[dir][num], _G(pixel_y)[dir][num], draw_page);
+		xpset(_G(pixel_x)[dir][num], _G(pixel_y)[dir][num], draw_page, _G(pixel_c)[dir]);
+	}
+#else
+	error("TODO: place_pixel");
+#endif
+}
+
+void replace_pixel(int dir, int num) {
+#ifdef TODO
+	if (point_within(_G(pixel_x)[dir][num], _G(pixel_y)[dir][num], 0, 0, 319, 191)) {
+		xpset(_G(pixel_x)[dir][num], _G(pixel_y)[dir][num], draw_page, _G(pixel_p)[dir][num]);
+	}
+#else
+	error("TODO: replace_pixel");
+#endif
+}
+
+void throw_lightning() {
+#ifdef TODO
+	int i, r, loop, x, y, ax, ay;
+
+	for (i = 0; i < MAX_ACTORS; i++) _G(actor)[i].show = 0;
+
+	xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], draw_page);
+	xshowpage(draw_page);
+	play_sound(ELECTRIC, 1);
+	for (loop = 0; loop < 10; loop++) {
+		for (i = 0; i < 8; i++) {
+			_G(pixel_x)[i][0] = _G(thor)->x + 7;
+			_G(pixel_y)[i][0] = _G(thor)->y + 7;
+			_G(pixel_c)[i] = 14 + g_events->getRandomNumber(1);
+		}
+		for (r = 0; r < 8; r++) {
+			for (i = 1; i < 25; i++) {
+				place_pixel(r, i);
+			}
+		}
+		timer_cnt = 0;
+		while (timer_cnt < 3);
+		for (r = 7; r >= 0; r--) {
+			for (i = 1; i < 25; i++) {
+				replace_pixel(r, i);
+			}
+		}
+		timer_cnt = 0;
+		while (timer_cnt < 3);
+	}
+	x = _G(thor)->x + 7;
+	y = _G(thor)->y + 7;
+	for (i = 3; i < MAX_ACTORS; i++) {
+		if (!_G(actor)[i].used) continue;
+		ax = _G(actor)[i].x + (_G(actor)[i].size_x / 2);
+		ay = _G(actor)[i].y + (_G(actor)[i].size_y / 2);
+		if ((abs(ax - x) < 30) && (abs(ay - y) < 30)) {
+			_G(actor)[i].magic_hit = 1;
+			_G(actor)[i].vunerable = 0;
+			actor_damaged(&_G(actor)[i], 254);
+		}
+	}
+#else
+	error("TODO: throw lightning");
+#endif
+}
+
+void not_enough_magic() {
+	if (!_G(magic_inform)) odin_speaks(2006, 0);
+	//xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], draw_page);
+	_G(magic_inform) = 1;
+}
+
+void cannot_carry_more() {
+	if (!_G(carry_inform))
+		odin_speaks(2007, 0);
+	_G(carry_inform) = 1;
+}
+
+void delete_object() {
+
+	_G(thor_info).inventory &= 0xbf;
+	_G(thor_info).item = 1;
+	display_item();
+}
+
+} // namespace Got
diff --git a/engines/got/game/object.h b/engines/got/game/object.h
new file mode 100644
index 00000000000..68ad7256825
--- /dev/null
+++ b/engines/got/game/object.h
@@ -0,0 +1,37 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GAME_OBJECT_H
+#define GOT_GAME_OBJECT_H
+
+#include "got/data/defines.h"
+
+namespace Got {
+
+extern void show_objects(int level, unsigned int pg);
+extern void pick_up_object(int p);
+extern int drop_object(ACTOR *actr);
+extern int _drop_obj(ACTOR *actr, int o);
+extern void delete_object();
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/game/panel.cpp b/engines/got/game/panel.cpp
new file mode 100644
index 00000000000..231ec78566a
--- /dev/null
+++ b/engines/got/game/panel.cpp
@@ -0,0 +1,31 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/textconsole.h"
+#include "got/game/panel.h"
+
+namespace Got {
+
+void boss_status(int health) {
+	error("TODO: boss_status");
+}
+
+} // namespace Got
diff --git a/engines/got/game/panel.h b/engines/got/game/panel.h
new file mode 100644
index 00000000000..7b2c02f057f
--- /dev/null
+++ b/engines/got/game/panel.h
@@ -0,0 +1,40 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GAME_PANEL_H
+#define GOT_GAME_PANEL_H
+
+#include "got/data/defines.h"
+
+namespace Got {
+
+extern void boss_status(int health);
+
+// Dummy functions for displaying on-screen elements
+// that are now handled by the GameContent and GameStatus views
+inline void display_item() {}
+inline void display_health() {}
+inline void display_magic() {}
+inline void d_restore() {}
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
new file mode 100644
index 00000000000..d6fd40305f5
--- /dev/null
+++ b/engines/got/game/script.cpp
@@ -0,0 +1,31 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/textconsole.h"
+#include "got/game/script.h"
+
+namespace Got {
+
+void execute_script(long index, Graphics::ManagedSurface *pic) {
+	error("TODO: execute_script");
+}
+
+} // namespace Got
diff --git a/engines/got/game/script.h b/engines/got/game/script.h
new file mode 100644
index 00000000000..46305477c87
--- /dev/null
+++ b/engines/got/game/script.h
@@ -0,0 +1,33 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GAME_SCRIPT_H
+#define GOT_GAME_SCRIPT_H
+
+#include "got/data/defines.h"
+
+namespace Got {
+
+extern void execute_script(long index, Graphics::ManagedSurface *pic);
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/game/shot_movement.cpp b/engines/got/game/shot_movement.cpp
new file mode 100644
index 00000000000..391cb4f0825
--- /dev/null
+++ b/engines/got/game/shot_movement.cpp
@@ -0,0 +1,540 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/game/shot_movement.h"
+#include "got/game/move.h"
+#include "got/game/move_patterns.h"
+#include "got/game/object.h"
+#include "got/events.h"
+#include "got/vars.h"
+
+namespace Got {
+
+int shot_movement_none(ACTOR *actr);
+int shot_movement_one(ACTOR *actr);
+int shot_movement_two(ACTOR *actr);
+int shot_movement_three(ACTOR *actr);
+int shot_movement_four(ACTOR *actr);
+int shot_movement_five(ACTOR *actr);
+int shot_movement_six(ACTOR *actr);
+int shot_movement_seven(ACTOR *actr);
+int shot_movement_eight(ACTOR *actr);
+int shot_movement_nine(ACTOR *actr);
+int shot_movement_ten(ACTOR *actr);
+int shot_movement_eleven(ACTOR *actr);
+
+int (*const shot_movement_func[]) (ACTOR *actr) = {
+  shot_movement_none,
+  shot_movement_one,
+  shot_movement_two,
+  shot_movement_three,
+  shot_movement_four,
+  shot_movement_five,
+  shot_movement_six,
+  shot_movement_seven,
+  shot_movement_eight,
+  shot_movement_nine,
+  shot_movement_ten,
+  shot_movement_eleven
+};
+
+void next_shot_frame(ACTOR *actr) {
+	if (actr->directions == 4 && actr->frames == 1) {
+		actr->next = actr->last_dir;
+		actr->dir = 0;
+	} else {
+		actr->frame_count--;
+
+		if (actr->frame_count <= 0) {
+			actr->next++;
+			if (actr->next > 3)
+				actr->next = 0;
+
+			actr->frame_count = actr->frame_speed;
+		}
+	}
+}
+
+// boss - snake
+int shot_movement_none(ACTOR *actr) {   
+	actr->temp3--;
+	if (!actr->temp3) {
+		actor_destroyed(actr);
+		if (_G(actor)[actr->creator].num_shots)
+			_G(actor)[actr->creator].num_shots--;
+	}
+
+	next_shot_frame(actr);
+	if (actr->directions == 1)
+		return 0;
+
+	return actr->last_dir;
+}
+
+int shot_movement_one(ACTOR *actr) {
+	int d, x1 = 0, y1 = 0;
+
+	d = actr->last_dir;
+
+	switch (d) {
+	case 0:
+		x1 = actr->x;
+		y1 = actr->y - 2;
+		break;
+	case 1:
+		x1 = actr->x;
+		y1 = actr->y + 2;
+		break;
+	case 2:
+		x1 = actr->x - 2;
+		y1 = actr->y;
+		break;
+	case 3:
+		x1 = actr->x + 2;
+		y1 = actr->y;
+		break;
+	}
+
+	if (!check_move3(x1, y1, actr)) {
+		actor_destroyed(actr);
+		if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+	} else {
+		next_shot_frame(actr);
+		actr->last_dir = d;
+	}
+
+	if (actr->directions == 1)
+		return 0;
+	if (actr->directions == 4 && actr->frames == 1)
+		return 0;
+
+	return d;
+}
+
+int shot_movement_two(ACTOR *actr) {
+	int d, x1 = 0, y1 = 0;
+
+	d = actr->last_dir;
+
+	switch (d) {
+	case 0:
+		x1 = actr->x;
+		y1 = actr->y - 2;
+		break;
+	case 1:
+		x1 = actr->x;
+		y1 = actr->y + 2;
+		break;
+	case 2:
+		x1 = actr->x - 2;
+		y1 = actr->y;
+		break;
+	case 3:
+		x1 = actr->x + 2;
+		y1 = actr->y;
+		break;
+	}
+	if (!check_move4(x1, y1, actr)) {
+		actor_destroyed(actr);
+		if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+	} else {
+		next_shot_frame(actr);
+		actr->last_dir = d;
+	}
+	if (actr->directions == 1) return 0;
+	if (actr->directions == 4 && actr->frames == 1) return 0;
+	return d;
+}
+
+int shot_movement_three(ACTOR *actr) {       //serpent fire
+	int d;
+
+	d = actr->last_dir;
+	actr->x -= 2;
+
+	actr->temp3--;
+	actr->temp4--;
+
+	if (overlap(_G(thor_x1) - 1, _G(thor_y1) - 1, _G(thor_x2) + 1, _G(thor_y2) + 1,
+		actr->x, actr->y, actr->x + 15, actr->y + 15)) {
+		actr->move = 0;
+		actr->speed = 6;
+		thor_damaged(actr);
+		actr->x += 2;
+	}
+	if (!actr->temp4) {
+		actr->temp4 = actr->temp5;
+		actr->speed++;
+		if (actr->speed > 6) actr->move = 0;
+	}
+	if (!actr->temp3) {
+		actor_destroyed(actr);
+		if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+	} else {
+		next_shot_frame(actr);
+		actr->last_dir = d;
+	}
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int shot_movement_four(ACTOR *actr) {          //wraith balls
+	int x1, y1, xd, yd, d;
+
+	if (actr->temp1) {
+		actr->temp1--;
+		if (!actr->temp1) {
+			actor_destroyed(actr);
+			_G(apple_drop)++;
+			if (_G(apple_drop) == 4) {
+				if (_drop_obj(actr, 5)) _G(apple_drop) = 0;
+				else _G(apple_drop) = 3;
+			} else _drop_obj(actr, 3);
+			return 0;
+		}
+	}
+	if (overlap(_G(thor)->x - 1, _G(thor)->y - 1, _G(thor_x2) + 1, _G(thor_y2) + 1,
+		actr->x, actr->y, actr->x + 15, actr->y + 15)) {
+		thor_damaged(actr);
+		actor_destroyed(actr);
+		return 0;
+	}
+
+	x1 = actr->x;
+	y1 = actr->y;
+	xd = yd = 0;
+	d = actr->last_dir;
+
+	if ((x1 > (_G(thor_x1))+1)) xd = -2;
+	else if ((x1 < (_G(thor_x1))-1)) xd = 2;
+
+	if (actr->actor_num == 1) {
+		if (y1 < (_G(thor_y1) - 6)) yd = 2;
+		else if (y1 > (_G(thor_y1) - 6)) yd = -2;
+	} else {
+		if (y1 < (_G(thor_real_y1) - 1)) yd = 2;
+		else if (y1 > (_G(thor_real_y1) + 1)) yd = -2;
+	}
+
+	if (xd && yd) {
+		if (xd == -2 && yd == -2) d = 2;
+		else if (xd == -2 && yd == 2) d = 2;
+		else if (xd == 2 && yd == -2) d = 3;
+		else if (xd == 2 && yd == 2) d = 3;
+		x1 += xd;
+		y1 += yd;
+		if (check_move3(x1, y1, actr)) {
+			next_frame(actr);
+			actr->last_dir = d;
+			if (actr->directions == 1) return 0;
+			return d;
+		}
+	} else {
+		if (xd == 0 && yd == 2) d = 1;
+		else if (xd == 0 && yd == -2) d = 0;
+		else if (xd == 2 && yd == 0) d = 3;
+		else if (xd == -2 && yd == 0) d = 2;
+	}
+	x1 = actr->x;
+	y1 = actr->y;
+	actr->toggle ^= 1;
+
+	if (actr->toggle) {
+		if (xd) {
+			x1 += xd;
+			if (check_move3(x1, y1, actr)) {
+				if (xd > 0) d = 3;
+				else d = 2;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1) return 0;
+				return d;
+			}
+			x1 = actr->x;
+		}
+		if (yd) {
+			y1 += yd;
+			if (check_move3(x1, y1, actr)) {
+				if (yd > 0) d = 1;
+				else d = 0;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1) return 0;
+				return d;
+			}
+		}
+		y1 = actr->y;
+	} else {
+		if (yd) {
+			y1 += yd;
+			if (check_move3(x1, y1, actr)) {
+				if (yd > 0) d = 1;
+				else d = 0;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1) return 0;
+				return d;
+			}
+			y1 = actr->y;
+		}
+		if (xd) {
+			x1 += xd;
+			if (check_move3(x1, y1, actr)) {
+				if (xd > 0) d = 3;
+				else d = 2;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1) return 0;
+				return d;
+			}
+		}
+	}
+	check_move3(actr->x, actr->y, actr);
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+int shot_movement_five(ACTOR *actr) {   //no move, frame cycle
+
+	next_shot_frame(actr);
+	if (actr->directions == 1) return 0;
+	return actr->last_dir;
+}
+
+int shot_movement_six(ACTOR *actr) {   //wraith spots
+
+	actr->temp1--;
+	if (!actr->temp1) {
+		actor_destroyed(actr);
+		if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+	} else next_shot_frame(actr);
+	if (actr->directions == 1) return 0;
+	return actr->last_dir;
+}
+
+#define YV actr->i1
+#define YC actr->i2
+#define BC actr->i3
+#define YD actr->i4
+#define XD actr->i5
+#define XC actr->i6
+#define IV 100
+#define IC 50
+int shot_movement_seven(ACTOR *actr) {   //skull drop
+
+	if (actr->temp3) {
+		actr->temp3--;
+		goto done;
+	}
+	if (overlap(actr->x, actr->y, actr->x + actr->size_x, actr->y + actr->size_y,
+		_G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15))
+		thor_damaged(actr);
+
+	actr->temp2++;
+	if (actr->temp2 > 2) {
+		if (actr->temp4) actr->temp4--;
+		actr->temp2 = 0;
+	}
+	actr->temp3 = actr->temp4;
+
+	actr->y += 2;
+	if (actr->y > 160 - 36) {
+		actr->x += (4 - g_events->getRandomNumber(8));
+		actr->move = 8;
+		YV = IV;
+		YC = 0;
+		BC = IC;
+		YD = 0;
+		XC = 3;
+		if (actr->x < 150) XD = 1;
+		else XD = 0;
+	}
+
+done:
+	next_shot_frame(actr);
+	if (actr->directions == 1) return 0;
+	return actr->last_dir;
+}
+
+int shot_movement_eight(ACTOR *actr) {   //skull bounce
+	int x, y;
+
+	x = actr->x;
+	y = actr->y;
+
+	XC--;
+	if (!XC) {
+		XC = 3;
+		if (XD) x += 2;
+		else x -= 2;
+	}
+	YC += YV;
+	if (YC > (IV - 1)) {
+		if (!YD) {
+			YV -= 8;
+			YC -= IV;
+			y -= 2;
+		} else {
+			YV += 8;
+			YC -= IV;
+			y += 2;
+		}
+	}
+	if (YV < 0) {
+		YV = 0;
+		BC = 1;
+	}
+	if (YV > IV) {
+		YV = IV;
+		BC = 1;
+	}
+	BC--;
+	if (!BC) {
+		BC = IC;
+		if (YD) YV = IV;
+		YD ^= 1;
+	}
+	if (y > 164) y = 164;
+	//   8       311
+	if (x<1 || x>(319 - actr->size_x)) {
+		if (!actr->dead) if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+		actor_destroyed(actr);
+	}
+	if (overlap(actr->x, actr->y, actr->x + actr->size_x, actr->y + actr->size_y,
+		_G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15))
+		thor_damaged(actr);
+	actr->x = x;
+	actr->y = y;
+
+//done:
+	next_shot_frame(actr);
+	if (actr->directions == 1) return 0;
+	return actr->last_dir;
+}
+
+int shot_movement_nine(ACTOR *actr) {   //skull explode
+
+	actr->next++;
+	if (actr->next == 3) {
+		_G(actor)[actr->creator].num_shots--;
+		actor_destroyed(actr);
+		return 0;
+	}
+	if (actr->directions == 1) return 0;
+	return actr->last_dir;
+}
+
+int shot_movement_ten(ACTOR *actr) {  //skull - stalagtite
+	int f;
+
+	f = 0;
+	actr->y += 2;
+
+	if (overlap(actr->x, actr->y, actr->x + actr->size_x, actr->y + actr->size_y,
+		_G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15)) {
+		thor_damaged(actr);
+		f = 1;
+	}
+	if ((actr->y > 160) || f) {
+		if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+		actor_destroyed(actr);
+	}
+
+	return 0;
+}
+
+#undef  YD
+#undef  XD
+#define YA actr->i1
+#define XA actr->i2
+#define YD actr->i3
+#define XD actr->i4
+#define DIR actr->i5
+#define CNT actr->i6
+
+void calc_angle(int x1, int y1, int x2, int y2, ACTOR *actr) {
+
+	if (x1 < x2) {
+		XA = -2;
+		XD = x2 - x1;
+	} else if (x1 > x2) {
+		XA = 2;
+		XD = x1 - x2;
+	} else {
+		XA = 0;
+		XD = 0;
+	}
+
+	if (y1 < y2) {
+		YA = -2;
+		YD = y2 - y1;
+	} else if (y1 > y2) {
+		YA = 2;
+		YD = y1 - y2;
+	} else {
+		YA = 0;
+		YD = 0;
+	}
+
+	if (YD >= XD) DIR = 1;
+	else DIR = 0;
+	CNT = 0;
+}
+
+int shot_movement_eleven(ACTOR *actr) {  //angle throw
+	int x1, y1;
+
+	x1 = actr->x;
+	y1 = actr->y;
+
+	if (!actr->temp1) {
+		calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actr);
+		actr->temp1 = 1;
+	}
+
+	if (DIR) {
+		y1 += YA;
+		CNT += XD;
+		if (CNT >= YD) {
+			x1 += XA;
+			CNT -= YD;
+		}
+	} else {
+		x1 += XA;
+		CNT += YD;
+		if (CNT >= XD) {
+			y1 += YA;
+			CNT -= XD;
+		}
+	}
+
+	if (!check_move3(x1, y1, actr)) {
+		if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+		actor_destroyed(actr);
+	} else next_frame(actr);
+
+	if (actr->directions == 1) return 0;
+	return actr->last_dir;
+}
+
+} // namespace Got
diff --git a/engines/got/game/shot_movement.h b/engines/got/game/shot_movement.h
new file mode 100644
index 00000000000..07a7b9b9ce3
--- /dev/null
+++ b/engines/got/game/shot_movement.h
@@ -0,0 +1,33 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GAME_SHOT_MOVEMENT_H
+#define GOT_GAME_SHOT_MOVEMENT_H
+
+#include "got/data/defines.h"
+
+namespace Got {
+
+extern int (*const shot_movement_func[]) (ACTOR *actr);
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/game/shot_pattern.cpp b/engines/got/game/shot_pattern.cpp
new file mode 100644
index 00000000000..bfffb4cd112
--- /dev/null
+++ b/engines/got/game/shot_pattern.cpp
@@ -0,0 +1,224 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/game/shot_pattern.h"
+#include "got/game/move.h"
+#include "got/vars.h"
+
+namespace Got {
+
+int shot_pattern_none(ACTOR *actr);
+int shot_pattern_one(ACTOR *actr);
+int shot_pattern_two(ACTOR *actr);
+int shot_pattern_three(ACTOR *actr);
+int shot_pattern_four(ACTOR *actr);
+int shot_pattern_five(ACTOR *actr);
+int shot_pattern_six(ACTOR *actr);
+int shot_pattern_seven(ACTOR *actr);
+int shot_pattern_eight(ACTOR *actr);
+
+int (*const shot_pattern_func[])(ACTOR *actr) = {
+	shot_pattern_none,
+	shot_pattern_one,
+	shot_pattern_two,
+	shot_pattern_three,
+	shot_pattern_four,
+	shot_pattern_five,
+	shot_pattern_six,
+	shot_pattern_seven,
+	shot_pattern_eight,
+};
+
+// No shooting
+int shot_pattern_none(ACTOR *actr) {
+	actr = actr;
+	return 0;
+}
+
+// Uni-directional seek
+int shot_pattern_one(ACTOR *actr) {
+	switch (actr->last_dir) {
+	case 0:
+		if (ABS(_G(thor_x1) - actr->x) < 8) {
+			if (actr->y > _G(thor_real_y1)) {  //r
+				if (actor_shoots(actr, 0)) return 1;
+			}
+		}
+		break;
+	case 1:
+		if (ABS(_G(thor_x1) - actr->x) < 8) {
+			if (actr->y < _G(thor_real_y1)) {  //r
+				if (actor_shoots(actr, 1)) return 1;
+			}
+		}
+		break;
+	case 2:
+		if (ABS(_G(thor_real_y1) - actr->y) < 8) { //r
+			if (actr->x > _G(thor_x1)) {
+				if (actor_shoots(actr, 2)) return 1;
+			}
+		}
+		break;
+	case 3:
+		if (ABS(_G(thor_real_y1) - actr->y) < 8) { //r
+			if (actr->x < _G(thor_x1)) {
+				if (actor_shoots(actr, 3)) return 1;
+			}
+		}
+		break;
+	}
+
+	return 0;
+}
+
+// Omni directional
+int shot_pattern_two(ACTOR *actr) {
+	if (ABS(_G(thor)->x - actr->x) < 8) {
+		if (_G(thor)->y > actr->y)
+			actor_shoots(actr, 1);
+		else if (_G(thor)->y < actr->y)
+			actor_shoots(actr, 0);
+		else return 0;
+	} else if (ABS(_G(thor)->y - actr->y) < 8) {
+		if (_G(thor)->x > actr->x)
+			actor_shoots(actr, 3);
+		else if (_G(thor)->x < actr->x)
+			actor_shoots(actr, 2);
+	} else {
+		return 0;
+	}
+
+	return 1;
+}
+
+// Uni directional (backwards)
+int shot_pattern_three(ACTOR *actr) {
+	int ld;
+
+	ld = actr->last_dir;
+	if (shot_pattern_one(actr)) {
+		actr->last_dir = reverse_direction(actr);
+		return 1;
+	}
+
+	actr->last_dir = reverse_direction(actr);
+	shot_pattern_one(actr);
+	actr->last_dir = ld;
+
+	return 1;
+}
+
+// Omni-directional not solid shot
+int shot_pattern_four(ACTOR *actr) {
+	if (ABS(_G(thor)->x - actr->x) < 8) {
+		if (_G(thor)->y > actr->y)
+			actor_always_shoots(actr, 1);
+		else if (_G(thor)->y < actr->y)
+			actor_always_shoots(actr, 0);
+		else
+			return 0;
+	} else if (ABS(_G(thor)->y - actr->y) < 8) {
+		if (_G(thor)->x > actr->x)
+			actor_always_shoots(actr, 3);
+		else if (_G(thor)->x < actr->x)
+			actor_always_shoots(actr, 2);
+	} else {
+		return 0;
+	}
+
+	return 1;
+}
+
+// Boss - snake
+int shot_pattern_five(ACTOR *actr) {   
+	int num;
+
+	if (_G(rand1) < 15) {
+		if ((actr->temp1 == 0) && (actr->temp2 == 0)) {
+			actr->y += 16;
+			actr->shots_allowed = 3 + _G(setup).skill;
+			actor_shoots(actr, 2);
+			play_sound(BOSS12, 0);
+			//     num=actr->creator;
+			num = actr->shot_actor;
+			actr->shot_cnt = 50;
+			_G(actor)[num].temp3 = 120;
+			_G(actor)[num].temp4 = 5 + (_G(rand2) % 17);
+			_G(actor)[num].temp5 = _G(actor)[num].temp4;
+			actr->y -= 16;
+			return 1;
+		}
+	}
+
+	return 0;
+}
+
+// 4 surrounding squares
+int shot_pattern_six(ACTOR *actr) {
+	int pos;
+
+	pos = ((actr->x) / 16) + (((actr->y) / 16) * 20);
+
+	if (_G(thor_pos) == pos - 20)
+		actor_shoots(actr, 0);
+	else if (_G(thor_pos) == pos + 20)
+		actor_shoots(actr, 1);
+	else if (_G(thor_pos) == pos - 1)
+		actor_shoots(actr, 2);
+	else if (_G(thor_pos) == pos + 1)
+		actor_shoots(actr, 3);
+	else
+		return 0;
+
+	actr->frame_sequence[3] = 3;
+	actr->next = 3;
+	return 1;
+}
+
+// none
+int shot_pattern_seven(ACTOR *actr) {
+	actr = actr;
+	return 0;
+}
+
+// random
+int shot_pattern_eight(ACTOR *actr) {
+	if (!actr->i2) {
+		actr->i1 = actr->func_pass;
+		actr->i2 = 1;
+	}
+
+	if (actr->i1) {
+		actr->i1--;
+	} else {
+		if (_G(rand1) < 10) {
+			actr->i1 = _G(thor_x1);
+			actr->i2 = _G(thor_real_y1);
+			actr->i1 = actr->func_pass;
+			actor_shoots(actr, 0);
+			return 1;
+		}
+	}
+
+	return 0;
+}
+
+} // namespace Got
diff --git a/engines/got/game/shot_pattern.h b/engines/got/game/shot_pattern.h
new file mode 100644
index 00000000000..588fd8f6e0d
--- /dev/null
+++ b/engines/got/game/shot_pattern.h
@@ -0,0 +1,33 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GAME_SHOT_PATTERN_H
+#define GOT_GAME_SHOT_PATTERN_H
+
+#include "got/data/defines.h"
+
+namespace Got {
+
+extern int (*const shot_pattern_func[])(ACTOR *actr);
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/game/special_tile.cpp b/engines/got/game/special_tile.cpp
new file mode 100644
index 00000000000..8296fc0b13a
--- /dev/null
+++ b/engines/got/game/special_tile.cpp
@@ -0,0 +1,208 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/game/special_tile.h"
+#include "got/game/back.h"
+#include "got/vars.h"
+
+namespace Got {
+
+int open_door1(int y, int x);
+int cash_door1(int y, int x, int amount);
+
+int special_tile_thor(int x, int y, int icon) {
+	int cx, cy, f;
+
+	f = 0;
+	switch (icon) {
+	case 201:
+		return open_door1(x, y);
+	case 202:
+		if (_G(thor)->x > 300)
+			_G(end_tile) = 1;     // ending bridge
+		return 1;
+	case 203:
+		return 0;
+	case 204:
+		return 0;
+	case 205:
+		if (!_G(diag) && _G(thor)->dir != 1)
+			return 1;
+		break;
+	case 206:
+		if (!_G(diag) && _G(thor)->dir != 0)
+			return 1;
+		break;
+	case 207:
+		if (!_G(diag) && _G(thor)->dir != 3)
+			return 1;
+		break;
+	case 208:
+		if (!_G(diag) && _G(thor)->dir != 2)
+			return 1;
+		break;
+	case 209:
+		return cash_door1(x, y, 10);
+	case 210:
+		return cash_door1(x, y, 100);
+	case 211:
+		place_tile(y, x, 79);
+		_G(exit_flag) = 2;
+		return 1;
+	case 212:
+	case 213:
+		return 0;
+	case 214:        //teleport tiles
+	case 215:
+	case 216:
+	case 217:
+		return 0;
+	case 218:
+	case 219:
+		f = 1;
+	case 220:     //hole tiles
+	case 221:
+	case 222:
+	case 223:
+	case 224:
+	case 225:
+	case 226:
+	case 227:
+	case 228:
+	case 229:
+		cx = (_G(thor_x1) + 7) / 16;
+		cy = (_G(thor_real_y1) + 8) / 16;
+		if (_G(scrn).icon[cy][cx] == icon) {
+			_G(thor)->vunerable = STAMINA;
+			if (icon < 224 && icon>219) play_sound(FALL, 0);
+			_G(new_level) = _G(scrn).new_level[icon - 220 + (f * 6)];
+			_G(warp_scroll) = 0;
+			if (_G(new_level) > 119) {
+				_G(warp_scroll) = 1;
+				_G(new_level) -= 128;
+			}
+
+			_G(new_level_tile) = _G(scrn).new_level_loc[icon - 220 + (f * 6)];
+			_G(warp_flag) = 1;
+
+			if (_G(warp_scroll)) {
+				if (_G(thor)->dir == 0) _G(thor)->y = 175;
+				else if (_G(thor)->dir == 1) _G(thor)->y = 0;
+				else if (_G(thor)->dir == 2) _G(thor)->x = 304;
+				else if (_G(thor)->dir == 3) _G(thor)->x = 0;
+			} else {
+				_G(thor)->x = (_G(new_level_tile) % 20) * 16;
+				_G(thor)->y = ((_G(new_level_tile) / 20) * 16) - 2;
+			}
+			_G(thor)->last_x[0] = _G(thor)->x;
+			_G(thor)->last_x[1] = _G(thor)->x;
+			_G(thor)->last_y[0] = _G(thor)->y;
+			_G(thor)->last_y[1] = _G(thor)->y;
+			return 0;
+		}
+
+		return 1;
+	}
+	return 0;
+}
+
+int special_tile(ACTOR *actr, int x, int y, int icon) {
+	switch (icon) {
+	case 201:
+	case 202:
+	case 203:
+	case 204:
+		break;
+	case 205:
+	case 206:
+	case 207:
+	case 208:
+		return 1;
+	case 209:
+	case 210:
+		return 0;
+	case 214:
+	case 215:
+	case 216:
+	case 217:
+		return 0;
+	case 224:
+	case 225:
+	case 226:
+	case 227:
+		if (!actr->flying) return 0;
+		return 1;
+	default:
+		return 1;
+
+	}
+
+	return 0;
+}
+
+void erase_door(int x, int y) {
+	play_sound(DOOR, 0);
+	_G(scrn).icon[y][x] = _G(scrn).bg_color;
+
+	//x = x << 4;
+	//y = y << 4;
+	//xfput(x, y, PAGE2, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
+	//xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, draw_page, 320, 320);
+	//xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, display_page, 320, 320);
+}
+
+int open_door1(int y, int x) {
+	if (_G(thor_info).keys > 0) {
+		erase_door(x, y);
+		_G(thor_info).keys--;
+		//display_keys();
+		return 1;
+	} else {
+		if (!_G(door_inform)) {
+			odin_speaks(2003, 0);
+			_G(door_inform) = 1;
+		}
+	}
+
+	return 0;
+}
+
+int cash_door1(int y, int x, int amount) {
+	if (_G(thor_info).jewels >= amount) {
+		erase_door(x, y);
+		_G(thor_info).jewels -= amount;
+		//display_jewels();
+		return 1;
+	} else {
+		if (amount == 10 && !_G(cash1_inform)) {
+			odin_speaks(2005, 0);
+			_G(cash1_inform) = 1;
+		}
+		if (amount == 100 && !_G(cash2_inform)) {
+			odin_speaks(2004, 0);
+			_G(cash2_inform) = 1;
+		}
+	}
+
+	return 0;
+}
+
+} // namespace Got
diff --git a/engines/got/game/special_tile.h b/engines/got/game/special_tile.h
new file mode 100644
index 00000000000..c6a747b6424
--- /dev/null
+++ b/engines/got/game/special_tile.h
@@ -0,0 +1,34 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GAME_SPECIAL_TILE_H
+#define GOT_GAME_SPECIAL_TILE_H
+
+#include "got/data/defines.h"
+
+namespace Got {
+
+extern int special_tile_thor(int x, int y, int icon);
+extern int special_tile(ACTOR *actr, int x, int y, int icon);
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 0e699fc6db2..b3119830370 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -9,9 +9,18 @@ MODULE_OBJS = \
 	sound.o \
 	vars.o \
 	data/defines.o \
+	game/boss1.o \
 	game/back.o \
 	game/init.o \
 	game/main.o \
+	game/move.o \
+	game/move_patterns.o \
+	game/object.o \
+	game/panel.o \
+	game/script.o \
+	game/shot_movement.o \
+	game/shot_pattern.o \
+	game/special_tile.o \
 	game/status.o \
 	gfx/font.o \
 	gfx/gfx_chunks.o \
diff --git a/engines/got/prototypes.h b/engines/got/prototypes.h
deleted file mode 100644
index 71bee0f650f..00000000000
--- a/engines/got/prototypes.h
+++ /dev/null
@@ -1,255 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef GOT_PROTOTYPES_H
-#define GOT_PROTOTYPES_H
-
-#include "common/scummsys.h"
-
-namespace Got {
-
-//G_LIB.LIB
-
-#ifdef DEPRECATED
-void xsetmode(void);
-void xshowpage(unsigned page);
-void xline(int x0, int y0, int x1, int y1, int page, int color);
-void xfillrectangle(int StartX, int StartY, int EndX, int EndY,
-	unsigned int PageBase, int Color);
-void xpset(int X, int Y, unsigned int PageBase, int Color);
-int  xpoint(int X, int Y, unsigned int PageBase);
-void xget(int x1, int y1, int x2, int y2, unsigned int pagebase,
-	char *buff, int invis);
-void xput(int x, int y, unsigned int pagebase, char *buff);
-void xput2(int x, int y, unsigned int pagebase, char *buff);
-void xtext(int x, int y, unsigned int pagebase, char *buff, int color);
-void xtext1(int x, int y, unsigned int pagebase, char *buff, int color);
-void xtextx(int x, int y, unsigned int pagebase, char *buff, int color);
-
-void xfput(int x, int y, unsigned int pagebase, char *buff);
-void xfarput(int x, int y, unsigned int pagebase, char *buff);
-void xcopyd2dmasked(int SourceStartX,
-	int SourceStartY, int SourceEndX, int SourceEndY,
-	int DestStartX, int DestStartY, MASK_IMAGE *Source,
-	unsigned int DestPageBase, int DestBitmapWidth);
-void xcopyd2dmasked2(
-	int SourceEndX, int SourceEndY,
-	int DestStartX, int DestStartY, MASK_IMAGE *Source,
-	unsigned int DestPageBase);
-void xcopys2d(int SourceStartX, int SourceStartY,
-	int SourceEndX, int SourceEndY, int DestStartX,
-	int DestStartY, byte *SourcePtr, unsigned int DestPageBase,
-	int SourceBitmapWidth, int DestBitmapWidth);
-void xcopyd2d(int SourceStartX, int SourceStartY,
-	int SourceEndX, int SourceEndY, int DestStartX,
-	int DestStartY, unsigned int SourcePageBase,
-	unsigned int DestPageBase, int SourceBitmapWidth,
-	int DestBitmapWidth);
-unsigned int xcreatmaskimage(MASK_IMAGE *ImageToSet,
-	unsigned int DispMemStart, char *Image, int ImageWidth,
-	int ImageHeight, char *Mask);
-unsigned int xcreatmaskimage2(MASK_IMAGE *ImageToSet,
-	unsigned int DispMemStart, char *Image, int ImageWidth,
-	int ImageHeight, char *Mask);
-
-void xddfast(int source_x, int source_y, int width, int height,
-	int dest_x, int dest_y,
-	unsigned int source_page, unsigned int dest_page);
-void xsetpal(unsigned char color, unsigned char R, unsigned char G, unsigned char B);
-void xgetpal(char *pal, int num_colrs, int start_index);
-#endif
-
-//G_MAIN.C
-void run_gotm(void);
-void printt(int val);
-void thor_dies(void);
-void thor_spins(int flag);
-void thor_spins(int flag);
-void pause(int delay);
-void rotate_pal(void);
-int  rnd(int max);
-
-//G_GRP.C
-
-void xprint(int x, int y, char *string, unsigned int page, int color);
-void xprintx(int x, int y, char *string, unsigned int page, int color);
-void split_screen(void);
-int  load_palette(void);
-void xbox(int x1, int y1, int x2, int y2, unsigned page, int color);
-void fade_in(void);
-void fade_out(void);
-void unsplit_screen(void);
-void screen_dump(void);
-void show_all_actors(void);
-
-//G_INIT.C
-int initialize(void);
-void exit_code(int ex_flag);
-//void keyboard_int();              // interrupt prototype
-void demo_key_set(void);
-void wait_not_response(void);
-int  wait_response(void);
-int  get_response(void);
-void wait_key(int index);
-void wait_not_key(int index);
-int  wait_ekey(int index);
-int  wait_not_ekey(int index);
-void joy_key(void);
-void set_joy(void);
-void merge_keys(void);
-int  setup_boss(int num);
-void story(void);
-
-
-//G_PANEL.C
-void boss_status(int health);
-int  select_option(const char *option[], const char *title, int ipos);
-int  option_menu(void);
-int  ask_exit(void);
-int  select_sound(void);
-int  select_music(void);
-int  select_slow(void);
-int  select_scroll(void);
-void select_fastmode(void);
-void select_skill(void);
-void hammer_smack(int x, int y);
-void show_scr(void);
-
-
-//G_BACK.C
-void build_screen(unsigned int pg);
-void scroll_level_left(void);
-void scroll_level_up(void);
-void scroll_level_right(void);
-void scroll_level_down(void);
-void phase_level(void);
-void copy_bg_icon(int num, unsigned int src_page, unsigned int dst_page);
-int  odin_speaks(int index, int item);
-void d_restore(void);
-int  actor_speaks(ACTOR *actr, int index, int item);
-int  display_speech(int item, char *pic, int tf);
-void select_item(void);
-void show_item(int item);
-int  use_thunder(int flag);
-int  use_hourglass(int flag);
-int  use_boots(int flag);
-void use_item(void);
-int  switch_icons(void);
-int  rotate_arrows(void);
-void kill_enemies(int iy, int ix);
-void remove_objects(int y, int x);
-void place_tile(int x, int y, int tile);
-int  bgtile(int x, int y);
-
-//G_MOVE.C
-void next_frame(ACTOR *actr);
-int  point_within(int x, int y, int x1, int y1, int x2, int y2);
-int  overlap(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
-int  reverse_direction(ACTOR *actr);
-void thor_shoots(void);
-void actor_damaged(ACTOR *actr, int damage);
-void thor_damaged(ACTOR *actr);
-void actor_destroyed(ACTOR *actr);
-int  actor_shoots(ACTOR *actr, int dir);
-void actor_always_shoots(ACTOR *actr, int dir);
-void move_actor(ACTOR *actr);
-
-//G_MOVPAT.C
-int  check_move0(int x, int y, ACTOR *actr);
-int  check_move1(int x, int y, ACTOR *actr);
-int  check_move2(int x, int y, ACTOR *actr);
-int  check_move3(int x, int y, ACTOR *actr);
-int  check_move4(int x, int y, ACTOR *actr);
-int  check_thor_move(int x, int y, ACTOR *actr);
-void set_thor_vars(void);
-
-//G_OBJECT.C
-void show_objects(int level, unsigned int pg);
-void pick_up_object(int p);
-int  drop_object(ACTOR *actr);
-int  _drop_obj(ACTOR *actr, int o);
-void delete_object(void);
-
-//G_SPTILE.C
-int special_tile_thor(int x, int y, int icon);
-int special_tile(ACTOR *actr, int x, int y, int icon);
-
-//G_SBFX.C
-int  sbfx_init(void);
-void sbfx_exit(void);
-
-//G_SOUND.C
-int  sound_init(void);
-void sound_exit(void);
-void play_sound(int index, int priority_override);
-int  sound_playing(void);
-
-//G_MUSIC.C
-int  music_init(void);
-void music_play(int num, int override);
-void music_pause(void);
-void music_resume(void);
-int  music_is_on(void);
-
-//G_SCRIPT.C
-void execute_script(long index, char *pic);
-
-//G_BOSS1.C   //serpent
-
-int  boss1_movement(ACTOR *actr);
-void check_boss1_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num);
-void boss_level1(void);
-int  boss_dead1(void);
-void closing_sequence1(void);
-
-//G_BOSS21.C  //wraith
-
-int  boss21_movement(ACTOR *actr);
-void check_boss21_hit(void);
-void boss_level21(void);
-int  boss_dead21(void);
-void closing_sequence21(void);
-
-//G_BOSS22.C  //skull
-
-int  boss22_movement(ACTOR *actr);
-void check_boss22_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num);
-void boss_level22(void);
-int  boss_dead22(void);
-void check_boss21_hit(void);
-void closing_sequence22(void);
-void boss22_set(int d, int x, int y);
-int  boss22a_movement(ACTOR *actr);
-int  boss22b_movement(ACTOR *actr);
-
-//G_ASM.ASM
-void xdisplay_actors(ACTOR *act, unsigned int page);
-void xerase_actors(ACTOR *act, unsigned int page);
-void pal_fade_in(char *buff);
-void pal_fade_out(char *buff);
-void read_joystick(void);
-void UnLZSS(char *src, char *dest, int len);
-#define REPEAT(a) for(rep=0;rep<a;rep++)
-#define IN_RANGE(v,l,h) (v>=l && v<=h)
-
-} // namespace Got
-
-#endif
diff --git a/engines/got/sound.cpp b/engines/got/sound.cpp
index 62bf66f6e4e..a8935a554b7 100644
--- a/engines/got/sound.cpp
+++ b/engines/got/sound.cpp
@@ -205,4 +205,28 @@ const char *Sound::getMusicName(int num) const {
 	return name;
 }
 
+void play_sound(int index, bool priority_override) {
+	_G(sound).play_sound(index, priority_override);
+}
+
+bool sound_playing() {
+	return _G(sound).sound_playing();
+}
+
+void music_play(int num, bool override) {
+	_G(sound).music_play(num, override);
+}
+
+void music_play(const char *name, bool override) {
+	_G(sound).music_play(name, override);
+}
+
+void music_pause() {
+	_G(sound).music_pause();
+}
+
+void music_resume() {
+	_G(sound).music_resume();
+}
+
 } // namespace Got
diff --git a/engines/got/sound.h b/engines/got/sound.h
index b17a61215f8..99f67fb221b 100644
--- a/engines/got/sound.h
+++ b/engines/got/sound.h
@@ -82,6 +82,13 @@ public:
 	bool music_is_on() const;
 };
 
+extern void play_sound(int index, bool priority_override);
+extern bool sound_playing();
+extern void music_play(int num, bool override);
+extern void music_play(const char *name, bool override);
+extern void music_pause();
+extern void music_resume();
+
 } // namespace Got
 
 #endif
diff --git a/engines/got/utils/file.cpp b/engines/got/utils/file.cpp
index 693f705dac6..9f71b35b4e6 100644
--- a/engines/got/utils/file.cpp
+++ b/engines/got/utils/file.cpp
@@ -21,7 +21,6 @@
 
 #include "common/file.h"
 #include "got/utils/file.h"
-#include "got/prototypes.h"
 #include "got/vars.h"
 
 namespace Got {
@@ -244,4 +243,15 @@ long res_read(const Common::String &name, void *buff, bool failAllowed) {
 	}
 }
 
+void *res_falloc_read(const Common::String &name) {
+	Common::File f;
+	if (f.open(Common::Path(name))) {
+		byte *result = (byte *)malloc(f.size());
+		f.read(result, f.size());
+		return result;
+	} else {
+		return nullptr;
+	}
+}
+
 } // End of namespace Got
diff --git a/engines/got/utils/file.h b/engines/got/utils/file.h
index 153f2505330..f99d9f5f5e1 100644
--- a/engines/got/utils/file.h
+++ b/engines/got/utils/file.h
@@ -43,6 +43,7 @@ extern bool load_game(int flag);
 extern void help();
 extern long res_read(const Common::String &name, void *buff,
 	bool failAllowed = false);
+extern void *res_falloc_read(const Common::String &name);
 
 class File : public Common::File {
 public:
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 31a15f35aec..5d13f11dfe5 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -32,19 +32,21 @@ Vars *g_vars;
 
 Vars::Vars() :
 		_hampic("HAMPIC", 262, false),
+		_odin("ODINPIC", 262, false),
 		_objects("OBJECTS", 262, false),
 		_status("STATUS", -1, false) {
 	g_vars = this;
 }
 
 void Vars::load() {
+	_bgPics.load();
 	_font.load();
 	_gfx.load();
-	_bgPics.load();
 	_hampic.load();
 	_objects.load();
-	_status.load();
+	_odin.load();
 	_sound.load();
+	_status.load();
 
 	_music_flag = !ConfMan.getBool("music_mute");
 	_sound_flag = _pcsound_flag = !ConfMan.getBool("sfx_mute");
@@ -86,7 +88,6 @@ void Vars::load() {
  
 	res_read("RANDOM", _rnd_array);
 	res_read("DEMO", _demo_key);
-	res_read("ODINPIC", _odin);
 
 	Gfx::load_palette();
 }
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 8a06ae953a8..7ece6ee89b8 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -53,6 +53,7 @@ public:
 	Gfx::Font _font;
 	Gfx::Pics _hampic;
 	Gfx::Pics _objects;
+	Gfx::Pics _odin;
 
 	Gfx::Pics _status;
 	Sound _sound;
@@ -61,6 +62,7 @@ public:
 	uint _display_page = 0, _draw_page = 0;
 	uint _page3_offset = 0;
 	int8 _pge = 0;
+	int _exit_flag = 0;
 
 	byte _key_flag[100] = {};
 	byte _joy_flag[100] = {};
@@ -68,6 +70,7 @@ public:
 	int8 _break_code = 0;
 	int8 _scan_code = 0, _last_scan_code = 0;
 	int8 _diag = 0;
+	bool _diag_flag = false;
 	bool _slow_mode = false, _startup = true;
 	int8 _shot_ok = 0;
 	int _thor_x1 = 0, _thor_y1 = 0, _thor_x2 = 0, _thor_y2 = 0,
@@ -148,7 +151,6 @@ public:
 	int _joystick = 0, _joylx = 0, _joyly = 0,
 		_joyhx = 0, _joyhy = 0;
 	byte _res_file[16] = {};
-	byte _odin[4][262] = {};
 	int _load_game_flag = 0;
 	bool _music_flag = false, _sound_flag = false, _pcsound_flag = false;
 	int _cash1_inform = 0, _cash2_inform = 0, _door_inform = 0,
@@ -190,6 +192,11 @@ public:
 	byte *_magic_mask_buff = nullptr;
 	byte *_ami_store1 = nullptr, *_ami_store2 = nullptr;
 	byte *_mask_store1 = nullptr, *_mask_store2 = nullptr;
+	bool _thor_special_flag = false;
+	int  _pixel_x[8][25] = {};
+	int  _pixel_y[8][25] = {};
+	byte _pixel_p[8][25] = {};
+	byte _pixel_c[8] = {};
 };
 
 #define _G(X) (g_vars->_##X)
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index a6474c314e8..8c48e836bb5 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -21,6 +21,7 @@
 
 #include "got/views/game_content.h"
 #include "got/game/back.h"
+#include "got/game/move.h"
 #include "got/gfx/image.h"
 #include "got/vars.h"
 
@@ -28,12 +29,23 @@ namespace Got {
 namespace Views {
 
 void GameContent::draw() {
-	GfxSurface s = getSurface();
+	GfxSurface s;
+	if (_shakeDelta.x != 0 || _shakeDelta.y != 0) {
+		s = getSurface();
+	} else {
+		s.create(320, 192);
+	}
 	s.clear();
 
 	drawBackground(s);
 	drawObjects(s);
 	drawEnemies(s, &_G(actor)[MAX_ACTORS - 1]);
+
+	// If we're shaking the screen, render the content with the shake X/Y
+	if (_shakeDelta.x != 0 || _shakeDelta.y != 0) {
+		GfxSurface win = getSurface();
+		win.blitFrom(s, _shakeDelta);
+	}
 }
 
 bool GameContent::msgGame(const GameMessage &msg) {
@@ -45,6 +57,11 @@ bool GameContent::msgGame(const GameMessage &msg) {
 	return false;
 }
 
+bool GameContent::tick() {
+	checkThunderShake();
+	return true;
+}
+
 void GameContent::drawBackground(GfxSurface &s) {
 	for (int y = 0; y < TILES_Y; y++) {
 		for (int x = 0; x < TILES_X; x++) {
@@ -104,5 +121,31 @@ void GameContent::drawEnemies(GfxSurface &s, ACTOR *lastActor) {
 	}
 }
 
+void GameContent::checkThunderShake() {
+	if (_G(thunder_flag)) {
+		// Introduce a random screen shake by rendering screen 1 pixel offset randomly
+		static const int8 DELTA_X[4] = { -1, 1, 0, 0 };
+		static const int8 DELTA_Y[4] = { 0, 0, -1, 1 };
+		int delta = g_events->getRandomNumber(3);
+
+		_shakeDelta.x = DELTA_X[delta];
+		_shakeDelta.y = DELTA_Y[delta];
+
+		_G(thunder_flag)--;
+		if ((_G(thunder_flag) < MAX_ACTORS) && _G(thunder_flag) > 2) {
+			if (_G(actor)[_G(thunder_flag)].used) {
+				_G(actor)[_G(thunder_flag)].vunerable = 0;
+				actor_damaged(&_G(actor)[_G(thunder_flag)], 20);
+			}
+		}
+
+		redraw();
+
+	} else if (_shakeDelta.x != 0 || _shakeDelta.y != 0) {
+		_shakeDelta = Common::Point(0, 0);
+		redraw();
+	}
+}
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index 07a58e355da..978494f9803 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -30,9 +30,12 @@ namespace Views {
 
 class GameContent : public View {
 private:
+	Common::Point _shakeDelta;
+
 	void drawBackground(GfxSurface &s);
 	void drawObjects(GfxSurface &s);
 	void drawEnemies(GfxSurface &s, ACTOR *lastActor);
+	void checkThunderShake();
 
 public:
 	GameContent() : View("GameContent") {}
@@ -40,6 +43,7 @@ public:
 
 	void draw() override;
 	bool msgGame(const GameMessage &msg) override;
+	bool tick() override;
 };
 
 } // namespace Views


Commit: 1baf9b7d3e7b86c5405ed8c41509d79865f17c67
    https://github.com/scummvm/scummvm/commit/1baf9b7d3e7b86c5405ed8c41509d79865f17c67
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix rendering content view

Changed paths:
    engines/got/views/game_content.cpp


diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 8c48e836bb5..1caf8248ba2 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -31,9 +31,9 @@ namespace Views {
 void GameContent::draw() {
 	GfxSurface s;
 	if (_shakeDelta.x != 0 || _shakeDelta.y != 0) {
-		s = getSurface();
-	} else {
 		s.create(320, 192);
+	} else {
+		s = getSurface();
 	}
 	s.clear();
 


Commit: dc6b1724ed771d2f2b59e95a8f62cb30d4b010a9
    https://github.com/scummvm/scummvm/commit/dc6b1724ed771d2f2b59e95a8f62cb30d4b010a9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Change key variables into an enum

Changed paths:
    engines/got/game/move_patterns.cpp
    engines/got/game/object.cpp
    engines/got/vars.h


diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 8441f8af4b5..cdfc671d938 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -298,7 +298,7 @@ int check_move0(int x, int y, ACTOR *actr) {
 				thor_damaged(act);
 				if (act->solid < 2) {
 					if (!act->vunerable && (!(act->type & 1))) play_sound(PUNCH1, 0);
-					if (!_G(hammer)->used && _G(key_flag)[_G(key_fire)])
+					if (!_G(hammer)->used && _G(key_flag)[key_fire])
 						actor_damaged(act, _G(hammer)->strength);
 					else
 						actor_damaged(act, _G(thor)->strength);
@@ -595,9 +595,9 @@ int movement_zero(ACTOR *actr) {       //player control
 
 	set_thor_vars();
 
-	if (_G(key_flag)[_G(key_fire)])
+	if (_G(key_flag)[key_fire])
 		thor_shoots();
-	if (_G(key_flag)[_G(key_select)])
+	if (_G(key_flag)[key_select])
 		select_item();
 
 	if ((_G(hammer)->used) && (_G(hammer)->move == 5)) {
@@ -610,7 +610,7 @@ int movement_zero(ACTOR *actr) {       //player control
 	y = actr->y;
 	_G(diag_flag) = 0;
 	if (actr->move_counter) actr->move_counter--;
-	if (_G(key_flag)[_G(key_up)] && _G(key_flag)[_G(key_left)]) {
+	if (_G(key_flag)[key_up] && _G(key_flag)[key_left]) {
 		d = 2;
 		actr->dir = d;
 		_G(diag) = 1;
@@ -619,7 +619,7 @@ int movement_zero(ACTOR *actr) {       //player control
 			next_frame(actr);
 			return d;
 		}
-	} else if (_G(key_flag)[_G(key_up)] && _G(key_flag)[_G(key_right)]) {
+	} else if (_G(key_flag)[key_up] && _G(key_flag)[key_right]) {
 		d = 3;
 		actr->dir = d;
 		_G(diag) = 2;
@@ -628,7 +628,7 @@ int movement_zero(ACTOR *actr) {       //player control
 			next_frame(actr);
 			return d;
 		}
-	} else if (_G(key_flag)[_G(key_down)] && _G(key_flag)[_G(key_left)]) {
+	} else if (_G(key_flag)[key_down] && _G(key_flag)[key_left]) {
 		d = 2;
 		actr->dir = d;
 		_G(diag) = 4;
@@ -637,7 +637,7 @@ int movement_zero(ACTOR *actr) {       //player control
 			next_frame(actr);
 			return d;
 		}
-	} else if (_G(key_flag)[_G(key_down)] && _G(key_flag)[_G(key_right)]) {
+	} else if (_G(key_flag)[key_down] && _G(key_flag)[key_right]) {
 		d = 3;
 		actr->dir = d;
 		_G(diag) = 3;
@@ -648,8 +648,8 @@ int movement_zero(ACTOR *actr) {       //player control
 		}
 	}
 	_G(diag) = 0;
-	if (_G(key_flag)[_G(key_right)]) {
-		if (!_G(key_flag)[_G(key_left)]) {
+	if (_G(key_flag)[key_right]) {
+		if (!_G(key_flag)[key_left]) {
 			d = 3;
 			actr->dir = d;
 			if (check_thor_move(x + 2, y, actr)) {
@@ -658,8 +658,8 @@ int movement_zero(ACTOR *actr) {       //player control
 			}
 		}
 	}
-	if (_G(key_flag)[_G(key_left)]) {
-		if (!_G(key_flag)[_G(key_right)]) {
+	if (_G(key_flag)[key_left]) {
+		if (!_G(key_flag)[key_right]) {
 			d = 2;
 			actr->dir = d;
 			if (check_thor_move(x - 2, y, actr)) {
@@ -668,8 +668,8 @@ int movement_zero(ACTOR *actr) {       //player control
 			}
 		}
 	}
-	if (_G(key_flag)[_G(key_down)]) {
-		if (!_G(key_flag)[_G(key_up)]) {
+	if (_G(key_flag)[key_down]) {
+		if (!_G(key_flag)[key_up]) {
 			d = 1;
 			actr->dir = d;
 			if (check_thor_move(x, y + 2, actr)) {
@@ -678,8 +678,8 @@ int movement_zero(ACTOR *actr) {       //player control
 			}
 		}
 	}
-	if (_G(key_flag)[_G(key_up)]) {
-		if (!_G(key_flag)[_G(key_down)]) {
+	if (_G(key_flag)[key_up]) {
+		if (!_G(key_flag)[key_down]) {
 			d = 0;
 			actr->dir = d;
 			if (check_thor_move(x, y - 2, actr)) {
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index c7f2f7a93f7..23aab046c41 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -256,7 +256,7 @@ int use_hourglass(int flag) {
 					 510,540,570,600,630,660,690 };
 
 	if (_G(hourglass_flag)) {
-		if (_G(magic_cnt) > hour_time[_G(hourglass_flag)]) {
+		if ((int)_G(magic_cnt) > hour_time[_G(hourglass_flag)]) {
 			_G(hourglass_flag)++;
 			if (_G(hourglass_flag) == 16) {
 				_G(hourglass_flag) = 0;
@@ -415,7 +415,7 @@ void use_item() {
 	static int flag = 0;
 	int kf, ret = 0, mf;
 
-	kf = _G(key_flag)[_G(key_magic)];
+	kf = _G(key_flag)[key_magic];
 
 	if (!kf && _G(tornado_used)) {
 		actor_destroyed(&_G(actor)[2]);
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 7ece6ee89b8..712d61ce82c 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -41,6 +41,12 @@ class Vars;
 
 extern Vars *g_vars;
 
+enum Key {
+	key_fire, key_up, key_down, key_left, key_right,
+	key_magic, key_select,
+	KEY_MAX
+};
+
 class Vars {
 public:
 	Vars();
@@ -124,10 +130,6 @@ public:
 	ACTOR _explosion;
 	ACTOR _sparkle;
 	THOR_INFO _thor_info;
-	Common::KeyCode _key_fire = Common::KEYCODE_LALT,
-		_key_up = Common::KEYCODE_UP, _key_down = Common::KEYCODE_DOWN,
-		_key_left = Common::KEYCODE_LEFT, _key_right = Common::KEYCODE_RIGHT,
-		_key_magic = Common::KEYCODE_LCTRL, _key_select = Common::KEYCODE_SPACE;
 	int _boss_dead = 0;
 
 	int _warp_flag = 0;


Commit: 1d11468a146fbc17a7d44d423e9b9cf0b12eb357
    https://github.com/scummvm/scummvm/commit/1d11468a146fbc17a7d44d423e9b9cf0b12eb357
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Encapsulate sd data as it's own class

Changed paths:
  A engines/got/data/sd_data.cpp
  A engines/got/data/sd_data.h
    engines/got/game/back.cpp
    engines/got/game/init.cpp
    engines/got/game/object.cpp
    engines/got/module.mk
    engines/got/utils/file.cpp
    engines/got/utils/file.h
    engines/got/vars.cpp
    engines/got/vars.h


diff --git a/engines/got/data/sd_data.cpp b/engines/got/data/sd_data.cpp
new file mode 100644
index 00000000000..63b814d589a
--- /dev/null
+++ b/engines/got/data/sd_data.cpp
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/memstream.h"
+#include "got/data/sd_data.h"
+#include "got/utils/file.h"
+
+namespace Got {
+
+SdData::SdData() {
+	_data = new byte[61440];
+}
+
+SdData::~SdData() {
+	delete[] _data;
+}
+
+void SdData::load() {
+	Common::String fname = Common::String::format("SDAT%d", _area);
+	res_read(fname, _data);
+}
+
+void SdData::setArea(int area) {
+	if (area != _area) {
+		_area = area;
+		load();
+	}
+}
+
+void SdData::sync(Common::Serializer &s) {
+	// TODO
+}
+
+void SdData::load(int level, LEVEL *dest) {
+	byte *addr = getLevelAddr(level);
+	Common::MemoryReadStream inStream(addr, 512);
+	dest->load(&inStream);
+}
+
+void SdData::save(int level, LEVEL *src) {
+	byte *addr = getLevelAddr(level);
+	Common::MemoryWriteStream outStream(addr, 512);
+	src->save(&outStream);
+}
+
+} // namespace Got
diff --git a/engines/got/data/sd_data.h b/engines/got/data/sd_data.h
new file mode 100644
index 00000000000..f5c8aac98ee
--- /dev/null
+++ b/engines/got/data/sd_data.h
@@ -0,0 +1,59 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_DATA_SD_DATA_H
+#define GOT_DATA_SD_DATA_H
+
+#include "common/serializer.h"
+#include "got/data/defines.h"
+
+namespace Got {
+
+class SdData {
+private:
+	byte *_data;
+	int _area = 1;
+
+	byte *getLevelAddr(int level) const {
+		return _data + level * 512;
+	}
+public:
+	SdData();
+	~SdData();
+	void load();
+
+	bool getArea() const {
+		return _area;
+	}
+	void setArea(int area);
+
+	void sync(Common::Serializer &s);
+	void load(int level, LEVEL *dest);
+	void save(int level, LEVEL *src);
+
+	operator const byte *() const {
+		return _data;
+	}
+};
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index ff5078eb8a1..b6ebb7af11b 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -20,7 +20,6 @@
  */
 
 #include "common/file.h"
-#include "common/memstream.h"
 #include "got/game/back.h"
 #include "got/game/move.h"
 #include "got/game/panel.h"
@@ -58,10 +57,8 @@ void show_level(int new_level) {
 	// This doesn't make sense, because that would put the ending in the middle of static_y.
 	// Plus, it follows with an entire copy of scrn into sd_data anyway, so the first
 	// move seems entirely redundant.
-	Common::MemoryWriteStream outStream(_G(sd_data) + (_G(current_level) * 512), 512);
-	_G(scrn).save(&outStream);
-	Common::MemoryReadStream inStream(_G(sd_data) + (_G(current_level) * 512), 512);
-	_G(scrn).load(&inStream);
+	_G(sd_data).save(_G(current_level), &_G(scrn));
+	_G(sd_data).load(_G(new_level), &_G(scrn));
 
 	_G(scrnp) = (byte *)&_G(scrn);
 	_G(level_type) = _G(scrn).type;
diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index 29f811377b4..cd1a51bcf18 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -34,11 +34,7 @@ namespace Got {
 
 int setup_level() {
 	_G(bgPics).setArea(_G(area));
-
-	if (_G(load_game_flag) != 1) {
-		if (!load_sd_data())
-			return 0;
-	}
+	_G(sd_data).setArea(_G(area));
 
 	return 1;
 }
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index 23aab046c41..f16c5e49d71 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -399,7 +399,8 @@ int use_tornado(int flag) {
 
 int use_object(int flag) {
 	if (!flag) return 0;
-	if (!_G(thor_info).inventory & 64) return 0;
+	if (!(_G(thor_info).inventory & 64))
+		return 0;
 
 	//xshowpage(draw_page);
 	//xerase_actors(actor, display_page);
diff --git a/engines/got/module.mk b/engines/got/module.mk
index b3119830370..4a2b086af8a 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -9,6 +9,7 @@ MODULE_OBJS = \
 	sound.o \
 	vars.o \
 	data/defines.o \
+	data/sd_data.o \
 	game/boss1.o \
 	game/back.o \
 	game/init.o \
diff --git a/engines/got/utils/file.cpp b/engines/got/utils/file.cpp
index 9f71b35b4e6..49899fdafbd 100644
--- a/engines/got/utils/file.cpp
+++ b/engines/got/utils/file.cpp
@@ -39,17 +39,6 @@ long file_size(char *path) {
 	return f.open(Common::Path(path)) ? f.size() : -1;
 }
 
-bool load_sd_data() {
-	Common::String fname = Common::String::format("SDAT%d", _G(area));
-
-	if (!_G(sd_data))
-		_G(sd_data) = new byte[61440];
-	if (!_G(sd_data))
-		return false;
-
-	return res_read(fname, _G(sd_data)) > 0;
-}
-
 bool load_actor(int /*file*/, int num) {
 	Common::String fname = Common::String::format("ACTOR%d", num);
 
diff --git a/engines/got/utils/file.h b/engines/got/utils/file.h
index f99d9f5f5e1..fc57fecefb8 100644
--- a/engines/got/utils/file.h
+++ b/engines/got/utils/file.h
@@ -31,7 +31,6 @@ extern long file_size(const char *path);
 extern unsigned int read_file(const char *filename, const char *buff,
 	long offset, unsigned int amount, int key);
 
-extern bool load_sd_data();
 extern bool load_actor(int, int num);
 extern bool load_picture(int index, char *buff);
 extern void setup_filenames(int level);
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 5d13f11dfe5..5d1e99be79b 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -45,6 +45,7 @@ void Vars::load() {
 	_hampic.load();
 	_objects.load();
 	_odin.load();
+	_sd_data.load();
 	_sound.load();
 	_status.load();
 
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 712d61ce82c..0076d299c2d 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -25,6 +25,7 @@
 #include "common/events.h"
 #include "graphics/screen.h"
 #include "got/data/defines.h"
+#include "got/data/sd_data.h"
 #include "got/sound.h"
 #include "got/gfx/font.h"
 #include "got/gfx/gfx_chunks.h"
@@ -60,8 +61,8 @@ public:
 	Gfx::Pics _hampic;
 	Gfx::Pics _objects;
 	Gfx::Pics _odin;
-
 	Gfx::Pics _status;
+	SdData _sd_data;
 	Sound _sound;
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
@@ -104,8 +105,6 @@ public:
 	LEVEL _scrn;
 	byte *_scrnp = nullptr;
 
-	byte *_sd_data = nullptr;
-
 	SETUP _setup;
 	SETUP _last_setup;
 	byte *_tmp_buff = nullptr;


Commit: 848f9d104b741ca100e15a84c30a3978906cddeb
    https://github.com/scummvm/scummvm/commit/848f9d104b741ca100e15a84c30a3978906cddeb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Setting up sync methods for classes stored in savegames

Changed paths:
  A engines/got/data/level.cpp
  A engines/got/data/level.h
  A engines/got/data/setup.cpp
  A engines/got/data/setup.h
  A engines/got/data/thor_info.cpp
  A engines/got/data/thor_info.h
  R engines/got/data/defines.cpp
    engines/got/data/defines.h
    engines/got/data/sd_data.cpp
    engines/got/data/sd_data.h
    engines/got/got.cpp
    engines/got/module.mk


diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index 1f1e464c6c7..3878e723b4d 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -25,45 +25,16 @@
 #include "common/scummsys.h"
 #include "common/serializer.h"
 #include "graphics/managed_surface.h"
+#include "got/data/level.h"
+#include "got/data/sd_data.h"
+#include "got/data/setup.h"
+#include "got/data/thor_info.h"
 
 namespace Got {
 
 #define REPEAT(a) for(rep=0;rep<a;rep++)
 #define IN_RANGE(v,l,h) (v>=l && v<=h)
 
-#define OBJECTS_COUNT 30
-
-struct LEVEL {                    // size=512
-	byte icon[12][20] = {};       // 0   grid of icons
-	byte bg_color = 0;            // 240 background color
-	byte type = 0;                // 241 music
-	byte actor_type[16] = {};     // 242 type of enemies (12 max)
-	byte actor_loc[16] = {};      // 254 location of enemies
-	byte actor_value[16] = {};    // pass value
-	byte pal_colors[3] = {};      // change 251,253,254 to these three
-	byte actor_invis[16] = {};
-	byte extra[13] = {};
-
-	byte static_obj[OBJECTS_COUNT] = {};     // 302 static objects (treasure, keys,etc)
-	int  static_x[OBJECTS_COUNT] = {};       // 332 X coor of static objects
-	int  static_y[OBJECTS_COUNT] = {};       // 392 Y coor of static objects
-	byte new_level[10] = {};      // 452 level jump for icon 200-204
-	byte new_level_loc[10] = {};  // 462 grid location to jump in to
-	byte area = 0;                // 472 game area (1=forest,etc)
-	byte actor_dir[16] = {};      // initial dir
-	byte future[3] = {};          // 473
-
-	void sync(Common::Serializer &s);
-	void load(Common::SeekableReadStream *src) {
-		Common::Serializer s(src, nullptr);
-		sync(s);
-	}
-	void save(Common::WriteStream *dest) {
-		Common::Serializer s(nullptr, dest);
-		sync(s);
-	}
-};
-
 #define DIRECTION_COUNT 4
 #define FRAME_COUNT 4
 
@@ -180,136 +151,11 @@ struct ACTOR_DATA {                 //5200
 	ACTOR_NFO shot_info = {};       //40
 };
 
-struct SETUP {
-	SETUP() :
-		f00(0), f01(0), f02(0), f03(0), f04(0), f05(0), f06(0), f07(0), f08(0), f09(0),
-		f10(0), f11(0), f12(0), f13(0), f14(0), f15(0), f16(0), f17(0), f18(0), f19(0),
-		f20(0), f21(0), f22(0), f23(0), f24(0), f25(0), f26(0), f27(0), f28(0), f29(0),
-		f30(0), f31(0), f32(0), f33(0), f34(0), f35(0), f36(0), f37(0), f38(0), f39(0),
-		f40(0), f41(0), f42(0), f43(0), f44(0), f45(0), f46(0), f47(0), f48(0), f49(0),
-		f50(0), f51(0), f52(0), f53(0), f54(0), f55(0), f56(0), f57(0), f58(0), f59(0),
-		f60(0), f61(0), f62(0), f63(0) {
-	}
-
-	unsigned int  f00 : 1;
-	unsigned int  f01 : 1;
-	unsigned int  f02 : 1;
-	unsigned int  f03 : 1;
-	unsigned int  f04 : 1;
-	unsigned int  f05 : 1;
-	unsigned int  f06 : 1;
-	unsigned int  f07 : 1;
-
-	unsigned int  f08 : 1;
-	unsigned int  f09 : 1;
-	unsigned int  f10 : 1;
-	unsigned int  f11 : 1;
-	unsigned int  f12 : 1;
-	unsigned int  f13 : 1;
-	unsigned int  f14 : 1;
-	unsigned int  f15 : 1;
-
-	unsigned int  f16 : 1;
-	unsigned int  f17 : 1;
-	unsigned int  f18 : 1;
-	unsigned int  f19 : 1;
-	unsigned int  f20 : 1;
-	unsigned int  f21 : 1;
-	unsigned int  f22 : 1;
-	unsigned int  f23 : 1;
-
-	unsigned int  f24 : 1;
-	unsigned int  f25 : 1;
-	unsigned int  f26 : 1;
-	unsigned int  f27 : 1;
-	unsigned int  f28 : 1;
-	unsigned int  f29 : 1;
-	unsigned int  f30 : 1;
-	unsigned int  f31 : 1;
-
-	unsigned int  f32 : 1;
-	unsigned int  f33 : 1;
-	unsigned int  f34 : 1;
-	unsigned int  f35 : 1;
-	unsigned int  f36 : 1;
-	unsigned int  f37 : 1;
-	unsigned int  f38 : 1;
-	unsigned int  f39 : 1;
-
-	unsigned int  f40 : 1;
-	unsigned int  f41 : 1;
-	unsigned int  f42 : 1;
-	unsigned int  f43 : 1;
-	unsigned int  f44 : 1;
-	unsigned int  f45 : 1;
-	unsigned int  f46 : 1;
-	unsigned int  f47 : 1;
-
-	unsigned int  f48 : 1;
-	unsigned int  f49 : 1;
-	unsigned int  f50 : 1;
-	unsigned int  f51 : 1;
-	unsigned int  f52 : 1;
-	unsigned int  f53 : 1;
-	unsigned int  f54 : 1;
-	unsigned int  f55 : 1;
-
-	unsigned int  f56 : 1;
-	unsigned int  f57 : 1;
-	unsigned int  f58 : 1;
-	unsigned int  f59 : 1;
-	unsigned int  f60 : 1;
-	unsigned int  f61 : 1;
-	unsigned int  f62 : 1;
-	unsigned int  f63 : 1;
-
-	byte value[16] = {};
-	byte junk = 0;
-	byte game = 0;
-	byte area = 0;          //1,2,3
-	byte pc_sound = 0;      //1=enabled
-	byte dig_sound = 0;     //1 & !pc_sound = enabled
-	byte music = 0;         //1=enabled
-	byte speed = 0;         //1=slow mode (for slower 286's)
-	byte scroll_flag = 0;   //unused
-	byte boss_dead[3] = {};
-	byte skill = 0;         //0=easy, 1=normal, 2=hard
-	byte game_over = 0;
-	byte future[19] = {};   //probably not needed
-};
-
 struct PIC_HEADER {
 	byte width = 0;
 	byte height = 0;
 };
 
-struct THOR_INFO {
-	byte magic = 0;
-	byte keys = 0;
-	int  jewels = 0;
-	byte last_area = 0;
-	byte last_screen = 0;
-	byte last_icon = 0;
-	byte last_dir = 0;
-	int  inventory = 0;
-	byte item = 0;         //currently selected item
-	byte last_health = 0;
-	byte last_magic = 0;
-	int  last_jewels = 0;
-	byte last_keys = 0;
-	byte last_item = 0;
-	int  last_inventory = 0;
-	byte level = 0;         //current level (1,2,3)
-	long score = 0;
-	long last_score = 0;
-	byte object = 0;
-	const char *object_name = nullptr;
-	byte last_object = 0;
-	const char *last_object_name = nullptr;
-	byte armor = 0;
-	byte future[65] = {};
-};
-
 struct HEADER {
 	long offset = 0;
 	long length = 0;
diff --git a/engines/got/data/defines.cpp b/engines/got/data/level.cpp
similarity index 100%
rename from engines/got/data/defines.cpp
rename to engines/got/data/level.cpp
diff --git a/engines/got/data/level.h b/engines/got/data/level.h
new file mode 100644
index 00000000000..cfaa4c418d6
--- /dev/null
+++ b/engines/got/data/level.h
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_DATA_LEVEL_H
+#define GOT_DATA_LEVEL_H
+
+#include "common/serializer.h"
+
+namespace Got {
+
+#define OBJECTS_COUNT 30
+
+struct LEVEL {                    // size=512
+	byte icon[12][20] = {};       // 0   grid of icons
+	byte bg_color = 0;            // 240 background color
+	byte type = 0;                // 241 music
+	byte actor_type[16] = {};     // 242 type of enemies (12 max)
+	byte actor_loc[16] = {};      // 254 location of enemies
+	byte actor_value[16] = {};    // pass value
+	byte pal_colors[3] = {};      // change 251,253,254 to these three
+	byte actor_invis[16] = {};
+	byte extra[13] = {};
+
+	byte static_obj[OBJECTS_COUNT] = {};     // 302 static objects (treasure, keys,etc)
+	int  static_x[OBJECTS_COUNT] = {};       // 332 X coor of static objects
+	int  static_y[OBJECTS_COUNT] = {};       // 392 Y coor of static objects
+	byte new_level[10] = {};      // 452 level jump for icon 200-204
+	byte new_level_loc[10] = {};  // 462 grid location to jump in to
+	byte area = 0;                // 472 game area (1=forest,etc)
+	byte actor_dir[16] = {};      // initial dir
+	byte future[3] = {};          // 473
+
+	void sync(Common::Serializer &s);
+	void load(Common::SeekableReadStream *src) {
+		Common::Serializer s(src, nullptr);
+		sync(s);
+	}
+	void save(Common::WriteStream *dest) {
+		Common::Serializer s(nullptr, dest);
+		sync(s);
+	}
+};
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/data/sd_data.cpp b/engines/got/data/sd_data.cpp
index 63b814d589a..38009b99c56 100644
--- a/engines/got/data/sd_data.cpp
+++ b/engines/got/data/sd_data.cpp
@@ -25,8 +25,10 @@
 
 namespace Got {
 
+#define SD_DATA_SIZE 61440
+
 SdData::SdData() {
-	_data = new byte[61440];
+	_data = new byte[SD_DATA_SIZE];
 }
 
 SdData::~SdData() {
@@ -46,7 +48,7 @@ void SdData::setArea(int area) {
 }
 
 void SdData::sync(Common::Serializer &s) {
-	// TODO
+	s.syncBytes(_data, SD_DATA_SIZE);
 }
 
 void SdData::load(int level, LEVEL *dest) {
diff --git a/engines/got/data/sd_data.h b/engines/got/data/sd_data.h
index f5c8aac98ee..fbbd8b81190 100644
--- a/engines/got/data/sd_data.h
+++ b/engines/got/data/sd_data.h
@@ -23,7 +23,7 @@
 #define GOT_DATA_SD_DATA_H
 
 #include "common/serializer.h"
-#include "got/data/defines.h"
+#include "got/data/level.h"
 
 namespace Got {
 
diff --git a/engines/got/data/setup.cpp b/engines/got/data/setup.cpp
new file mode 100644
index 00000000000..a6d8e90ae50
--- /dev/null
+++ b/engines/got/data/setup.cpp
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/data/setup.h"
+
+namespace Got {
+
+void SETUP::sync(Common::Serializer &s) {
+	// Write out the flags
+	s.syncBytes((byte *)this, 16);
+
+	s.syncBytes(value, 16);
+	s.syncAsByte(junk);
+	s.syncAsByte(game);
+	s.syncAsByte(area);
+	s.syncAsByte(pc_sound);
+	s.syncAsByte(dig_sound);
+	s.syncAsByte(music);
+	s.syncAsByte(speed);
+	s.syncAsByte(scroll_flag);
+	s.syncBytes(boss_dead, 3);
+	s.syncAsByte(skill);
+	s.syncAsByte(game_over);
+	s.syncBytes(future, 19);
+}
+
+} // namespace Got
diff --git a/engines/got/data/setup.h b/engines/got/data/setup.h
new file mode 100644
index 00000000000..129e56695b1
--- /dev/null
+++ b/engines/got/data/setup.h
@@ -0,0 +1,131 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_DATA_SETUP_H
+#define GOT_DATA_SETUP_H
+
+#include "common/serializer.h"
+
+namespace Got {
+
+struct SETUP {
+	SETUP() :
+		f00(0), f01(0), f02(0), f03(0), f04(0), f05(0), f06(0), f07(0), f08(0), f09(0),
+		f10(0), f11(0), f12(0), f13(0), f14(0), f15(0), f16(0), f17(0), f18(0), f19(0),
+		f20(0), f21(0), f22(0), f23(0), f24(0), f25(0), f26(0), f27(0), f28(0), f29(0),
+		f30(0), f31(0), f32(0), f33(0), f34(0), f35(0), f36(0), f37(0), f38(0), f39(0),
+		f40(0), f41(0), f42(0), f43(0), f44(0), f45(0), f46(0), f47(0), f48(0), f49(0),
+		f50(0), f51(0), f52(0), f53(0), f54(0), f55(0), f56(0), f57(0), f58(0), f59(0),
+		f60(0), f61(0), f62(0), f63(0) {
+	}
+
+	unsigned int  f00 : 1;
+	unsigned int  f01 : 1;
+	unsigned int  f02 : 1;
+	unsigned int  f03 : 1;
+	unsigned int  f04 : 1;
+	unsigned int  f05 : 1;
+	unsigned int  f06 : 1;
+	unsigned int  f07 : 1;
+
+	unsigned int  f08 : 1;
+	unsigned int  f09 : 1;
+	unsigned int  f10 : 1;
+	unsigned int  f11 : 1;
+	unsigned int  f12 : 1;
+	unsigned int  f13 : 1;
+	unsigned int  f14 : 1;
+	unsigned int  f15 : 1;
+
+	unsigned int  f16 : 1;
+	unsigned int  f17 : 1;
+	unsigned int  f18 : 1;
+	unsigned int  f19 : 1;
+	unsigned int  f20 : 1;
+	unsigned int  f21 : 1;
+	unsigned int  f22 : 1;
+	unsigned int  f23 : 1;
+
+	unsigned int  f24 : 1;
+	unsigned int  f25 : 1;
+	unsigned int  f26 : 1;
+	unsigned int  f27 : 1;
+	unsigned int  f28 : 1;
+	unsigned int  f29 : 1;
+	unsigned int  f30 : 1;
+	unsigned int  f31 : 1;
+
+	unsigned int  f32 : 1;
+	unsigned int  f33 : 1;
+	unsigned int  f34 : 1;
+	unsigned int  f35 : 1;
+	unsigned int  f36 : 1;
+	unsigned int  f37 : 1;
+	unsigned int  f38 : 1;
+	unsigned int  f39 : 1;
+
+	unsigned int  f40 : 1;
+	unsigned int  f41 : 1;
+	unsigned int  f42 : 1;
+	unsigned int  f43 : 1;
+	unsigned int  f44 : 1;
+	unsigned int  f45 : 1;
+	unsigned int  f46 : 1;
+	unsigned int  f47 : 1;
+
+	unsigned int  f48 : 1;
+	unsigned int  f49 : 1;
+	unsigned int  f50 : 1;
+	unsigned int  f51 : 1;
+	unsigned int  f52 : 1;
+	unsigned int  f53 : 1;
+	unsigned int  f54 : 1;
+	unsigned int  f55 : 1;
+
+	unsigned int  f56 : 1;
+	unsigned int  f57 : 1;
+	unsigned int  f58 : 1;
+	unsigned int  f59 : 1;
+	unsigned int  f60 : 1;
+	unsigned int  f61 : 1;
+	unsigned int  f62 : 1;
+	unsigned int  f63 : 1;
+
+	byte value[16] = {};
+	byte junk = 0;
+	byte game = 0;
+	byte area = 0;          //1,2,3
+	byte pc_sound = 0;      //1=enabled
+	byte dig_sound = 0;     //1 & !pc_sound = enabled
+	byte music = 0;         //1=enabled
+	byte speed = 0;         //1=slow mode (for slower 286's)
+	byte scroll_flag = 0;   //unused
+	byte boss_dead[3] = {};
+	byte skill = 0;         //0=easy, 1=normal, 2=hard
+	byte game_over = 0;
+	byte future[19] = {};   //probably not needed
+
+	void sync(Common::Serializer &s);
+};
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/data/thor_info.cpp b/engines/got/data/thor_info.cpp
new file mode 100644
index 00000000000..1408988a95b
--- /dev/null
+++ b/engines/got/data/thor_info.cpp
@@ -0,0 +1,57 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * as.syncAsUint32LE(with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/data/thor_info.h"
+
+namespace Got {
+
+void THOR_INFO::sync(Common::Serializer &s) {
+	uint32 ptr = 0;
+
+	s.syncAsByte(magic);
+	s.syncAsByte(keys);
+	s.syncAsSint16LE(jewels);
+	s.syncAsByte(last_area);
+	s.syncAsByte(last_screen);
+	s.syncAsByte(last_icon);
+	s.syncAsByte(last_dir);
+	s.syncAsSint16LE(inventory);
+	s.syncAsByte(item);
+	s.syncAsByte(last_health);
+	s.syncAsByte(last_magic);
+	s.syncAsSint16LE(last_jewels);
+	s.syncAsByte(last_keys);
+	s.syncAsByte(last_item);
+	s.syncAsSint16LE(last_inventory);
+	s.syncAsByte(level);
+	s.syncAsUint32LE(score);
+	s.syncAsUint32LE(last_score);
+
+	s.syncAsByte(object);
+	s.syncAsUint32LE(ptr);
+	s.syncAsByte(last_object);
+	s.syncAsUint32LE(ptr);
+
+	s.syncAsByte(armor);
+	s.syncBytes(future, 65);
+}
+
+} // namespace Got
diff --git a/engines/got/data/thor_info.h b/engines/got/data/thor_info.h
new file mode 100644
index 00000000000..8d4bec373e1
--- /dev/null
+++ b/engines/got/data/thor_info.h
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_DATA_THOR_INFO_H
+#define GOT_DATA_THOR_INFO_H
+
+#include "common/serializer.h"
+
+namespace Got {
+
+struct THOR_INFO {
+	byte magic = 0;
+	byte keys = 0;
+	int  jewels = 0;
+	byte last_area = 0;
+	byte last_screen = 0;
+	byte last_icon = 0;
+	byte last_dir = 0;
+	int  inventory = 0;
+	byte item = 0;         //currently selected item
+	byte last_health = 0;
+	byte last_magic = 0;
+	int  last_jewels = 0;
+	byte last_keys = 0;
+	byte last_item = 0;
+	int  last_inventory = 0;
+	byte level = 0;         //current level (1,2,3)
+	long score = 0;
+	long last_score = 0;
+	byte object = 0;
+	const char *object_name = nullptr;
+	byte last_object = 0;
+	const char *last_object_name = nullptr;
+	byte armor = 0;
+	byte future[65] = {};
+
+	void sync(Common::Serializer &s);
+};
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 0147fa43e2a..6c6a7e51d56 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -73,12 +73,16 @@ Common::Error GotEngine::run() {
 }
 
 Common::Error GotEngine::syncGame(Common::Serializer &s) {
-	// The Serializer has methods isLoading() and isSaving()
-	// if you need to specific steps; for example setting
-	// an array size after reading it's length, whereas
-	// for saving it would write the existing array's length
-	int dummy = 0;
-	s.syncAsUint32LE(dummy);
+	byte version = 1;
+	s.syncAsByte(version);
+
+	_G(setup).sync(s);
+	_G(thor_info).sync(s);
+	_G(sd_data).sync(s);
+
+	if (s.isLoading()) {
+		// TODO
+	}
 
 	return Common::kNoError;
 }
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 4a2b086af8a..b41cb408f6b 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -8,8 +8,10 @@ MODULE_OBJS = \
 	metaengine.o \
 	sound.o \
 	vars.o \
-	data/defines.o \
+	data/level.o \
 	data/sd_data.o \
+	data/setup.o \
+	data/thor_info.o \
 	game/boss1.o \
 	game/back.o \
 	game/init.o \


Commit: 54f629fc68dbadd43597d3ccc6d486918a9168e7
    https://github.com/scummvm/scummvm/commit/54f629fc68dbadd43597d3ccc6d486918a9168e7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Adding console load command

Changed paths:
    engines/got/console.cpp
    engines/got/console.h
    engines/got/got.cpp
    engines/got/got.h


diff --git a/engines/got/console.cpp b/engines/got/console.cpp
index f7e077b8d9d..0c9dc371e53 100644
--- a/engines/got/console.cpp
+++ b/engines/got/console.cpp
@@ -19,9 +19,11 @@
  *
  */
 
+#include "common/file.h"
 #include "got/console.h"
 #include "got/events.h"
 #include "got/vars.h"
+#include "got/got.h"
 
 namespace Got {
 
@@ -29,6 +31,7 @@ Console::Console() : GUI::Debugger() {
 	registerCmd("view",   WRAP_METHOD(Console, cmdView));
 	registerCmd("sound", WRAP_METHOD(Console, cmdSound));
 	registerCmd("music", WRAP_METHOD(Console, cmdMusic));
+	registerCmd("load", WRAP_METHOD(Console, cmdLoad));
 }
 
 Console::~Console() {
@@ -56,4 +59,22 @@ bool Console::cmdMusic(int argc, const char **argv) {
 	return false;
 }
 
+bool Console::cmdLoad(int argc, const char **argv) {
+	if (argc == 2) {
+		Common::File f;
+		if (!f.open(argv[1])) {
+			debugPrintf("Could not open savegame\n");
+			return true;
+		} else {
+			f.skip(32); // Skip the 32 bytes title
+
+			g_engine->loadGameStream(&f);
+			return false;
+		}
+	}
+
+	debugPrintf("load <original savegame name>\n");
+	return true;
+}
+
 } // namespace Got
diff --git a/engines/got/console.h b/engines/got/console.h
index 0cb9eb8bc24..ff3de1e8b9f 100644
--- a/engines/got/console.h
+++ b/engines/got/console.h
@@ -32,6 +32,7 @@ private:
 	bool cmdView(int argc, const char **argv);
 	bool cmdSound(int argc, const char **argv);
 	bool cmdMusic(int argc, const char **argv);
+	bool cmdLoad(int argc, const char **argv);
 
 public:
 	Console();
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 6c6a7e51d56..e801afa7cdb 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -33,6 +33,8 @@
 
 namespace Got {
 
+#define SAVEGAME_VERSION 1
+
 GotEngine *g_engine;
 
 GotEngine::GotEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst),
@@ -72,15 +74,33 @@ Common::Error GotEngine::run() {
 	return Common::kNoError;
 }
 
-Common::Error GotEngine::syncGame(Common::Serializer &s) {
-	byte version = 1;
-	s.syncAsByte(version);
+Common::Error GotEngine::saveGameStream(Common::WriteStream *stream, bool isAutosave) {
+	stream->writeByte(SAVEGAME_VERSION);
+	Common::Serializer s(nullptr, stream);
+	s.setVersion(SAVEGAME_VERSION);
+
+	return syncGame(s);
+}
+
+Common::Error GotEngine::loadGameStream(Common::SeekableReadStream *stream) {
+	byte version = stream->readByte();
+	if (version != SAVEGAME_VERSION)
+		error("Invalid savegame version");
+
+	Common::Serializer s(stream, nullptr);
+	s.setVersion(version);
 
+	return syncGame(s);
+}
+
+
+Common::Error GotEngine::syncGame(Common::Serializer &s) {
 	_G(setup).sync(s);
 	_G(thor_info).sync(s);
 	_G(sd_data).sync(s);
 
 	if (s.isLoading()) {
+
 		// TODO
 	}
 
diff --git a/engines/got/got.h b/engines/got/got.h
index 6d8ffd5e831..adf0bf885f4 100644
--- a/engines/got/got.h
+++ b/engines/got/got.h
@@ -99,14 +99,8 @@ public:
 	 */
 	Common::Error syncGame(Common::Serializer &s);
 
-	Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override {
-		Common::Serializer s(nullptr, stream);
-		return syncGame(s);
-	}
-	Common::Error loadGameStream(Common::SeekableReadStream *stream) override {
-		Common::Serializer s(stream, nullptr);
-		return syncGame(s);
-	}
+	Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
+	Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
 };
 
 extern GotEngine *g_engine;


Commit: 8c99d99f0e282dce5d39e8e7869d3f082411c46e
    https://github.com/scummvm/scummvm/commit/8c99d99f0e282dce5d39e8e7869d3f082411c46e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Further savegame loading code

Changed paths:
    engines/got/got.cpp
    engines/got/vars.cpp
    engines/got/vars.h


diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index e801afa7cdb..ce1dc4ea372 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -29,6 +29,7 @@
 #include "got/got.h"
 #include "got/detection.h"
 #include "got/console.h"
+#include "got/gfx/image.h"
 #include "got/utils/res_archive.h"
 
 namespace Got {
@@ -100,8 +101,50 @@ Common::Error GotEngine::syncGame(Common::Serializer &s) {
 	_G(sd_data).sync(s);
 
 	if (s.isLoading()) {
-
-		// TODO
+		int area = _G(setup).area;
+		if (area == 0)
+			area = 1;
+
+		g_vars->setArea(area);
+
+		_G(current_area) = _G(thor_info).last_screen;
+
+		_G(thor)->x = (_G(thor_info).last_icon % 20) * 16;
+		_G(thor)->y = ((_G(thor_info).last_icon / 20) * 16) - 1;
+		if (_G(thor)->x < 1) _G(thor)->x = 1;
+		if (_G(thor)->y < 0) _G(thor)->y = 0;
+		_G(thor)->dir = _G(thor_info).last_dir;
+		_G(thor)->last_dir = _G(thor_info).last_dir;
+		_G(thor)->health = _G(thor_info).last_health;
+		_G(thor)->num_moves = 1;
+		_G(thor)->vunerable = 60;
+		_G(thor)->show = 60;
+		_G(thor)->speed_count = 6;
+		load_new_thor();
+
+		if (!_G(music_flag))
+			_G(setup).music = 0;
+		if (!_G(sound_flag))
+			_G(setup).dig_sound = 0;
+		if (_G(setup).music == 1) {
+			if (GAME1 == 1 && _G(current_area) == 59) {
+//				if (flag)
+					music_play(5, 1);
+			} else {
+				//if (flag)
+				music_play(_G(level_type), 1);
+			}
+		} else {
+			_G(setup).music = 1;
+			music_pause();
+			_G(setup).music = 0;
+		}
+
+		_G(game_over) = _G(setup).game_over;
+		_G(slow_mode) = _G(setup).speed;
+
+		// Switch to game view
+		g_events->replaceView("Game", true);
 	}
 
 	return Common::kNoError;
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 5d1e99be79b..a6a3a51a592 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -100,4 +100,12 @@ Vars::~Vars() {
 	delete[] _mask_buff;
 }
 
+void Vars::setArea(int areaNum) {
+	if (areaNum != _area) {
+		_area = areaNum;
+		_sd_data.setArea(areaNum);
+		_bgPics.setArea(areaNum);
+	}
+}
+
 } // namespace Got
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 0076d299c2d..5882fe6ef48 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -54,6 +54,7 @@ public:
 	~Vars();
 
 	void load();
+	void setArea(int areaNum);
 
 	Gfx::GfxChunks _gfx;
 	Gfx::BgPics _bgPics;


Commit: d6fd50bb7bebd430ff602df3aa74179224eacef9
    https://github.com/scummvm/scummvm/commit/d6fd50bb7bebd430ff602df3aa74179224eacef9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Set correct starting level for each area

Changed paths:
    engines/got/vars.cpp
    engines/got/vars.h


diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index a6a3a51a592..21c27417635 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -105,6 +105,23 @@ void Vars::setArea(int areaNum) {
 		_area = areaNum;
 		_sd_data.setArea(areaNum);
 		_bgPics.setArea(areaNum);
+
+		switch (areaNum) {
+		case 1:
+			_current_level = 23;
+			break;
+
+		case 2:
+			_current_level = 51;
+			break;
+
+		case 3:
+			_current_level = 33;
+			break;
+
+		default:
+			break;
+		}
 	}
 }
 
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 5882fe6ef48..b494237aed1 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -182,7 +182,8 @@ public:
 	int8 _main_loop = 0;
 	int8 _end_tile = 0;
 	byte _pbuff[PALETTE_SIZE] = {};
-	int _current_level, _new_level;
+	int _current_level = 23;
+	int _new_level = 0;
 	int _new_level_tile = 0, _current_area = 0;
 	uint _latch_mem = 0;
 	byte *_enemy_mb = nullptr;


Commit: 60daa62acc2ea8a18c5775fa69bf13ec8b2f1b3f
    https://github.com/scummvm/scummvm/commit/60daa62acc2ea8a18c5775fa69bf13ec8b2f1b3f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added Select Game view

Changed paths:
  A engines/got/views/dialogs/select_game.cpp
  A engines/got/views/dialogs/select_game.h
    engines/got/module.mk
    engines/got/views/views.h


diff --git a/engines/got/module.mk b/engines/got/module.mk
index b41cb408f6b..ede0889f10b 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -48,6 +48,7 @@ MODULE_OBJS = \
 	views/dialogs/play_game.o \
 	views/dialogs/quit.o \
 	views/dialogs/quit_game.o \
+	views/dialogs/select_game.o \
 	views/dialogs/set_sound.o
 
 # This module can be built as a plugin
diff --git a/engines/got/views/dialogs/select_game.cpp b/engines/got/views/dialogs/select_game.cpp
new file mode 100644
index 00000000000..b09e85df41d
--- /dev/null
+++ b/engines/got/views/dialogs/select_game.cpp
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/select_game.h"
+#include "got/got.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+static const char *OPTIONS[] = {
+	"Part 1: Serpent Surprise!",
+	"Part 2: Non-stick Nognir",
+	"Part 3: Lookin' for Loki",
+	nullptr
+};
+
+SelectGame::SelectGame() : SelectOption("SelectGame", "Play WHich Game?", OPTIONS) {
+}
+
+void SelectGame::selected() {
+	// Select the game area to start from
+	g_vars->setArea(_selectedItem + 1);
+
+	// Switch to the game view
+	replaceView("Game", true);
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/select_game.h b/engines/got/views/dialogs/select_game.h
new file mode 100644
index 00000000000..2897b45cb99
--- /dev/null
+++ b/engines/got/views/dialogs/select_game.h
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_SELECT_GAME_H
+#define GOT_VIEWS_DIALOGS_SELECT_GAME_H
+
+#include "got/views/dialogs/select_option.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class SelectGame : public SelectOption {
+public:
+	SelectGame();
+	virtual ~SelectGame() {
+	}
+
+	void selected() override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index 22a7301b05d..0629d4add09 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -30,6 +30,7 @@
 #include "got/views/dialogs/options_menu.h"
 #include "got/views/dialogs/quit.h"
 #include "got/views/dialogs/quit_game.h"
+#include "got/views/dialogs/select_game.h"
 #include "got/views/dialogs/set_sound.h"
 
 namespace Got {
@@ -45,6 +46,7 @@ struct Views {
 	Dialogs::OptionsMenu _optionsMenu;
 	Dialogs::Quit _quit;
 	Dialogs::QuitGame _quitGame;
+	Dialogs::SelectGame _selectGame;
 	Dialogs::SetSound _setSound;
 };
 


Commit: ce1ae1ac1c2144932e13729cfbd306c309a53746
    https://github.com/scummvm/scummvm/commit/ce1ae1ac1c2144932e13729cfbd306c309a53746
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Adding once-per-frame checks

Changed paths:
    engines/got/events.cpp
    engines/got/events.h
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index c97b603dd6f..ea64a37bfb7 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -68,15 +68,27 @@ void Events::runGame() {
 		g_system->delayMillis(10);
 		if ((currTime = g_system->getMillis()) >= nextFrameTime) {
 			nextFrameTime = currTime + FRAME_DELAY;
-			tick();
-			drawElements();
-			_screen->update();
+			nextFrame();
 		}
 	}
 
 	delete _screen;
 }
 
+void Events::nextFrame() {
+	// Update state variables
+	_G(rand1) = getRandomNumber(99);
+	_G(rand2) = getRandomNumber(99);
+	_G(pge) = _G(pge) ^ 1;
+
+	// Do once-per-frame tick action to the views
+	tick();
+
+	// Draw the current view's elements as needed, and update screen
+	drawElements();
+	_screen->update();
+}
+
 void Events::processEvent(Common::Event &ev) {
 	switch (ev.type) {
 	case Common::EVENT_KEYDOWN:
diff --git a/engines/got/events.h b/engines/got/events.h
index ca0f459f2c8..1da12c27f5a 100644
--- a/engines/got/events.h
+++ b/engines/got/events.h
@@ -258,6 +258,9 @@ class Events : public UIElement {
 private:
 	Graphics::Screen *_screen = nullptr;
 	Common::Stack<UIElement *> _views;
+
+	void nextFrame();
+
 protected:
 	/**
 	 * Process an event
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 1caf8248ba2..48b97595f03 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -22,6 +22,7 @@
 #include "got/views/game_content.h"
 #include "got/game/back.h"
 #include "got/game/move.h"
+#include "got/game/object.h"
 #include "got/gfx/image.h"
 #include "got/vars.h"
 
@@ -59,6 +60,9 @@ bool GameContent::msgGame(const GameMessage &msg) {
 
 bool GameContent::tick() {
 	checkThunderShake();
+	checkSwitchFlag();
+	checkForItem();
+
 	return true;
 }
 
@@ -147,5 +151,28 @@ void GameContent::checkThunderShake() {
 	}
 }
 
+void GameContent::checkSwitchFlag() {
+	if (_G(switch_flag)) {
+		switch (_G(switch_flag)) {
+		case 1:
+			switch_icons();
+			break;
+		case 2:
+			rotate_arrows();
+			break;
+		default:
+			break;
+		}
+
+		_G(switch_flag) = 0;
+	}
+}
+
+void GameContent::checkForItem() {
+	int thor_pos = ((_G(thor)->x + 7) / 16) + (((_G(thor)->y + 8) / 16) * 20);
+	if (_G(object_map)[thor_pos])
+		pick_up_object(thor_pos);
+}
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index 978494f9803..aedc589b0dd 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -36,6 +36,8 @@ private:
 	void drawObjects(GfxSurface &s);
 	void drawEnemies(GfxSurface &s, ACTOR *lastActor);
 	void checkThunderShake();
+	void checkSwitchFlag();
+	void checkForItem();
 
 public:
 	GameContent() : View("GameContent") {}


Commit: 59ca89d57a53f14de93cd3b13c59637477d001ca
    https://github.com/scummvm/scummvm/commit/59ca89d57a53f14de93cd3b13c59637477d001ca
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Console command for setting magic

Changed paths:
    engines/got/console.cpp
    engines/got/console.h
    engines/got/events.cpp
    engines/got/views/game.cpp
    engines/got/views/game_content.cpp


diff --git a/engines/got/console.cpp b/engines/got/console.cpp
index 0c9dc371e53..a05dd74f076 100644
--- a/engines/got/console.cpp
+++ b/engines/got/console.cpp
@@ -32,6 +32,7 @@ Console::Console() : GUI::Debugger() {
 	registerCmd("sound", WRAP_METHOD(Console, cmdSound));
 	registerCmd("music", WRAP_METHOD(Console, cmdMusic));
 	registerCmd("load", WRAP_METHOD(Console, cmdLoad));
+	registerCmd("magic", WRAP_METHOD(Console, cmdMagic));
 }
 
 Console::~Console() {
@@ -77,4 +78,10 @@ bool Console::cmdLoad(int argc, const char **argv) {
 	return true;
 }
 
+bool Console::cmdMagic(int argc, const char **argv) {
+	_G(thor_info).magic = (argc == 2) ? CLIP(atoi(argv[1]), 0, 150): 150;
+	
+	return false;
+}
+
 } // namespace Got
diff --git a/engines/got/console.h b/engines/got/console.h
index ff3de1e8b9f..72955a927de 100644
--- a/engines/got/console.h
+++ b/engines/got/console.h
@@ -33,6 +33,7 @@ private:
 	bool cmdSound(int argc, const char **argv);
 	bool cmdMusic(int argc, const char **argv);
 	bool cmdLoad(int argc, const char **argv);
+	bool cmdMagic(int argc, const char **argv);
 
 public:
 	Console();
diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index ea64a37bfb7..7e5d54cd19c 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -80,6 +80,7 @@ void Events::nextFrame() {
 	_G(rand1) = getRandomNumber(99);
 	_G(rand2) = getRandomNumber(99);
 	_G(pge) = _G(pge) ^ 1;
+	_G(shot_ok) = true;
 
 	// Do once-per-frame tick action to the views
 	tick();
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index d79d679b058..40756d7d858 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -57,7 +57,13 @@ bool Game::msgAction(const ActionMessage &msg) {
 }
 
 bool Game::tick() {
-	return true;
+	// There are many things in original game code that can trigger
+	// changes on screen, and for simplicity they each no longer have
+	// the code that partially updates the screen. Due to this,
+	// we set to redraw the screen every frame in case of updates
+	redraw();
+
+	return false;
 }
 
 } // namespace Views
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 48b97595f03..a1ab0802ccd 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -63,7 +63,7 @@ bool GameContent::tick() {
 	checkSwitchFlag();
 	checkForItem();
 
-	return true;
+	return false;
 }
 
 void GameContent::drawBackground(GfxSurface &s) {


Commit: e2b7cbd03529a2e8f25deb3bfd66085d2634f73d
    https://github.com/scummvm/scummvm/commit/e2b7cbd03529a2e8f25deb3bfd66085d2634f73d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Adding in script parser

Changed paths:
    engines/got/game/back.cpp
    engines/got/game/back.h
    engines/got/game/main.cpp
    engines/got/game/main.h
    engines/got/game/move_patterns.cpp
    engines/got/game/script.cpp
    engines/got/game/script.h
    engines/got/vars.h
    engines/got/views/game.cpp
    engines/got/views/game.h
    engines/got/views/game_content.cpp


diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index b6ebb7af11b..3c5c0a81fc4 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -152,15 +152,13 @@ void show_level(int new_level) {
 #endif
 }
 
-int odin_speaks(int index, int item) {
-	execute_script((long)index, &_G(odin)[0]);
+void odin_speaks(int index, int item) {
+	execute_script((long)index, &_G(odin));
+
 	if (!_G(thor)->health) {
 		_G(thor)->show = 0;
 		_G(exit_flag) = 2;
 	}
-
-	item = item;
-	return 1;
 }
 
 
@@ -297,7 +295,7 @@ int actor_speaks(ACTOR *actr, int index, int item) {
 	Common::String str;
 	int v;
 	long lind;
-	Graphics::ManagedSurface *pic;
+	Gfx::Pics *pic;
 
 	if (actr->type != 4)
 		return 0;
@@ -310,9 +308,9 @@ int actor_speaks(ACTOR *actr, int index, int item) {
 	Gfx::Pics pics(str, -1, false);
 	if (Common::File::exists(Common::Path(str))) {
 		pics.load();
-		pic = &pics[0];
+		pic = &pics;
 	} else {
-		pic = &_G(odin)[0];
+		pic = &_G(odin);
 	}
 
 	lind = (long)_G(current_level);
diff --git a/engines/got/game/back.h b/engines/got/game/back.h
index 6223ad0a543..d937b6bb8af 100644
--- a/engines/got/game/back.h
+++ b/engines/got/game/back.h
@@ -37,7 +37,7 @@ extern const char *item_name[];
  * GameContent view takes care of the scene rendering.
 */
 extern void show_level(int new_level);
-extern int odin_speaks(int index, int item);
+extern void odin_speaks(int index, int item);
 extern int switch_icons();
 extern int rotate_arrows();
 extern void kill_enemies(int iy, int ix);
diff --git a/engines/got/game/main.cpp b/engines/got/game/main.cpp
index 5b4de8a7bd8..af0faf7d0e8 100644
--- a/engines/got/game/main.cpp
+++ b/engines/got/game/main.cpp
@@ -26,7 +26,6 @@
 namespace Got {
 
 void setup_load() {
-
 	_G(thor)->used = 1;
 	_G(new_level) = _G(thor_info).last_screen;
 	_G(thor)->x = (_G(thor_info).last_icon % 20) * 16;
@@ -69,4 +68,8 @@ void setup_load() {
 	show_level(_G(new_level));
 }
 
+void pause(int delay) {
+	g_system->delayMillis(delay);
+}
+
 } // namespace Got
diff --git a/engines/got/game/main.h b/engines/got/game/main.h
index 4891d57a374..e49017143f5 100644
--- a/engines/got/game/main.h
+++ b/engines/got/game/main.h
@@ -27,6 +27,7 @@
 namespace Got {
 
 extern void setup_load();
+extern void pause(int delay);
 
 } // namespace Got
 
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index cdfc671d938..7c6bf1b9afd 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -856,7 +856,7 @@ int special_movement_three(ACTOR *actr) {  //yellow globe
 	lind = (long)_G(current_level);
 	lind = lind * 1000;
 	lind += (long)actr->actor_num;
-	execute_script(lind, &_G(odin)[0]);
+	execute_script(lind, &_G(odin));
 
 	return 0;
 }
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index d6fd40305f5..addf18d9938 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -21,11 +21,1146 @@
 
 #include "common/textconsole.h"
 #include "got/game/script.h"
+#include "got/game/back.h"
+#include "got/game/main.h"
+#include "got/game/object.h"
+#include "got/game/status.h"
+#include "got/gfx/image.h"
+#include "got/utils/file.h"
+#include "got/events.h"
+#include "got/vars.h"
 
 namespace Got {
 
-void execute_script(long index, Graphics::ManagedSurface *pic) {
-	error("TODO: execute_script");
+#define ERROR_MAX 10
+#define SCR_BUFF_SIZE 5000
+
+static const char *scr_command[] = {
+	"!@#$%","END","GOTO","GOSUB","RETURN","FOR","NEXT",
+	"IF","ELSE","RUN",
+	"ADDJEWELS","ADDHEALTH","ADDMAGIC","ADDKEYS",
+	"ADDSCORE","SAY","ASK","SOUND","PLACETILE",
+	"ITEMGIVE","ITEMTAKE","ITEMSAY","SETFLAG","LTOA",
+	"PAUSE","TEXT","EXEC","VISIBLE","RANDOM",
+	NULL
+};
+
+static const char *internal_variable[] = {
+	"@JEWELS","@HEALTH","@MAGIC","@SCORE",
+	"@SCREEN","@KEYS",
+	"@OW","@GULP","@SWISH","@YAH","@ELECTRIC",
+	"@THUNDER","@DOOR","@FALL","@ANGEL","@WOOP",
+	"@DEAD","@BRAAPP","@WIND","@PUNCH","@CLANG",
+	"@EXPLODE","@FLAG","@ITEM","@THORTILE",
+	"@THORPOS",
+	NULL
+};
+
+static const char *scr_error[] = {
+	"!@#$%","Out of Memory","Can't Read Script",
+	"Too Many Labels","No END",
+	"Syntax","Out of Range","Undefined Label",
+	"RETURN Without GOSUB","Nesting",
+	"NEXT Without FOR",
+	NULL
+};
+
+static const char *offense[] = {
+	"Cussing","Rebellion","Kissing Your Mother Goodbye",
+	"Being a Thunder God","Door-to-Door Sales",
+	"Carrying a Concealed Hammer"
+};
+
+static const char *reason[] = {
+	"We heard you say 'Booger'.",
+	"You look kind of rebellious.",
+	"Your mother turned you in.",
+	"We don't want you here.",
+	"Nobody wants your sweepers.",
+	"That's a dangerous weapon."
+};
+
+Scripts::ScrFunction Scripts::scr_func[5] = {
+	&Scripts::scr_func1,
+	&Scripts::scr_func2,
+	&Scripts::scr_func3,
+	&Scripts::scr_func4,
+	&Scripts::scr_func5,
+};
+
+Scripts *g_scripts;
+
+void execute_script(long index, Gfx::Pics *pic) {
+	g_scripts->execute_script(index, pic);
+}
+
+Scripts::Scripts() {
+	g_scripts = this;
+}
+
+Scripts::~Scripts() {
+	g_scripts = nullptr;
+}
+
+void Scripts::execute_script(long index, Gfx::Pics *pic) {
+	int i, ret, re_execute;
+
+	// Firstly hide any on-screen actors
+	g_events->send(GameMessage("HIDE_ACTORS"));
+
+	scr_index = index;
+	scr_pic = pic;
+
+	Common::fill(num_var, num_var + 26, 0);
+	Common::fill((char *)str_var, (char *)str_var + 81 * 26, 0);
+
+	re_execute = 0;
+run_script:                            // Jump point for RUN command
+
+	// Clear line label buffer, line ptrs, and the gosub stack
+	Common::fill((char *)line_label, (char *)line_label + 32 * 9, 0);
+	Common::fill(line_ptr, line_ptr + 32, (char *)nullptr);
+	Common::fill(gosub_stack, gosub_stack + 32, (char *)nullptr);
+	gosub_ptr = 0;
+
+	for (i = 0; i < 11; i++) {
+		for_var[i] = 0;
+		for_val[i] = 0;
+		for_stack[i] = 0;
+	}
+	for_ptr = 0;
+
+	i = read_script_file();
+	if (i != 0) {
+		script_error(i);
+		script_exit();
+		return;
+	}
+	if (!re_execute)
+		script_entry();
+
+	buff_ptr = buffer;
+
+	for (;;) {
+		if (_G(cheat) && _G(key_flag)[_B]) break;
+		ret = get_command();
+		if (ret == -1)
+			break;       // ignore NO END error
+		else if (ret == -2) {
+			script_error(5);       // syntax error
+			break;
+		} else if (ret > 0) {
+			ret = exec_command(ret);
+			if (ret == -100) {         //RUN command
+				re_execute = 1;
+				if (buffer) free(buffer);
+				goto run_script;
+			}
+			if (!ret) break;
+		}
+	}
+
+	script_exit();
+}
+
+void Scripts::script_exit() {
+	if (buffer)
+		free(buffer);
+}
+
+int Scripts::skip_colon() {
+	while (*buff_ptr == 0 || *buff_ptr == ':') {
+		buff_ptr++;
+		if (buff_ptr > buff_end) return 0;
+	}
+
+	return 1;
+}
+
+int Scripts::get_command() {
+	int ret, i, len;
+
+	if (!skip_colon()) return -1;
+
+	i = 0;
+	while (1) {
+		if (!scr_command[i])
+			break;           // Lookup command
+
+		len = strlen(scr_command[i]);
+		if (!strncmp(buff_ptr, (char *)scr_command[i], len)) {
+			buff_ptr += len;
+			return i;
+		}
+
+		i++;
+	}
+
+	if (Common::isAlpha(*buff_ptr)) {
+		if (*(buff_ptr + 1) == '=') {           // Num var assignment
+			i = (*buff_ptr) - 65;
+			buff_ptr += 2;
+			ret = calc_value();
+			if (!ret) return -2;
+			else {
+				num_var[i] = lvalue; return 0;
+			}
+		} else if (*(buff_ptr + 1) == '$' && *(buff_ptr + 2) == '=') {
+			i = (*buff_ptr) - 65;
+			buff_ptr += 3;
+			ret = calc_string(0);                 // String var assignment
+			if (ret == 0) return -2;
+			else if (ret == -1) return -3;
+			if (strlen(temps) > 80) return -3;
+			Common::strcpy_s(str_var[i], temps);
+			return 0;
+		}
+	}
+
+	return -2;
+}
+
+int Scripts::calc_string(int mode) {
+	// if mode==1 stop at comma
+	char varstr[255];
+	char varnum;
+
+	Common::strcpy_s(varstr, "");
+
+	if (!skip_colon()) return 0;
+
+strloop:
+	if (*buff_ptr == '"') {
+		get_str();
+		if (strlen(varstr) + strlen(temps) < 255)
+			Common::strcat_s(varstr, temps);
+		goto nextstr;
+	}
+	if (Common::isAlpha(*buff_ptr)) {
+		if (*(buff_ptr + 1) == '$') {
+			varnum = (*buff_ptr) - 65;
+			if (strlen(varstr) + strlen(str_var[varnum]) < 255)
+				Common::strcat_s(varstr, str_var[varnum]);
+			buff_ptr += 2;
+			goto nextstr;
+		}
+	}
+	return 0;
+
+nextstr:
+	if (*buff_ptr == 0 || *buff_ptr == 58) {
+		buff_ptr++;
+		goto strdone;
+	}
+	if (*buff_ptr == ',' && mode == 1) goto strdone;
+
+	if (*buff_ptr == '+') {
+		buff_ptr++;
+		goto strloop;
+	}
+	return 0;
+
+strdone:
+	if (strlen(varstr) > 255) return -1;
+	Common::strcpy_s(temps, (char *) varstr);
+	return 1;
+}
+
+void Scripts::get_str() {
+	int t;
+
+	buff_ptr++;
+	t = 0;
+
+	while (1) {
+		if (*buff_ptr == '"' || *buff_ptr == 0) {
+			temps[t] = 0;
+			if (*buff_ptr == '"') buff_ptr++;
+			return;
+		}
+
+		temps[t++] = *buff_ptr;
+		buff_ptr++;
+	}
+}
+
+int Scripts::calc_value() {
+	long tmpval2;
+	char exptype;
+	char ch;
+
+	tmpval2 = 0;
+	exptype = 1;
+
+	while (1) {
+		if (!get_next_val()) return 0;
+		switch (exptype) {
+		case 0:
+			tmpval2 = tmpval2 * ltemp;
+			break;
+		case 1:
+			tmpval2 = tmpval2 + ltemp;
+			break;
+		case 2:
+			tmpval2 = tmpval2 - ltemp;
+			break;
+		case 3:
+			if (ltemp != 0) tmpval2 = tmpval2 / ltemp;
+			break;
+		}
+
+		ch = *buff_ptr;
+		switch (ch) {
+		case 42:
+			exptype = 0;                       /* multiply */
+			break;
+		case 43:
+			exptype = 1;                       /* add */
+			break;
+		case 45:
+			exptype = 2;                       /* minus */
+			break;
+		case 47:
+			exptype = 3;                       /* divide */
+			break;
+		default:
+			lvalue = tmpval2;
+			return 1;
+		}
+
+		buff_ptr++;
+	}
+}
+
+int Scripts::get_next_val() {
+	char ch;
+	char tmpstr[25];
+	int t;
+
+	ch = *buff_ptr;
+	if (ch == 0 || ch == ':') return 0;
+	if (ch == 64) return get_internal_variable();
+
+	if (Common::isAlpha(ch)) {
+		buff_ptr++;
+		ltemp = num_var[ch - 65];
+		return 1;
+	}
+
+	t = 0;
+	if (strchr("0123456789-", ch)) {
+		tmpstr[0] = ch;
+		t++;
+		buff_ptr++;
+		while (strchr("0123456789", *buff_ptr) && *buff_ptr != 0) {
+			tmpstr[t] = *buff_ptr;
+			buff_ptr++;
+			t++;
+		}
+		tmpstr[t] = 0;
+		if (t > 10) return 0;
+		ltemp = atol(tmpstr);
+		return 1;
+	}
+
+	return 0;
+}
+
+int Scripts::get_internal_variable() {
+	int i, len;
+	char b;
+	byte *sp;
+
+	i = 0;
+	while (1) {
+		if (!internal_variable[i]) return 0;         // Lookup internal variable
+		len = strlen(internal_variable[i]);
+		if (!strncmp(buff_ptr, internal_variable[i], len)) {
+			buff_ptr += len;
+			break;
+		}
+		i++;
+	}
+	switch (i) {
+	case 0:
+		ltemp = _G(thor_info).jewels;
+		break;
+	case 1:
+		ltemp = _G(thor)->health;
+		break;
+	case 2:
+		ltemp = _G(thor_info).magic;
+		break;
+	case 3:
+		ltemp = _G(thor_info).score;
+		break;
+	case 4:
+		ltemp = _G(current_level);
+		break;
+	case 5:
+		ltemp = _G(thor_info).keys;
+		break;
+	case 6:
+	case 7:
+	case 8:
+	case 9:
+	case 10:
+	case 11:
+	case 12:
+	case 13:
+	case 14:
+	case 15:
+	case 16:
+	case 17:
+	case 18:
+	case 19:
+	case 20:
+	case 21:
+		ltemp = (long)(i - 5l);
+		break;
+	case 22:
+		if (!calc_value())
+			return 0;
+		i = (int)lvalue;
+		if (i < 1 || i>64)
+			return 0;
+
+		sp = (byte *)&_G(setup);
+		sp += (i / 8);
+		b = 1;
+		b = b << (i % 8);
+		if (*sp & b)
+			ltemp = 1;
+		else
+			ltemp = 0;
+		break;
+	case 23:
+		if (_G(thor_info).inventory & 64) ltemp = _G(thor_info).object;
+		else ltemp = 0;
+		break;
+	case 24:
+		ltemp = _G(scrn).icon[(_G(thor)->y + 8) / 16][(_G(thor)->x + 7) / 16];
+		break;
+	case 25:
+		ltemp = (((_G(thor)->y + 8) / 16) * 20) + ((_G(thor)->x + 7) / 16);
+		break;
+	default:
+		return 0;
+	}
+
+	return 1;
+}
+
+int Scripts::get_line(char *src, char *dst) {
+	int cnt;
+
+	cnt = 0;
+	while (*src != 13) {
+		if (*src != 10) {
+			*dst = *src;
+			dst++;
+		}
+		cnt++;
+		src++;
+	}
+
+	*dst = 0;
+	cnt++;
+	src++;
+
+	return cnt;
+}
+
+int Scripts::read_script_file() {
+	char temp_buff[255];
+	char quote_flag;
+	int  i, len, p, ret, cnt;
+	char ch;
+	char *sb;
+	char *sbuff = nullptr;
+	Common::String str;
+	char tmps[255];
+
+	buffer = (char *)malloc(SCR_BUFF_SIZE);
+	if (!buffer) {
+		ret = 1; goto done;
+	};
+	buff_ptr = buffer;
+	Common::fill(buffer, buffer + SCR_BUFF_SIZE, 0);
+
+	sbuff = (char *)malloc(25000l);
+	if (!sbuff) {
+		ret = 1; goto done;
+	};
+	sb = sbuff;
+
+	str = Common::String::format("SPEAK%d", _G(area));
+	if (res_read(str.c_str(), sb) < 0) {
+		ret = 6; goto done;
+	}
+
+	str = Common::String::format("|%d", scr_index);
+	Common::strcpy_s(temp_buff, str.c_str());
+
+	while (1) {
+		cnt = get_line(sb, (char *)tmps);
+		sb += cnt;
+		if (!strcmp(tmps, "|EOF")) {
+			ret = 2; goto done;
+		}
+		if (!strcmp(tmps, temp_buff)) break;
+	}
+	num_labels = 0;
+	while (1) {
+		cnt = get_line(sb, (char *)tmps);
+		if (!strcmp(tmps, "|STOP")) {
+			if (buff_ptr != buffer) {
+				buff_end = buff_ptr; ret = 0; goto done;
+			}
+			ret = 2;
+			goto done;
+		}
+		sb += cnt;
+		len = strlen(tmps);
+		if (len < 2) {
+			*buff_ptr = 0;
+			buff_ptr++;
+			continue;
+		}
+		quote_flag = 0;
+		p = 0;
+		for (i = 0; i < len; i++) {
+			ch = tmps[i];
+			if (ch == 34) quote_flag ^= 1;
+			else if (ch == 13 || ch == 10) {  //check for CR
+				temp_buff[p] = 0;
+				break;
+			} else if ((ch == 39 || ch == 96) && !quote_flag) {
+				temp_buff[p] = 0;
+				break;
+			}
+			if (!quote_flag) ch = toupper(ch);
+			if (quote_flag || ch > 32) {
+				temp_buff[p++] = ch;
+			}
+		}
+		temp_buff[p] = 0;
+
+		len = strlen(temp_buff);
+		if (len < 10 && temp_buff[len - 1] == ':') {       //line label
+			temp_buff[len - 1] = 0;
+			line_ptr[num_labels] = buff_ptr;
+			Common::strcpy_s(line_label[num_labels++], (char *) temp_buff);
+			if (num_labels > 31) {
+				ret = 3; goto done;
+			}
+			*buff_ptr = 0;
+			buff_ptr++;
+			continue;
+		}
+
+		Common::strcpy_s(buff_ptr, SCR_BUFF_SIZE, temp_buff);
+		buff_ptr += strlen(temp_buff);
+		*buff_ptr = 0;
+		buff_ptr++;
+	}
+
+done:
+	if (sbuff)
+		free(sbuff);
+
+	return ret;
+}
+
+void Scripts::script_error(int err_num) {
+	int line_num;
+	char *tb;
+
+	line_num = 1;
+	tb = buffer;
+
+	while (1) {
+		if (*tb == 0) line_num++;
+		if (tb >= buff_ptr) break;
+		tb++;
+	}
+
+	if (err_num > ERROR_MAX)
+		err_num = 5;       // unknown=syntax
+
+	warning("%s in Line #%d", scr_error[err_num], line_num);
+}
+
+int Scripts::cmd_goto() {
+	int i, len;
+	char s[255];
+	char *p;
+
+	Common::strcpy_s(s, buff_ptr);
+	p = strchr(s, ':');
+	if (p) *p = 0;
+
+	for (i = 0; i < num_labels; i++) {
+		len = strlen(s);
+		if (len == 0) break;
+		if (!strcmp(s, line_label[i])) {
+			new_ptr = line_ptr[i];
+			buff_ptr += len;
+			return 0;
+		}
+	}
+	return 8;
+}
+
+int Scripts::cmd_if() {
+	long tmpval1, tmpval2;
+	char exptype, ch;
+
+	if (!calc_value()) return 5;
+	tmpval1 = lvalue;
+	exptype = *buff_ptr;
+	buff_ptr++;
+
+	ch = *buff_ptr;
+	if (ch == 60 || ch == 61 || ch == 62) {
+		if (exptype == *buff_ptr) return 5;
+		exptype += *buff_ptr;
+		buff_ptr++;
+	}
+	if (!calc_value()) return 5;
+	tmpval2 = lvalue;
+	buff_ptr += 4;
+	switch (exptype) {
+	case 60:                              /* less than */
+		if (tmpval1 < tmpval2) goto iftrue;
+		goto iffalse;
+	case 61:                              /* equal */
+		if (tmpval1 == tmpval2) goto iftrue;
+		goto iffalse;
+	case 62:                              /* greater than */
+		if (tmpval1 > tmpval2) goto iftrue;
+		goto iffalse;
+	case 121:                              /* less than or equal */
+		if (tmpval1 <= tmpval2) goto iftrue;
+		goto iffalse;
+	case 122:                              /* less or greater (not equal) */
+		if (tmpval1 != tmpval2) goto iftrue;
+		goto iffalse;
+	case 123:                              /* greater than or equal */
+		if (tmpval1 >= tmpval2) goto iftrue;
+		goto iffalse;
+	default:
+		return 5;
+	}
+
+iffalse:
+	while (*buff_ptr != 0) buff_ptr++;
+	while (*buff_ptr == 0) buff_ptr++;
+
+	if (!strncmp(buff_ptr, "ELSE", 4)) buff_ptr += 4;
+
+iftrue:
+	return 0;
+}
+
+int Scripts::cmd_run() {
+	if (!calc_value()) return 5;
+	buff_ptr++;
+	scr_index = lvalue;
+	return -100;
+}
+
+int Scripts::cmd_addjewels() {
+	if (!calc_value())
+		return 5;
+
+	buff_ptr++;
+
+	add_jewels(lvalue);
+	return 0;
+}
+
+int Scripts::cmd_addhealth() {
+	if (!calc_value()) return 5;
+	buff_ptr++;
+	add_health((int)lvalue);
+	return 0;
+}
+
+int Scripts::cmd_addmagic() {
+	if (!calc_value()) return 5;
+	buff_ptr++;
+	add_magic((int)lvalue);
+	return 0;
+}
+
+int Scripts::cmd_addkeys() {
+
+	if (!calc_value()) return 5;
+	buff_ptr++;
+	add_keys((int)lvalue);
+	return 0;
+}
+
+int Scripts::cmd_addscore() {
+
+	if (!calc_value()) return 5;
+	buff_ptr++;
+	add_score((int)lvalue);
+	return 0;
+}
+
+int Scripts::cmd_say(int mode, int type) {
+#ifdef TODO
+	char *p;
+	int obj;
+
+	if (mode) {
+		if (!calc_value()) return 5;
+		buff_ptr++;
+		obj = (int)lvalue;
+		if (obj < 0 || obj>32) return 6;
+		if (obj) obj += 10;
+	} else obj = 0;
+
+	Common::fill(_G(tmp_buff), _G(tmp_buff) + TMP_SIZE, 0);
+	p = (char *)_G(tmp_buff);
+
+	while (calc_string(0)) {
+		Common::strcpy_s(p, TMP_SIZE, temps);
+		p += strlen(temps);
+		*(p) = 10;
+		p++;
+	}
+	*(p - 1) = 0;
+
+	display_speech(obj, (char *)scr_pic, type);
+	d_restore();
+	return 0;
+#else
+	error("TODO: cmd_say");
+#endif
+}
+
+int Scripts::cmd_ask() {
+#ifdef TODO
+	int i, v, p;
+	char title[41];
+	char *op[] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
+	char opts[10][41];
+
+	memset(_G(tmp_buff), 0, TMP_SIZE);
+	memset(opts, 0, 10 * 41);
+
+	if (!skip_colon()) return 5;
+
+	if (Common::isAlpha(*buff_ptr)) {
+		v = *buff_ptr - 65;
+		buff_ptr++;
+		if (*buff_ptr != ',') return 5;
+		buff_ptr++;
+	} else return 5;
+
+	if (!calc_string(1)) return 5;
+
+	strncpy(title, temps, 41);
+	title[40] = 0;
+
+	if (*buff_ptr == ',') {
+		buff_ptr++;
+		if (!calc_value()) return 5;
+		buff_ptr++;
+		p = (int)lvalue;
+	} else return 5;
+
+	i = 0;
+	while (calc_string(0)) {
+		strncpy((char *) opts[i], temps, 41);
+		opts[i][40] = 0;
+		op[i] = opts[i];
+		i++;
+		if (i > 9) return 3;
+	}
+	if (p > i) p = 0;
+	num_var[v] = select_option(op, title, p - 1);
+	d_restore();
+	return 0;
+#else
+	error("TODO: cmd_ask");
+#endif
+}
+
+int Scripts::cmd_sound() {
+	if (!calc_value()) return 5;
+	buff_ptr++;
+	if (lvalue < 1 || lvalue>16) return 6;
+	play_sound((int)lvalue - 1, 1);
+	return 0;
+}
+
+int Scripts::cmd_settile() {
+	int screen, pos, tile;
+	LEVEL *lvl;
+
+	if (!calc_value()) return 5;
+	buff_ptr++;
+	screen = (int)lvalue;
+	if (!calc_value()) return 5;
+	buff_ptr++;
+	pos = (int)lvalue;
+	if (!calc_value()) return 5;
+	tile = (int)lvalue;
+	if (screen < 0 || screen>119) return 6;
+	if (pos < 0 || pos>239) return 6;
+	if (tile < 0 || tile>230) return 6;
+	if (screen == _G(current_level)) {
+		place_tile(pos % 20, pos / 20, tile);
+	} else {
+		lvl = (LEVEL *) (_G(sd_data) + (screen * 512));
+		lvl->icon[pos / 20][pos % 20] = tile;
+	}
+	return 0;
+}
+
+int Scripts::cmd_itemgive() {
+#ifdef TODO
+	int i;
+
+	if (!calc_value()) return 5;
+	buff_ptr++;
+	i = (int)lvalue;
+	if (i < 1 || i > 15) return 6;
+
+	_G(thor_info).inventory |= 64;
+	_G(thor_info).item = 7;
+	_G(thor_info).object = i;
+	display_item();
+	_G(thor_info).object_name = object_names[_G(thor_info).object - 1];
+	return 0;
+#else
+	error("TODO: cmd_itemgive");
+#endif
+}
+
+int Scripts::cmd_itemtake() {
+	delete_object();
+	return 0;
+}
+
+int Scripts::cmd_setflag() {
+	int i;
+	char b;
+	byte *sp;
+
+	if (!calc_value())
+		return 5;
+	i = (int)lvalue;
+	if (i < 1 || i>64)
+		return 6;
+
+	sp = (byte *)&_G(setup);
+	sp += (i / 8);
+	b = 1;
+	b = b << (i % 8);
+	*sp |= b;
+	return 0;
+}
+
+int Scripts::cmd_ltoa() {
+	int sv;
+	char str[21];
+
+	if (!calc_value()) return 5;
+	buff_ptr++;
+
+	if (Common::isAlpha(*buff_ptr)) {
+		if (*(buff_ptr + 1) == '$') {
+			sv = (*buff_ptr) - 65;
+			buff_ptr += 2;
+		} else return 5;
+	} else return 5;
+
+	ltoa(lvalue, str, 10);
+	Common::strcpy_s(str_var[sv], (char *) str);
+	return 0;
+}
+
+int Scripts::cmd_pause() {
+	if (!calc_value())
+		return 5;
+	buff_ptr++;
+	if (lvalue < 1 || lvalue>65535l)
+		return 6;
+
+	pause((int)lvalue);
+	return 0;
+}
+
+int Scripts::cmd_visible() {
+	if (!calc_value()) return 5;
+	buff_ptr++;
+	if (lvalue < 1 || lvalue>16) return 6;
+
+	actor_visible((int)lvalue);
+	return 0;
+}
+
+int Scripts::cmd_random() {
+	int v, r;
+
+	if (Common::isAlpha(*buff_ptr)) {
+		v = *buff_ptr - 65;
+		buff_ptr++;
+		if (*buff_ptr != ',') return 5;
+		buff_ptr++;
+	} else return 5;
+
+	if (!calc_value()) return 5;
+	buff_ptr++;
+	r = (int)lvalue;
+	if (r < 1 || r>1000) return 6;
+
+	num_var[v] = g_events->getRandomNumber(r - 1);
+	return 0;
+}
+
+void Scripts::scr_func1() {
+	play_sound(FALL, 1);
+	if (_G(key_flag)[_FOUR]) return;
+	_G(new_level) = 109;
+	_G(new_level_tile) = 215;
+	_G(thor)->x = (_G(new_level_tile) % 20) * 16;
+	_G(thor)->y = ((_G(new_level_tile) / 20) * 16) - 2;
+
+	_G(thor)->last_x[0] = _G(thor)->x;
+	_G(thor)->last_x[1] = _G(thor)->x;
+	_G(thor)->last_y[0] = _G(thor)->y;
+	_G(thor)->last_y[1] = _G(thor)->y;
+	_G(thor)->show = 2;
+}
+
+void Scripts::scr_func2() {
+	int r;
+
+	r = g_events->getRandomNumber(5);
+	Common::strcpy_s(str_var[0], 81, offense[r]);
+	Common::strcpy_s(str_var[1], 81, reason[r]);
+}
+
+void Scripts::scr_func3() {
+	int p, x, y, o;
+
+	p = (((_G(thor)->y + 8) / 16) * 20) + ((_G(thor)->x + 7) / 16);
+	y = p / 20;
+	x = p % 20;
+	if (y < 0 || x < 0 || y>11 || x>19) {
+		play_sound(BRAAPP, 1);
+#if 0
+		while (_G(key_flag)[key_magic])
+			rotate_pal();
+#endif
+		return;
+	}
+	if (_G(scrn).icon[y][x] < 174 || _G(scrn).icon[y][x]>178) {
+		play_sound(BRAAPP, 1);
+#if 0
+		while (_G(key_flag)[key_magic]) rotate_pal();
+#endif
+		return;
+	}
+	num_var[0] = 1;
+	play_sound(WOOP, 1);
+	if (_G(current_level) == 106 && p == 69) {
+		place_tile(x, y, 220);
+#if 0
+		while (_G(key_flag)[key_magic]) rotate_pal();
+#endif
+		return;
+	}
+#if 0
+	while (_G(key_flag)[key_magic]) rotate_pal();
+#endif
+	place_tile(x, y, 191);
+	if ((g_events->getRandomNumber(99)) < 25 ||
+		(_G(current_level) == 13 && p == 150 && !_G(setup).f26 && _G(setup).f28)) {
+		if (!_G(object_map)[p] && _G(scrn).icon[y][x] >= 140) {  // nothing there and solid
+			o = g_events->getRandomNumber(1, 5);
+			if (_G(current_level) == 13 && p == 150 && !_G(setup).f26 && _G(setup).f28)
+				o = 20;
+
+			_G(object_map)[p] = o;
+			_G(object_index)[p] = 31;  //actor is 3-15
+			x = (p % 20) * 16;
+			y = (p / 20) * 16;
+#ifdef TODO
+			xfput(x, y, PAGE2, (char *) objects[o - 1]);
+			xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, draw_page, 320, 320);
+			xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, display_page, 320, 320);
+			pause(30);
+#else
+			error("TODO: display/wait");
+#endif
+		}
+	}
+}
+
+void Scripts::scr_func4() {
+	_G(thunder_flag) = 60;
+}
+
+void Scripts::scr_func5() {
+	_G(scrn).actor_loc[0] -= 2;
+	_G(scrn).actor_loc[1] -= 2;
+	_G(scrn).actor_loc[2] -= 2;
+	_G(scrn).actor_loc[3] -= 2;
+	_G(actor)[3].i1 = 16;
+}
+
+int Scripts::cmd_exec() {
+	if (!calc_value()) return 5;
+	buff_ptr++;
+	if (lvalue < 1 || lvalue>10)
+		return 6;
+
+	(this->*scr_func[lvalue - 1])();
+	return 0;
+}
+
+int Scripts::exec_command(int num) {
+	int ret;
+	char ch;
+
+	ret = 0;
+	switch (num) {
+	case 1:                          // end
+		return 0;
+	case 2:                          // goto
+		ret = cmd_goto();
+		if (!ret) buff_ptr = new_ptr;
+		break;
+	case 3:                          // gosub
+		ret = cmd_goto();
+		if (!ret) {
+			gosub_ptr++;
+			if (gosub_ptr > 31) {
+				ret = 10; break;
+			}
+			gosub_stack[gosub_ptr] = buff_ptr;
+			buff_ptr = new_ptr;
+		}
+		break;
+	case 4:                         //return
+		if (!gosub_ptr) {
+			ret = 9; break;
+		}
+		buff_ptr = gosub_stack[gosub_ptr--];
+		break;
+	case 5:                         //for
+		for_ptr++;
+		if (for_ptr > 10) {
+			ret = 10; break;
+		}
+		ch = *buff_ptr;
+		if (!Common::isAlpha(ch)) {
+			ret = 5; break;
+		}
+		ch -= 65;
+		for_var[for_ptr] = ch;
+		buff_ptr += 2;
+		if (!calc_value()) {
+			ret = 5; break;
+		}
+		num_var[for_var[for_ptr]] = lvalue;
+		buff_ptr += 2;
+		if (!calc_value()) {
+			ret = 5; break;
+		}
+		for_val[for_ptr] = lvalue;
+		for_stack[for_ptr] = buff_ptr;
+		break;
+	case 6:                         //next
+		if (!for_ptr) {
+			ret = 11; break;
+		}
+		num_var[for_var[for_ptr]] = num_var[for_var[for_ptr]] + 1;
+		if (num_var[for_var[for_ptr]] <= for_val[for_ptr])
+			buff_ptr = for_stack[for_ptr];
+		else for_ptr--;
+		break;
+	case 7:                         // if
+		ret = cmd_if();
+		break;
+	case 8:                         // else
+		while (*buff_ptr != 0) buff_ptr++;
+		break;
+	case 9:                         // run
+		ret = cmd_run();
+		if (ret < 0) return -100;
+		break;
+	case 10:                        // addjewels
+		ret = cmd_addjewels();
+		break;
+	case 11:                        // addhealth
+		ret = cmd_addhealth();
+		break;
+	case 12:                        // addmagic
+		ret = cmd_addmagic();
+		break;
+	case 13:                        // addkeys
+		ret = cmd_addkeys();
+		break;
+	case 14:                        // addscore
+		ret = cmd_addscore();
+		break;
+	case 15:                        // say
+		ret = cmd_say(0, 1);
+		break;
+	case 16:                        // ask
+		ret = cmd_ask();
+		break;
+	case 17:                        // sound
+		ret = cmd_sound();
+		break;
+	case 18:                        // settile
+		ret = cmd_settile();
+		break;
+	case 19:                        // itemgive
+		ret = cmd_itemgive();
+		break;
+	case 20:                        // itemtake
+		ret = cmd_itemtake();
+		break;
+	case 21:                        // itemsay
+		ret = cmd_say(1, 1);
+		break;
+	case 22:                        // setflag
+		ret = cmd_setflag();
+		break;
+	case 23:                        // ltoa
+		ret = cmd_ltoa();
+		break;
+	case 24:                        // pause
+		ret = cmd_pause();
+		break;
+	case 25:                        // text
+		ret = cmd_say(0, 0);
+		break;
+	case 26:                        // exec
+		ret = cmd_exec();
+		break;
+	case 27:                        // visible
+		ret = cmd_visible();
+		break;
+	case 28:                        // random
+		ret = cmd_random();
+		break;
+	default:
+		ret = 5;
+	}
+	if (ret > 0) {
+		script_error(ret); return 0;
+	}
+	return 1;
 }
 
 } // namespace Got
diff --git a/engines/got/game/script.h b/engines/got/game/script.h
index 46305477c87..e281e017472 100644
--- a/engines/got/game/script.h
+++ b/engines/got/game/script.h
@@ -23,10 +23,86 @@
 #define GOT_GAME_SCRIPT_H
 
 #include "got/data/defines.h"
+#include "got/gfx/gfx_pics.h"
 
 namespace Got {
 
-extern void execute_script(long index, Graphics::ManagedSurface *pic);
+class Scripts {
+private:
+	long  num_var[26] = {};        // numeric variables
+	char  str_var[26][81] = {};    // string vars
+	char  line_label[32][9] = {};  // line label look up table
+	char  *line_ptr[32] = {};      // line label pointers
+	char  *new_ptr = nullptr;
+	int   num_labels = 0;          // number of labels
+	char  *gosub_stack[32] = {};   // stack for GOSUB return addresses
+	char  gosub_ptr = 0;           // GOSUB stack pointer
+	char  *for_stack[10] = {};     // FOR stack
+	long  for_val[10] = {};        // current FOR value
+	char  for_var[10] = {};        // ending FOR value (target var)
+	char  for_ptr = 0;	           // FOR stack pointer
+	char  *buff_ptr = nullptr;     // pointer to current command
+	char  *buff_end = nullptr;	   // pointer to end of buffer
+	char  *buffer = nullptr;       // buffer space (alloc'ed)
+	long  scr_index = 0;
+	Gfx::Pics *scr_pic = nullptr;
+	long  lvalue = 0;
+	long  ltemp = 0;
+	char  temps[255] = {};
+
+private:
+	int  read_script_file();
+	void script_error(int err_num);
+	int  get_command();
+	int  skip_colon();
+	int  calc_value();
+	int  get_next_val();
+	int  calc_string(int mode);
+	void get_str();
+	int  get_internal_variable();
+	int  exec_command(int num);
+	int get_line(char *src, char *dst);
+	void script_entry() {}
+	void script_exit();
+
+	int cmd_goto();
+	int cmd_if();
+	int cmd_run();
+	int cmd_addjewels();
+	int cmd_addhealth();
+	int cmd_addmagic();
+	int cmd_addkeys();
+	int cmd_addscore();
+	int cmd_say(int mode, int type);
+	int cmd_ask();
+	int cmd_sound();
+	int cmd_settile();
+	int cmd_itemgive();
+	int cmd_itemtake();
+	int cmd_setflag();
+	int cmd_ltoa();
+	int cmd_pause();
+	int cmd_visible();
+	int cmd_random();
+	int cmd_exec();
+
+	void scr_func1();
+	void scr_func2();
+	void scr_func3();
+	void scr_func4();
+	void scr_func5();
+
+	typedef void (Scripts:: *ScrFunction)();
+	static ScrFunction scr_func[5];
+
+public:
+	Scripts();
+	~Scripts();
+
+	void execute_script(long index, Gfx::Pics *pic);
+};
+
+extern void execute_script(long index, Gfx::Pics *pic);
 
 } // namespace Got
 
diff --git a/engines/got/vars.h b/engines/got/vars.h
index b494237aed1..d8bf1b8a3af 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -26,6 +26,7 @@
 #include "graphics/screen.h"
 #include "got/data/defines.h"
 #include "got/data/sd_data.h"
+#include "got/game/script.h"
 #include "got/sound.h"
 #include "got/gfx/font.h"
 #include "got/gfx/gfx_chunks.h"
@@ -65,6 +66,7 @@ public:
 	Gfx::Pics _status;
 	SdData _sd_data;
 	Sound _sound;
+	Scripts _scripts;
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
 	uint _display_page = 0, _draw_page = 0;
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 40756d7d858..846992da962 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "got/views/game.h"
+#include "got/game/back.h"
 #include "got/game/init.h"
 #include "got/metaengine.h"
 #include "got/vars.h"
@@ -52,6 +53,19 @@ void Game::draw() {
 	s.clear();
 }
 
+bool Game::msgKeypress(const KeypressMessage &msg) {
+	switch (msg.keycode) {
+	case Common::KEYCODE_F1:
+		odin_speaks(2008, -1);
+		return true;
+
+	default:
+		break;
+	}
+
+	return false;
+}
+
 bool Game::msgAction(const ActionMessage &msg) {
 	return true;
 }
diff --git a/engines/got/views/game.h b/engines/got/views/game.h
index df7ee18f9b3..483853ecf05 100644
--- a/engines/got/views/game.h
+++ b/engines/got/views/game.h
@@ -41,6 +41,7 @@ public:
 
 	bool msgFocus(const FocusMessage &msg) override;
 	bool msgUnfocus(const UnfocusMessage &msg) override;
+	bool msgKeypress(const KeypressMessage &msg) override;
 	bool msgAction(const ActionMessage &msg) override;
 	void draw() override;
 	bool tick() override;
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index a1ab0802ccd..079a173d708 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -53,6 +53,12 @@ bool GameContent::msgGame(const GameMessage &msg) {
 	if (msg._name == "SHOW_LEVEL") {
 		show_level(msg._value);
 		return true;
+	} else if (msg._name == "HIDE_ACTORS") {
+		// Hide all actors and immediately redraw the screen
+		for (int i = 0; i < MAX_ACTORS; i++)
+			_G(actor)[i].show = 0;
+		draw();
+		return true;
 	}
 
 	return false;


Commit: 7bf87ecabc9a7957dc816998c2ce3f38b9626635
    https://github.com/scummvm/scummvm/commit/7bf87ecabc9a7957dc816998c2ce3f38b9626635
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Have key and action events set key_flags array

The original code heavily uses the key_flags in various
places to check for keys being pressed, and it's populated
directly from a custom keyboard interrupt. As such, it
can't easily be entirely refactored to simple key->response
semantics. Particularly in cases of movement, where you can
move in diagonals by holding multiple movement keys.

So the engine supports standard event dispatch for views and
dialogs, which are simple and self-contained, and for gameplay
it sets the key_flags, allowing the engine to check once per
frame and do actions based on the flag settings.

Changed paths:
    engines/got/events.cpp
    engines/got/events.h
    engines/got/metaengine.h
    engines/got/vars.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 7e5d54cd19c..748c7fade61 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -93,12 +93,23 @@ void Events::nextFrame() {
 void Events::processEvent(Common::Event &ev) {
 	switch (ev.type) {
 	case Common::EVENT_KEYDOWN:
+		if (ev.kbd.keycode < 100)
+			_G(key_flag)[ev.kbd.keycode] = true;
+
 		if (ev.kbd.keycode < Common::KEYCODE_NUMLOCK)
 			msgKeypress(KeypressMessage(ev.kbd));
 		break;
+	case Common::EVENT_KEYUP:
+		if (ev.kbd.keycode < 100)
+			_G(key_flag)[ev.kbd.keycode] = false;
+		break;
 	case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+		_G(key_flag)[actionToKeyFlag(ev.customType)] = true;
 		msgAction(ActionMessage(ev.customType));
 		break;
+	case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
+		_G(key_flag)[actionToKeyFlag(ev.customType)] = false;
+		break;
 	case Common::EVENT_LBUTTONDOWN:
 	case Common::EVENT_RBUTTONDOWN:
 	case Common::EVENT_MBUTTONDOWN:
@@ -117,6 +128,11 @@ void Events::processEvent(Common::Event &ev) {
 	}
 }
 
+int Events::actionToKeyFlag(int action) const {
+	return (action == KEYBIND_ESCAPE) ? Common::KEYCODE_ESCAPE :
+		(int)action;
+}
+
 void Events::replaceView(UIElement *ui, bool replaceAllViews, bool fadeOutIn) {
 	assert(ui);
 	UIElement *priorView = focusedView();
diff --git a/engines/got/events.h b/engines/got/events.h
index 1da12c27f5a..79a3643604d 100644
--- a/engines/got/events.h
+++ b/engines/got/events.h
@@ -260,6 +260,7 @@ private:
 	Common::Stack<UIElement *> _views;
 
 	void nextFrame();
+	int actionToKeyFlag(int action) const;
 
 protected:
 	/**
diff --git a/engines/got/metaengine.h b/engines/got/metaengine.h
index 100a25fd82f..b8ef996c325 100644
--- a/engines/got/metaengine.h
+++ b/engines/got/metaengine.h
@@ -28,7 +28,7 @@ namespace Got {
 
 enum KeybindingAction {
 	KEYBIND_NONE, KEYBIND_UP, KEYBIND_DOWN, KEYBIND_LEFT, KEYBIND_RIGHT,
-	KEYBIND_SELECT, KEYBIND_ESCAPE, KEYBIND_FIRE, KEYBIND_MAGIC
+	KEYBIND_SELECT, KEYBIND_FIRE, KEYBIND_MAGIC, KEYBIND_ESCAPE
 };
 
 } // namespace Got
diff --git a/engines/got/vars.h b/engines/got/vars.h
index d8bf1b8a3af..e718c8a2fe2 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -27,10 +27,11 @@
 #include "got/data/defines.h"
 #include "got/data/sd_data.h"
 #include "got/game/script.h"
-#include "got/sound.h"
 #include "got/gfx/font.h"
 #include "got/gfx/gfx_chunks.h"
 #include "got/gfx/gfx_pics.h"
+#include "got/metaengine.h"
+#include "got/sound.h"
 
 namespace Got {
 
@@ -44,9 +45,14 @@ class Vars;
 extern Vars *g_vars;
 
 enum Key {
-	key_fire, key_up, key_down, key_left, key_right,
-	key_magic, key_select,
-	KEY_MAX
+	key_none = KEYBIND_NONE,
+	key_up = KEYBIND_UP,
+	key_down = KEYBIND_DOWN,
+	key_left = KEYBIND_LEFT,
+	key_right = KEYBIND_RIGHT,
+	key_fire = KEYBIND_FIRE, 
+	key_magic = KEYBIND_ESCAPE,
+	key_select = KEYBIND_SELECT
 };
 
 class Vars {


Commit: 72a5b4c74c409ceb565178fc17b873ee6bb2a7aa
    https://github.com/scummvm/scummvm/commit/72a5b4c74c409ceb565178fc17b873ee6bb2a7aa
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Hook s/l keys to the save/load dialogs

Changed paths:
    engines/got/views/game.cpp


diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 846992da962..8b0337ab4ba 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -59,6 +59,14 @@ bool Game::msgKeypress(const KeypressMessage &msg) {
 		odin_speaks(2008, -1);
 		return true;
 
+	case Common::KEYCODE_s:
+		g_engine->saveGameDialog();
+		break;
+
+	case Common::KEYCODE_l:
+		g_engine->loadGameDialog();
+		break;
+
 	default:
 		break;
 	}


Commit: 8a3a36853268b3ed6226f743f8103ff686076c36
    https://github.com/scummvm/scummvm/commit/8a3a36853268b3ed6226f743f8103ff686076c36
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Beginnings of select item dialog

Changed paths:
    engines/got/game/back.cpp
    engines/got/got.cpp
    engines/got/got.h
    engines/got/metaengine.cpp
    engines/got/module.mk
    engines/got/views/dialogs/dialog.cpp
    engines/got/views/dialogs/dialog.h
    engines/got/views/dialogs/select_option.cpp
    engines/got/views/game.cpp
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h
    engines/got/views/views.h


diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index 3c5c0a81fc4..b6ff01ffd5b 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -25,6 +25,7 @@
 #include "got/game/panel.h"
 #include "got/game/script.h"
 #include "got/gfx/image.h"
+#include "got/events.h"
 #include "got/vars.h"
 
 namespace Got {
@@ -288,7 +289,10 @@ int bgtile(int x, int y) {
 }
 
 void select_item() {
-	error("TODO: select_item");
+	// Only allow opening the dialog if something isn't currently going on
+	if (g_engine->canSaveAutosaveCurrently()) {
+		g_events->addView("SelectItem");
+	}
 }
 
 int actor_speaks(ACTOR *actr, int index, int item) {
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index ce1dc4ea372..97aa30d5b43 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -31,6 +31,7 @@
 #include "got/console.h"
 #include "got/gfx/image.h"
 #include "got/utils/res_archive.h"
+#include "got/views/game_content.h"
 
 namespace Got {
 
@@ -150,4 +151,16 @@ Common::Error GotEngine::syncGame(Common::Serializer &s) {
 	return Common::kNoError;
 }
 
+bool GotEngine::canSaveGameStateCurrently(Common::U32String *msg) {
+	if (_G(key_flag)[key_magic] || _G(tornado_used) || _G(lightning_used) ||
+			_G(thunder_flag) || _G(hourglass_flag) || _G(thor)->num_moves > 1 ||
+			_G(shield_on))
+		return false;
+
+	// TODO: Consider if there is a cleaner way to do this. Maybe have a
+	// global flag or a message sent to the views 
+	Views::GameContent *content = (Views::GameContent *)findView("GameContent");
+	return content && content->canSaveLoad();
+}
+
 } // End of namespace Got
diff --git a/engines/got/got.h b/engines/got/got.h
index adf0bf885f4..1926c9e0676 100644
--- a/engines/got/got.h
+++ b/engines/got/got.h
@@ -86,11 +86,9 @@ public:
 		    (f == kSupportsReturnToLauncher);
 	};
 
+	bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
 	bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override {
-		return true;
-	}
-	bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override {
-		return true;
+		return canSaveGameStateCurrently();
 	}
 
 	/**
diff --git a/engines/got/metaengine.cpp b/engines/got/metaengine.cpp
index 67c0ae73eb3..9755a7522c8 100644
--- a/engines/got/metaengine.cpp
+++ b/engines/got/metaengine.cpp
@@ -57,7 +57,8 @@ static const KeybindingRecord GAME_KEYS[] = {
 	{ KEYBIND_DOWN, "DOWN", _s("Down"), "DOWN", "JOY_DOWN"},
 	{ KEYBIND_LEFT, "LEFT", _s("Left"), "LEFT", "JOY_LEFT"},
 	{ KEYBIND_RIGHT, "RIGHT", _s("Right"), "RIGHT", "JOY_RIGHT"},
-	{ KEYBIND_SELECT, "SELECT", _s("Select"), "RETURN", "JOY_A" },
+	{ KEYBIND_MAGIC, "MAGIC", _s("Magic"), "CTRL", "JOY_A" },
+	{ KEYBIND_SELECT, "SELECT", _s("Select"), "SPACE", "JOY_B" },
 	// I18N: ESC key
 	{ KEYBIND_ESCAPE, "ESCAPE", _s("Escape"), "ESCAPE", nullptr },
 	{ KEYBIND_NONE, nullptr, nullptr, nullptr, nullptr }
diff --git a/engines/got/module.mk b/engines/got/module.mk
index ede0889f10b..341323e722a 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -49,6 +49,7 @@ MODULE_OBJS = \
 	views/dialogs/quit.o \
 	views/dialogs/quit_game.o \
 	views/dialogs/select_game.o \
+	views/dialogs/select_item.o \
 	views/dialogs/set_sound.o
 
 # This module can be built as a plugin
diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
index 4033c1ad739..686a4dbc5f3 100644
--- a/engines/got/views/dialogs/dialog.cpp
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -26,13 +26,19 @@ namespace Got {
 namespace Views {
 namespace Dialogs {
 
+Dialog::Dialog(const Common::String &name) : View(name) {
+	_bounds.setBorderSize(16);
+}
+
 void Dialog::draw() {
 	// Clear the inner content first
 	GfxSurface s = getSurface(true);
 	s.clear(215);
 
-	// Draw four corners
 	s = getSurface();
+	assert((s.w % 16) == 0 && (s.h % 16) == 0);
+
+	// Draw four corners
 	s.blitFrom(_G(bgPics)[192], Common::Point(0, 0));
 	s.blitFrom(_G(bgPics)[193], Common::Point(_bounds.width() - 16, 0));
 	s.blitFrom(_G(bgPics)[194], Common::Point(0, _bounds.height() - 16));
diff --git a/engines/got/views/dialogs/dialog.h b/engines/got/views/dialogs/dialog.h
index 13fa46c44ea..82ef7463975 100644
--- a/engines/got/views/dialogs/dialog.h
+++ b/engines/got/views/dialogs/dialog.h
@@ -31,10 +31,8 @@ namespace Dialogs {
 
 class Dialog : public View {
 public:
-	Dialog(const Common::String &name) : View(name) {
-	}
-	virtual ~Dialog() {
-	}
+	Dialog(const Common::String &name);
+	virtual ~Dialog() {}
 
 	void draw() override;
 };
diff --git a/engines/got/views/dialogs/select_option.cpp b/engines/got/views/dialogs/select_option.cpp
index bb30b8a2487..5284c6fc843 100644
--- a/engines/got/views/dialogs/select_option.cpp
+++ b/engines/got/views/dialogs/select_option.cpp
@@ -55,7 +55,6 @@ SelectOption::SelectOption(const Common::String &name, const char *title,
 	y2 = (y1 + h);
 
 	_bounds = Common::Rect(x1 - 16, y1 - 16, x2 + 16, y2 + 16);
-	_bounds.setBorderSize(16);
 }
 
 void SelectOption::draw() {
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 8b0337ab4ba..ba40f2a7cb7 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -75,7 +75,13 @@ bool Game::msgKeypress(const KeypressMessage &msg) {
 }
 
 bool Game::msgAction(const ActionMessage &msg) {
-	return true;
+	switch (msg._action) {
+	case KEYBIND_SELECT:
+		select_item();
+		return true;
+	}
+
+	return false;
 }
 
 bool Game::tick() {
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 079a173d708..08dc23fb527 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -180,5 +180,10 @@ void GameContent::checkForItem() {
 		pick_up_object(thor_pos);
 }
 
+bool GameContent::canSaveLoad() const {
+	// TODO: Disallow saving during animations like scene changes or Thor dying
+	return true;
+}
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index aedc589b0dd..3b92e842e98 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -46,6 +46,8 @@ public:
 	void draw() override;
 	bool msgGame(const GameMessage &msg) override;
 	bool tick() override;
+
+	bool canSaveLoad() const;
 };
 
 } // namespace Views
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index 0629d4add09..1af061f67ea 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -31,6 +31,7 @@
 #include "got/views/dialogs/quit.h"
 #include "got/views/dialogs/quit_game.h"
 #include "got/views/dialogs/select_game.h"
+#include "got/views/dialogs/select_item.h"
 #include "got/views/dialogs/set_sound.h"
 
 namespace Got {
@@ -47,6 +48,7 @@ struct Views {
 	Dialogs::Quit _quit;
 	Dialogs::QuitGame _quitGame;
 	Dialogs::SelectGame _selectGame;
+	Dialogs::SelectItem _selectItem;
 	Dialogs::SetSound _setSound;
 };
 


Commit: fdba0a776d6c95f33154543293b13117fc0067e8
    https://github.com/scummvm/scummvm/commit/fdba0a776d6c95f33154543293b13117fc0067e8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Finished Select Item dialog

Changed paths:
  A engines/got/views/dialogs/select_item.cpp
  A engines/got/views/dialogs/select_item.h


diff --git a/engines/got/views/dialogs/select_item.cpp b/engines/got/views/dialogs/select_item.cpp
new file mode 100644
index 00000000000..108fb118a39
--- /dev/null
+++ b/engines/got/views/dialogs/select_item.cpp
@@ -0,0 +1,172 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/select_item.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+#define _HRZSP 24
+
+static const char *ITEM_NAMES[] = {
+	"Enchanted Apple", "Lightning Power", "Winged Boots",
+	"Wind Power", "Amulet of Protection","Thunder Power"
+};
+
+SelectItem::SelectItem() : Dialog("SelectItem") {
+	setBounds(Common::Rect(56, 48, 264, 160));
+}
+
+void SelectItem::draw() {
+	int b;
+	const char *objn;
+
+	Dialog::draw();
+	GfxSurface s = getSurface();
+
+	if (_G(thor_info).inventory == 0) {
+		s.print(Common::Point(44, 52), "No Items Found", 14);
+		return;
+	}
+
+	b = 1;
+	for (int l = 0; l < 7; l++, b = b << 1) {
+		if (_G(thor_info).inventory & b) {
+			if (l < 6)
+				s.blitFrom(_G(objects)[l + 26],
+					Common::Point(82 - 56 + (l * _HRZSP), 72 - 48));
+			else
+				s.blitFrom(_G(objects)[_G(thor_info).object + 10],
+					Common::Point(82 - 56 + (l * _HRZSP), 72 - 48));
+		}
+	}
+
+	if (_selectedItem < 6)
+		objn = ITEM_NAMES[_selectedItem];
+	else
+		objn = _G(thor_info).object_name;
+
+	s.print(Common::Point((s.w - (strlen(objn) * 8)) / 2, 66), objn, 12);
+	s.frameRect(Common::Rect(26 + (_selectedItem * _HRZSP), 22,
+		43 + (_selectedItem * _HRZSP), 42), 15);
+}
+
+bool SelectItem::msgFocus(const FocusMessage &msg) {
+	int b;
+
+	_selectedItem = _G(thor_info).item - 1;
+	if (_selectedItem < 1)
+		_selectedItem = 0;
+
+	b = 1 << _selectedItem;
+	for (;;) {
+		if (_G(thor_info).inventory & b)
+			break;
+		if (_selectedItem < 7)
+			_selectedItem++;
+		else
+			_selectedItem = 0;
+
+		b = 1 << _selectedItem;
+	}
+
+	return true;
+}
+
+bool SelectItem::msgKeypress(const KeypressMessage &msg) {
+	if (_G(thor_info).inventory == 0 ||
+			msg.keycode == Common::KEYCODE_SPACE ||
+			msg.keycode == Common::KEYCODE_RETURN) {
+		close();
+		return true;
+	}
+
+	return false;
+}
+
+bool SelectItem::msgAction(const ActionMessage &msg) {
+	int b;
+
+	if (_G(thor_info).inventory == 0) {
+		close();
+		return true;
+	}
+
+	switch (msg._action) {
+	case KEYBIND_ESCAPE:
+		close();
+		break;
+
+	case KEYBIND_SELECT:
+	case KEYBIND_FIRE:
+	case KEYBIND_MAGIC:
+		selectItem();
+		break;
+
+	case KEYBIND_LEFT:
+		for (;;) {
+			if (_selectedItem > 0)
+				_selectedItem--;
+			else
+				_selectedItem = 8;
+
+			b = 1 << _selectedItem;
+			if (_G(thor_info).inventory & b)
+				break;
+		}
+
+		play_sound(WOOP, 1);
+		redraw();
+		break;
+
+	case KEYBIND_RIGHT:
+		while (1) {
+			if (_selectedItem < 9)
+				_selectedItem++;
+			else
+				_selectedItem = 0;
+
+			b = 1 << _selectedItem;
+			if (_G(thor_info).inventory & b)
+				break;
+		}
+
+		play_sound(WOOP, 1);
+		redraw();
+		break;
+
+	default:
+		break;
+	}
+
+	return true;
+}
+
+void SelectItem::selectItem() {
+	_G(thor_info).item = _selectedItem + 1;
+	close();
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/select_item.h b/engines/got/views/dialogs/select_item.h
new file mode 100644
index 00000000000..d3ffaa3d243
--- /dev/null
+++ b/engines/got/views/dialogs/select_item.h
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_SELECT_ITEM_H
+#define GOT_VIEWS_DIALOGS_SELECT_ITEM_H
+
+#include "got/views/dialogs/dialog.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class SelectItem : public Dialog {
+private:
+	int _selectedItem;
+
+	void selectItem();
+
+public:
+	SelectItem();
+	virtual ~SelectItem() {}
+
+	void draw() override;
+	bool msgFocus(const FocusMessage &msg) override;
+	bool msgKeypress(const KeypressMessage &msg) override;
+	bool msgAction(const ActionMessage &msg) override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif


Commit: 26b26b2bba0c0d8ff29620b13b955f20ba4cebee
    https://github.com/scummvm/scummvm/commit/26b26b2bba0c0d8ff29620b13b955f20ba4cebee
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Change console load command to use Save file manager

Changed paths:
    engines/got/console.cpp


diff --git a/engines/got/console.cpp b/engines/got/console.cpp
index a05dd74f076..bb5a428c39c 100644
--- a/engines/got/console.cpp
+++ b/engines/got/console.cpp
@@ -19,7 +19,8 @@
  *
  */
 
-#include "common/file.h"
+#include "common/savefile.h"
+#include "common/system.h"
 #include "got/console.h"
 #include "got/events.h"
 #include "got/vars.h"
@@ -62,14 +63,15 @@ bool Console::cmdMusic(int argc, const char **argv) {
 
 bool Console::cmdLoad(int argc, const char **argv) {
 	if (argc == 2) {
-		Common::File f;
-		if (!f.open(argv[1])) {
+		Common::SeekableReadStream *f;
+		if ((f = g_system->getSavefileManager()->openForLoading(argv[1])) == nullptr) {
 			debugPrintf("Could not open savegame\n");
 			return true;
 		} else {
-			f.skip(32); // Skip the 32 bytes title
+			f->skip(32); // Skip the 32 bytes title
 
-			g_engine->loadGameStream(&f);
+			g_engine->loadGameStream(f);
+			delete f;
 			return false;
 		}
 	}


Commit: 59098c4eca280c4381c7a64f22f38f88bbfbf75e
    https://github.com/scummvm/scummvm/commit/59098c4eca280c4381c7a64f22f38f88bbfbf75e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Implement palette cycling animations

Changed paths:
    engines/got/events.cpp
    engines/got/events.h
    engines/got/gfx/palette.cpp


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 748c7fade61..6376cec01fd 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -30,6 +30,21 @@ namespace Got {
 
 Events *g_events;
 
+// Index and RGB63 values used for palette animation
+// like water effects and gems sparkling
+static const uint16 PAL_CLR1[] = {
+	0xf300, 0x003b, 0xf000, 0x003b, 0xf100, 0x003b, 0xf200, 0x003b
+};
+static const uint16 PAL_SET1[] = {
+	0xf027, 0x273f, 0xf127, 0x273f, 0xf227, 0x273f, 0xf327, 0x273f
+};
+static const uint16 PAL_CLR2[] = {
+	0xf73b, 0x0000, 0xf43b, 0x0000, 0xf53b, 0x0000, 0xf63b, 0x0000
+};
+static const uint16 PAL_SET2[] = {
+	0xf43f, 0x2727, 0xf53f, 0x2727, 0xf63f, 0x2727, 0xf73f, 0x2727
+};
+
 Events::Events() : UIElement("Root", nullptr) {
 	g_events = this;
 }
@@ -40,6 +55,7 @@ Events::~Events() {
 
 void Events::runGame() {
 	uint currTime, nextFrameTime = 0;
+	int palCycleCtr = 0;
 	_screen = new Graphics::Screen();
 	Views::Views views;	// Loads all views in the structure
 
@@ -66,6 +82,13 @@ void Events::runGame() {
 			break;
 
 		g_system->delayMillis(10);
+
+		// Rotate the palette
+		if (++palCycleCtr == 2) {
+			palCycleCtr = 0;
+			rotatePalette();
+		}
+
 		if ((currTime = g_system->getMillis()) >= nextFrameTime) {
 			nextFrameTime = currTime + FRAME_DELAY;
 			nextFrame();
@@ -90,6 +113,45 @@ void Events::nextFrame() {
 	_screen->update();
 }
 
+#define LOOP_THRESHOLD 5
+
+void Events::rotatePalette() {
+	const uint16 *entry;
+	++_palLoop;
+
+	if (_palLoop > LOOP_THRESHOLD) {
+		_palLoop = 0;
+	} else {
+		switch (_palLoop) {
+		case LOOP_THRESHOLD - 4:
+			entry = &PAL_CLR2[_palCnt2];
+			break;
+		case LOOP_THRESHOLD - 3:
+			entry = &PAL_SET2[_palCnt2];
+
+			_palCnt2 += 2;
+			if (_palCnt2 >= 8)
+				_palCnt2 = 0;
+			break;
+		case LOOP_THRESHOLD - 2:
+			entry = &PAL_CLR1[_palCnt1];
+			break;
+		case LOOP_THRESHOLD - 1:
+			entry = &PAL_SET1[_palCnt1];
+
+			_palCnt1 += 2;
+			if (_palCnt1 >= 8)
+				_palCnt1 = 0;
+			break;
+		default:
+			return;
+		}
+
+		Gfx::xsetpal(entry[0] >> 8, (entry[0] & 0xff) << 2,
+			(entry[1] >> 8) << 2, (entry[1] & 0xff) << 2);
+	}
+}
+
 void Events::processEvent(Common::Event &ev) {
 	switch (ev.type) {
 	case Common::EVENT_KEYDOWN:
diff --git a/engines/got/events.h b/engines/got/events.h
index 79a3643604d..50b15e71805 100644
--- a/engines/got/events.h
+++ b/engines/got/events.h
@@ -258,9 +258,13 @@ class Events : public UIElement {
 private:
 	Graphics::Screen *_screen = nullptr;
 	Common::Stack<UIElement *> _views;
+	int _palLoop = 0;
+	int _palCnt1 = 0;
+	int _palCnt2 = 0;
 
 	void nextFrame();
 	int actionToKeyFlag(int action) const;
+	void rotatePalette();
 
 protected:
 	/**
diff --git a/engines/got/gfx/palette.cpp b/engines/got/gfx/palette.cpp
index 840caaec030..64cdf23e4e3 100644
--- a/engines/got/gfx/palette.cpp
+++ b/engines/got/gfx/palette.cpp
@@ -39,8 +39,6 @@ void load_palette() {
 		error("Cannot Read PALETTE");
 
 	g_system->getPaletteManager()->setPalette(saved_palette, 0, 256);
-
-	set_screen_pal();
 }
 
 void set_screen_pal() {


Commit: ad12b225d3527f656cdd081860bf0f1e968de34b
    https://github.com/scummvm/scummvm/commit/ad12b225d3527f656cdd081860bf0f1e968de34b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix Select Items dialog when inventory empty

Changed paths:
    engines/got/views/dialogs/select_item.cpp


diff --git a/engines/got/views/dialogs/select_item.cpp b/engines/got/views/dialogs/select_item.cpp
index 108fb118a39..5d7b7f5cbae 100644
--- a/engines/got/views/dialogs/select_item.cpp
+++ b/engines/got/views/dialogs/select_item.cpp
@@ -74,20 +74,24 @@ void SelectItem::draw() {
 bool SelectItem::msgFocus(const FocusMessage &msg) {
 	int b;
 
-	_selectedItem = _G(thor_info).item - 1;
-	if (_selectedItem < 1)
-		_selectedItem = 0;
-
-	b = 1 << _selectedItem;
-	for (;;) {
-		if (_G(thor_info).inventory & b)
-			break;
-		if (_selectedItem < 7)
-			_selectedItem++;
-		else
+	if (_G(thor_info).inventory == 0) {
+		_selectedItem = -1;
+	} else {
+		_selectedItem = _G(thor_info).item - 1;
+		if (_selectedItem < 1)
 			_selectedItem = 0;
 
 		b = 1 << _selectedItem;
+		for (;;) {
+			if (_G(thor_info).inventory & b)
+				break;
+			if (_selectedItem < 7)
+				_selectedItem++;
+			else
+				_selectedItem = 0;
+
+			b = 1 << _selectedItem;
+		}
 	}
 
 	return true;


Commit: 4f1bc015639b54fb9a3ad6b6904f1e0c0582a059
    https://github.com/scummvm/scummvm/commit/4f1bc015639b54fb9a3ad6b6904f1e0c0582a059
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Beginning to hook in movement code

Changed paths:
    engines/got/data/defines.h
    engines/got/views/game.cpp
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index 3878e723b4d..a56bf08cbce 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -115,6 +115,10 @@ struct ACTOR {                      // Size=256
 	byte future2[25] = {};
 
 	void loadFixed(Common::SeekableReadStream *src);
+
+	int getPos() const {
+		return ((x + 7) / 16) + (((y + 8) / 16) * 20);
+	}
 };
 
 struct ACTOR_NFO {				//size=40
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index ba40f2a7cb7..56afe9b36b6 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -91,7 +91,7 @@ bool Game::tick() {
 	// we set to redraw the screen every frame in case of updates
 	redraw();
 
-	return false;
+	return View::tick();
 }
 
 } // namespace Views
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 08dc23fb527..95330fee24e 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -22,6 +22,7 @@
 #include "got/views/game_content.h"
 #include "got/game/back.h"
 #include "got/game/move.h"
+#include "got/game/move_patterns.h"
 #include "got/game/object.h"
 #include "got/gfx/image.h"
 #include "got/vars.h"
@@ -68,10 +69,16 @@ bool GameContent::tick() {
 	checkThunderShake();
 	checkSwitchFlag();
 	checkForItem();
+	moveActors();
 
 	return false;
 }
 
+bool GameContent::canSaveLoad() const {
+	// TODO: Disallow saving during animations like scene changes or Thor dying
+	return true;
+}
+
 void GameContent::drawBackground(GfxSurface &s) {
 	for (int y = 0; y < TILES_Y; y++) {
 		for (int x = 0; x < TILES_X; x++) {
@@ -175,14 +182,34 @@ void GameContent::checkSwitchFlag() {
 }
 
 void GameContent::checkForItem() {
-	int thor_pos = ((_G(thor)->x + 7) / 16) + (((_G(thor)->y + 8) / 16) * 20);
+	int thor_pos = _G(thor)->getPos();
 	if (_G(object_map)[thor_pos])
 		pick_up_object(thor_pos);
 }
 
-bool GameContent::canSaveLoad() const {
-	// TODO: Disallow saving during animations like scene changes or Thor dying
-	return true;
+void GameContent::moveActors() {
+	for (int i = 0; i < MAX_ACTORS; i++) {
+		if (_G(actor)[i].used) {
+			if (_G(hourglass_flag))
+				if ((i > 2) && (!_G(pge)) && (!(_G(actor)[i].magic_hurts & HOURGLASS_MAGIC)))
+					continue;
+
+			_G(actor)[i].move_count = _G(actor)[i].num_moves;
+			while (_G(actor)[i].move_count--)
+				move_actor(&_G(actor)[i]);
+
+			if (i == 0)
+				set_thor_vars();
+
+			if (_G(new_level) != _G(current_level))
+				return;
+		}
+	}
+
+	int thor_pos = _G(thor)->getPos();
+	_G(thor)->center_x = thor_pos % 20;
+	_G(thor)->center_y = thor_pos / 20;
+
 }
 
 } // namespace Views
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index 3b92e842e98..accf0934289 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -38,6 +38,7 @@ private:
 	void checkThunderShake();
 	void checkSwitchFlag();
 	void checkForItem();
+	void moveActors();
 
 public:
 	GameContent() : View("GameContent") {}


Commit: 4732098859d90baf8882d9e2b628e3f3a1f21e74
    https://github.com/scummvm/scummvm/commit/4732098859d90baf8882d9e2b628e3f3a1f21e74
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Hook in use_item call

Changed paths:
    engines/got/game/object.cpp
    engines/got/game/object.h
    engines/got/views/game_content.cpp


diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index f16c5e49d71..75c6f4cbb6a 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -402,13 +402,7 @@ int use_object(int flag) {
 	if (!(_G(thor_info).inventory & 64))
 		return 0;
 
-	//xshowpage(draw_page);
-	//xerase_actors(actor, display_page);
-	//xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], display_page);
-	//xshowpage(display_page);
-
 	odin_speaks((_G(thor_info).object - 1) + 5501, _G(thor_info).object - 1);
-	//xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], draw_page);
 	return 1;
 }
 
diff --git a/engines/got/game/object.h b/engines/got/game/object.h
index 68ad7256825..175c38773cb 100644
--- a/engines/got/game/object.h
+++ b/engines/got/game/object.h
@@ -26,11 +26,11 @@
 
 namespace Got {
 
-extern void show_objects(int level, unsigned int pg);
 extern void pick_up_object(int p);
 extern int drop_object(ACTOR *actr);
 extern int _drop_obj(ACTOR *actr, int o);
 extern void delete_object();
+extern void use_item();
 
 } // namespace Got
 
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 95330fee24e..a2e15a49bc3 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -70,6 +70,7 @@ bool GameContent::tick() {
 	checkSwitchFlag();
 	checkForItem();
 	moveActors();
+	use_item();
 
 	return false;
 }


Commit: dd3542fb14783b05b508f1b6fa5e6c98524d0d3d
    https://github.com/scummvm/scummvm/commit/dd3542fb14783b05b508f1b6fa5e6c98524d0d3d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Thor and enemy are moving!

Changed paths:
    engines/got/game/move_patterns.cpp


diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 7c6bf1b9afd..be8348d8e2c 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -168,7 +168,7 @@ int check_move0(int x, int y, ACTOR *actr) {
 	int x3, x4, y3, y4;
 	int i, ti;
 	ACTOR *act;
-	char icn1, icn2, icn3, icn4;
+	byte icn1, icn2, icn3, icn4;
 
 	_G(thor_icon1) = 0;
 	_G(thor_icon2) = 0;
@@ -316,7 +316,7 @@ int check_move1(int x, int y, ACTOR *actr) {   //check hammer move
 	int  x1, x2, y1, y2, i;
 	int  x3, y3, x4, y4;
 	int  icn, f;
-	char icn1, icn2, icn3, icn4;
+	byte icn1, icn2, icn3, icn4;
 
 	ACTOR *act;
 
@@ -386,7 +386,7 @@ int check_move2(int x, int y, ACTOR *actr) {   //check enemy move
 	int x1, x2, y1, y2, i;
 	int x3, y3, x4, y4;
 	int icn;
-	char icn1, icn2, icn3, icn4;
+	byte icn1, icn2, icn3, icn4;
 
 	ACTOR *act;
 
@@ -459,7 +459,7 @@ int check_move2(int x, int y, ACTOR *actr) {   //check enemy move
 int check_move3(int x, int y, ACTOR *actr) {   //check enemy shot move
 	int x1, x2, y1, y2;
 	int x3, x4, y3, y4, i;
-	char icn1, icn2, icn3, icn4;
+	byte icn1, icn2, icn3, icn4;
 	ACTOR *act;
 
 	int icn;
@@ -532,11 +532,15 @@ int check_move4(int x, int y, ACTOR *actr) {   //flying enemies
 
 #define THOR_PAD1 2
 #define THOR_PAD2 4
+
 int  check_thor_move(int x, int y, ACTOR *actr) {
+	if (check_move0(x, y, actr))
+		return 1;
+	if (_G(diag_flag) || _G(thor_special_flag))
+		return 0;
+	if ((_G(thor_icon1) + _G(thor_icon2) + _G(thor_icon3) + _G(thor_icon4)) > 1)
+		return 0;
 
-	if (check_move0(x, y, actr)) return 1;
-	if (_G(diag_flag) || _G(thor_special_flag)) return 0;
-	if ((_G(thor_icon1) + _G(thor_icon2) + _G(thor_icon3) + _G(thor_icon4)) > 1) return 0;
 	switch (actr->dir) {
 	case 0:
 		if (_G(thor_icon1)) {
@@ -585,6 +589,7 @@ int  check_thor_move(int x, int y, ACTOR *actr) {
 		}
 		break;
 	}
+
 	return 0;
 }
 
@@ -698,7 +703,7 @@ int check_special_move1(int x, int y, ACTOR *actr) {
 	int x1, x2, y1, y2, i;
 	int x3, y3, x4, y4;
 	int icn;
-	char icn1, icn2, icn3, icn4;
+	byte icn1, icn2, icn3, icn4;
 
 	ACTOR *act;
 


Commit: 881ed9983d225c9012f40a1219ac7ca70a146862
    https://github.com/scummvm/scummvm/commit/881ed9983d225c9012f40a1219ac7ca70a146862
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix default keybindings

Changed paths:
    engines/got/metaengine.cpp


diff --git a/engines/got/metaengine.cpp b/engines/got/metaengine.cpp
index 9755a7522c8..277c7c1a1ee 100644
--- a/engines/got/metaengine.cpp
+++ b/engines/got/metaengine.cpp
@@ -57,10 +57,11 @@ static const KeybindingRecord GAME_KEYS[] = {
 	{ KEYBIND_DOWN, "DOWN", _s("Down"), "DOWN", "JOY_DOWN"},
 	{ KEYBIND_LEFT, "LEFT", _s("Left"), "LEFT", "JOY_LEFT"},
 	{ KEYBIND_RIGHT, "RIGHT", _s("Right"), "RIGHT", "JOY_RIGHT"},
-	{ KEYBIND_MAGIC, "MAGIC", _s("Magic"), "CTRL", "JOY_A" },
-	{ KEYBIND_SELECT, "SELECT", _s("Select"), "SPACE", "JOY_B" },
+	{ KEYBIND_FIRE, "FIRE", _s("Magic"), "LALT", "JOY_A" },
+	{ KEYBIND_MAGIC, "MAGIC", _s("Magic"), "LCTRL", "JOY_B" },
+	{ KEYBIND_SELECT, "SELECT", _s("Select"), "SPACE", "JOY_X" },
 	// I18N: ESC key
-	{ KEYBIND_ESCAPE, "ESCAPE", _s("Escape"), "ESCAPE", nullptr },
+	{ KEYBIND_ESCAPE, "ESCAPE", _s("Escape"), "ESCAPE", "JOY_Y" },
 	{ KEYBIND_NONE, nullptr, nullptr, nullptr, nullptr }
 };
 


Commit: 81ac36d5b5c31906bb596e0b1852dfb3e3b10b37
    https://github.com/scummvm/scummvm/commit/81ac36d5b5c31906bb596e0b1852dfb3e3b10b37
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Implement load_new_thor

Changed paths:
    engines/got/gfx/image.cpp


diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index 9ac831478cc..206930d077c 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -295,12 +295,9 @@ void setup_magic_item(int item) {
 }
 
 void load_new_thor() {
-#ifdef TODO
-	int rep;
 	byte *ami;
 	byte *mb;
 
-
 	mb = _G(mask_buff);
 	ami = _G(ami_buff);
 
@@ -308,21 +305,12 @@ void load_new_thor() {
 	_G(ami_buff) = _G(ami_store1);
 
 	load_actor(0, 100 + _G(thor_info).armor);   // Load thor
-	for (rep = 0; rep < 16; rep++) {
-		make_mask(&_G(actor)[0].pic[rep / 4][rep % 4], PAGE3 + (144 * rep), &_G(tmp_buff)[256 * rep], 16, 16);
-	}
-	_G(mask_buff) = _G(mask_store2);
-	_G(ami_buff) = _G(ami_store2);
-	load_actor(0, 103 + _G(thor_info).armor);   // Load hammer
-	for (rep = 0; rep < 16; rep++) {
-		make_mask(&_G(actor)[1].pic[rep / 4][rep % 4], 52464u + (144 * rep), &_G(tmp_buff)[256 * rep], 16, 16);
-	}
+
+	// TODO: Confirm if this is an okay replacement for original mask code
+	make_actor_surface(&_G(actor)[0]);
 
 	_G(ami_buff) = ami;
 	_G(mask_buff) = mb;
-#else
-	error("TODO: load_new_thor");
-#endif
 }
 
 } // namespace Got


Commit: 95d55c84b4063da927ba516d35c83fe1f8df6ffe
    https://github.com/scummvm/scummvm/commit/95d55c84b4063da927ba516d35c83fe1f8df6ffe
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Don't draw hammer when not in use

Changed paths:
    engines/got/views/game_content.cpp


diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index a2e15a49bc3..c99fdf907f5 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -117,7 +117,7 @@ void GameContent::drawEnemies(GfxSurface &s, ACTOR *lastActor) {
 
 	for (int actor_num = 0; actor_num <= MAX_ACTORS; ) {
 		// Check for blinking flag
-		if (!(actor_ptr->show & 2)) {
+		if (actor_ptr->used && !(actor_ptr->show & 2)) {
 			actor_ptr->last_x[0] = actor_ptr->x;
 			actor_ptr->last_y[0] = actor_ptr->y;
 


Commit: 5491cdb7c1a40a06bc4d1738068b2fab72c28ae2
    https://github.com/scummvm/scummvm/commit/5491cdb7c1a40a06bc4d1738068b2fab72c28ae2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Add proper decrementing of dead in unused actors

Changed paths:
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index c99fdf907f5..a447fc5dcc1 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -72,6 +72,7 @@ bool GameContent::tick() {
 	moveActors();
 	use_item();
 
+	updateActors();
 	return false;
 }
 
@@ -210,7 +211,15 @@ void GameContent::moveActors() {
 	int thor_pos = _G(thor)->getPos();
 	_G(thor)->center_x = thor_pos % 20;
 	_G(thor)->center_y = thor_pos / 20;
+}
+
+void GameContent::updateActors() {
+	for (int i = 0; i < MAX_ACTORS; ++i) {
+		ACTOR *actor = &_G(actor)[i];
 
+		if (!actor->used && actor->dead > 0)
+			actor->dead--;
+	}
 }
 
 } // namespace Views
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index accf0934289..4b24afbec57 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -39,6 +39,7 @@ private:
 	void checkSwitchFlag();
 	void checkForItem();
 	void moveActors();
+	void updateActors();
 
 public:
 	GameContent() : View("GameContent") {}


Commit: 17dc5a72d2f078ecce517c18c6d651d148c9d7ed
    https://github.com/scummvm/scummvm/commit/17dc5a72d2f078ecce517c18c6d651d148c9d7ed
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Clean up constant arrays in script.cpp

Changed paths:
    engines/got/game/script.cpp


diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index addf18d9938..0c8e9b47381 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -35,43 +35,43 @@ namespace Got {
 #define ERROR_MAX 10
 #define SCR_BUFF_SIZE 5000
 
-static const char *scr_command[] = {
-	"!@#$%","END","GOTO","GOSUB","RETURN","FOR","NEXT",
-	"IF","ELSE","RUN",
-	"ADDJEWELS","ADDHEALTH","ADDMAGIC","ADDKEYS",
-	"ADDSCORE","SAY","ASK","SOUND","PLACETILE",
-	"ITEMGIVE","ITEMTAKE","ITEMSAY","SETFLAG","LTOA",
-	"PAUSE","TEXT","EXEC","VISIBLE","RANDOM",
+static const char *SCR_COMMAND[] = {
+	"!@#$%", "END", "GOTO", "GOSUB", "RETURN", "FOR", "NEXT",
+	"IF", "ELSE", "RUN",
+	"ADDJEWELS", "ADDHEALTH", "ADDMAGIC", "ADDKEYS",
+	"ADDSCORE", "SAY", "ASK", "SOUND", "PLACETILE",
+	"ITEMGIVE", "ITEMTAKE", "ITEMSAY", "SETFLAG", "LTOA",
+	"PAUSE", "TEXT", "EXEC", "VISIBLE", "RANDOM",
 	NULL
 };
 
-static const char *internal_variable[] = {
-	"@JEWELS","@HEALTH","@MAGIC","@SCORE",
-	"@SCREEN","@KEYS",
-	"@OW","@GULP","@SWISH","@YAH","@ELECTRIC",
-	"@THUNDER","@DOOR","@FALL","@ANGEL","@WOOP",
-	"@DEAD","@BRAAPP","@WIND","@PUNCH","@CLANG",
-	"@EXPLODE","@FLAG","@ITEM","@THORTILE",
+static const char *INTERNAL_VARIABLE[] = {
+	"@JEWELS", "@HEALTH", "@MAGIC", "@SCORE",
+	"@SCREEN", "@KEYS",
+	"@OW", "@GULP", "@SWISH", "@YAH", "@ELECTRIC",
+	"@THUNDER", "@DOOR", "@FALL", "@ANGEL", "@WOOP",
+	"@DEAD", "@BRAAPP", "@WIND", "@PUNCH", "@CLANG",
+	"@EXPLODE", "@FLAG", "@ITEM", "@THORTILE",
 	"@THORPOS",
 	NULL
 };
 
-static const char *scr_error[] = {
-	"!@#$%","Out of Memory","Can't Read Script",
-	"Too Many Labels","No END",
-	"Syntax","Out of Range","Undefined Label",
-	"RETURN Without GOSUB","Nesting",
+static const char *SCR_ERROR[] = {
+	"!@#$%", "Out of Memory", "Can't Read Script",
+	"Too Many Labels", "No END",
+	"Syntax", "Out of Range", "Undefined Label",
+	"RETURN Without GOSUB", "Nesting",
 	"NEXT Without FOR",
 	NULL
 };
 
-static const char *offense[] = {
-	"Cussing","Rebellion","Kissing Your Mother Goodbye",
-	"Being a Thunder God","Door-to-Door Sales",
+static const char *OFFENSE[] = {
+	"Cussing", "Rebellion", "Kissing Your Mother Goodbye",
+	"Being a Thunder God", "Door-to-Door Sales",
 	"Carrying a Concealed Hammer"
 };
 
-static const char *reason[] = {
+static const char *REASON[] = {
 	"We heard you say 'Booger'.",
 	"You look kind of rebellious.",
 	"Your mother turned you in.",
@@ -184,11 +184,11 @@ int Scripts::get_command() {
 
 	i = 0;
 	while (1) {
-		if (!scr_command[i])
+		if (!SCR_COMMAND[i])
 			break;           // Lookup command
 
-		len = strlen(scr_command[i]);
-		if (!strncmp(buff_ptr, (char *)scr_command[i], len)) {
+		len = strlen(SCR_COMMAND[i]);
+		if (!strncmp(buff_ptr, (char *)SCR_COMMAND[i], len)) {
 			buff_ptr += len;
 			return i;
 		}
@@ -373,9 +373,9 @@ int Scripts::get_internal_variable() {
 
 	i = 0;
 	while (1) {
-		if (!internal_variable[i]) return 0;         // Lookup internal variable
-		len = strlen(internal_variable[i]);
-		if (!strncmp(buff_ptr, internal_variable[i], len)) {
+		if (!INTERNAL_VARIABLE[i]) return 0;         // Lookup internal variable
+		len = strlen(INTERNAL_VARIABLE[i]);
+		if (!strncmp(buff_ptr, INTERNAL_VARIABLE[i], len)) {
 			buff_ptr += len;
 			break;
 		}
@@ -588,7 +588,7 @@ void Scripts::script_error(int err_num) {
 	if (err_num > ERROR_MAX)
 		err_num = 5;       // unknown=syntax
 
-	warning("%s in Line #%d", scr_error[err_num], line_num);
+	warning("%s in Line #%d", SCR_ERROR[err_num], line_num);
 }
 
 int Scripts::cmd_goto() {
@@ -943,8 +943,8 @@ void Scripts::scr_func2() {
 	int r;
 
 	r = g_events->getRandomNumber(5);
-	Common::strcpy_s(str_var[0], 81, offense[r]);
-	Common::strcpy_s(str_var[1], 81, reason[r]);
+	Common::strcpy_s(str_var[0], 81, OFFENSE[r]);
+	Common::strcpy_s(str_var[1], 81, REASON[r]);
 }
 
 void Scripts::scr_func3() {


Commit: d14c5bec8b8e9c6e7f0c06af123a9a21fd97c241
    https://github.com/scummvm/scummvm/commit/d14c5bec8b8e9c6e7f0c06af123a9a21fd97c241
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Add support for script parser to be paused

This will be used for opcodes like ASK, where it displays
a dialog prompting the user to pick an option. The script
parser will be paused when the dialog is shown, and then
resumed once the option is chosen.

Changed paths:
    engines/got/game/script.cpp
    engines/got/game/script.h


diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 0c8e9b47381..9080cdd5c45 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -103,8 +103,6 @@ Scripts::~Scripts() {
 }
 
 void Scripts::execute_script(long index, Gfx::Pics *pic) {
-	int i, ret, re_execute;
-
 	// Firstly hide any on-screen actors
 	g_events->send(GameMessage("HIDE_ACTORS"));
 
@@ -113,9 +111,11 @@ void Scripts::execute_script(long index, Gfx::Pics *pic) {
 
 	Common::fill(num_var, num_var + 26, 0);
 	Common::fill((char *)str_var, (char *)str_var + 81 * 26, 0);
+	runScript();
+}
 
-	re_execute = 0;
-run_script:                            // Jump point for RUN command
+void Scripts::runScript(bool firstTime) {
+	int i;
 
 	// Clear line label buffer, line ptrs, and the gosub stack
 	Common::fill((char *)line_label, (char *)line_label + 32 * 9, 0);
@@ -123,11 +123,9 @@ run_script:                            // Jump point for RUN command
 	Common::fill(gosub_stack, gosub_stack + 32, (char *)nullptr);
 	gosub_ptr = 0;
 
-	for (i = 0; i < 11; i++) {
-		for_var[i] = 0;
-		for_val[i] = 0;
-		for_stack[i] = 0;
-	}
+	Common::fill(for_var, for_var + 11, 0);
+	Common::fill(for_val, for_val + 11, 0);
+	Common::fill(for_stack, for_stack + 11, (char *)nullptr);
 	for_ptr = 0;
 
 	i = read_script_file();
@@ -136,27 +134,36 @@ run_script:                            // Jump point for RUN command
 		script_exit();
 		return;
 	}
-	if (!re_execute)
+
+	if (firstTime)
 		script_entry();
 
 	buff_ptr = buffer;
+	scriptLoop();
+}
+
+void Scripts::scriptLoop() {
+	int ret;
 
-	for (;;) {
+	while (!_paused) {
 		if (_G(cheat) && _G(key_flag)[_B]) break;
 		ret = get_command();
 		if (ret == -1)
-			break;       // ignore NO END error
+			break;       // Ignore NO END error
 		else if (ret == -2) {
-			script_error(5);       // syntax error
+			script_error(5);       // Syntax error
 			break;
 		} else if (ret > 0) {
 			ret = exec_command(ret);
-			if (ret == -100) {         //RUN command
-				re_execute = 1;
-				if (buffer) free(buffer);
-				goto run_script;
+			if (ret == -100) {         // RUN command
+				if (buffer)
+					free(buffer);
+
+				runScript(false);
+				return;
 			}
-			if (!ret) break;
+			if (!ret)
+				break;
 		}
 	}
 
@@ -892,7 +899,7 @@ int Scripts::cmd_pause() {
 	if (lvalue < 1 || lvalue>65535l)
 		return 6;
 
-	pause((int)lvalue);
+	Got::pause((int)lvalue);
 	return 0;
 }
 
diff --git a/engines/got/game/script.h b/engines/got/game/script.h
index e281e017472..a5544deb412 100644
--- a/engines/got/game/script.h
+++ b/engines/got/game/script.h
@@ -39,8 +39,8 @@ private:
 	char  gosub_ptr = 0;           // GOSUB stack pointer
 	char  *for_stack[10] = {};     // FOR stack
 	long  for_val[10] = {};        // current FOR value
-	char  for_var[10] = {};        // ending FOR value (target var)
-	char  for_ptr = 0;	           // FOR stack pointer
+	int8  for_var[10] = {};        // ending FOR value (target var)
+	int8  for_ptr = 0;	           // FOR stack pointer
 	char  *buff_ptr = nullptr;     // pointer to current command
 	char  *buff_end = nullptr;	   // pointer to end of buffer
 	char  *buffer = nullptr;       // buffer space (alloc'ed)
@@ -49,6 +49,7 @@ private:
 	long  lvalue = 0;
 	long  ltemp = 0;
 	char  temps[255] = {};
+	bool _paused = false;
 
 private:
 	int  read_script_file();
@@ -95,11 +96,22 @@ private:
 	typedef void (Scripts:: *ScrFunction)();
 	static ScrFunction scr_func[5];
 
+	void runScript(bool firstTime = true);
+	void scriptLoop();
+
 public:
 	Scripts();
 	~Scripts();
 
 	void execute_script(long index, Gfx::Pics *pic);
+
+	void pause() {
+		_paused = true;
+	}
+	void resume() {
+		_paused = false;
+		scriptLoop();
+	}
 };
 
 extern void execute_script(long index, Gfx::Pics *pic);


Commit: d5e79f30e1812030f3efa06691aef0cffee8d764
    https://github.com/scummvm/scummvm/commit/d5e79f30e1812030f3efa06691aef0cffee8d764
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Adding Ask view for script-based queries

Changed paths:
  A engines/got/views/dialogs/ask.cpp
  A engines/got/views/dialogs/ask.h
    engines/got/game/script.cpp
    engines/got/game/script.h
    engines/got/module.mk
    engines/got/views/dialogs/select_option.cpp
    engines/got/views/dialogs/select_option.h
    engines/got/views/views.h


diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 9080cdd5c45..524cfe59e2a 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -27,6 +27,7 @@
 #include "got/game/status.h"
 #include "got/gfx/image.h"
 #include "got/utils/file.h"
+#include "got/views/dialogs/ask.h"
 #include "got/events.h"
 #include "got/vars.h"
 
@@ -750,51 +751,65 @@ int Scripts::cmd_say(int mode, int type) {
 }
 
 int Scripts::cmd_ask() {
-#ifdef TODO
-	int i, v, p;
-	char title[41];
-	char *op[] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
-	char opts[10][41];
+	int v = 0;
+	uint p;
+	char title[41], opt[41];
+	Common::StringArray opts;
 
 	memset(_G(tmp_buff), 0, TMP_SIZE);
-	memset(opts, 0, 10 * 41);
 
-	if (!skip_colon()) return 5;
+	if (!skip_colon())
+		return 5;
 
 	if (Common::isAlpha(*buff_ptr)) {
 		v = *buff_ptr - 65;
 		buff_ptr++;
 		if (*buff_ptr != ',') return 5;
 		buff_ptr++;
-	} else return 5;
+	} else {
+		return 5;
+	}
 
-	if (!calc_string(1)) return 5;
+	if (!calc_string(1))
+		return 5;
 
 	strncpy(title, temps, 41);
 	title[40] = 0;
 
 	if (*buff_ptr == ',') {
 		buff_ptr++;
-		if (!calc_value()) return 5;
+		if (!calc_value())
+			return 5;
+
 		buff_ptr++;
-		p = (int)lvalue;
-	} else return 5;
+		p = lvalue;
+	} else {
+		return 5;
+	}
+
+	_askVar = v;
 
-	i = 0;
 	while (calc_string(0)) {
-		strncpy((char *) opts[i], temps, 41);
-		opts[i][40] = 0;
-		op[i] = opts[i];
-		i++;
-		if (i > 9) return 3;
+		Common::strcpy_s(opt, temps);
+		opts.push_back(opt);
+
+		if (opts.size() > 9)
+			return 3;
 	}
-	if (p > i) p = 0;
-	num_var[v] = select_option(op, title, p - 1);
-	d_restore();
+
+	if (p > opts.size())
+		p = 0;
+
+	// Pause the script execution, and open up an ask window.
+	// Execution of the script will resume after a selection.
+	pause();
+	Views::Dialogs::Ask::show(title, opts);
 	return 0;
-#else
-	error("TODO: cmd_ask");
-#endif
+}
+
+void Scripts::setAskResponse(int option) {
+	num_var[_askVar] = option;
+	resume();
 }
 
 int Scripts::cmd_sound() {
diff --git a/engines/got/game/script.h b/engines/got/game/script.h
index a5544deb412..41e47d72e55 100644
--- a/engines/got/game/script.h
+++ b/engines/got/game/script.h
@@ -50,6 +50,7 @@ private:
 	long  ltemp = 0;
 	char  temps[255] = {};
 	bool _paused = false;
+	int _askVar = -1;
 
 private:
 	int  read_script_file();
@@ -112,6 +113,8 @@ public:
 		_paused = false;
 		scriptLoop();
 	}
+
+	void setAskResponse(int option);
 };
 
 extern void execute_script(long index, Gfx::Pics *pic);
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 341323e722a..432cb858652 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -43,6 +43,7 @@ MODULE_OBJS = \
 	views/title.o \
 	views/dialogs/dialog.o \
 	views/dialogs/select_option.o \
+	views/dialogs/ask.o \
 	views/dialogs/main_menu.o \
 	views/dialogs/options_menu.o \
 	views/dialogs/play_game.o \
diff --git a/engines/got/views/dialogs/ask.cpp b/engines/got/views/dialogs/ask.cpp
new file mode 100644
index 00000000000..6d254088277
--- /dev/null
+++ b/engines/got/views/dialogs/ask.cpp
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/ask.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+Ask::Ask() : SelectOption("Ask") {
+}
+
+void Ask::show(const Common::String &title, const Common::StringArray &options) {
+	Ask *view = (Ask *)g_events->findView("Ask");
+	view->setContent(title, options);
+	view->addView();
+}
+
+void Ask::closed() {
+	_G(scripts).setAskResponse(_selectedItem + 1);
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/ask.h b/engines/got/views/dialogs/ask.h
new file mode 100644
index 00000000000..096242df49c
--- /dev/null
+++ b/engines/got/views/dialogs/ask.h
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_ASK_H
+#define GOT_VIEWS_DIALOGS_ASK_H
+
+#include "got/views/dialogs/select_option.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class Ask : public SelectOption {
+public:
+	Ask();
+	virtual ~Ask() {}
+
+	static void show(const Common::String &title,
+		const Common::StringArray &options);
+	void closed() override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/dialogs/select_option.cpp b/engines/got/views/dialogs/select_option.cpp
index 5284c6fc843..1edb0a0cd2f 100644
--- a/engines/got/views/dialogs/select_option.cpp
+++ b/engines/got/views/dialogs/select_option.cpp
@@ -31,16 +31,26 @@ const char *ON_OFF[] = { "On", "Off", nullptr };
 const char *YES_NO[] = { "Yes", "No", nullptr };
 
 SelectOption::SelectOption(const Common::String &name, const char *title,
-		const char *options[]) :
-		Dialog(name), _title(title) {
-	// Load the options list into the string array
+		const char *options[]) : Dialog(name) {
+	// Set up string array of options
+	Common::StringArray optionsArray;
 	for (const char **option = options; *option; ++option)
-		_options.push_back(*option);
+		optionsArray.push_back(*option);
+
+	setContent(title, optionsArray);
+}
+
+SelectOption::SelectOption(const Common::String &name) : Dialog(name) {
+}
+
+void SelectOption::setContent(const Common::String &title,
+		const Common::StringArray &options) {
+	_title = title;
 
 	// Calculate the bounds for the dialog
 	int w, h, x1, y1, x2, y2;
 
-	w = strlen(title);
+	w = title.size();
 	for (uint i = 0; i < _options.size(); ++i)
 		w = MAX(w, (int)_options[i].size());
 
@@ -106,6 +116,7 @@ bool SelectOption::msgAction(const ActionMessage &msg) {
 		break;
 
 	case KEYBIND_ESCAPE:
+		_selectedItem = -1;
 		closed();
 
 	default:
diff --git a/engines/got/views/dialogs/select_option.h b/engines/got/views/dialogs/select_option.h
index a4d2cbd1f94..55e4f6bd48b 100644
--- a/engines/got/views/dialogs/select_option.h
+++ b/engines/got/views/dialogs/select_option.h
@@ -44,6 +44,8 @@ private:
 protected:
 	int _selectedItem = 0;
 
+	void setContent(const Common::String &title,
+		const Common::StringArray &options);
 	virtual void closed() {
 		close();
 	}
@@ -52,8 +54,8 @@ protected:
 public:
 	SelectOption(const Common::String &name, const char *title,
 		const char *options[]);
-	virtual ~SelectOption() {
-	}
+	SelectOption(const Common::String &name);
+	virtual ~SelectOption() {}
 
 	bool msgFocus(const FocusMessage &msg) override {
 		_selectedItem = 0;
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index 1af061f67ea..94f3b446433 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -26,6 +26,7 @@
 #include "got/views/part_title.h"
 #include "got/views/story.h"
 #include "got/views/title.h"
+#include "got/views/dialogs/ask.h"
 #include "got/views/dialogs/main_menu.h"
 #include "got/views/dialogs/options_menu.h"
 #include "got/views/dialogs/quit.h"
@@ -43,6 +44,7 @@ struct Views {
 	Story _story;
 	Title _title;
 
+	Dialogs::Ask _ask;
 	Dialogs::MainMenu _mainMenu;
 	Dialogs::OptionsMenu _optionsMenu;
 	Dialogs::Quit _quit;


Commit: 20873350f8d1c1acdc2c2ffec65213e7dc737499
    https://github.com/scummvm/scummvm/commit/20873350f8d1c1acdc2c2ffec65213e7dc737499
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added Say dialog

Changed paths:
  A engines/got/views/dialogs/say.cpp
  A engines/got/views/dialogs/say.h
    engines/got/game/script.cpp
    engines/got/gfx/font.cpp
    engines/got/gfx/font.h
    engines/got/module.mk
    engines/got/vars.h
    engines/got/views/views.h


diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 524cfe59e2a..70a5340139b 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -24,10 +24,12 @@
 #include "got/game/back.h"
 #include "got/game/main.h"
 #include "got/game/object.h"
+#include "got/game/panel.h"
 #include "got/game/status.h"
 #include "got/gfx/image.h"
 #include "got/utils/file.h"
 #include "got/views/dialogs/ask.h"
+#include "got/views/dialogs/say.h"
 #include "got/events.h"
 #include "got/vars.h"
 
@@ -168,12 +170,15 @@ void Scripts::scriptLoop() {
 		}
 	}
 
-	script_exit();
+	if (!_paused)
+		script_exit();
 }
 
 void Scripts::script_exit() {
-	if (buffer)
+	if (buffer) {
 		free(buffer);
+		buffer = nullptr;
+	}
 }
 
 int Scripts::skip_colon() {
@@ -719,7 +724,6 @@ int Scripts::cmd_addscore() {
 }
 
 int Scripts::cmd_say(int mode, int type) {
-#ifdef TODO
 	char *p;
 	int obj;
 
@@ -742,12 +746,10 @@ int Scripts::cmd_say(int mode, int type) {
 	}
 	*(p - 1) = 0;
 
-	display_speech(obj, (char *)scr_pic, type);
-	d_restore();
+	pause();
+	Views::Dialogs::Say::show(obj, scr_pic, type);
+
 	return 0;
-#else
-	error("TODO: cmd_say");
-#endif
 }
 
 int Scripts::cmd_ask() {
diff --git a/engines/got/gfx/font.cpp b/engines/got/gfx/font.cpp
index b3ede04261e..adfee9403ae 100644
--- a/engines/got/gfx/font.cpp
+++ b/engines/got/gfx/font.cpp
@@ -26,7 +26,7 @@
 namespace Got {
 namespace Gfx {
 
-static const byte DIALOG_COLOR[] = { 14,54,120,138,15,0,0,0,0,0,0,0,0,0,0,0 };
+const byte DIALOG_COLOR[] = { 14,54,120,138,15,0,0,0,0,0,0,0,0,0,0,0 };
 
 void Font::load() {
 	Common::File f;
diff --git a/engines/got/gfx/font.h b/engines/got/gfx/font.h
index 7c7be236851..106869b300d 100644
--- a/engines/got/gfx/font.h
+++ b/engines/got/gfx/font.h
@@ -29,6 +29,8 @@
 namespace Got {
 namespace Gfx {
 
+extern const byte DIALOG_COLOR[];
+
 class Font : public Graphics::Font {
 private:
 	Common::Array<Graphics::ManagedSurface> _font;
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 432cb858652..7ccd413e19c 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -49,6 +49,7 @@ MODULE_OBJS = \
 	views/dialogs/play_game.o \
 	views/dialogs/quit.o \
 	views/dialogs/quit_game.o \
+	views/dialogs/say.o \
 	views/dialogs/select_game.o \
 	views/dialogs/select_item.o \
 	views/dialogs/set_sound.o
diff --git a/engines/got/vars.h b/engines/got/vars.h
index e718c8a2fe2..90610a4bdd7 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -212,10 +212,6 @@ public:
 
 #define _G(X) (g_vars->_##X)
 
-extern byte dialog_color[];
-extern const char *options_yesno[];
-extern const char *save_filename;
-
 } // namespace Got
 
 #endif
diff --git a/engines/got/views/dialogs/say.cpp b/engines/got/views/dialogs/say.cpp
new file mode 100644
index 00000000000..f17faefac3c
--- /dev/null
+++ b/engines/got/views/dialogs/say.cpp
@@ -0,0 +1,190 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/say.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+#define _HRZSP 24
+
+Say::Say() : Dialog("Say") {
+	setBounds(Common::Rect(32, 48, 288, 160));
+}
+
+void Say::show(int item, Gfx::Pics *pic, int type) {
+	Say *view = (Say *)g_events->findView("Say");
+	view->_item = item;
+	view->_pic = pic;
+	view->_type = type;
+	view->addView();
+}
+
+bool Say::msgFocus(const FocusMessage &msg) {
+	if (!_type)
+		play_sound(WOOP, 1);
+
+	_content = (const char *)_G(tmp_buff);
+	_contentLength = 0;
+	_waitForResponse = WAIT_NONE;
+	_woopCtr = 0;
+	_picIndex = 0;
+
+	return true;
+}
+
+bool Say::msgUnfocus(const UnfocusMessage &msg) {
+	// Since the Ask dialog is shown by scripts, closing the view
+	// starts the calling script running again
+	_G(scripts).resume();
+	return true;
+}
+
+void Say::draw() {
+	Dialog::draw();
+	GfxSurface s = getSurface();
+
+	s.blitFrom((*_pic)[_picIndex], Common::Point(120, 17));
+	if (_item)
+		s.blitFrom(_G(objects)[_item], Common::Point(160, 17));
+
+	const char *p = _content;
+	const char *endP = _content + _contentLength;
+	int color = 14;
+	int x = 20, lc = 0;
+	int ch;
+
+	while (p < endP) {
+		if (*p == '~' && Common::isXDigit(*(p + 1))) {
+			p++;
+			ch = *p;
+			p++;
+			if (Common::isDigit(ch))
+				ch -= '0';
+			else
+				ch = toupper(ch) - 'A' + 10;
+
+			color = Gfx::DIALOG_COLOR[ch];
+			continue;
+		}
+
+		if (*p == '\n') {
+			x = 20;
+			lc++;
+			if (lc > 4) {
+				// Got a full text to display
+				if (_waitForResponse == WAIT_NONE)
+					_waitForResponse = WAIT_MORE;
+				_picIndex = 1;
+				break;
+			}
+
+			p++;
+			continue;
+		}
+
+		s.printChar(*p, x, 35 + (lc * 10), color);
+
+		p++;
+		x += 8;
+	}
+
+	if (_waitForResponse == WAIT_MORE)
+		s.print(Common::Point(184, 86), "More...", 15);
+}
+
+bool Say::msgKeypress(const KeypressMessage &msg) {
+	if (_waitForResponse == WAIT_DONE) {
+		close();
+	} else if (_waitForResponse == WAIT_MORE) {
+		_waitForResponse = WAIT_NONE;
+		_content = _content + _contentLength;
+		_contentLength = 0;
+		redraw();
+	} else {
+		showEntirePage();
+		redraw();
+	}
+
+	return false;
+}
+
+bool Say::msgAction(const ActionMessage &msg) {
+	if (msg._action == KEYBIND_ESCAPE || _waitForResponse == WAIT_DONE) {
+		close();
+	} else if (_waitForResponse == WAIT_MORE) {
+		_waitForResponse = WAIT_NONE;
+		_content = _content + _contentLength;
+		_contentLength = 0;
+		redraw();
+	} else {
+		showEntirePage();
+		redraw();
+	}
+
+	return true;
+}
+
+bool Say::tick() {
+	if (_waitForResponse == WAIT_NONE) {
+		const char *contentEnd = _content + ++_contentLength;
+
+		if (*contentEnd == '~' && Common::isXDigit(*(contentEnd + 1)))
+			++_contentLength;
+
+		if (!*contentEnd) {
+			// Reached end of text to display
+			_waitForResponse = WAIT_DONE;
+			_picIndex = 1;
+		} else if (++_picIndex > 3) {
+			_picIndex = 0;
+		}
+
+		if (_type && ++_woopCtr > 5) {
+			play_sound(WOOP, 1);
+		}
+
+		redraw();
+	}
+
+	return true;
+}
+
+void Say::showEntirePage() {
+	int lc = 0;
+	char c;
+
+	for (_contentLength = 0; (c = *(_content + _contentLength)) != 0; ++_contentLength) {
+		if (c == '~' && Common::isXDigit(*(_content + _contentLength + 1)))
+			++_contentLength;
+		else if (c == '\n') {
+			if (++lc > 4)
+				break;
+		}
+	}
+}
+
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/say.h b/engines/got/views/dialogs/say.h
new file mode 100644
index 00000000000..cdb2081c067
--- /dev/null
+++ b/engines/got/views/dialogs/say.h
@@ -0,0 +1,69 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_SAY_H
+#define GOT_VIEWS_DIALOGS_SAY_H
+
+#include "got/views/dialogs/dialog.h"
+#include "got/gfx/gfx_pics.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class Say : public Dialog {
+	enum WaitResponse {
+		WAIT_NONE, WAIT_MORE, WAIT_DONE
+	};
+private:
+	Gfx::Pics *_pic = nullptr;
+	int _item = 0;
+	int _type = 0;
+	int _picIndex = 0;
+	const char *_content = nullptr;
+	int _contentLength = 0;
+	int _woopCtr = 0;
+	WaitResponse _waitForResponse = WAIT_NONE;
+
+	/**
+	 * Advance to showing the entirety of the current page
+	 */
+	void showEntirePage();
+
+public:
+	Say();
+	virtual ~Say() {}
+
+	static void show(int item, Gfx::Pics *pic, int type);
+
+	void draw() override;
+	bool msgFocus(const FocusMessage &msg) override;
+	bool msgUnfocus(const UnfocusMessage &msg) override;
+	bool msgKeypress(const KeypressMessage &msg) override;
+	bool msgAction(const ActionMessage &msg) override;
+	bool tick() override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index 94f3b446433..7ea6d92e078 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -31,6 +31,7 @@
 #include "got/views/dialogs/options_menu.h"
 #include "got/views/dialogs/quit.h"
 #include "got/views/dialogs/quit_game.h"
+#include "got/views/dialogs/say.h"
 #include "got/views/dialogs/select_game.h"
 #include "got/views/dialogs/select_item.h"
 #include "got/views/dialogs/set_sound.h"
@@ -49,6 +50,7 @@ struct Views {
 	Dialogs::OptionsMenu _optionsMenu;
 	Dialogs::Quit _quit;
 	Dialogs::QuitGame _quitGame;
+	Dialogs::Say _say;
 	Dialogs::SelectGame _selectGame;
 	Dialogs::SelectItem _selectItem;
 	Dialogs::SetSound _setSound;


Commit: 4591c4e4321fadf948a4ad432f97c45afd918e95
    https://github.com/scummvm/scummvm/commit/4591c4e4321fadf948a4ad432f97c45afd918e95
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Compilation fixes

Changed paths:
    engines/got/data/level.cpp
    engines/got/data/level.h
    engines/got/data/sd_data.h
    engines/got/game/back.cpp
    engines/got/game/object.cpp
    engines/got/game/script.cpp
    engines/got/game/script.h


diff --git a/engines/got/data/level.cpp b/engines/got/data/level.cpp
index 3b76795a7f5..c5e4796106d 100644
--- a/engines/got/data/level.cpp
+++ b/engines/got/data/level.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "common/memstream.h"
 #include "got/data/defines.h"
 
 namespace Got {
@@ -51,6 +52,27 @@ void LEVEL::sync(Common::Serializer &s) {
 	s.syncBytes(future, 3);
 }
 
+void LEVEL::load(Common::SeekableReadStream *src) {
+	Common::Serializer s(src, nullptr);
+	sync(s);
+}
+
+void LEVEL::save(Common::WriteStream *dest) {
+	Common::Serializer s(nullptr, dest);
+	sync(s);
+}
+
+void LEVEL::load(const byte *src) {
+	Common::MemoryReadStream stream(src, 512);
+	load(&stream);
+}
+
+void LEVEL::save(byte *dest) {
+	Common::MemoryWriteStream stream(dest, 512);
+	save(&stream);
+}
+
+
 void ACTOR::loadFixed(Common::SeekableReadStream *src) {
 	move = src->readByte();
 	width = src->readByte();
diff --git a/engines/got/data/level.h b/engines/got/data/level.h
index cfaa4c418d6..c7e2211b4fc 100644
--- a/engines/got/data/level.h
+++ b/engines/got/data/level.h
@@ -49,14 +49,10 @@ struct LEVEL {                    // size=512
 	byte future[3] = {};          // 473
 
 	void sync(Common::Serializer &s);
-	void load(Common::SeekableReadStream *src) {
-		Common::Serializer s(src, nullptr);
-		sync(s);
-	}
-	void save(Common::WriteStream *dest) {
-		Common::Serializer s(nullptr, dest);
-		sync(s);
-	}
+	void load(Common::SeekableReadStream *src);
+	void save(Common::WriteStream * dest);
+	void load(const byte *src);
+	void save(byte *dest);
 };
 
 } // namespace Got
diff --git a/engines/got/data/sd_data.h b/engines/got/data/sd_data.h
index fbbd8b81190..208763e8e15 100644
--- a/engines/got/data/sd_data.h
+++ b/engines/got/data/sd_data.h
@@ -52,6 +52,9 @@ public:
 	operator const byte *() const {
 		return _data;
 	}
+	operator byte *() {
+		return _data;
+	}
 };
 
 } // namespace Got
diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index b6ff01ffd5b..97456f82e3d 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -250,31 +250,35 @@ dead:
 }
 
 void remove_objects(int y, int x) {
-	int p, ix, iy;
+	int p;
 
 	p = (y * 20) + x;
-	ix = x * 16;
-	iy = y * 16;
 
 	if (_G(object_map)[p] > 0) {
-		//xfput(ix, iy, PAGE2, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
-		//xfput(ix, iy, PAGE2, (char far *) (bg_pics + (_G(scrn).icon[y][x] * 262)));
-		//xcopyd2d(ix, iy, ix + 16, iy + 16, ix, iy, PAGE2, draw_page, 320, 320);
+#if 0
+		ix = x * 16;
+		iy = y * 16;
+		xfput(ix, iy, PAGE2, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
+		xfput(ix, iy, PAGE2, (char far *) (bg_pics + (_G(scrn).icon[y][x] * 262)));
+		xcopyd2d(ix, iy, ix + 16, iy + 16, ix, iy, PAGE2, draw_page, 320, 320);
+#endif
 		_G(object_map)[p] = 0;
 		_G(object_index)[p] = 0;
 	}
 }
 
 void place_tile(int x, int y, int tile) {
+#if 0
 	int ix, iy;
 
 	ix = x * 16;
 	iy = y * 16;
 
-	//xfput(ix, iy, PAGE2, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
-	//xfput(ix, iy, PAGE2, (char far *) (bg_pics + (tile * 262)));
-	//xcopyd2d(ix, iy, ix + 16, iy + 16, ix, iy, PAGE2, draw_page, 320, 320);
-	//xcopyd2d(ix, iy, ix + 16, iy + 16, ix, iy, PAGE2, display_page, 320, 320);
+	xfput(ix, iy, PAGE2, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
+	xfput(ix, iy, PAGE2, (char far *) (bg_pics + (tile * 262)));
+	xcopyd2d(ix, iy, ix + 16, iy + 16, ix, iy, PAGE2, draw_page, 320, 320);
+	xcopyd2d(ix, iy, ix + 16, iy + 16, ix, iy, PAGE2, display_page, 320, 320);
+#endif
 	_G(scrn).icon[y][x] = tile;
 	remove_objects(y, x);
 }
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index 75c6f4cbb6a..f8be9dec6a4 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -194,17 +194,19 @@ int drop_object(ACTOR *actr) {
 }
 
 int _drop_obj(ACTOR *actr, int o) {
-	int x, y, p;
+	int p;
 
 	p = (actr->x + (actr->size_x / 2)) / 16 + (((actr->y + (actr->size_y / 2)) / 16) * 20);
 	if (!_G(object_map)[p] && _G(scrn).icon[p / 20][p % 20] >= 140) {  //nothing there and solid
 		_G(object_map)[p] = o;
 		_G(object_index)[p] = 27 + actr->actor_num;  //actor is 3-15
+#if 0
 		x = (p % 20) * 16;
 		y = (p / 20) * 16;
-		//xfput(x, y, PAGE2, (char far *) objects[o - 1]);
-		//xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, draw_page, 320, 320);
-		//xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, display_page, 320, 320);
+		xfput(x, y, PAGE2, (char far *) objects[o - 1]);
+		xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, draw_page, 320, 320);
+		xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, display_page, 320, 320);
+#endif
 		return 1;
 	}
 
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 70a5340139b..2cd72c0fc1d 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -201,7 +201,7 @@ int Scripts::get_command() {
 			break;           // Lookup command
 
 		len = strlen(SCR_COMMAND[i]);
-		if (!strncmp(buff_ptr, (char *)SCR_COMMAND[i], len)) {
+		if (!strncmp(buff_ptr, SCR_COMMAND[i], len)) {
 			buff_ptr += len;
 			return i;
 		}
@@ -236,7 +236,7 @@ int Scripts::get_command() {
 int Scripts::calc_string(int mode) {
 	// if mode==1 stop at comma
 	char varstr[255];
-	char varnum;
+	uint varnum;
 
 	Common::strcpy_s(varstr, "");
 
@@ -512,7 +512,7 @@ int Scripts::read_script_file() {
 		ret = 6; goto done;
 	}
 
-	str = Common::String::format("|%d", scr_index);
+	str = Common::String::format("|%ld", scr_index);
 	Common::strcpy_s(temp_buff, str.c_str());
 
 	while (1) {
@@ -840,8 +840,10 @@ int Scripts::cmd_settile() {
 	if (screen == _G(current_level)) {
 		place_tile(pos % 20, pos / 20, tile);
 	} else {
-		lvl = (LEVEL *) (_G(sd_data) + (screen * 512));
-		lvl->icon[pos / 20][pos % 20] = tile;
+		LEVEL tmp;
+		tmp.load(_G(sd_data) + (screen * 512));
+		tmp.icon[pos / 20][pos % 20] = tile;
+		tmp.save(_G(sd_data) + (screen * 512));
 	}
 	return 0;
 }
@@ -892,7 +894,6 @@ int Scripts::cmd_setflag() {
 
 int Scripts::cmd_ltoa() {
 	int sv;
-	char str[21];
 
 	if (!calc_value()) return 5;
 	buff_ptr++;
@@ -904,8 +905,8 @@ int Scripts::cmd_ltoa() {
 		} else return 5;
 	} else return 5;
 
-	ltoa(lvalue, str, 10);
-	Common::strcpy_s(str_var[sv], (char *) str);
+	Common::String str = Common::String::format("%ld", lvalue);
+	Common::strcpy_s(str_var[sv], str.c_str());
 	return 0;
 }
 
diff --git a/engines/got/game/script.h b/engines/got/game/script.h
index 41e47d72e55..407f5e7b644 100644
--- a/engines/got/game/script.h
+++ b/engines/got/game/script.h
@@ -36,7 +36,7 @@ private:
 	char  *new_ptr = nullptr;
 	int   num_labels = 0;          // number of labels
 	char  *gosub_stack[32] = {};   // stack for GOSUB return addresses
-	char  gosub_ptr = 0;           // GOSUB stack pointer
+	int   gosub_ptr = 0;           // GOSUB stack pointer
 	char  *for_stack[10] = {};     // FOR stack
 	long  for_val[10] = {};        // current FOR value
 	int8  for_var[10] = {};        // ending FOR value (target var)


Commit: 01f7f63fbe0a58b2b8aa3a5b8777334af1f2608e
    https://github.com/scummvm/scummvm/commit/01f7f63fbe0a58b2b8aa3a5b8777334af1f2608e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Speed up gameplay to match original

Changed paths:
    engines/got/events.cpp


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 6376cec01fd..4f074a8dceb 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -89,6 +89,9 @@ void Events::runGame() {
 			rotatePalette();
 		}
 
+		// Do tick action to the views to handle gameplay logic
+		tick();
+
 		if ((currTime = g_system->getMillis()) >= nextFrameTime) {
 			nextFrameTime = currTime + FRAME_DELAY;
 			nextFrame();
@@ -105,9 +108,6 @@ void Events::nextFrame() {
 	_G(pge) = _G(pge) ^ 1;
 	_G(shot_ok) = true;
 
-	// Do once-per-frame tick action to the views
-	tick();
-
 	// Draw the current view's elements as needed, and update screen
 	drawElements();
 	_screen->update();


Commit: 8464712a9abed40ac1360655c2d3a7ed662cb175
    https://github.com/scummvm/scummvm/commit/8464712a9abed40ac1360655c2d3a7ed662cb175
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Introducing a new mode field for GameContent view

Changed paths:
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index a447fc5dcc1..99d05d56375 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -76,11 +76,6 @@ bool GameContent::tick() {
 	return false;
 }
 
-bool GameContent::canSaveLoad() const {
-	// TODO: Disallow saving during animations like scene changes or Thor dying
-	return true;
-}
-
 void GameContent::drawBackground(GfxSurface &s) {
 	for (int y = 0; y < TILES_Y; y++) {
 		for (int x = 0; x < TILES_X; x++) {
@@ -142,6 +137,8 @@ void GameContent::drawEnemies(GfxSurface &s, ACTOR *lastActor) {
 
 void GameContent::checkThunderShake() {
 	if (_G(thunder_flag)) {
+		_mode = MODE_THUNDER;
+
 		// Introduce a random screen shake by rendering screen 1 pixel offset randomly
 		static const int8 DELTA_X[4] = { -1, 1, 0, 0 };
 		static const int8 DELTA_Y[4] = { 0, 0, -1, 1 };
@@ -158,10 +155,11 @@ void GameContent::checkThunderShake() {
 			}
 		}
 
-		redraw();
+		if (!_G(thunder_flag)) {
+			_mode = MODE_NORMAL;
+			_shakeDelta = Common::Point(0, 0);
+		}
 
-	} else if (_shakeDelta.x != 0 || _shakeDelta.y != 0) {
-		_shakeDelta = Common::Point(0, 0);
 		redraw();
 	}
 }
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index 4b24afbec57..4801a8a9fc3 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -29,7 +29,12 @@ namespace Got {
 namespace Views {
 
 class GameContent : public View {
+	enum Mode {
+		MODE_NORMAL = 0, MODE_ROOM_CHANGE = 1, MODE_THUNDER = 2,
+		MODE_THOR_DIES = 3
+	};
 private:
+	Mode _mode = MODE_NORMAL;
 	Common::Point _shakeDelta;
 
 	void drawBackground(GfxSurface &s);
@@ -49,7 +54,9 @@ public:
 	bool msgGame(const GameMessage &msg) override;
 	bool tick() override;
 
-	bool canSaveLoad() const;
+	bool canSaveLoad() const {
+		return _mode == MODE_NORMAL;
+	}
 };
 
 } // namespace Views


Commit: 1e3e70d53fdc406e0088162adc3109cf71fbcb2f
    https://github.com/scummvm/scummvm/commit/1e3e70d53fdc406e0088162adc3109cf71fbcb2f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Implement area transitions

Changed paths:
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 99d05d56375..190aab0d39f 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -30,9 +30,13 @@
 namespace Got {
 namespace Views {
 
+GameContent::GameContent() : View("GameContent") {
+	_surface.create(320, 192);
+}
+
 void GameContent::draw() {
 	GfxSurface s;
-	if (_shakeDelta.x != 0 || _shakeDelta.y != 0) {
+	if (_mode == MODE_THUNDER || _mode == MODE_AREA_CHANGE) {
 		s.create(320, 192);
 	} else {
 		s = getSurface();
@@ -44,9 +48,43 @@ void GameContent::draw() {
 	drawEnemies(s, &_G(actor)[MAX_ACTORS - 1]);
 
 	// If we're shaking the screen, render the content with the shake X/Y
-	if (_shakeDelta.x != 0 || _shakeDelta.y != 0) {
+	if (_mode == MODE_THUNDER) {
+		GfxSurface win = getSurface();
+		win.clear();
+		win.blitFrom(s, _moveDelta);
+	} else if (_mode == MODE_AREA_CHANGE) {
+		// Draw parts of the new scene along with parts of the old one
+		// as it's scrolled off-screen
 		GfxSurface win = getSurface();
-		win.blitFrom(s, _shakeDelta);
+
+		switch (_transitionDir) {
+		case DIR_LEFT:
+			win.blitFrom(s, Common::Rect(320 - _transitionPos, 0, 320, 192),
+				Common::Point(0, 0));
+			win.blitFrom(_surface, Common::Rect(0, 0, 320 - _transitionPos, 192),
+				Common::Point(_transitionPos, 0));
+			break;
+		case DIR_RIGHT:
+			win.blitFrom(_surface, Common::Rect(_transitionPos, 0, 320, 192),
+				Common::Point(0, 0));
+			win.blitFrom(s, Common::Rect(0, 0, _transitionPos, 192),
+				Common::Point(320 - _transitionPos, 0));
+			break;
+		case DIR_UP:
+			win.blitFrom(s, Common::Rect(0, 192 - _transitionPos, 320, 192),
+				Common::Point(0, 0));
+			win.blitFrom(_surface, Common::Rect(0, 0, 320, 192 - _transitionPos),
+				Common::Point(0, _transitionPos));
+			break;
+		case DIR_DOWN:
+			win.blitFrom(_surface, Common::Rect(0, _transitionPos, 320, 192),
+				Common::Point(0, 0));
+			win.blitFrom(s, Common::Rect(0, 0, 320, _transitionPos),
+				Common::Point(0, 192 - _transitionPos));
+			break;
+		default:
+			break;
+		}
 	}
 }
 
@@ -67,12 +105,17 @@ bool GameContent::msgGame(const GameMessage &msg) {
 
 bool GameContent::tick() {
 	checkThunderShake();
-	checkSwitchFlag();
-	checkForItem();
-	moveActors();
-	use_item();
 
-	updateActors();
+	if (_mode == MODE_NORMAL) {
+		checkSwitchFlag();
+		checkForItem();
+		moveActors();
+		use_item();
+		updateActors();
+	}
+
+	checkForAreaChange();
+
 	return false;
 }
 
@@ -144,8 +187,8 @@ void GameContent::checkThunderShake() {
 		static const int8 DELTA_Y[4] = { 0, 0, -1, 1 };
 		int delta = g_events->getRandomNumber(3);
 
-		_shakeDelta.x = DELTA_X[delta];
-		_shakeDelta.y = DELTA_Y[delta];
+		_moveDelta.x = DELTA_X[delta];
+		_moveDelta.y = DELTA_Y[delta];
 
 		_G(thunder_flag)--;
 		if ((_G(thunder_flag) < MAX_ACTORS) && _G(thunder_flag) > 2) {
@@ -157,7 +200,7 @@ void GameContent::checkThunderShake() {
 
 		if (!_G(thunder_flag)) {
 			_mode = MODE_NORMAL;
-			_shakeDelta = Common::Point(0, 0);
+			_moveDelta = Common::Point(0, 0);
 		}
 
 		redraw();
@@ -220,5 +263,112 @@ void GameContent::updateActors() {
 	}
 }
 
+void GameContent::checkForAreaChange() {
+	if (_mode == MODE_AREA_CHANGE) {
+		// Area transition is already in progress
+		switch (_transitionDir) {
+		case DIR_LEFT:
+		case DIR_RIGHT:
+			_transitionPos += 32;
+			if (_transitionPos == 320)
+				_mode = MODE_NORMAL;
+			break;
+		case DIR_UP:
+		case DIR_DOWN:
+			_transitionPos += 16;
+			if (_transitionPos == 192)
+				_mode = MODE_NORMAL;
+			break;
+		default:
+			break;
+		}
+
+		if (_mode == MODE_NORMAL)
+			areaChanged();
+
+	} else if (_G(new_level) != _G(current_level)) {
+		// Area transition beginning
+		_G(thor)->show = 0;
+		_G(hammer)->used = 0;
+		_G(tornado_used) = 0;
+
+		show_level(_G(new_level));
+
+		if (_G(warp_flag))
+			_G(current_level) = _G(new_level) - 5;   // Force phase
+
+		_G(warp_flag) = 0;
+		if (_G(warp_scroll)) {
+			_G(warp_scroll) = 0;
+			if (_G(thor)->dir == 0)
+				_G(current_level) = _G(new_level) + 10;
+			else if (_G(thor)->dir == 1)
+				_G(current_level) = _G(new_level) - 10;
+			else if (_G(thor)->dir == 2)
+				_G(current_level) = _G(new_level) + 1;
+			else if (_G(thor)->dir == 3)
+				_G(current_level) = _G(new_level) - 1;
+		}
+
+		if (!_G(setup).scroll_flag)
+			_G(current_level) = _G(new_level); // Force no scroll
+
+		if (_G(music_current) != _G(level_type))
+			music_pause();
+
+		_transitionPos = 0;
+		_surface.copyFrom(getSurface());
+
+		switch (_G(new_level) - _G(current_level)) {
+		case 0:
+			// Nothing to do
+			areaChanged();
+			break;
+		case -1:
+			_mode = MODE_AREA_CHANGE;
+			_transitionDir = DIR_LEFT;
+			break;
+		case 1:
+			_mode = MODE_AREA_CHANGE;
+			_transitionDir = DIR_RIGHT;
+			break;
+		case -10:
+			_mode = MODE_AREA_CHANGE;
+			_transitionDir = DIR_UP;
+			break;
+		case 10:
+			_mode = MODE_AREA_CHANGE;
+			_transitionDir = DIR_DOWN;
+			break;
+		default:
+			// TODO: Original had weird as hell random delay calculation.
+			// Not sure that it's really necessary
+			areaChanged();
+			break;
+		}
+	} 
+}
+
+void GameContent::areaChanged() {
+	_G(current_level) = _G(new_level);
+
+	_G(thor_info).last_health = _G(thor)->health;
+	_G(thor_info).last_magic = _G(thor_info).magic;
+	_G(thor_info).last_jewels = _G(thor_info).jewels;
+	_G(thor_info).last_keys = _G(thor_info).keys;
+	_G(thor_info).last_score = _G(thor_info).score;
+	_G(thor_info).last_item = _G(thor_info).item;
+	_G(thor_info).last_screen = _G(current_level);
+	_G(thor_info).last_icon = ((_G(thor)->x + 8) / 16) + (((_G(thor)->y + 14) / 16) * 20);
+	_G(thor_info).last_dir = _G(thor)->dir;
+	_G(thor_info).last_inventory = _G(thor_info).inventory;
+	_G(thor_info).last_object = _G(thor_info).object;
+	_G(thor_info).last_object_name = _G(thor_info).object_name;
+
+	_G(last_setup) = _G(setup);
+
+	music_play(_G(level_type), 0);
+}
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index 4801a8a9fc3..55d979567b0 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -30,13 +30,19 @@ namespace Views {
 
 class GameContent : public View {
 	enum Mode {
-		MODE_NORMAL = 0, MODE_ROOM_CHANGE = 1, MODE_THUNDER = 2,
+		MODE_NORMAL = 0, MODE_AREA_CHANGE = 1, MODE_THUNDER = 2,
 		MODE_THOR_DIES = 3
 	};
+	enum TransitionDir {
+		DIR_LEFT, DIR_RIGHT, DIR_UP, DIR_DOWN
+	};
 private:
 	Mode _mode = MODE_NORMAL;
-	Common::Point _shakeDelta;
-
+	GfxSurface _surface;
+	Common::Point _moveDelta;
+	TransitionDir _transitionDir = DIR_LEFT;
+	int _transitionPos = 0;
+	
 	void drawBackground(GfxSurface &s);
 	void drawObjects(GfxSurface &s);
 	void drawEnemies(GfxSurface &s, ACTOR *lastActor);
@@ -45,9 +51,11 @@ private:
 	void checkForItem();
 	void moveActors();
 	void updateActors();
+	void checkForAreaChange();
+	void areaChanged();
 
 public:
-	GameContent() : View("GameContent") {}
+	GameContent();
 	virtual ~GameContent() {}
 
 	void draw() override;


Commit: aefa0ad18efa301f5151147d363f577cc60880cc
    https://github.com/scummvm/scummvm/commit/aefa0ad18efa301f5151147d363f577cc60880cc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix Thor being drawn twice during area transitions

Changed paths:
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 190aab0d39f..922f00c6329 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -45,7 +45,7 @@ void GameContent::draw() {
 
 	drawBackground(s);
 	drawObjects(s);
-	drawEnemies(s, &_G(actor)[MAX_ACTORS - 1]);
+	drawEnemies(s);
 
 	// If we're shaking the screen, render the content with the shake X/Y
 	if (_mode == MODE_THUNDER) {
@@ -150,8 +150,8 @@ void GameContent::drawObjects(GfxSurface &s) {
 	}
 }
 
-void GameContent::drawEnemies(GfxSurface &s, ACTOR *lastActor) {
-	ACTOR *actor_ptr = lastActor;
+void GameContent::drawEnemies(GfxSurface &s) {
+	ACTOR *actor_ptr = &_G(actor)[MAX_ACTORS - 1];
 	ACTOR *actor2_storage = nullptr;
 
 	for (int actor_num = 0; actor_num <= MAX_ACTORS; ) {
@@ -289,9 +289,17 @@ void GameContent::checkForAreaChange() {
 	} else if (_G(new_level) != _G(current_level)) {
 		// Area transition beginning
 		_G(thor)->show = 0;
+		_G(thor)->used = 0;
 		_G(hammer)->used = 0;
 		_G(tornado_used) = 0;
 
+		// Draws the old area without Thor, and then save a copy of it.
+		// This will be used to scroll old area off-screen as new area scrolls in
+		draw();
+		_surface.copyFrom(getSurface());
+
+		// Set up new level
+		_G(thor)->used = 1;
 		show_level(_G(new_level));
 
 		if (_G(warp_flag))
@@ -317,7 +325,6 @@ void GameContent::checkForAreaChange() {
 			music_pause();
 
 		_transitionPos = 0;
-		_surface.copyFrom(getSurface());
 
 		switch (_G(new_level) - _G(current_level)) {
 		case 0:
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index 55d979567b0..246f90cb8c1 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -45,7 +45,7 @@ private:
 	
 	void drawBackground(GfxSurface &s);
 	void drawObjects(GfxSurface &s);
-	void drawEnemies(GfxSurface &s, ACTOR *lastActor);
+	void drawEnemies(GfxSurface &s);
 	void checkThunderShake();
 	void checkSwitchFlag();
 	void checkForItem();


Commit: 4177952ff88d463eeaeab0be450a2d8313e123a3
    https://github.com/scummvm/scummvm/commit/4177952ff88d463eeaeab0be450a2d8313e123a3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Move game mode enum/value into global vars

Changed paths:
    engines/got/game/script.cpp
    engines/got/got.cpp
    engines/got/vars.h
    engines/got/views/game.cpp
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 2cd72c0fc1d..33d6923d6f9 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -824,7 +824,6 @@ int Scripts::cmd_sound() {
 
 int Scripts::cmd_settile() {
 	int screen, pos, tile;
-	LEVEL *lvl;
 
 	if (!calc_value()) return 5;
 	buff_ptr++;
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 97aa30d5b43..1ce3029acbf 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -157,10 +157,8 @@ bool GotEngine::canSaveGameStateCurrently(Common::U32String *msg) {
 			_G(shield_on))
 		return false;
 
-	// TODO: Consider if there is a cleaner way to do this. Maybe have a
-	// global flag or a message sent to the views 
-	Views::GameContent *content = (Views::GameContent *)findView("GameContent");
-	return content && content->canSaveLoad();
+	// Only allow if not in the middle of area transition, dying, etc.
+	return _G(gameMode) == MODE_NORMAL;
 }
 
 } // End of namespace Got
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 90610a4bdd7..018b0c706e2 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -55,6 +55,11 @@ enum Key {
 	key_select = KEYBIND_SELECT
 };
 
+enum GameMode {
+	MODE_NORMAL = 0, MODE_AREA_CHANGE = 1, MODE_THUNDER = 2,
+	MODE_THOR_DIES = 3
+};
+
 class Vars {
 public:
 	Vars();
@@ -73,6 +78,7 @@ public:
 	SdData _sd_data;
 	Sound _sound;
 	Scripts _scripts;
+	GameMode _gameMode = MODE_NORMAL;
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
 	uint _display_page = 0, _draw_page = 0;
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 56afe9b36b6..90c953e051f 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -54,6 +54,9 @@ void Game::draw() {
 }
 
 bool Game::msgKeypress(const KeypressMessage &msg) {
+	if (_G(gameMode) != MODE_NORMAL)
+		return false;
+
 	switch (msg.keycode) {
 	case Common::KEYCODE_F1:
 		odin_speaks(2008, -1);
@@ -75,6 +78,9 @@ bool Game::msgKeypress(const KeypressMessage &msg) {
 }
 
 bool Game::msgAction(const ActionMessage &msg) {
+	if (_G(gameMode) != MODE_NORMAL)
+		return false;
+
 	switch (msg._action) {
 	case KEYBIND_SELECT:
 		select_item();
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 922f00c6329..b423c44a3dd 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -36,7 +36,7 @@ GameContent::GameContent() : View("GameContent") {
 
 void GameContent::draw() {
 	GfxSurface s;
-	if (_mode == MODE_THUNDER || _mode == MODE_AREA_CHANGE) {
+	if (_G(gameMode) == MODE_THUNDER || _G(gameMode) == MODE_AREA_CHANGE) {
 		s.create(320, 192);
 	} else {
 		s = getSurface();
@@ -48,11 +48,11 @@ void GameContent::draw() {
 	drawEnemies(s);
 
 	// If we're shaking the screen, render the content with the shake X/Y
-	if (_mode == MODE_THUNDER) {
+	if (_G(gameMode) == MODE_THUNDER) {
 		GfxSurface win = getSurface();
 		win.clear();
 		win.blitFrom(s, _moveDelta);
-	} else if (_mode == MODE_AREA_CHANGE) {
+	} else if (_G(gameMode) == MODE_AREA_CHANGE) {
 		// Draw parts of the new scene along with parts of the old one
 		// as it's scrolled off-screen
 		GfxSurface win = getSurface();
@@ -106,7 +106,7 @@ bool GameContent::msgGame(const GameMessage &msg) {
 bool GameContent::tick() {
 	checkThunderShake();
 
-	if (_mode == MODE_NORMAL) {
+	if (_G(gameMode) == MODE_NORMAL) {
 		checkSwitchFlag();
 		checkForItem();
 		moveActors();
@@ -180,7 +180,7 @@ void GameContent::drawEnemies(GfxSurface &s) {
 
 void GameContent::checkThunderShake() {
 	if (_G(thunder_flag)) {
-		_mode = MODE_THUNDER;
+		_G(gameMode) = MODE_THUNDER;
 
 		// Introduce a random screen shake by rendering screen 1 pixel offset randomly
 		static const int8 DELTA_X[4] = { -1, 1, 0, 0 };
@@ -199,7 +199,7 @@ void GameContent::checkThunderShake() {
 		}
 
 		if (!_G(thunder_flag)) {
-			_mode = MODE_NORMAL;
+			_G(gameMode) = MODE_NORMAL;
 			_moveDelta = Common::Point(0, 0);
 		}
 
@@ -264,26 +264,26 @@ void GameContent::updateActors() {
 }
 
 void GameContent::checkForAreaChange() {
-	if (_mode == MODE_AREA_CHANGE) {
+	if (_G(gameMode) == MODE_AREA_CHANGE) {
 		// Area transition is already in progress
 		switch (_transitionDir) {
 		case DIR_LEFT:
 		case DIR_RIGHT:
 			_transitionPos += 32;
 			if (_transitionPos == 320)
-				_mode = MODE_NORMAL;
+				_G(gameMode) = MODE_NORMAL;
 			break;
 		case DIR_UP:
 		case DIR_DOWN:
 			_transitionPos += 16;
 			if (_transitionPos == 192)
-				_mode = MODE_NORMAL;
+				_G(gameMode) = MODE_NORMAL;
 			break;
 		default:
 			break;
 		}
 
-		if (_mode == MODE_NORMAL)
+		if (_G(gameMode) == MODE_NORMAL)
 			areaChanged();
 
 	} else if (_G(new_level) != _G(current_level)) {
@@ -332,19 +332,19 @@ void GameContent::checkForAreaChange() {
 			areaChanged();
 			break;
 		case -1:
-			_mode = MODE_AREA_CHANGE;
+			_G(gameMode) = MODE_AREA_CHANGE;
 			_transitionDir = DIR_LEFT;
 			break;
 		case 1:
-			_mode = MODE_AREA_CHANGE;
+			_G(gameMode) = MODE_AREA_CHANGE;
 			_transitionDir = DIR_RIGHT;
 			break;
 		case -10:
-			_mode = MODE_AREA_CHANGE;
+			_G(gameMode) = MODE_AREA_CHANGE;
 			_transitionDir = DIR_UP;
 			break;
 		case 10:
-			_mode = MODE_AREA_CHANGE;
+			_G(gameMode) = MODE_AREA_CHANGE;
 			_transitionDir = DIR_DOWN;
 			break;
 		default:
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index 246f90cb8c1..9d68ff16013 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -29,15 +29,10 @@ namespace Got {
 namespace Views {
 
 class GameContent : public View {
-	enum Mode {
-		MODE_NORMAL = 0, MODE_AREA_CHANGE = 1, MODE_THUNDER = 2,
-		MODE_THOR_DIES = 3
-	};
 	enum TransitionDir {
 		DIR_LEFT, DIR_RIGHT, DIR_UP, DIR_DOWN
 	};
 private:
-	Mode _mode = MODE_NORMAL;
 	GfxSurface _surface;
 	Common::Point _moveDelta;
 	TransitionDir _transitionDir = DIR_LEFT;
@@ -61,10 +56,6 @@ public:
 	void draw() override;
 	bool msgGame(const GameMessage &msg) override;
 	bool tick() override;
-
-	bool canSaveLoad() const {
-		return _mode == MODE_NORMAL;
-	}
 };
 
 } // namespace Views


Commit: ba58536de0b31f01fe6cf73d701605f47acd4a13
    https://github.com/scummvm/scummvm/commit/ba58536de0b31f01fe6cf73d701605f47acd4a13
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Move the fire/select actions to Game view msgAction

Changed paths:
    engines/got/game/move.cpp
    engines/got/game/move.h
    engines/got/game/move_patterns.cpp
    engines/got/views/dialogs/say.cpp
    engines/got/views/dialogs/say.h
    engines/got/views/game.cpp


diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index 365ba97ef46..2cb7b89ce38 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -65,7 +65,7 @@ int reverse_direction(ACTOR *actr) {
 	return 1;
 }
 
-void thor_shoots(void) {
+void thor_shoots() {
 	if ((_G(hammer)->used != 1) && (!_G(hammer)->dead) && (!_G(thor)->shot_cnt)) {
 		play_sound(SWISH, 0);
 		_G(thor)->shot_cnt = 20;
diff --git a/engines/got/game/move.h b/engines/got/game/move.h
index c3b071b93b0..8624e0f44fc 100644
--- a/engines/got/game/move.h
+++ b/engines/got/game/move.h
@@ -30,7 +30,7 @@ extern void next_frame(ACTOR *actr);
 extern bool point_within(int x, int y, int x1, int y1, int x2, int y2);
 extern bool overlap(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
 extern int  reverse_direction(ACTOR *actr);
-extern void thor_shoots(void);
+extern void thor_shoots();
 extern void thor_damaged(ACTOR *actr);
 extern void actor_destroyed(ACTOR *actr);
 extern int  actor_shoots(ACTOR *actr, int dir);
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index be8348d8e2c..7d85b7d7a36 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -600,11 +600,6 @@ int movement_zero(ACTOR *actr) {       //player control
 
 	set_thor_vars();
 
-	if (_G(key_flag)[key_fire])
-		thor_shoots();
-	if (_G(key_flag)[key_select])
-		select_item();
-
 	if ((_G(hammer)->used) && (_G(hammer)->move == 5)) {
 		if (overlap(_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2),
 			_G(hammer)->x, _G(hammer)->y, _G(hammer)->x + 13, _G(hammer)->y + 13)) {
diff --git a/engines/got/views/dialogs/say.cpp b/engines/got/views/dialogs/say.cpp
index f17faefac3c..3d6df535e9b 100644
--- a/engines/got/views/dialogs/say.cpp
+++ b/engines/got/views/dialogs/say.cpp
@@ -64,7 +64,6 @@ void Say::draw() {
 	Dialog::draw();
 	GfxSurface s = getSurface();
 
-	s.blitFrom((*_pic)[_picIndex], Common::Point(120, 17));
 	if (_item)
 		s.blitFrom(_G(objects)[_item], Common::Point(160, 17));
 
@@ -109,6 +108,8 @@ void Say::draw() {
 		x += 8;
 	}
 
+	s.blitFrom((*_pic)[_picIndex], Common::Point(120, 17));
+
 	if (_waitForResponse == WAIT_MORE)
 		s.print(Common::Point(184, 86), "More...", 15);
 }
@@ -146,7 +147,8 @@ bool Say::msgAction(const ActionMessage &msg) {
 }
 
 bool Say::tick() {
-	if (_waitForResponse == WAIT_NONE) {
+	if (_waitForResponse == WAIT_NONE && ++_contentCtr > 3) {
+		_contentCtr = 0;
 		const char *contentEnd = _content + ++_contentLength;
 
 		if (*contentEnd == '~' && Common::isXDigit(*(contentEnd + 1)))
@@ -160,8 +162,9 @@ bool Say::tick() {
 			_picIndex = 0;
 		}
 
-		if (_type && ++_woopCtr > 5) {
+		if (_type) {
 			play_sound(WOOP, 1);
+			_woopCtr = 0;
 		}
 
 		redraw();
diff --git a/engines/got/views/dialogs/say.h b/engines/got/views/dialogs/say.h
index cdb2081c067..954e192c6dc 100644
--- a/engines/got/views/dialogs/say.h
+++ b/engines/got/views/dialogs/say.h
@@ -41,6 +41,7 @@ private:
 	const char *_content = nullptr;
 	int _contentLength = 0;
 	int _woopCtr = 0;
+	int _contentCtr = 0;
 	WaitResponse _waitForResponse = WAIT_NONE;
 
 	/**
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 90c953e051f..2ea0d67237b 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -22,6 +22,7 @@
 #include "got/views/game.h"
 #include "got/game/back.h"
 #include "got/game/init.h"
+#include "got/game/move.h"
 #include "got/metaengine.h"
 #include "got/vars.h"
 
@@ -82,6 +83,10 @@ bool Game::msgAction(const ActionMessage &msg) {
 		return false;
 
 	switch (msg._action) {
+	case KEYBIND_FIRE:
+		thor_shoots();
+		break;
+
 	case KEYBIND_SELECT:
 		select_item();
 		return true;


Commit: b83e3abb0e320c23134ce759f548f9e8d9460f62
    https://github.com/scummvm/scummvm/commit/b83e3abb0e320c23134ce759f548f9e8d9460f62
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added Thor death animation

Changed paths:
    engines/got/data/setup.cpp
    engines/got/got.cpp
    engines/got/got.h
    engines/got/metaengine.cpp
    engines/got/metaengine.h
    engines/got/views/game.cpp
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/data/setup.cpp b/engines/got/data/setup.cpp
index a6d8e90ae50..b81bd9d3d16 100644
--- a/engines/got/data/setup.cpp
+++ b/engines/got/data/setup.cpp
@@ -24,8 +24,9 @@
 namespace Got {
 
 void SETUP::sync(Common::Serializer &s) {
-	// Write out the flags
-	s.syncBytes((byte *)this, 16);
+	// Sync the flags bit-fields
+	assert(((byte *)&value - (byte *)this) == 8);
+	s.syncBytes((byte *)this, 8);
 
 	s.syncBytes(value, 16);
 	s.syncAsByte(junk);
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 1ce3029acbf..cc38be97f6d 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -101,54 +101,58 @@ Common::Error GotEngine::syncGame(Common::Serializer &s) {
 	_G(thor_info).sync(s);
 	_G(sd_data).sync(s);
 
-	if (s.isLoading()) {
-		int area = _G(setup).area;
-		if (area == 0)
-			area = 1;
-
-		g_vars->setArea(area);
-
-		_G(current_area) = _G(thor_info).last_screen;
-
-		_G(thor)->x = (_G(thor_info).last_icon % 20) * 16;
-		_G(thor)->y = ((_G(thor_info).last_icon / 20) * 16) - 1;
-		if (_G(thor)->x < 1) _G(thor)->x = 1;
-		if (_G(thor)->y < 0) _G(thor)->y = 0;
-		_G(thor)->dir = _G(thor_info).last_dir;
-		_G(thor)->last_dir = _G(thor_info).last_dir;
-		_G(thor)->health = _G(thor_info).last_health;
-		_G(thor)->num_moves = 1;
-		_G(thor)->vunerable = 60;
-		_G(thor)->show = 60;
-		_G(thor)->speed_count = 6;
-		load_new_thor();
-
-		if (!_G(music_flag))
-			_G(setup).music = 0;
-		if (!_G(sound_flag))
-			_G(setup).dig_sound = 0;
-		if (_G(setup).music == 1) {
-			if (GAME1 == 1 && _G(current_area) == 59) {
+	if (s.isLoading())
+		savegameLoaded();
+
+	return Common::kNoError;
+}
+
+void GotEngine::savegameLoaded() {
+	int area = _G(setup).area;
+	if (area == 0)
+		area = 1;
+
+	g_vars->setArea(area);
+
+	_G(current_area) = _G(thor_info).last_screen;
+
+	_G(thor)->x = (_G(thor_info).last_icon % 20) * 16;
+	_G(thor)->y = ((_G(thor_info).last_icon / 20) * 16) - 1;
+	if (_G(thor)->x < 1) _G(thor)->x = 1;
+	if (_G(thor)->y < 0) _G(thor)->y = 0;
+	_G(thor)->dir = _G(thor_info).last_dir;
+	_G(thor)->last_dir = _G(thor_info).last_dir;
+	_G(thor)->health = _G(thor_info).last_health;
+	_G(thor)->num_moves = 1;
+	_G(thor)->vunerable = 60;
+	_G(thor)->show = 60;
+	_G(thor)->speed_count = 6;
+	load_new_thor();
+
+	if (!_G(music_flag))
+		_G(setup).music = 0;
+	if (!_G(sound_flag))
+		_G(setup).dig_sound = 0;
+	if (_G(setup).music == 1) {
+		if (GAME1 == 1 && _G(current_area) == 59) {
 //				if (flag)
-					music_play(5, 1);
-			} else {
-				//if (flag)
-				music_play(_G(level_type), 1);
-			}
+				music_play(5, 1);
 		} else {
-			_G(setup).music = 1;
-			music_pause();
-			_G(setup).music = 0;
+			//if (flag)
+			music_play(_G(level_type), 1);
 		}
-
-		_G(game_over) = _G(setup).game_over;
-		_G(slow_mode) = _G(setup).speed;
-
-		// Switch to game view
-		g_events->replaceView("Game", true);
+	} else {
+		_G(setup).music = 1;
+		music_pause();
+		_G(setup).music = 0;
 	}
 
-	return Common::kNoError;
+	_G(game_over) = _G(setup).game_over;
+	_G(slow_mode) = _G(setup).speed;
+
+	// Trigger a "Thor died" action, which displays the loaded scene
+	g_events->replaceView("Game", true);
+	g_events->send(GameMessage("THOR_DIES"));
 }
 
 bool GotEngine::canSaveGameStateCurrently(Common::U32String *msg) {
diff --git a/engines/got/got.h b/engines/got/got.h
index 1926c9e0676..6f412be8cd6 100644
--- a/engines/got/got.h
+++ b/engines/got/got.h
@@ -46,6 +46,9 @@ class GotEngine : public Engine, public Events {
 private:
 	const ADGameDescription *_gameDescription;
 	Common::RandomSource _randomSource;
+
+	void savegameLoaded();
+
 protected:
 	// Engine APIs
 	Common::Error run() override;
diff --git a/engines/got/metaengine.cpp b/engines/got/metaengine.cpp
index 277c7c1a1ee..ee36854087b 100644
--- a/engines/got/metaengine.cpp
+++ b/engines/got/metaengine.cpp
@@ -62,6 +62,7 @@ static const KeybindingRecord GAME_KEYS[] = {
 	{ KEYBIND_SELECT, "SELECT", _s("Select"), "SPACE", "JOY_X" },
 	// I18N: ESC key
 	{ KEYBIND_ESCAPE, "ESCAPE", _s("Escape"), "ESCAPE", "JOY_Y" },
+	{ KEYBIND_THOR_DIES, "THOR_DIES", _s("Thor Dies"), "d", nullptr },
 	{ KEYBIND_NONE, nullptr, nullptr, nullptr, nullptr }
 };
 
diff --git a/engines/got/metaengine.h b/engines/got/metaengine.h
index b8ef996c325..f91c8d2c90d 100644
--- a/engines/got/metaengine.h
+++ b/engines/got/metaengine.h
@@ -28,7 +28,8 @@ namespace Got {
 
 enum KeybindingAction {
 	KEYBIND_NONE, KEYBIND_UP, KEYBIND_DOWN, KEYBIND_LEFT, KEYBIND_RIGHT,
-	KEYBIND_SELECT, KEYBIND_FIRE, KEYBIND_MAGIC, KEYBIND_ESCAPE
+	KEYBIND_SELECT, KEYBIND_FIRE, KEYBIND_MAGIC, KEYBIND_ESCAPE,
+	KEYBIND_THOR_DIES
 };
 
 } // namespace Got
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 2ea0d67237b..a3138505606 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -90,6 +90,13 @@ bool Game::msgAction(const ActionMessage &msg) {
 	case KEYBIND_SELECT:
 		select_item();
 		return true;
+
+	case KEYBIND_THOR_DIES:
+		_content.send(GameMessage("THOR_DIES"));
+		return true;
+
+	default:
+		break;
 	}
 
 	return false;
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index b423c44a3dd..2b169ac05ec 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -30,6 +30,10 @@
 namespace Got {
 namespace Views {
 
+#define SPIN_INTERVAL 4
+#define SPIN_COUNT 20
+#define DEATH_THRESHOLD (SPIN_COUNT * SPIN_INTERVAL)
+
 GameContent::GameContent() : View("GameContent") {
 	_surface.create(320, 192);
 }
@@ -45,7 +49,7 @@ void GameContent::draw() {
 
 	drawBackground(s);
 	drawObjects(s);
-	drawEnemies(s);
+	drawActors(s);
 
 	// If we're shaking the screen, render the content with the shake X/Y
 	if (_G(gameMode) == MODE_THUNDER) {
@@ -89,15 +93,15 @@ void GameContent::draw() {
 }
 
 bool GameContent::msgGame(const GameMessage &msg) {
-	if (msg._name == "SHOW_LEVEL") {
-		show_level(msg._value);
-		return true;
-	} else if (msg._name == "HIDE_ACTORS") {
+	if (msg._name == "HIDE_ACTORS") {
 		// Hide all actors and immediately redraw the screen
 		for (int i = 0; i < MAX_ACTORS; i++)
 			_G(actor)[i].show = 0;
 		draw();
 		return true;
+	} else if (msg._name == "THOR_DIES") {
+		thorDies();
+		return true;
 	}
 
 	return false;
@@ -106,12 +110,28 @@ bool GameContent::msgGame(const GameMessage &msg) {
 bool GameContent::tick() {
 	checkThunderShake();
 
-	if (_G(gameMode) == MODE_NORMAL) {
+	switch (_G(gameMode)) {
+	case MODE_NORMAL:
 		checkSwitchFlag();
 		checkForItem();
 		moveActors();
 		use_item();
 		updateActors();
+		break;
+
+	case MODE_THOR_DIES:
+		if (_deathCtr < DEATH_THRESHOLD) {
+			spinThor();
+		} else if (_deathCtr < DEATH_THRESHOLD + 60) {
+			_G(thor)->used = 0;
+			++_deathCtr;
+		} else {
+			thorDead();
+		}
+		break;
+
+	default:
+		break;
 	}
 
 	checkForAreaChange();
@@ -150,7 +170,7 @@ void GameContent::drawObjects(GfxSurface &s) {
 	}
 }
 
-void GameContent::drawEnemies(GfxSurface &s) {
+void GameContent::drawActors(GfxSurface &s) {
 	ACTOR *actor_ptr = &_G(actor)[MAX_ACTORS - 1];
 	ACTOR *actor2_storage = nullptr;
 
@@ -176,6 +196,9 @@ void GameContent::drawEnemies(GfxSurface &s) {
 				actor2_storage = actor_ptr;
 		} while (actor_num == (MAX_ACTORS - 3));
 	}
+
+	if (_G(gameMode) == MODE_THOR_DIES && _deathCtr >= DEATH_THRESHOLD)
+		s.blitFrom(_G(objects)[10], Common::Point(_G(thor)->x, _G(thor)->y));
 }
 
 void GameContent::checkThunderShake() {
@@ -377,5 +400,86 @@ void GameContent::areaChanged() {
 	music_play(_G(level_type), 0);
 }
 
+void GameContent::thorDies() {
+	// Stop any actors on-screen from moving
+	for (int li = 0; li < MAX_ACTORS; li++)
+		_G(actor)[li].show = 0;
+	_G(actor)[2].used = 0;
+
+	// Set the state for showing death animation
+	_G(gameMode) = MODE_THOR_DIES;
+	_deathCtr = 0;
+	_G(shield_on) = false;
+
+	play_sound(DEAD, 1);
+}
+
+void GameContent::spinThor() {
+	static const byte DIRS[] = { 0,2,1,3 };
+
+	_G(thor)->dir = DIRS[(_deathCtr / SPIN_INTERVAL) % 4];
+	_G(thor)->last_dir = DIRS[(_deathCtr / SPIN_INTERVAL) % 4];
+
+	++_deathCtr;
+}
+
+void GameContent::thorDead() {
+	int li = _G(thor_info).item;
+	int ln = _G(thor_info).inventory;
+
+	_G(new_level) = _G(thor_info).last_screen;
+	_G(thor)->x = (_G(thor_info).last_icon % 20) * 16;
+	_G(thor)->y = ((_G(thor_info).last_icon / 20) * 16) - 1;
+	if (_G(thor)->x < 1) _G(thor)->x = 1;
+	if (_G(thor)->y < 0) _G(thor)->y = 0;
+	_G(thor)->last_x[0] = _G(thor)->x;
+	_G(thor)->last_x[1] = _G(thor)->x;
+	_G(thor)->last_y[0] = _G(thor)->y;
+	_G(thor)->last_y[1] = _G(thor)->y;
+	_G(thor)->dir = _G(thor_info).last_dir;
+	_G(thor)->last_dir = _G(thor_info).last_dir;
+	_G(thor)->health = _G(thor_info).last_health;
+	_G(thor_info).magic = _G(thor_info).last_magic;
+	_G(thor_info).jewels = _G(thor_info).last_jewels;
+	_G(thor_info).keys = _G(thor_info).last_keys;
+	_G(thor_info).score = _G(thor_info).last_score;
+	_G(thor_info).object = _G(thor_info).last_object;
+	_G(thor_info).object_name = _G(thor_info).last_object_name;
+
+	if (ln == _G(thor_info).last_inventory) {
+		_G(thor_info).item = li;
+	} else {
+		_G(thor_info).item = _G(thor_info).last_item;
+		_G(thor_info).inventory = _G(thor_info).last_inventory;
+	}
+
+	_G(setup) = _G(last_setup);
+
+	_G(thor)->num_moves = 1;
+	_G(thor)->vunerable = 60;
+	_G(thor)->show = 60;
+	_G(hourglass_flag) = 0;
+	_G(apple_flag) = 0;
+	_G(bomb_flag) = 0;
+	_G(thunder_flag) = 0;
+	_G(lightning_used) = 0;
+	_G(tornado_used) = 0;
+	_G(shield_on) = 0;
+	music_resume();
+	_G(actor)[1].used = 0;
+	_G(actor)[2].used = 0;
+	_G(thor)->speed_count = 6;
+	_G(thor)->used = 1;
+
+	// Load saved data for new level back into scrn
+	_G(scrn).load(_G(sd_data) + (_G(new_level) * 512));
+
+	_G(gameMode) = MODE_NORMAL;
+	_deathCtr = 0;
+
+	show_level(_G(new_level));
+	set_thor_vars();
+}
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index 9d68ff16013..d32717417bb 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -37,10 +37,11 @@ private:
 	Common::Point _moveDelta;
 	TransitionDir _transitionDir = DIR_LEFT;
 	int _transitionPos = 0;
-	
+	int _deathCtr = 0;
+
 	void drawBackground(GfxSurface &s);
 	void drawObjects(GfxSurface &s);
-	void drawEnemies(GfxSurface &s);
+	void drawActors(GfxSurface &s);
 	void checkThunderShake();
 	void checkSwitchFlag();
 	void checkForItem();
@@ -48,6 +49,9 @@ private:
 	void updateActors();
 	void checkForAreaChange();
 	void areaChanged();
+	void thorDies();
+	void spinThor();
+	void thorDead();
 
 public:
 	GameContent();


Commit: f2dd139e747cbcc0ef8dcabaf3cb6098cbef7fae
    https://github.com/scummvm/scummvm/commit/f2dd139e747cbcc0ef8dcabaf3cb6098cbef7fae
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Hooking up savegame loading

Changed paths:
    engines/got/got.cpp
    engines/got/views/game.cpp
    engines/got/views/game.h
    engines/got/views/game_content.cpp


diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index cc38be97f6d..9aeb4b0e559 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -29,6 +29,7 @@
 #include "got/got.h"
 #include "got/detection.h"
 #include "got/console.h"
+#include "got/game/init.h"
 #include "got/gfx/image.h"
 #include "got/utils/res_archive.h"
 #include "got/views/game_content.h"
@@ -71,6 +72,9 @@ Common::Error GotEngine::run() {
 	resInit();
 	_vars.load();
 
+	// General initialization
+	initialize();
+
 	runGame();
 
 	return Common::kNoError;
@@ -150,9 +154,9 @@ void GotEngine::savegameLoaded() {
 	_G(game_over) = _G(setup).game_over;
 	_G(slow_mode) = _G(setup).speed;
 
-	// Trigger a "Thor died" action, which displays the loaded scene
+	// Notify the game view that a savegame has been loaded
 	g_events->replaceView("Game", true);
-	g_events->send(GameMessage("THOR_DIES"));
+	g_events->send(GameMessage("SAVEGAME_LOADED"));
 }
 
 bool GotEngine::canSaveGameStateCurrently(Common::U32String *msg) {
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index a3138505606..8a610d06821 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -36,19 +36,6 @@ Game::Game() : View("Game") {
 	_status.setBounds(Common::Rect(0, 240 - 48, 320, 240));
 }
 
-bool Game::msgFocus(const FocusMessage &msg) {
-	if (_firstTime) {
-		initialize();
-		_firstTime = false;
-	}
-
-	return true;
-}
-
-bool Game::msgUnfocus(const UnfocusMessage &msg) {
-	return true;
-}
-
 void Game::draw() {
 	GfxSurface s = getSurface();
 	s.clear();
diff --git a/engines/got/views/game.h b/engines/got/views/game.h
index 483853ecf05..6f0eefbd308 100644
--- a/engines/got/views/game.h
+++ b/engines/got/views/game.h
@@ -33,14 +33,11 @@ class Game : public View {
 private:
 	GameContent _content;
 	GameStatus _status;
-	bool _firstTime = true;
 
 public:
 	Game();
 	virtual ~Game() {}
 
-	bool msgFocus(const FocusMessage &msg) override;
-	bool msgUnfocus(const UnfocusMessage &msg) override;
 	bool msgKeypress(const KeypressMessage &msg) override;
 	bool msgAction(const ActionMessage &msg) override;
 	void draw() override;
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 2b169ac05ec..54dffdb7ff7 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -102,6 +102,11 @@ bool GameContent::msgGame(const GameMessage &msg) {
 	} else if (msg._name == "THOR_DIES") {
 		thorDies();
 		return true;
+	} else if (msg._name == "SAVEGAME_LOADED") {
+		// Savegame loading uses the same ending part of the Thor death
+		// sequence to set up the loaded area in the default state
+		thorDead();
+		return true;
 	}
 
 	return false;


Commit: a2b084b73d79bf57e7cac7f54a9e393bca30b521
    https://github.com/scummvm/scummvm/commit/a2b084b73d79bf57e7cac7f54a9e393bca30b521
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fixes for savegame loading

Changed paths:
    engines/got/game/back.cpp
    engines/got/game/back.h
    engines/got/got.cpp
    engines/got/vars.h
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index 97456f82e3d..068c6c0ab00 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -77,8 +77,8 @@ void show_level(int new_level) {
 
 	if (_G(warp_flag))
 		_G(current_level) = new_level - 5;   //force phase
-
 	_G(warp_flag) = 0;
+
 	if (_G(warp_scroll)) {
 		_G(warp_scroll) = 0;
 		if (_G(thor)->dir == 0)
@@ -97,60 +97,55 @@ void show_level(int new_level) {
 	if (_G(music_current) != _G(level_type))
 		_G(sound).music_pause();
 
-#ifdef TODO
-	switch (new_level - _G(current_level)) {
+	switch (_G(new_level) - _G(current_level)) {
 	case 0:
-		xshowpage(draw_page);
-		xcopyd2d(0, 0, 320, 192, 0, 0, draw_page, display_page, 320, 320);
+		// Nothing to do
+		show_level_done();
 		break;
-	case 1:
-	{
-		scroll_level_right(); break;
-	}
-	case 10:
-	{
-		scroll_level_down(); break;
-	}
 	case -1:
-	{
-		scroll_level_left(); break;
-	}
+		_G(gameMode) = MODE_AREA_CHANGE;
+		_G(transitionDir) = DIR_LEFT;
+		break;
+	case 1:
+		_G(gameMode) = MODE_AREA_CHANGE;
+		_G(transitionDir) = DIR_RIGHT;
+		break;
 	case -10:
-	{
-		scroll_level_up(); break;
-	}
+		_G(gameMode) = MODE_AREA_CHANGE;
+		_G(transitionDir) = DIR_UP;
+		break;
+	case 10:
+		_G(gameMode) = MODE_AREA_CHANGE;
+		_G(transitionDir) = DIR_DOWN;
+		break;
 	default:
-		phase_level();
+		// TODO: Original had weird as hell random delay calculation.
+		// Not sure that it's really necessary
+		show_level_done();
+		break;
 	}
-	build_screen(PAGE2);
-	show_objects(new_level, PAGE2);
-
-	_G(current_level) = new_level;
-	thor_info.last_health = _G(thor)->health;
-	thor_info.last_magic = thor_info.magic;
-	thor_info.last_jewels = thor_info.jewels;
-	thor_info.last_keys = thor_info.keys;
-	thor_info.last_score = thor_info.score;
-	thor_info.last_item = thor_info.item;
-	thor_info.last_screen = _G(current_level);
-	thor_info.last_icon = ((_G(thor)->x + 8) / 16) + (((_G(thor)->y + 14) / 16) * 20);
-	thor_info.last_dir = _G(thor)->dir;
-	thor_info.last_inventory = thor_info.inventory;
-	thor_info.last_object = thor_info.object;
-	thor_info.last_object_name = thor_info.object_name;
+}
+
+
+void show_level_done() {
+	_G(current_level) = _G(new_level);
+
+	_G(thor_info).last_health = _G(thor)->health;
+	_G(thor_info).last_magic = _G(thor_info).magic;
+	_G(thor_info).last_jewels = _G(thor_info).jewels;
+	_G(thor_info).last_keys = _G(thor_info).keys;
+	_G(thor_info).last_score = _G(thor_info).score;
+	_G(thor_info).last_item = _G(thor_info).item;
+	_G(thor_info).last_screen = _G(current_level);
+	_G(thor_info).last_icon = ((_G(thor)->x + 8) / 16) + (((_G(thor)->y + 14) / 16) * 20);
+	_G(thor_info).last_dir = _G(thor)->dir;
+	_G(thor_info).last_inventory = _G(thor_info).inventory;
+	_G(thor_info).last_object = _G(thor_info).object;
+	_G(thor_info).last_object_name = _G(thor_info).object_name;
 
 	_G(last_setup) = _G(setup);
 
-	f = 1;
-	if (GAME1 && new_level == BOSS_LEVEL1) {
-		if (!_G(setup).boss_dead[0]) {
-			if (!auto_load) boss_level1();
-			f = 0;
-		}
-	}
-	if (startup) f = 0;
-	if (f) music_play(_G(level_type), 0);
-#endif
+	music_play(_G(level_type), 0);
 }
 
 void odin_speaks(int index, int item) {
diff --git a/engines/got/game/back.h b/engines/got/game/back.h
index d937b6bb8af..c23f3ffb046 100644
--- a/engines/got/game/back.h
+++ b/engines/got/game/back.h
@@ -37,6 +37,7 @@ extern const char *item_name[];
  * GameContent view takes care of the scene rendering.
 */
 extern void show_level(int new_level);
+extern void show_level_done();
 extern void odin_speaks(int index, int item);
 extern int switch_icons();
 extern int rotate_arrows();
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 9aeb4b0e559..632fdb769fc 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -30,6 +30,7 @@
 #include "got/detection.h"
 #include "got/console.h"
 #include "got/game/init.h"
+#include "got/game/main.h"
 #include "got/gfx/image.h"
 #include "got/utils/res_archive.h"
 #include "got/views/game_content.h"
@@ -154,9 +155,8 @@ void GotEngine::savegameLoaded() {
 	_G(game_over) = _G(setup).game_over;
 	_G(slow_mode) = _G(setup).speed;
 
-	// Notify the game view that a savegame has been loaded
 	g_events->replaceView("Game", true);
-	g_events->send(GameMessage("SAVEGAME_LOADED"));
+	setup_load();
 }
 
 bool GotEngine::canSaveGameStateCurrently(Common::U32String *msg) {
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 018b0c706e2..2544089d262 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -60,6 +60,11 @@ enum GameMode {
 	MODE_THOR_DIES = 3
 };
 
+enum TransitionDir {
+	DIR_LEFT, DIR_RIGHT, DIR_UP, DIR_DOWN
+};
+
+
 class Vars {
 public:
 	Vars();
@@ -79,6 +84,7 @@ public:
 	Sound _sound;
 	Scripts _scripts;
 	GameMode _gameMode = MODE_NORMAL;
+	TransitionDir _transitionDir = DIR_LEFT;
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
 	uint _display_page = 0, _draw_page = 0;
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 54dffdb7ff7..d69a444f774 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -61,7 +61,7 @@ void GameContent::draw() {
 		// as it's scrolled off-screen
 		GfxSurface win = getSurface();
 
-		switch (_transitionDir) {
+		switch (_G(transitionDir)) {
 		case DIR_LEFT:
 			win.blitFrom(s, Common::Rect(320 - _transitionPos, 0, 320, 192),
 				Common::Point(0, 0));
@@ -102,11 +102,6 @@ bool GameContent::msgGame(const GameMessage &msg) {
 	} else if (msg._name == "THOR_DIES") {
 		thorDies();
 		return true;
-	} else if (msg._name == "SAVEGAME_LOADED") {
-		// Savegame loading uses the same ending part of the Thor death
-		// sequence to set up the loaded area in the default state
-		thorDead();
-		return true;
 	}
 
 	return false;
@@ -294,7 +289,7 @@ void GameContent::updateActors() {
 void GameContent::checkForAreaChange() {
 	if (_G(gameMode) == MODE_AREA_CHANGE) {
 		// Area transition is already in progress
-		switch (_transitionDir) {
+		switch (_G(transitionDir)) {
 		case DIR_LEFT:
 		case DIR_RIGHT:
 			_transitionPos += 32;
@@ -311,8 +306,10 @@ void GameContent::checkForAreaChange() {
 			break;
 		}
 
-		if (_G(gameMode) == MODE_NORMAL)
-			areaChanged();
+		if (_G(gameMode) == MODE_NORMAL) {
+			_transitionPos = 0;
+			show_level_done();
+		}
 
 	} else if (_G(new_level) != _G(current_level)) {
 		// Area transition beginning
@@ -329,82 +326,9 @@ void GameContent::checkForAreaChange() {
 		// Set up new level
 		_G(thor)->used = 1;
 		show_level(_G(new_level));
-
-		if (_G(warp_flag))
-			_G(current_level) = _G(new_level) - 5;   // Force phase
-
-		_G(warp_flag) = 0;
-		if (_G(warp_scroll)) {
-			_G(warp_scroll) = 0;
-			if (_G(thor)->dir == 0)
-				_G(current_level) = _G(new_level) + 10;
-			else if (_G(thor)->dir == 1)
-				_G(current_level) = _G(new_level) - 10;
-			else if (_G(thor)->dir == 2)
-				_G(current_level) = _G(new_level) + 1;
-			else if (_G(thor)->dir == 3)
-				_G(current_level) = _G(new_level) - 1;
-		}
-
-		if (!_G(setup).scroll_flag)
-			_G(current_level) = _G(new_level); // Force no scroll
-
-		if (_G(music_current) != _G(level_type))
-			music_pause();
-
-		_transitionPos = 0;
-
-		switch (_G(new_level) - _G(current_level)) {
-		case 0:
-			// Nothing to do
-			areaChanged();
-			break;
-		case -1:
-			_G(gameMode) = MODE_AREA_CHANGE;
-			_transitionDir = DIR_LEFT;
-			break;
-		case 1:
-			_G(gameMode) = MODE_AREA_CHANGE;
-			_transitionDir = DIR_RIGHT;
-			break;
-		case -10:
-			_G(gameMode) = MODE_AREA_CHANGE;
-			_transitionDir = DIR_UP;
-			break;
-		case 10:
-			_G(gameMode) = MODE_AREA_CHANGE;
-			_transitionDir = DIR_DOWN;
-			break;
-		default:
-			// TODO: Original had weird as hell random delay calculation.
-			// Not sure that it's really necessary
-			areaChanged();
-			break;
-		}
 	} 
 }
 
-void GameContent::areaChanged() {
-	_G(current_level) = _G(new_level);
-
-	_G(thor_info).last_health = _G(thor)->health;
-	_G(thor_info).last_magic = _G(thor_info).magic;
-	_G(thor_info).last_jewels = _G(thor_info).jewels;
-	_G(thor_info).last_keys = _G(thor_info).keys;
-	_G(thor_info).last_score = _G(thor_info).score;
-	_G(thor_info).last_item = _G(thor_info).item;
-	_G(thor_info).last_screen = _G(current_level);
-	_G(thor_info).last_icon = ((_G(thor)->x + 8) / 16) + (((_G(thor)->y + 14) / 16) * 20);
-	_G(thor_info).last_dir = _G(thor)->dir;
-	_G(thor_info).last_inventory = _G(thor_info).inventory;
-	_G(thor_info).last_object = _G(thor_info).object;
-	_G(thor_info).last_object_name = _G(thor_info).object_name;
-
-	_G(last_setup) = _G(setup);
-
-	music_play(_G(level_type), 0);
-}
-
 void GameContent::thorDies() {
 	// Stop any actors on-screen from moving
 	for (int li = 0; li < MAX_ACTORS; li++)
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index d32717417bb..b89ada551c2 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -29,13 +29,9 @@ namespace Got {
 namespace Views {
 
 class GameContent : public View {
-	enum TransitionDir {
-		DIR_LEFT, DIR_RIGHT, DIR_UP, DIR_DOWN
-	};
 private:
 	GfxSurface _surface;
 	Common::Point _moveDelta;
-	TransitionDir _transitionDir = DIR_LEFT;
 	int _transitionPos = 0;
 	int _deathCtr = 0;
 


Commit: 0c28a0c32401cb8902605b15a28cdd36e50f07fc
    https://github.com/scummvm/scummvm/commit/0c28a0c32401cb8902605b15a28cdd36e50f07fc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix explosion/sparkle loading

Changed paths:
    engines/got/data/defines.h
    engines/got/data/level.cpp
    engines/got/game/move.cpp
    engines/got/gfx/image.cpp


diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index a56bf08cbce..2b2133e2f59 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -115,6 +115,7 @@ struct ACTOR {                      // Size=256
 	byte future2[25] = {};
 
 	void loadFixed(Common::SeekableReadStream *src);
+	void loadFixed(const byte *src);
 
 	int getPos() const {
 		return ((x + 7) / 16) + (((y + 8) / 16) * 20);
diff --git a/engines/got/data/level.cpp b/engines/got/data/level.cpp
index c5e4796106d..6a509bbcce7 100644
--- a/engines/got/data/level.cpp
+++ b/engines/got/data/level.cpp
@@ -101,4 +101,9 @@ void ACTOR::loadFixed(Common::SeekableReadStream *src) {
 	src->read(future1, 4);
 }
 
+void ACTOR::loadFixed(const byte *src) {
+	Common::MemoryReadStream stream(src, 40);
+	loadFixed(&stream);
+}
+
 } // namespace Got
diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index 2cb7b89ce38..a93b440c7f6 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -157,7 +157,7 @@ void thor_damaged(ACTOR *actr) {
 
 void actor_destroyed(ACTOR *actr) {
 	int x, y, x1, y1, r, n, t;
-	int pge = 0;
+	int pge = _G(pge);
 
 	if (actr->actor_num > 2) {
 		x = actr->last_x[pge ^ 1];
diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index 206930d077c..ff8fd80b865 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -116,13 +116,13 @@ int load_standard_actors() {
 	make_actor_surface(&_G(actor)[1]);
 
 	load_actor(0, 106);   // Load sparkle
-	memcpy(&_G(sparkle), (_G(tmp_buff) + 5120), 40);
+	_G(sparkle).loadFixed(_G(tmp_buff) + 5120);
 	setup_actor(&_G(sparkle), 20, 0, 100, 100);
 	_G(sparkle).used = 0;
 	make_actor_surface(&_G(sparkle));
 
 	load_actor(0, 107);   // Load explosion
-	memcpy(&_G(explosion), (_G(tmp_buff) + 5120), 40);
+	_G(explosion).loadFixed(_G(tmp_buff) + 5120);
 	setup_actor(&_G(explosion), 21, 0, 100, 100);
 	_G(explosion).used = 0;
 	make_actor_surface(&_G(explosion));


Commit: 2ceee45724d6ae3034e11a7c345b4be4bfc66eeb
    https://github.com/scummvm/scummvm/commit/2ceee45724d6ae3034e11a7c345b4be4bfc66eeb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: More global object loading fixes

Changed paths:
    engines/got/gfx/image.cpp


diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index ff8fd80b865..a257a75934a 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -129,8 +129,7 @@ int load_standard_actors() {
 
 	load_actor(0, 108);   // Load tornado
 
-	Common::MemoryReadStream mi((const byte *)_G(tmp_buff) + 5120, 40);
-	_G(magic_item)[0].loadFixed(&mi);
+	_G(magic_item)[0].loadFixed((const byte *)_G(tmp_buff) + 5120);
 	Common::copy(_G(tmp_buff), _G(tmp_buff) + 1024, _G(magic_pic)[0]);
 
 	setup_actor(&_G(magic_item)[0], 20, 0, 0, 0);
@@ -138,8 +137,7 @@ int load_standard_actors() {
 
 	load_actor(0, 1099);   // Load shield
 
-	mi.seek(0);
-	_G(magic_item)[1].loadFixed(&mi);
+	_G(magic_item)[1].loadFixed((const byte *)_G(tmp_buff) + 5120);
 	Common::copy(_G(tmp_buff), _G(tmp_buff) + 1024, _G(magic_pic)[1]);
 
 	setup_actor(&_G(magic_item)[1], 20, 0, 0, 0);
@@ -149,7 +147,7 @@ int load_standard_actors() {
 	_G(magic_ami) = _G(ami_buff);
 	_G(magic_mask_buff) = _G(mask_buff);
 
-	make_actor_surface(&_G(magic_item)[0]);  // To fool next lines
+	make_actor_surface(&_G(magic_item)[0]);
 
 	_G(enemy_mb) = _G(mask_buff);
 	_G(enemy_ami) = _G(ami_buff);


Commit: 13824811d0f69da268499bf306fece46a11dd3d4
    https://github.com/scummvm/scummvm/commit/13824811d0f69da268499bf306fece46a11dd3d4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix sparkles to appear where enemies die

Changed paths:
  A engines/got/data/actor.cpp
  A engines/got/data/actor.h
    engines/got/data/defines.h
    engines/got/data/level.cpp
    engines/got/game/move.cpp
    engines/got/module.mk


diff --git a/engines/got/data/actor.cpp b/engines/got/data/actor.cpp
new file mode 100644
index 00000000000..b46d7d27112
--- /dev/null
+++ b/engines/got/data/actor.cpp
@@ -0,0 +1,94 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/algorithm.h"
+#include "common/memstream.h"
+#include "got/data/actor.h"
+
+namespace Got {
+
+void ACTOR::loadFixed(Common::SeekableReadStream *src) {
+	move = src->readByte();
+	width = src->readByte();
+	height = src->readByte();
+	directions = src->readByte();
+	frames = src->readByte();
+	frame_speed = src->readByte();
+	src->read(frame_sequence, 4);
+	speed = src->readByte();
+	size_x = src->readByte();
+	size_y = src->readByte();
+	strength = src->readByte();
+	health = src->readByte();
+	num_moves = src->readByte();
+	shot_type = src->readByte();
+	shot_pattern = src->readByte();
+	shots_allowed = src->readByte();
+	solid = src->readByte();
+	flying = src->readByte();
+	rating = src->readByte();
+	type = src->readByte();
+	src->read(name, 9);
+	func_num = src->readByte();
+	func_pass = src->readByte();
+	magic_hurts = src->readSint16LE();
+	src->read(future1, 4);
+}
+
+void ACTOR::loadFixed(const byte *src) {
+	Common::MemoryReadStream stream(src, 40);
+	loadFixed(&stream);
+}
+
+void ACTOR::copyFixedAndPics(const ACTOR &src) {
+	move = src.move;
+	width = src.width;
+	height = src.height;
+	directions = src.directions;
+	frames = src.frames;
+	frame_speed = src.frame_speed;
+	Common::copy(src.frame_sequence, src.frame_sequence + 4, frame_sequence);
+	speed = src.speed;
+	size_x = src.size_x;
+	size_y = src.size_y;
+	strength = src.strength;
+	health = src.health;
+	num_moves = src.num_moves;
+	shot_type = src.shot_type;
+	shot_pattern = src.shot_pattern;
+	shots_allowed = src.shots_allowed;
+	solid = src.solid;
+	flying = src.flying;
+	rating = src.rating;
+	type = src.type;
+	Common::copy(src.name, src.name + 9, name);
+	func_num = src.func_num;
+	func_pass = src.func_pass;
+	magic_hurts = src.magic_hurts;
+	Common::copy(src.future1, src.future1 + 4, future1);
+
+	// Copy all the surfaces for all the directions over
+	for (int d = 0; d < DIRECTION_COUNT; ++d)
+		for (int f = 0; f < FRAME_COUNT; ++f)
+			pic[d][f] = src.pic[d][f];
+}
+
+} // namespace Got
diff --git a/engines/got/data/actor.h b/engines/got/data/actor.h
new file mode 100644
index 00000000000..959adf11957
--- /dev/null
+++ b/engines/got/data/actor.h
@@ -0,0 +1,124 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/stream.h"
+#include "graphics/managed_surface.h"
+
+#ifndef GOT_DATA_ACTOR_H
+#define GOT_DATA_ACTOR_H
+
+namespace Got {
+
+#define DIRECTION_COUNT 4
+#define FRAME_COUNT 4
+
+struct ACTOR {                      // Size=256
+	// First part loaded from disk  (size=40)
+	byte move = 0;                  // Movement pattern (0=none)
+	byte width = 0;                 // Physical width
+	byte height = 0;                // Physical height
+	byte directions = 0;            // 1,2 or 4 (1=uni-directional)
+	byte frames = 0;                // # frames per direction
+	byte frame_speed = 0;           // # cycles between frame changes
+	byte frame_sequence[4] = {};    // Sequence
+	byte speed = 0;                 // Move every Nth cycle
+	byte size_x = 0;                // Non-physical padding on X coor
+	byte size_y = 0;                // Non-phsyical padding on Y coor
+	byte strength = 0;              // Hit strength
+	byte health = 0;                // 
+	byte num_moves = 0;             // # of moves every <speed> cycles
+	byte shot_type = 0;             // Actor # of shot
+	byte shot_pattern = 0;          // Func number to decide to shoot
+	byte shots_allowed = 0;         // # shots allowed on screen
+	byte solid = 0;                 // 1=solid (not ghost,etc)
+	byte flying = 0;                // 
+	byte rating = 0;                // rnd(100) < rating = jewel
+	byte type = 0;                  // Actor (0=thor,1=hammer,2=enemy,3=shot)
+	char name[9] = {};              // Actors name
+	byte func_num = 0;              // Special function when thor touches
+	byte func_pass = 0;             // Value to pass to func
+	uint16  magic_hurts = 0;           // Bitwise magic hurts flags
+	byte future1[4] = {};
+
+	// The rest is dynamic    //size=216
+	// Direction/frame surfaces
+	Graphics::ManagedSurface pic[DIRECTION_COUNT][FRAME_COUNT];
+
+	byte frame_count = 0;           // Count to switch frames
+	byte dir = 0;                   // Direction of travel
+	byte last_dir = 0;              // Last direction of travel
+	int  x = 0;                     // Actual X coor
+	int  y = 0;                     // Actual Y coor
+	int  center = 0;                // Center of object
+	int  last_x[2] = {};            // Last X coor on each page
+	int  last_y[2] = {};            // Last Y coor on each page
+	byte used = 0;                  // 1=active, 0=not active
+	byte next = 0;                  // Next frame to be shown
+	byte speed_count = 0;           // Count down to movement
+	byte vunerable = 0;             // Count down to vunerability
+	byte shot_cnt = 0;              // Count down to another shot
+	byte num_shots = 0;             // # of shots currently on screen
+	byte creator = 0;               // Which actor # created this actor
+	byte pause = 0;                 // Pause must be 0 to move
+	byte actor_num = 0;
+	byte move_count = 0;
+	byte dead = 0;
+	byte toggle = 0;
+	byte center_x = 0;
+	byte center_y = 0;
+	byte show = 0;                  // Display or not (for blinking)
+	byte temp1 = 0;
+	byte temp2 = 0;
+	byte counter = 0;
+	byte move_counter = 0;
+	byte edge_counter = 0;
+	byte temp3 = 0;
+	byte temp4 = 0;
+	byte temp5 = 0;
+	byte hit_thor = 0;
+	int  rand = 0;
+	byte init_dir = 0;
+	byte pass_value = 0;
+	byte shot_actor = 0;
+	byte magic_hit = 0;
+	byte temp6 = 0;
+	int  i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+	byte init_health = 0;
+	byte talk_counter = 0;
+	byte etype = 0;
+	byte future2[25] = {};
+
+	void loadFixed(Common::SeekableReadStream *src);
+	void loadFixed(const byte *src);
+
+	/**
+	 * Copies the fixed portion and pics from a source actor.
+	 */
+	void copyFixedAndPics(const ACTOR &src);
+
+	int getPos() const {
+		return ((x + 7) / 16) + (((y + 8) / 16) * 20);
+	}
+};
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index 2b2133e2f59..46f73567ed2 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -24,7 +24,7 @@
 
 #include "common/scummsys.h"
 #include "common/serializer.h"
-#include "graphics/managed_surface.h"
+#include "got/data/actor.h"
 #include "got/data/level.h"
 #include "got/data/sd_data.h"
 #include "got/data/setup.h"
@@ -35,93 +35,6 @@ namespace Got {
 #define REPEAT(a) for(rep=0;rep<a;rep++)
 #define IN_RANGE(v,l,h) (v>=l && v<=h)
 
-#define DIRECTION_COUNT 4
-#define FRAME_COUNT 4
-
-struct ACTOR {                      // Size=256
-	// First part loaded from disk  (size=40)
-	byte move = 0;                  // Movement pattern (0=none)
-	byte width = 0;                 // Physical width
-	byte height = 0;                // Physical height
-	byte directions = 0;            // 1,2 or 4 (1=uni-directional)
-	byte frames = 0;                // # frames per direction
-	byte frame_speed = 0;           // # cycles between frame changes
-	byte frame_sequence[4] = {};    // Sequence
-	byte speed = 0;                 // Move every Nth cycle
-	byte size_x = 0;                // Non-physical padding on X coor
-	byte size_y = 0;                // Non-phsyical padding on Y coor
-	byte strength = 0;              // Hit strength
-	byte health = 0;                // 
-	byte num_moves = 0;             // # of moves every <speed> cycles
-	byte shot_type = 0;             // Actor # of shot
-	byte shot_pattern = 0;          // Func number to decide to shoot
-	byte shots_allowed = 0;         // # shots allowed on screen
-	byte solid = 0;                 // 1=solid (not ghost,etc)
-	byte flying = 0;                // 
-	byte rating = 0;                // rnd(100) < rating = jewel
-	byte type = 0;                  // Actor (0=thor,1=hammer,2=enemy,3=shot)
-	char name[9] = {};              // Actors name
-	byte func_num = 0;              // Special function when thor touches
-	byte func_pass = 0;             // Value to pass to func
-	uint16  magic_hurts = 0;           // Bitwise magic hurts flags
-	byte future1[4] = {};
-
-	// The rest is dynamic    //size=216
-	// Direction/frame surfaces
-	Graphics::ManagedSurface pic[DIRECTION_COUNT][FRAME_COUNT];
-
-	byte frame_count = 0;           // Count to switch frames
-	byte dir = 0;                   // Direction of travel
-	byte last_dir = 0;              // Last direction of travel
-	int  x = 0;                     // Actual X coor
-	int  y = 0;                     // Actual Y coor
-	int  center = 0;                // Center of object
-	int  last_x[2] = {};            // Last X coor on each page
-	int  last_y[2] = {};            // Last Y coor on each page
-	byte used = 0;                  // 1=active, 0=not active
-	byte next = 0;                  // Next frame to be shown
-	byte speed_count = 0;           // Count down to movement
-	byte vunerable = 0;             // Count down to vunerability
-	byte shot_cnt = 0;              // Count down to another shot
-	byte num_shots = 0;             // # of shots currently on screen
-	byte creator = 0;               // Which actor # created this actor
-	byte pause = 0;                 // Pause must be 0 to move
-	byte actor_num = 0;
-	byte move_count = 0;
-	byte dead = 0;
-	byte toggle = 0;
-	byte center_x = 0;
-	byte center_y = 0;
-	byte show = 0;                  // Display or not (for blinking)
-	byte temp1 = 0;
-	byte temp2 = 0;
-	byte counter = 0;
-	byte move_counter = 0;
-	byte edge_counter = 0;
-	byte temp3 = 0;
-	byte temp4 = 0;
-	byte temp5 = 0;
-	byte hit_thor = 0;
-	int  rand = 0;
-	byte init_dir = 0;
-	byte pass_value = 0;
-	byte shot_actor = 0;
-	byte magic_hit = 0;
-	byte temp6 = 0;
-	int  i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
-	byte init_health = 0;
-	byte talk_counter = 0;
-	byte etype = 0;
-	byte future2[25] = {};
-
-	void loadFixed(Common::SeekableReadStream *src);
-	void loadFixed(const byte *src);
-
-	int getPos() const {
-		return ((x + 7) / 16) + (((y + 8) / 16) * 20);
-	}
-};
-
 struct ACTOR_NFO {				//size=40
 	byte move = 0;                  //movement pattern (0=none)
 	byte width = 0;                 //physical width
diff --git a/engines/got/data/level.cpp b/engines/got/data/level.cpp
index 6a509bbcce7..49edf3fd0fc 100644
--- a/engines/got/data/level.cpp
+++ b/engines/got/data/level.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "common/algorithm.h"
 #include "common/memstream.h"
 #include "got/data/defines.h"
 
@@ -72,38 +73,4 @@ void LEVEL::save(byte *dest) {
 	save(&stream);
 }
 
-
-void ACTOR::loadFixed(Common::SeekableReadStream *src) {
-	move = src->readByte();
-	width = src->readByte();
-	height = src->readByte();
-	directions = src->readByte();
-	frames = src->readByte();
-	frame_speed = src->readByte();
-	src->read(frame_sequence, 4);
-	speed = src->readByte();
-	size_x = src->readByte();
-	size_y = src->readByte();
-	strength = src->readByte();
-	health = src->readByte();
-	num_moves = src->readByte();
-	shot_type = src->readByte();
-	shot_pattern = src->readByte();
-	shots_allowed = src->readByte();
-	solid = src->readByte();
-	flying = src->readByte();
-	rating = src->readByte();
-	type = src->readByte();
-	src->read(name, 9);
-	func_num = src->readByte();
-	func_pass = src->readByte();
-	magic_hurts = src->readSint16LE();
-	src->read(future1, 4);
-}
-
-void ACTOR::loadFixed(const byte *src) {
-	Common::MemoryReadStream stream(src, 40);
-	loadFixed(&stream);
-}
-
 } // namespace Got
diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index a93b440c7f6..5edbe71c9ea 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -169,9 +169,9 @@ void actor_destroyed(ACTOR *actr) {
 		t = actr->type;
 
 		if (actr->func_num == 255)
-			*actr = _G(explosion);
+			actr->copyFixedAndPics(_G(explosion));
 		else
-			*actr = _G(sparkle);
+			actr->copyFixedAndPics(_G(sparkle));
 
 		actr->type = t;
 		actr->actor_num = n;
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 7ccd413e19c..c4b543cff43 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -8,6 +8,7 @@ MODULE_OBJS = \
 	metaengine.o \
 	sound.o \
 	vars.o \
+	data/actor.o \
 	data/level.o \
 	data/sd_data.o \
 	data/setup.o \


Commit: b008c82d714eebfe13822280f47b911a07f37c60
    https://github.com/scummvm/scummvm/commit/b008c82d714eebfe13822280f47b911a07f37c60
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix Say dialog crash when talking to NPCs

Changed paths:
    engines/got/game/back.cpp
    engines/got/game/move_patterns.cpp
    engines/got/game/script.cpp
    engines/got/game/script.h
    engines/got/gfx/gfx_pics.h
    engines/got/views/dialogs/say.cpp
    engines/got/views/dialogs/say.h
    engines/got/views/game_content.cpp


diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index 068c6c0ab00..679a7ef590e 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -149,7 +149,7 @@ void show_level_done() {
 }
 
 void odin_speaks(int index, int item) {
-	execute_script((long)index, &_G(odin));
+	execute_script((long)index, _G(odin));
 
 	if (!_G(thor)->health) {
 		_G(thor)->show = 0;
@@ -298,7 +298,6 @@ int actor_speaks(ACTOR *actr, int index, int item) {
 	Common::String str;
 	int v;
 	long lind;
-	Gfx::Pics *pic;
 
 	if (actr->type != 4)
 		return 0;
@@ -306,20 +305,18 @@ int actor_speaks(ACTOR *actr, int index, int item) {
 	if (v < 1 || v>20)
 		return 0;
 
-	str = Common::String::format("FACE%d", v);
+	lind = (long)_G(current_level);
+	lind = lind * 1000;
+	lind += (long)actr->actor_num;
 
-	Gfx::Pics pics(str, -1, false);
+	str = Common::String::format("FACE%d", v);
 	if (Common::File::exists(Common::Path(str))) {
-		pics.load();
-		pic = &pics;
+		Gfx::Pics pics(str, 262);
+		execute_script(lind, pics);
 	} else {
-		pic = &_G(odin);
+		execute_script(lind, _G(odin));
 	}
 
-	lind = (long)_G(current_level);
-	lind = lind * 1000;
-	lind += (long)actr->actor_num;
-	execute_script(lind, pic);
 	if (!_G(thor)->health) {
 		_G(thor)->show = 0;
 		_G(exit_flag) = 2;
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 7d85b7d7a36..669eeaf8095 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -856,7 +856,7 @@ int special_movement_three(ACTOR *actr) {  //yellow globe
 	lind = (long)_G(current_level);
 	lind = lind * 1000;
 	lind += (long)actr->actor_num;
-	execute_script(lind, &_G(odin));
+	execute_script(lind, _G(odin));
 
 	return 0;
 }
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 33d6923d6f9..eb3fb3cd8e7 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -93,8 +93,8 @@ Scripts::ScrFunction Scripts::scr_func[5] = {
 
 Scripts *g_scripts;
 
-void execute_script(long index, Gfx::Pics *pic) {
-	g_scripts->execute_script(index, pic);
+void execute_script(long index, const Gfx::Pics &speakerIcon) {
+	g_scripts->execute_script(index, speakerIcon);
 }
 
 Scripts::Scripts() {
@@ -105,12 +105,13 @@ Scripts::~Scripts() {
 	g_scripts = nullptr;
 }
 
-void Scripts::execute_script(long index, Gfx::Pics *pic) {
-	// Firstly hide any on-screen actors
-	g_events->send(GameMessage("HIDE_ACTORS"));
+void Scripts::execute_script(long index, const Gfx::Pics &speakerIcon) {
+	// Firstly disable any on-screen actors
+	for (int i = 0; i < MAX_ACTORS; i++)
+		_G(actor)[i].show = 0;
 
 	scr_index = index;
-	scr_pic = pic;
+	scr_pic = speakerIcon;
 
 	Common::fill(num_var, num_var + 26, 0);
 	Common::fill((char *)str_var, (char *)str_var + 81 * 26, 0);
diff --git a/engines/got/game/script.h b/engines/got/game/script.h
index 407f5e7b644..e3b92a1d95b 100644
--- a/engines/got/game/script.h
+++ b/engines/got/game/script.h
@@ -45,7 +45,7 @@ private:
 	char  *buff_end = nullptr;	   // pointer to end of buffer
 	char  *buffer = nullptr;       // buffer space (alloc'ed)
 	long  scr_index = 0;
-	Gfx::Pics *scr_pic = nullptr;
+	Gfx::Pics scr_pic;
 	long  lvalue = 0;
 	long  ltemp = 0;
 	char  temps[255] = {};
@@ -104,7 +104,7 @@ public:
 	Scripts();
 	~Scripts();
 
-	void execute_script(long index, Gfx::Pics *pic);
+	void execute_script(long index, const Gfx::Pics &speakerIcon);
 
 	void pause() {
 		_paused = true;
@@ -117,7 +117,7 @@ public:
 	void setAskResponse(int option);
 };
 
-extern void execute_script(long index, Gfx::Pics *pic);
+extern void execute_script(long index, const Gfx::Pics &speakerIcon);
 
 } // namespace Got
 
diff --git a/engines/got/gfx/gfx_pics.h b/engines/got/gfx/gfx_pics.h
index bdb7f01bd5f..025ba7cb254 100644
--- a/engines/got/gfx/gfx_pics.h
+++ b/engines/got/gfx/gfx_pics.h
@@ -59,7 +59,7 @@ public:
 class Pics : public GfxPics {
 private:
 	Common::String _resName;
-	int _blockSize;
+	int _blockSize = -1;
 
 public:
 	Pics(const Common::String &resName, int blockSize = -1,
@@ -68,6 +68,7 @@ public:
 		if (immediateLoad)
 			load();
 	}
+	Pics() {}
 
 	void load() {
 		GfxPics::load(_resName, _blockSize);
diff --git a/engines/got/views/dialogs/say.cpp b/engines/got/views/dialogs/say.cpp
index 3d6df535e9b..fc974f091ac 100644
--- a/engines/got/views/dialogs/say.cpp
+++ b/engines/got/views/dialogs/say.cpp
@@ -32,10 +32,10 @@ Say::Say() : Dialog("Say") {
 	setBounds(Common::Rect(32, 48, 288, 160));
 }
 
-void Say::show(int item, Gfx::Pics *pic, int type) {
+void Say::show(int item, const Gfx::Pics &speakerIcon, int type) {
 	Say *view = (Say *)g_events->findView("Say");
 	view->_item = item;
-	view->_pic = pic;
+	view->_speakerIcon = speakerIcon;
 	view->_type = type;
 	view->addView();
 }
@@ -108,7 +108,7 @@ void Say::draw() {
 		x += 8;
 	}
 
-	s.blitFrom((*_pic)[_picIndex], Common::Point(120, 17));
+	s.blitFrom(_speakerIcon[_picIndex], Common::Point(120, 17));
 
 	if (_waitForResponse == WAIT_MORE)
 		s.print(Common::Point(184, 86), "More...", 15);
diff --git a/engines/got/views/dialogs/say.h b/engines/got/views/dialogs/say.h
index 954e192c6dc..490b28e0576 100644
--- a/engines/got/views/dialogs/say.h
+++ b/engines/got/views/dialogs/say.h
@@ -34,7 +34,7 @@ class Say : public Dialog {
 		WAIT_NONE, WAIT_MORE, WAIT_DONE
 	};
 private:
-	Gfx::Pics *_pic = nullptr;
+	Gfx::Pics _speakerIcon;
 	int _item = 0;
 	int _type = 0;
 	int _picIndex = 0;
@@ -53,7 +53,7 @@ public:
 	Say();
 	virtual ~Say() {}
 
-	static void show(int item, Gfx::Pics *pic, int type);
+	static void show(int item, const Gfx::Pics &speakerIcon, int type);
 
 	void draw() override;
 	bool msgFocus(const FocusMessage &msg) override;
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index d69a444f774..5616aa59c5c 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -93,13 +93,7 @@ void GameContent::draw() {
 }
 
 bool GameContent::msgGame(const GameMessage &msg) {
-	if (msg._name == "HIDE_ACTORS") {
-		// Hide all actors and immediately redraw the screen
-		for (int i = 0; i < MAX_ACTORS; i++)
-			_G(actor)[i].show = 0;
-		draw();
-		return true;
-	} else if (msg._name == "THOR_DIES") {
+	if (msg._name == "THOR_DIES") {
 		thorDies();
 		return true;
 	}


Commit: f9877ec9144e72316703c75480a660b9cb63121a
    https://github.com/scummvm/scummvm/commit/f9877ec9144e72316703c75480a660b9cb63121a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix console original save loading, add original save saving

Changed paths:
    engines/got/console.cpp
    engines/got/console.h
    engines/got/data/thor_info.cpp


diff --git a/engines/got/console.cpp b/engines/got/console.cpp
index bb5a428c39c..8fcd8b8762a 100644
--- a/engines/got/console.cpp
+++ b/engines/got/console.cpp
@@ -33,6 +33,7 @@ Console::Console() : GUI::Debugger() {
 	registerCmd("sound", WRAP_METHOD(Console, cmdSound));
 	registerCmd("music", WRAP_METHOD(Console, cmdMusic));
 	registerCmd("load", WRAP_METHOD(Console, cmdLoad));
+	registerCmd("save", WRAP_METHOD(Console, cmdSave));
 	registerCmd("magic", WRAP_METHOD(Console, cmdMagic));
 }
 
@@ -62,21 +63,55 @@ bool Console::cmdMusic(int argc, const char **argv) {
 }
 
 bool Console::cmdLoad(int argc, const char **argv) {
-	if (argc == 2) {
-		Common::SeekableReadStream *f;
-		if ((f = g_system->getSavefileManager()->openForLoading(argv[1])) == nullptr) {
-			debugPrintf("Could not open savegame\n");
-			return true;
-		} else {
-			f->skip(32); // Skip the 32 bytes title
-
-			g_engine->loadGameStream(f);
-			delete f;
-			return false;
-		}
+	static const char *FILENAMES[3] = {
+		"savegam1.got", "savegam1.gt2", "savegam1.gt3"
+	};
+	Common::String filename = FILENAMES[_G(area) - 1];
+	if (argc == 2)
+		filename = argv[1];
+
+	Common::InSaveFile *f;
+	if ((f = g_system->getSavefileManager()->openForLoading(filename)) == nullptr) {
+		debugPrintf("Could not open %s\n", filename.c_str());
+		return true;
+	} else {
+		f->skip(32); // Skip the 32 bytes title
+
+		Common::Serializer s(f, nullptr);
+		g_engine->syncGame(s);
+		delete f;
+		return false;
+	}
+}
+
+bool Console::cmdSave(int argc, const char **argv) {
+	static const char *FILENAMES[3] = {
+		"savegam1.got", "savegam1.gt2", "savegam1.gt3"
+	};
+	Common::String filename = FILENAMES[_G(area) - 1];
+	if (argc == 2)
+		filename = argv[1];
+
+	Common::OutSaveFile *f;
+	if ((f = g_system->getSavefileManager()->openForSaving(filename, false)) == nullptr) {
+		debugPrintf("Could not create %s\n", filename.c_str());
+
+	} else {
+		// Write out dummy person name
+		char title[32];
+		Common::fill(title, title + 32, 0);
+		Common::strcpy_s(title, "ScummVM");
+
+		f->write(title, 32);
+
+		Common::Serializer s(nullptr, f);
+		g_engine->syncGame(s);
+
+		delete f;
+
+		debugPrintf("Created %s\n", filename.c_str());
 	}
 
-	debugPrintf("load <original savegame name>\n");
 	return true;
 }
 
diff --git a/engines/got/console.h b/engines/got/console.h
index 72955a927de..6849c926773 100644
--- a/engines/got/console.h
+++ b/engines/got/console.h
@@ -33,6 +33,7 @@ private:
 	bool cmdSound(int argc, const char **argv);
 	bool cmdMusic(int argc, const char **argv);
 	bool cmdLoad(int argc, const char **argv);
+	bool cmdSave(int argc, const char **argv);
 	bool cmdMagic(int argc, const char **argv);
 
 public:
diff --git a/engines/got/data/thor_info.cpp b/engines/got/data/thor_info.cpp
index 1408988a95b..d0ce3ff10f4 100644
--- a/engines/got/data/thor_info.cpp
+++ b/engines/got/data/thor_info.cpp
@@ -46,9 +46,9 @@ void THOR_INFO::sync(Common::Serializer &s) {
 	s.syncAsUint32LE(last_score);
 
 	s.syncAsByte(object);
-	s.syncAsUint32LE(ptr);
+	s.syncAsUint16LE(ptr);
 	s.syncAsByte(last_object);
-	s.syncAsUint32LE(ptr);
+	s.syncAsUint16LE(ptr);
 
 	s.syncAsByte(armor);
 	s.syncBytes(future, 65);


Commit: b7d6a920581d52574553f968449948a960863dcd
    https://github.com/scummvm/scummvm/commit/b7d6a920581d52574553f968449948a960863dcd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Remove duplication of filenames in console save/load

Changed paths:
    engines/got/console.cpp


diff --git a/engines/got/console.cpp b/engines/got/console.cpp
index 8fcd8b8762a..13d8dc8f8dc 100644
--- a/engines/got/console.cpp
+++ b/engines/got/console.cpp
@@ -28,6 +28,10 @@
 
 namespace Got {
 
+static const char *SAVE_FILENAMES[3] = {
+	"savegam1.got", "savegam1.gt2", "savegam1.gt3"
+};
+
 Console::Console() : GUI::Debugger() {
 	registerCmd("view",   WRAP_METHOD(Console, cmdView));
 	registerCmd("sound", WRAP_METHOD(Console, cmdSound));
@@ -63,10 +67,7 @@ bool Console::cmdMusic(int argc, const char **argv) {
 }
 
 bool Console::cmdLoad(int argc, const char **argv) {
-	static const char *FILENAMES[3] = {
-		"savegam1.got", "savegam1.gt2", "savegam1.gt3"
-	};
-	Common::String filename = FILENAMES[_G(area) - 1];
+	Common::String filename = SAVE_FILENAMES[_G(area) - 1];
 	if (argc == 2)
 		filename = argv[1];
 
@@ -85,10 +86,7 @@ bool Console::cmdLoad(int argc, const char **argv) {
 }
 
 bool Console::cmdSave(int argc, const char **argv) {
-	static const char *FILENAMES[3] = {
-		"savegam1.got", "savegam1.gt2", "savegam1.gt3"
-	};
-	Common::String filename = FILENAMES[_G(area) - 1];
+	Common::String filename = SAVE_FILENAMES[_G(area) - 1];
 	if (argc == 2)
 		filename = argv[1];
 


Commit: 44f5e0d652a0006c3ca095ac795be88b855940f1
    https://github.com/scummvm/scummvm/commit/44f5e0d652a0006c3ca095ac795be88b855940f1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Adding options dialogs, select option dialogs cleanup

Changed paths:
  A engines/got/views/dialogs/select_scroll.cpp
  A engines/got/views/dialogs/select_scroll.h
  A engines/got/views/dialogs/select_slow.cpp
  A engines/got/views/dialogs/select_slow.h
    engines/got/events.cpp
    engines/got/module.mk
    engines/got/views/dialogs/ask.cpp
    engines/got/views/dialogs/ask.h
    engines/got/views/dialogs/options_menu.cpp
    engines/got/views/dialogs/select_game.cpp
    engines/got/views/dialogs/select_option.cpp
    engines/got/views/dialogs/select_option.h
    engines/got/views/game.cpp
    engines/got/views/game.h
    engines/got/views/views.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 4f074a8dceb..1af941b0484 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -89,9 +89,6 @@ void Events::runGame() {
 			rotatePalette();
 		}
 
-		// Do tick action to the views to handle gameplay logic
-		tick();
-
 		if ((currTime = g_system->getMillis()) >= nextFrameTime) {
 			nextFrameTime = currTime + FRAME_DELAY;
 			nextFrame();
@@ -108,6 +105,9 @@ void Events::nextFrame() {
 	_G(pge) = _G(pge) ^ 1;
 	_G(shot_ok) = true;
 
+	// Do tick action to the views to handle gameplay logic
+	tick();
+
 	// Draw the current view's elements as needed, and update screen
 	drawElements();
 	_screen->update();
@@ -252,7 +252,7 @@ void Events::popView() {
 	priorView->msgUnfocus(UnfocusMessage());
 	_views.pop();
 
-	for (int i = 0; i < (int)_views.size() - 1; ++i) {
+	for (uint i = 0; i < _views.size(); ++i) {
 		_views[i]->redraw();
 		_views[i]->draw();
 	}
diff --git a/engines/got/module.mk b/engines/got/module.mk
index c4b543cff43..6cdb96d64ed 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -53,6 +53,8 @@ MODULE_OBJS = \
 	views/dialogs/say.o \
 	views/dialogs/select_game.o \
 	views/dialogs/select_item.o \
+	views/dialogs/select_scroll.o \
+	views/dialogs/select_slow.o \
 	views/dialogs/set_sound.o
 
 # This module can be built as a plugin
diff --git a/engines/got/views/dialogs/ask.cpp b/engines/got/views/dialogs/ask.cpp
index 6d254088277..af53ea33c90 100644
--- a/engines/got/views/dialogs/ask.cpp
+++ b/engines/got/views/dialogs/ask.cpp
@@ -36,6 +36,10 @@ void Ask::show(const Common::String &title, const Common::StringArray &options)
 }
 
 void Ask::closed() {
+	_G(scripts).setAskResponse(0);
+}
+
+void Ask::selected() {
 	_G(scripts).setAskResponse(_selectedItem + 1);
 }
 
diff --git a/engines/got/views/dialogs/ask.h b/engines/got/views/dialogs/ask.h
index 096242df49c..a1d494f0b18 100644
--- a/engines/got/views/dialogs/ask.h
+++ b/engines/got/views/dialogs/ask.h
@@ -36,6 +36,7 @@ public:
 	static void show(const Common::String &title,
 		const Common::StringArray &options);
 	void closed() override;
+	void selected() override;
 };
 
 } // namespace Dialogs
diff --git a/engines/got/views/dialogs/options_menu.cpp b/engines/got/views/dialogs/options_menu.cpp
index 89d1bc3077a..5d2ca35e8ee 100644
--- a/engines/got/views/dialogs/options_menu.cpp
+++ b/engines/got/views/dialogs/options_menu.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "got/views/dialogs/options_menu.h"
+#include "got/game/back.h"
 #include "got/gfx/palette.h"
 #include "got/utils/file.h"
 #include "got/vars.h"
@@ -39,10 +40,31 @@ OptionsMenu::OptionsMenu() : SelectOption("OptionsMenu", "Options Menu", OPTIONS
 void OptionsMenu::selected() {
 	switch (_selectedItem) {
 	case 0:
-		replaceView("SetSound");
+		addView("SetSound");
+		break;
+	case 1:
+		// skill level
+		break;
+	case 2:
+		close();
+		g_engine->saveGameDialog();
+		break;
+	case 3:
+		close();
+		g_engine->loadGameDialog();
+		break;
+	case 4:
+		g_events->send(GameMessage("THOR_DIES"));
+		break;
+	case 5:
+		addView("SelectSlow");
+		break;
+	case 6:
+		// Help
+		odin_speaks(2008, -1);
 		break;
 	case 7:
-		replaceView("QuitGame");
+		addView("QuitGame");
 		break;
 	default:
 		break;
diff --git a/engines/got/views/dialogs/select_game.cpp b/engines/got/views/dialogs/select_game.cpp
index b09e85df41d..36fcd6d9e5d 100644
--- a/engines/got/views/dialogs/select_game.cpp
+++ b/engines/got/views/dialogs/select_game.cpp
@@ -33,15 +33,15 @@ static const char *OPTIONS[] = {
 	nullptr
 };
 
-SelectGame::SelectGame() : SelectOption("SelectGame", "Play WHich Game?", OPTIONS) {
+SelectGame::SelectGame() : SelectOption("SelectGame", "Play Which Game?", OPTIONS) {
 }
 
 void SelectGame::selected() {
 	// Select the game area to start from
 	g_vars->setArea(_selectedItem + 1);
 
-	// Switch to the game view
-	replaceView("Game", true);
+	// Switch to the story view for the selected game area
+	replaceView("Story", true, true);
 }
 
 } // namespace Dialogs
diff --git a/engines/got/views/dialogs/select_option.cpp b/engines/got/views/dialogs/select_option.cpp
index 1edb0a0cd2f..623af93f776 100644
--- a/engines/got/views/dialogs/select_option.cpp
+++ b/engines/got/views/dialogs/select_option.cpp
@@ -46,6 +46,7 @@ SelectOption::SelectOption(const Common::String &name) : Dialog(name) {
 void SelectOption::setContent(const Common::String &title,
 		const Common::StringArray &options) {
 	_title = title;
+	_options = options;
 
 	// Calculate the bounds for the dialog
 	int w, h, x1, y1, x2, y2;
@@ -117,7 +118,9 @@ bool SelectOption::msgAction(const ActionMessage &msg) {
 
 	case KEYBIND_ESCAPE:
 		_selectedItem = -1;
+		close();
 		closed();
+		break;
 
 	default:
 		break;
@@ -126,6 +129,15 @@ bool SelectOption::msgAction(const ActionMessage &msg) {
 	return true;
 }
 
+bool SelectOption::msgKeypress(const KeypressMessage &msg) {
+	if (msg.keycode == Common::KEYCODE_RETURN) {
+		_smackCtr = 1;
+		return true;
+	}
+
+	return false;
+}
+
 bool SelectOption::tick() {
 	if (++_hammerFrame == 4)
 		_hammerFrame = 0;
@@ -137,6 +149,7 @@ bool SelectOption::tick() {
 			play_sound(CLANG, 1);
 		if (_smackCtr == 6) {
 			_smackCtr = 0;
+			close();
 			selected();
 		}	
 	}
diff --git a/engines/got/views/dialogs/select_option.h b/engines/got/views/dialogs/select_option.h
index 55e4f6bd48b..02fa2d06575 100644
--- a/engines/got/views/dialogs/select_option.h
+++ b/engines/got/views/dialogs/select_option.h
@@ -46,9 +46,7 @@ protected:
 
 	void setContent(const Common::String &title,
 		const Common::StringArray &options);
-	virtual void closed() {
-		close();
-	}
+	virtual void closed() {}
 	virtual void selected() {}
 
 public:
@@ -63,6 +61,7 @@ public:
 		return true;
 	}
 	bool msgAction(const ActionMessage &msg) override;
+	bool msgKeypress(const KeypressMessage &msg) override;
 	void draw() override;
 	bool tick() override;
 };
diff --git a/engines/got/views/dialogs/select_scroll.cpp b/engines/got/views/dialogs/select_scroll.cpp
new file mode 100644
index 00000000000..69aadf3f860
--- /dev/null
+++ b/engines/got/views/dialogs/select_scroll.cpp
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/select_scroll.h"
+#include "got/got.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+SelectScroll::SelectScroll() : SelectOption("SelectScroll", "Scroll Between Screens?", YES_NO) {
+}
+
+bool SelectScroll::msgFocus(const FocusMessage &msg) {
+	_selectedItem = 1 - _G(setup).scroll_flag;
+	return true;
+}
+
+void SelectScroll::selected() {
+	_G(setup).scroll_flag = (_selectedItem == 0) ? 1 : 0;
+	_G(last_setup) = _G(setup);
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/select_scroll.h b/engines/got/views/dialogs/select_scroll.h
new file mode 100644
index 00000000000..9fcfc431b01
--- /dev/null
+++ b/engines/got/views/dialogs/select_scroll.h
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_SELECT_SCROLL_H
+#define GOT_VIEWS_DIALOGS_SELECT_SCROLL_H
+
+#include "got/views/dialogs/select_option.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class SelectScroll : public SelectOption {
+public:
+	SelectScroll();
+	virtual ~SelectScroll() {
+	}
+
+	bool msgFocus(const FocusMessage &msg) override;
+	void selected() override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/dialogs/select_slow.cpp b/engines/got/views/dialogs/select_slow.cpp
new file mode 100644
index 00000000000..cc19e8cda97
--- /dev/null
+++ b/engines/got/views/dialogs/select_slow.cpp
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/select_slow.h"
+#include "got/got.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+static const char *OPTIONS[] = { 
+	"On  (slow computer)",
+	"Off (fast computer)",
+	nullptr
+};
+
+SelectSlow::SelectSlow() : SelectOption("SelectSlow", "Fast Mode", OPTIONS) {
+}
+
+void SelectSlow::selected() {
+	switch (_selectedItem) {
+	case 0:
+		_G(slow_mode) = 1;
+		break;
+	case 1:
+		_G(slow_mode) = 0;
+		break;
+	default:
+		break;
+	}
+
+	// Next select scrolling
+	addView("SelectScroll");
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/select_slow.h b/engines/got/views/dialogs/select_slow.h
new file mode 100644
index 00000000000..58ae1a5d7f0
--- /dev/null
+++ b/engines/got/views/dialogs/select_slow.h
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_SELECT_SLOW_H
+#define GOT_VIEWS_DIALOGS_SELECT_SLOW_H
+
+#include "got/views/dialogs/select_option.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class SelectSlow : public SelectOption {
+public:
+	SelectSlow();
+	virtual ~SelectSlow() {
+	}
+
+	void selected() override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 8a610d06821..d6b80776293 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -36,11 +36,6 @@ Game::Game() : View("Game") {
 	_status.setBounds(Common::Rect(0, 240 - 48, 320, 240));
 }
 
-void Game::draw() {
-	GfxSurface s = getSurface();
-	s.clear();
-}
-
 bool Game::msgKeypress(const KeypressMessage &msg) {
 	if (_G(gameMode) != MODE_NORMAL)
 		return false;
@@ -82,6 +77,10 @@ bool Game::msgAction(const ActionMessage &msg) {
 		_content.send(GameMessage("THOR_DIES"));
 		return true;
 
+	case KEYBIND_ESCAPE:
+		addView("OptionsMenu");
+		return true;
+
 	default:
 		break;
 	}
diff --git a/engines/got/views/game.h b/engines/got/views/game.h
index 6f0eefbd308..b3cac3eabeb 100644
--- a/engines/got/views/game.h
+++ b/engines/got/views/game.h
@@ -40,7 +40,6 @@ public:
 
 	bool msgKeypress(const KeypressMessage &msg) override;
 	bool msgAction(const ActionMessage &msg) override;
-	void draw() override;
 	bool tick() override;
 };
 
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index 7ea6d92e078..dea3c00a58b 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -33,6 +33,8 @@
 #include "got/views/dialogs/quit_game.h"
 #include "got/views/dialogs/say.h"
 #include "got/views/dialogs/select_game.h"
+#include "got/views/dialogs/select_scroll.h"
+#include "got/views/dialogs/select_slow.h"
 #include "got/views/dialogs/select_item.h"
 #include "got/views/dialogs/set_sound.h"
 
@@ -53,6 +55,8 @@ struct Views {
 	Dialogs::Say _say;
 	Dialogs::SelectGame _selectGame;
 	Dialogs::SelectItem _selectItem;
+	Dialogs::SelectScroll _selectScroll;
+	Dialogs::SelectSlow _selectSlow;
 	Dialogs::SetSound _setSound;
 };
 


Commit: cb53e9cbea9ba50c9f7b0afe622dce871654d602
    https://github.com/scummvm/scummvm/commit/cb53e9cbea9ba50c9f7b0afe622dce871654d602
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Add Save Game prompt dialog for quitting to DOS/Title

Changed paths:
  A engines/got/views/dialogs/save_game.cpp
  A engines/got/views/dialogs/save_game.h
    engines/got/module.mk
    engines/got/views/dialogs/quit_game.cpp
    engines/got/views/views.h


diff --git a/engines/got/module.mk b/engines/got/module.mk
index 6cdb96d64ed..36c00837712 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -50,6 +50,7 @@ MODULE_OBJS = \
 	views/dialogs/play_game.o \
 	views/dialogs/quit.o \
 	views/dialogs/quit_game.o \
+	views/dialogs/save_game.o \
 	views/dialogs/say.o \
 	views/dialogs/select_game.o \
 	views/dialogs/select_item.o \
diff --git a/engines/got/views/dialogs/quit_game.cpp b/engines/got/views/dialogs/quit_game.cpp
index 2143a361f1f..38a87781107 100644
--- a/engines/got/views/dialogs/quit_game.cpp
+++ b/engines/got/views/dialogs/quit_game.cpp
@@ -36,13 +36,14 @@ QuitGame::QuitGame() : SelectOption("QuitGame", "Quit Game?", OPTIONS) {
 void QuitGame::selected() {
 	switch (_selectedItem) {
 	case 0:
-		close();
 		break;
 	case 1:
-		replaceView("Title", true);
+		// Prompt for saving game before returning to title
+		send("SaveGame", GameMessage("TITLE"));
 		break;
 	case 2:
-		g_engine->quitGame();
+		// Prompt for saving game before quitting
+		send("SaveGame", GameMessage("QUIT"));
 		break;
 	default:
 		break;
diff --git a/engines/got/views/dialogs/save_game.cpp b/engines/got/views/dialogs/save_game.cpp
new file mode 100644
index 00000000000..3e717a457c8
--- /dev/null
+++ b/engines/got/views/dialogs/save_game.cpp
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/dialogs/save_game.h"
+#include "got/got.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+SaveGame::SaveGame() : SelectOption("SaveGame", "Save Game?", YES_NO) {
+}
+
+bool SaveGame::msgGame(const GameMessage &msg) {
+	if (msg._name == "TITLE" || msg._name == "QUIT") {
+		_isQuit = msg._name == "QUIT";
+		open();
+		return true;
+	}
+
+	return false;
+}
+
+void SaveGame::selected() {
+	if (_selectedItem == 0)
+		g_engine->saveGameDialog();
+
+	if (_isQuit)
+		g_engine->quitGame();
+	else
+		replaceView("Title", true, true);
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/save_game.h b/engines/got/views/dialogs/save_game.h
new file mode 100644
index 00000000000..687fdc57414
--- /dev/null
+++ b/engines/got/views/dialogs/save_game.h
@@ -0,0 +1,48 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_SAVE_GAME_H
+#define GOT_VIEWS_DIALOGS_SAVE_GAME_H
+
+#include "got/views/dialogs/select_option.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class SaveGame : public SelectOption {
+private:
+	bool _isQuit = false;
+
+public:
+	SaveGame();
+	virtual ~SaveGame() {
+	}
+
+	bool msgGame(const GameMessage &msg) override;
+	void selected() override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index dea3c00a58b..4f07f265912 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -31,6 +31,7 @@
 #include "got/views/dialogs/options_menu.h"
 #include "got/views/dialogs/quit.h"
 #include "got/views/dialogs/quit_game.h"
+#include "got/views/dialogs/save_game.h"
 #include "got/views/dialogs/say.h"
 #include "got/views/dialogs/select_game.h"
 #include "got/views/dialogs/select_scroll.h"
@@ -52,6 +53,7 @@ struct Views {
 	Dialogs::OptionsMenu _optionsMenu;
 	Dialogs::Quit _quit;
 	Dialogs::QuitGame _quitGame;
+	Dialogs::SaveGame _saveGame;
 	Dialogs::Say _say;
 	Dialogs::SelectGame _selectGame;
 	Dialogs::SelectItem _selectItem;


Commit: c8476b51b7f986f8815638d553ba673f5d750b6b
    https://github.com/scummvm/scummvm/commit/c8476b51b7f986f8815638d553ba673f5d750b6b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Sound/music toggle dialogs

Changed paths:
  A engines/got/views/dialogs/set_music.cpp
  A engines/got/views/dialogs/set_music.h
    engines/got/detection_tables.h
    engines/got/events.h
    engines/got/got.cpp
    engines/got/got.h
    engines/got/module.mk
    engines/got/sound.cpp
    engines/got/views/dialogs/set_sound.cpp
    engines/got/views/dialogs/set_sound.h
    engines/got/views/views.h


diff --git a/engines/got/detection_tables.h b/engines/got/detection_tables.h
index 95dae2c0cae..57031cacba4 100644
--- a/engines/got/detection_tables.h
+++ b/engines/got/detection_tables.h
@@ -35,17 +35,17 @@ const ADGameDescription gameDescriptions[] = {
 		Common::EN_ANY,
 		Common::kPlatformDOS,
 		ADGF_UNSTABLE,
-		GUIO1(GUIO_NONE)
+		GUIO1(GUIO_NOSPEECH)
 	},
 
-{
+	{
 		"gotdemo",
 		"Demo",
 		AD_ENTRY1s("gotres.dat", "747ed508ffa3808156a4eb080e9859f8", 739710),
 		Common::EN_ANY,
 		Common::kPlatformDOS,
 		ADGF_UNSTABLE | ADGF_DEMO,
-		GUIO1(GUIO_NONE)
+		GUIO1(GUIO_NOSPEECH)
 	},
 
 	AD_TABLE_END_MARKER
diff --git a/engines/got/events.h b/engines/got/events.h
index 50b15e71805..f7c7c66a8d7 100644
--- a/engines/got/events.h
+++ b/engines/got/events.h
@@ -30,7 +30,7 @@
 
 namespace Got {
 
-#define FRAME_RATE 20
+#define FRAME_RATE 50
 #define FRAME_DELAY (1000 / FRAME_RATE)
 
 using Gfx::GfxSurface;
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 632fdb769fc..39213595afc 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -75,6 +75,7 @@ Common::Error GotEngine::run() {
 
 	// General initialization
 	initialize();
+	syncSoundSettings();
 
 	runGame();
 
@@ -169,4 +170,15 @@ bool GotEngine::canSaveGameStateCurrently(Common::U32String *msg) {
 	return _G(gameMode) == MODE_NORMAL;
 }
 
+void GotEngine::syncSoundSettings() {
+	Engine::syncSoundSettings();
+
+	bool allSoundIsMuted = ConfMan.getBool("mute");
+
+	_mixer->muteSoundType(Audio::Mixer::kSFXSoundType,
+		ConfMan.getBool("sfx_mute") || allSoundIsMuted);
+	_mixer->muteSoundType(Audio::Mixer::kMusicSoundType,
+		ConfMan.getBool("music_mute") || allSoundIsMuted);
+}
+
 } // End of namespace Got
diff --git a/engines/got/got.h b/engines/got/got.h
index 6f412be8cd6..3faaa395253 100644
--- a/engines/got/got.h
+++ b/engines/got/got.h
@@ -102,6 +102,8 @@ public:
 
 	Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
 	Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
+
+	void syncSoundSettings() override;
 };
 
 extern GotEngine *g_engine;
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 36c00837712..3ef77d87745 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -56,6 +56,7 @@ MODULE_OBJS = \
 	views/dialogs/select_item.o \
 	views/dialogs/select_scroll.o \
 	views/dialogs/select_slow.o \
+	views/dialogs/set_music.o \
 	views/dialogs/set_sound.o
 
 # This module can be built as a plugin
diff --git a/engines/got/sound.cpp b/engines/got/sound.cpp
index a8935a554b7..9a146aff426 100644
--- a/engines/got/sound.cpp
+++ b/engines/got/sound.cpp
@@ -58,7 +58,7 @@ void Sound::play_sound(int index, bool priority_override) {
 	Common::MemoryReadStream *stream = new Common::MemoryReadStream(
 		_soundData + _digiSounds[index].offset, _digiSounds[index].length);
 	Audio::AudioStream *audioStream = Audio::makeVOCStream(stream, Audio::FLAG_UNSIGNED);
-	g_engine->_mixer->playStream(Audio::Mixer::kPlainSoundType,
+	g_engine->_mixer->playStream(Audio::Mixer::kSFXSoundType,
 		&_soundHandle, audioStream);
 }
 
diff --git a/engines/got/views/dialogs/set_music.cpp b/engines/got/views/dialogs/set_music.cpp
new file mode 100644
index 00000000000..d372640ec0c
--- /dev/null
+++ b/engines/got/views/dialogs/set_music.cpp
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/config-manager.h"
+#include "got/views/dialogs/set_music.h"
+#include "got/got.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+SetMusic::SetMusic() : SelectOption("SetMusic", "Set Music", ON_OFF) {
+}
+
+bool SetMusic::msgFocus(const FocusMessage &msg) {
+	_selectedItem = ConfMan.getBool("music_mute") ? 1 : 0;
+	return true;
+}
+
+void SetMusic::selected() {
+	ConfMan.setBool("music_mute", _selectedItem == 1);
+	ConfMan.flushToDisk();
+	g_engine->syncSoundSettings();
+}
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/dialogs/set_music.h b/engines/got/views/dialogs/set_music.h
new file mode 100644
index 00000000000..bff7896f775
--- /dev/null
+++ b/engines/got/views/dialogs/set_music.h
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_DIALOGS_SET_MUSIC_H
+#define GOT_VIEWS_DIALOGS_SET_MUSIC_H
+
+#include "got/views/dialogs/select_option.h"
+
+namespace Got {
+namespace Views {
+namespace Dialogs {
+
+class SetMusic : public SelectOption {
+public:
+	SetMusic();
+	virtual ~SetMusic() {
+	}
+
+	bool msgFocus(const FocusMessage &msg) override;
+	void selected() override;
+};
+
+} // namespace Dialogs
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/dialogs/set_sound.cpp b/engines/got/views/dialogs/set_sound.cpp
index 6cb7f1bdf60..056d5c9a440 100644
--- a/engines/got/views/dialogs/set_sound.cpp
+++ b/engines/got/views/dialogs/set_sound.cpp
@@ -19,21 +19,27 @@
  *
  */
 
+#include "common/config-manager.h"
 #include "got/views/dialogs/set_sound.h"
+#include "got/got.h"
 
 namespace Got {
 namespace Views {
 namespace Dialogs {
 
-static const char *OPTIONS[] = {
-	"None", "Digitized", nullptr
-};
+SetSound::SetSound() : SelectOption("SetSound", "Set Sound", ON_OFF) {
+}
 
-SetSound::SetSound() : SelectOption("SetSound", "Set Sound", OPTIONS) {
+bool SetSound::msgFocus(const FocusMessage &msg) {
+	_selectedItem = ConfMan.getBool("sfx_mute") ? 1 : 0;
+	return true;
 }
 
 void SetSound::selected() {
-	// TODO
+	ConfMan.setBool("sfx_mute", _selectedItem == 1);
+	ConfMan.flushToDisk();
+	g_engine->syncSoundSettings();
+	addView("SetMusic");
 }
 
 } // namespace Dialogs
diff --git a/engines/got/views/dialogs/set_sound.h b/engines/got/views/dialogs/set_sound.h
index 9f5c6f5a75f..5ac369369cd 100644
--- a/engines/got/views/dialogs/set_sound.h
+++ b/engines/got/views/dialogs/set_sound.h
@@ -34,6 +34,7 @@ public:
 	virtual ~SetSound() {
 	}
 
+	bool msgFocus(const FocusMessage &msg) override;
 	void selected() override;
 };
 
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index 4f07f265912..28981d2f762 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -37,6 +37,7 @@
 #include "got/views/dialogs/select_scroll.h"
 #include "got/views/dialogs/select_slow.h"
 #include "got/views/dialogs/select_item.h"
+#include "got/views/dialogs/set_music.h"
 #include "got/views/dialogs/set_sound.h"
 
 namespace Got {
@@ -59,6 +60,7 @@ struct Views {
 	Dialogs::SelectItem _selectItem;
 	Dialogs::SelectScroll _selectScroll;
 	Dialogs::SelectSlow _selectSlow;
+	Dialogs::SetMusic _setMusic;
 	Dialogs::SetSound _setSound;
 };
 


Commit: 79986a4b717dc3f5be21932ff414879c0f80502b
    https://github.com/scummvm/scummvm/commit/79986a4b717dc3f5be21932ff414879c0f80502b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Tweak game speed

Changed paths:
    engines/got/events.h
    engines/got/views/dialogs/say.cpp


diff --git a/engines/got/events.h b/engines/got/events.h
index f7c7c66a8d7..56c21a5db46 100644
--- a/engines/got/events.h
+++ b/engines/got/events.h
@@ -30,7 +30,7 @@
 
 namespace Got {
 
-#define FRAME_RATE 50
+#define FRAME_RATE 60
 #define FRAME_DELAY (1000 / FRAME_RATE)
 
 using Gfx::GfxSurface;
diff --git a/engines/got/views/dialogs/say.cpp b/engines/got/views/dialogs/say.cpp
index fc974f091ac..965a8b586dd 100644
--- a/engines/got/views/dialogs/say.cpp
+++ b/engines/got/views/dialogs/say.cpp
@@ -147,7 +147,7 @@ bool Say::msgAction(const ActionMessage &msg) {
 }
 
 bool Say::tick() {
-	if (_waitForResponse == WAIT_NONE && ++_contentCtr > 3) {
+	if (_waitForResponse == WAIT_NONE && ++_contentCtr > 1) {
 		_contentCtr = 0;
 		const char *contentEnd = _content + ++_contentLength;
 


Commit: 18b9e7c5129d067c98fbb8a7609ffc83dfe90d9e
    https://github.com/scummvm/scummvm/commit/18b9e7c5129d067c98fbb8a7609ffc83dfe90d9e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Skeleton views for opening screens

Changed paths:
  A engines/got/views/credits.cpp
  A engines/got/views/credits.h
  A engines/got/views/opening.cpp
  A engines/got/views/opening.h
  A engines/got/views/splash_screen.cpp
  A engines/got/views/splash_screen.h
    engines/got/module.mk
    engines/got/views/views.h


diff --git a/engines/got/module.mk b/engines/got/module.mk
index 3ef77d87745..21c5968877b 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -36,10 +36,13 @@ MODULE_OBJS = \
 	utils/file.o \
 	utils/res_archive.o \
 	views/view.o \
+	views/credits.o \
 	views/game.o \
 	views/game_content.o \
 	views/game_status.o \
+	views/opening.o \
 	views/part_title.o \
+	views/splash_screen.o \
 	views/story.o \
 	views/title.o \
 	views/dialogs/dialog.o \
diff --git a/engines/got/views/credits.cpp b/engines/got/views/credits.cpp
new file mode 100644
index 00000000000..c79285b7cd6
--- /dev/null
+++ b/engines/got/views/credits.cpp
@@ -0,0 +1,38 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/credits.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+
+void Credits::draw() {
+	GfxSurface s = getSurface();
+	s.print(Common::Point(10, 10), "Credits", 255);
+}
+
+bool Credits::tick() {
+	return true;
+}
+
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/credits.h b/engines/got/views/credits.h
new file mode 100644
index 00000000000..48de73b4eb9
--- /dev/null
+++ b/engines/got/views/credits.h
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_CREDITS_H
+#define GOT_VIEWS_CREDITS_H
+
+#include "got/views/view.h"
+
+namespace Got {
+namespace Views {
+
+class Credits : public View {
+public:
+	Credits() : View("Credits") {}
+	virtual ~Credits() {}
+
+	void draw() override;
+	bool tick() override;
+};
+
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/opening.cpp b/engines/got/views/opening.cpp
new file mode 100644
index 00000000000..6b6850424be
--- /dev/null
+++ b/engines/got/views/opening.cpp
@@ -0,0 +1,38 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/opening.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+
+void Opening::draw() {
+	GfxSurface s = getSurface();
+	s.print(Common::Point(10, 10), "Opening screen", 255);
+}
+
+bool Opening::tick() {
+	return true;
+}
+
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/opening.h b/engines/got/views/opening.h
new file mode 100644
index 00000000000..9782460da25
--- /dev/null
+++ b/engines/got/views/opening.h
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_OPENING_H
+#define GOT_VIEWS_OPENING_H
+
+#include "got/views/view.h"
+
+namespace Got {
+namespace Views {
+
+class Opening : public View {
+public:
+	Opening() : View("Opening") {}
+	virtual ~Opening() {}
+
+	void draw() override;
+	bool tick() override;
+};
+
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/splash_screen.cpp b/engines/got/views/splash_screen.cpp
new file mode 100644
index 00000000000..a09af4d97be
--- /dev/null
+++ b/engines/got/views/splash_screen.cpp
@@ -0,0 +1,38 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/views/splash_screen.h"
+#include "got/vars.h"
+
+namespace Got {
+namespace Views {
+
+void SplashScreen::draw() {
+	GfxSurface s = getSurface();
+	s.print(Common::Point(10, 10), "Splash screen", 255);
+}
+
+bool SplashScreen::tick() {
+	return true;
+}
+
+} // namespace Views
+} // namespace Got
diff --git a/engines/got/views/splash_screen.h b/engines/got/views/splash_screen.h
new file mode 100644
index 00000000000..f5195dacee5
--- /dev/null
+++ b/engines/got/views/splash_screen.h
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_VIEWS_SPLASH_SCREEN_H
+#define GOT_VIEWS_SPLASH_SCREEN_H
+
+#include "got/views/view.h"
+
+namespace Got {
+namespace Views {
+
+class SplashScreen : public View {
+public:
+	SplashScreen() : View("SplashScreen") {}
+	virtual ~SplashScreen() {}
+
+	void draw() override;
+	bool tick() override;
+};
+
+} // namespace Views
+} // namespace Got
+
+#endif
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index 28981d2f762..47f08aac693 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -22,8 +22,11 @@
 #ifndef GOT_VIEWS_H
 #define GOT_VIEWS_H
 
+#include "got/views/credits.h"
 #include "got/views/game.h"
+#include "got/views/opening.h"
 #include "got/views/part_title.h"
+#include "got/views/splash_screen.h"
 #include "got/views/story.h"
 #include "got/views/title.h"
 #include "got/views/dialogs/ask.h"
@@ -44,8 +47,11 @@ namespace Got {
 namespace Views {
 
 struct Views {
+	Credits _credits;
 	Game _game;
+	Opening _opening;
 	PartTitle _partTitle;
+	SplashScreen _splashScreen;
 	Story _story;
 	Title _title;
 


Commit: 8f22c27b6731194cfe892f6e0fec9a6c27f90e87
    https://github.com/scummvm/scummvm/commit/8f22c27b6731194cfe892f6e0fec9a6c27f90e87
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Initial background for startup Splash Screen

Changed paths:
    engines/got/events.cpp
    engines/got/gfx/gfx_chunks.cpp
    engines/got/gfx/gfx_chunks.h
    engines/got/gfx/palette.cpp
    engines/got/gfx/palette.h
    engines/got/views/splash_screen.cpp
    engines/got/views/splash_screen.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 1af941b0484..280590d1b9f 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -25,6 +25,7 @@
 #include "got/got.h"
 #include "got/gfx/palette.h"
 #include "got/views/views.h"
+#include "got/views/game.h"
 
 namespace Got {
 
@@ -86,7 +87,13 @@ void Events::runGame() {
 		// Rotate the palette
 		if (++palCycleCtr == 2) {
 			palCycleCtr = 0;
-			rotatePalette();
+
+			bool gameVisible = false;
+			for (uint i = 0; i < _views.size() && !gameVisible; ++i)
+				gameVisible = _views[i]->_name == "Game";
+
+			if (gameVisible)
+				rotatePalette();
 		}
 
 		if ((currTime = g_system->getMillis()) >= nextFrameTime) {
diff --git a/engines/got/gfx/gfx_chunks.cpp b/engines/got/gfx/gfx_chunks.cpp
index 53777568f80..f999f90f47c 100644
--- a/engines/got/gfx/gfx_chunks.cpp
+++ b/engines/got/gfx/gfx_chunks.cpp
@@ -73,6 +73,11 @@ GraphicChunk::operator const Graphics::ManagedSurface() const {
 	return s;
 }
 
+GraphicChunk::operator const Gfx::Palette63() const {
+	return Gfx::Palette63(_data);
+}
+
+
 
 void GfxChunks::load() {
 	// Get stream to access images
diff --git a/engines/got/gfx/gfx_chunks.h b/engines/got/gfx/gfx_chunks.h
index ce571dcdcac..bc95b29f807 100644
--- a/engines/got/gfx/gfx_chunks.h
+++ b/engines/got/gfx/gfx_chunks.h
@@ -24,6 +24,7 @@
 
 #include "common/stream.h"
 #include "graphics/managed_surface.h"
+#include "got/gfx/palette.h"
 
 namespace Got {
 namespace Gfx {
@@ -60,6 +61,11 @@ public:
 	 * Provides a managed surface wrapper for raw data
 	 */
 	operator const Graphics::ManagedSurface() const;
+
+	/**
+	 * Provides a data pointer, used for getting palette chunks
+	 */
+	operator const Gfx::Palette63() const;
 };
 
 /**
diff --git a/engines/got/gfx/palette.cpp b/engines/got/gfx/palette.cpp
index 64cdf23e4e3..b9815021c59 100644
--- a/engines/got/gfx/palette.cpp
+++ b/engines/got/gfx/palette.cpp
@@ -34,6 +34,12 @@ namespace Gfx {
 
 static byte saved_palette[PALETTE_SIZE];
 
+Palette63::Palette63(const byte *pal) {
+	for (uint i = 0; i < PALETTE_SIZE; ++i)
+		_pal[i] = pal[i] << 2;
+}
+
+
 void load_palette() {
 	if (res_read("PALETTE", saved_palette) < 0)
 		error("Cannot Read PALETTE");
diff --git a/engines/got/gfx/palette.h b/engines/got/gfx/palette.h
index ff3c9d195ee..eae392216fd 100644
--- a/engines/got/gfx/palette.h
+++ b/engines/got/gfx/palette.h
@@ -27,6 +27,16 @@
 namespace Got {
 namespace Gfx {
 
+struct Palette63 {
+	byte _pal[PALETTE_SIZE] = {};
+	Palette63() {}
+	Palette63(const byte *pal);
+
+	operator const byte *() const {
+		return _pal;
+	}
+};
+
 extern void load_palette();
 extern void set_screen_pal();
 extern void xsetpal(byte color, byte R, byte G, byte B);
diff --git a/engines/got/views/splash_screen.cpp b/engines/got/views/splash_screen.cpp
index a09af4d97be..24de5efa30a 100644
--- a/engines/got/views/splash_screen.cpp
+++ b/engines/got/views/splash_screen.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "got/views/splash_screen.h"
+#include "got/gfx/palette.h"
 #include "got/vars.h"
 
 namespace Got {
@@ -27,7 +28,14 @@ namespace Views {
 
 void SplashScreen::draw() {
 	GfxSurface s = getSurface();
-	s.print(Common::Point(10, 10), "Splash screen", 255);
+	s.clear();
+	s.blitFrom(_G(gfx)[92], Common::Point(0, 24));
+}
+
+bool SplashScreen::msgFocus(const FocusMessage &msg) {
+	Gfx::Palette63 pal = _G(gfx)[91];
+	Gfx::xsetpal(pal);
+	return true;
 }
 
 bool SplashScreen::tick() {
diff --git a/engines/got/views/splash_screen.h b/engines/got/views/splash_screen.h
index f5195dacee5..3abbd5d8278 100644
--- a/engines/got/views/splash_screen.h
+++ b/engines/got/views/splash_screen.h
@@ -32,6 +32,7 @@ public:
 	SplashScreen() : View("SplashScreen") {}
 	virtual ~SplashScreen() {}
 
+	bool msgFocus(const FocusMessage &msg) override;
 	void draw() override;
 	bool tick() override;
 };


Commit: ef8a39f6954ef027b8755c5dd771893ad70e0843
    https://github.com/scummvm/scummvm/commit/ef8a39f6954ef027b8755c5dd771893ad70e0843
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Splash screen animation

Changed paths:
    engines/got/events.cpp
    engines/got/views/splash_screen.cpp
    engines/got/views/splash_screen.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 280590d1b9f..fb48fb23bed 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -65,7 +65,7 @@ void Events::runGame() {
 	if (saveSlot != -1)
 		g_engine->loadGameState(saveSlot);
 
-	addView("Game");
+	addView("SplashScreen");
 
 	Common::Event e;
 	while (!_views.empty() && !shouldQuit()) {
diff --git a/engines/got/views/splash_screen.cpp b/engines/got/views/splash_screen.cpp
index 24de5efa30a..5e7ee66bc73 100644
--- a/engines/got/views/splash_screen.cpp
+++ b/engines/got/views/splash_screen.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "common/file.h"
 #include "got/views/splash_screen.h"
 #include "got/gfx/palette.h"
 #include "got/vars.h"
@@ -26,21 +27,130 @@
 namespace Got {
 namespace Views {
 
+#define SPLASH_FRAME_INTERVAL 2
+#define SPLASH_FRAME_COUNT 36
+
 void SplashScreen::draw() {
+	if (_frameCtr == -1) {
+	_frameCtr = 0;
 	GfxSurface s = getSurface();
+
+	// Display background. The rest of the logo animation will be
+	// done in the frame routines called from tick
 	s.clear();
 	s.blitFrom(_G(gfx)[92], Common::Point(0, 24));
+	}
 }
 
 bool SplashScreen::msgFocus(const FocusMessage &msg) {
 	Gfx::Palette63 pal = _G(gfx)[91];
 	Gfx::xsetpal(pal);
+
+	auto chunk = _G(gfx)[93];
+	int frameCount = READ_LE_UINT16(chunk._data);
+	assert(frameCount == SPLASH_FRAME_COUNT);
+	_chunkSize = chunk._data + 2;
+	_chunkPtr = chunk._data + 2 + SPLASH_FRAME_COUNT * 4;
+
+	_frameCtr = -1;
+	_delayCtr = 0;
+
 	return true;
 }
 
 bool SplashScreen::tick() {
+	if (++_delayCtr == SPLASH_FRAME_INTERVAL) {
+	_delayCtr = 0;
+
+	if (++_frameCtr < SPLASH_FRAME_COUNT) {
+		GfxSurface s = getSurface();
+		byte *dest = (byte *)s.getBasePtr(0, 24);
+		executeFrame(_chunkPtr, dest);
+		s.markAllDirty();
+
+		_chunkPtr += READ_LE_UINT32(_chunkSize);
+		_chunkSize += 4;
+	} else if (_frameCtr == (SPLASH_FRAME_COUNT + 50)) {
+		// Switch to the opening screen showing the game name
+		replaceView("Opening", true, true);
+	}
+	}
+
 	return true;
 }
+int frame = -1;
+
+void SplashScreen::executeFrame(const byte *src, byte *dest) {
+	const byte *codeP = src;
+	int count = 0;
+	int val = 0;
+
+	while (*codeP != 0xcb) {
+		if (codeP[0] == 0xc9) {
+			// leave
+			codeP++;
+		} else if (codeP[0] == 0x33 && codeP[1] == 0xc9) {
+			// xor cx, cx
+			count = 0;
+			codeP += 2;
+		} else if (codeP[0] == 0x81 && codeP[1] == 0xc6) {
+			// add si, 16-bit
+			src += READ_LE_INT16(codeP + 2);
+			codeP += 4;
+		} else if (codeP[0] == 0x81 && codeP[1] == 0xee) {
+			// sub si, 16-bit
+			src -= READ_LE_INT16(codeP + 2);
+			codeP += 4;
+		} else if (codeP[0] == 0x8b && codeP[1] == 0xdf) {
+			// mov bx, di
+			codeP += 2;
+		} else if (codeP[0] == 0x81 && codeP[1] == 0xc7) {
+			// add di, 16-bit
+			dest += READ_LE_INT16(codeP + 2);
+			codeP += 4;
+		} else if (codeP[0] == 0xb8) {
+			// mov ax, 16-bit
+			val = READ_LE_UINT16(codeP + 1);
+			codeP += 3;
+		} else if (codeP[0] == 0xb0) {
+			// mov al, 8-bit
+			val = codeP[1];
+			codeP += 2;
+		} else if (codeP[0] == 0xb1) {
+			// mov cl, 8-bit
+			count = codeP[1];
+			codeP += 2;
+		} else if (codeP[0] == 0xf3 && codeP[1] == 0xab) {
+			// rep stosw
+			while (count-- > 0) {
+				WRITE_LE_UINT16(dest, val);
+				dest += 2;
+			}
+			codeP += 2;
+		} else if (codeP[0] == 0xab) {
+			// stosw
+			WRITE_LE_UINT16(dest, val);
+			dest += 2;
+			codeP++;
+		} else if (codeP[0] == 0xaa) {
+			// stosb
+			*dest++ = (byte)val;
+			++codeP;
+		} else if (codeP[0] == 0xf3 && codeP[1] == 0xa5) {
+			// rep movsw
+			Common::copy(src, src + count * 2, dest);
+			src += count * 2;
+			dest += count * 2;
+			codeP += 2;
+		} else if (codeP[0] == 0xa4) {
+			// movsb
+			*dest++ = *src++;
+			++codeP;
+		} else {
+			error("Unhandled opcode");
+		}
+	}
+}
 
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/splash_screen.h b/engines/got/views/splash_screen.h
index 3abbd5d8278..ac409e491fc 100644
--- a/engines/got/views/splash_screen.h
+++ b/engines/got/views/splash_screen.h
@@ -28,6 +28,13 @@ namespace Got {
 namespace Views {
 
 class SplashScreen : public View {
+private:
+	const byte *_chunkSize = nullptr;
+	const byte *_chunkPtr = nullptr;
+	int _delayCtr = 0, _frameCtr = 0;
+
+	void executeFrame(const byte *src, byte *dest);
+
 public:
 	SplashScreen() : View("SplashScreen") {}
 	virtual ~SplashScreen() {}


Commit: dcbb227bdecda6e4c0204d77cd7a3b7b81ea25ab
    https://github.com/scummvm/scummvm/commit/dcbb227bdecda6e4c0204d77cd7a3b7b81ea25ab
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Initial fade in for splash screen

Changed paths:
    engines/got/events.cpp
    engines/got/gfx/palette.cpp
    engines/got/gfx/palette.h
    engines/got/views/splash_screen.cpp


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index fb48fb23bed..fc9c9f10a06 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -62,10 +62,11 @@ void Events::runGame() {
 
 	// Run the game
 	int saveSlot = ConfMan.getInt("save_slot");
-	if (saveSlot != -1)
+	if (saveSlot != -1) {
 		g_engine->loadGameState(saveSlot);
-
-	addView("SplashScreen");
+	} else {
+		addView("SplashScreen");
+	}
 
 	Common::Event e;
 	while (!_views.empty() && !shouldQuit()) {
diff --git a/engines/got/gfx/palette.cpp b/engines/got/gfx/palette.cpp
index b9815021c59..0d578eb4fff 100644
--- a/engines/got/gfx/palette.cpp
+++ b/engines/got/gfx/palette.cpp
@@ -101,13 +101,16 @@ void fade_out() {
 	}
 }
 
-void fade_in() {
+void fade_in(const byte *pal) {
 	byte tempPal[PALETTE_SIZE];
 	const byte *srcP;
 	byte *destP;
 	int count;
 	Common::Event evt;
 
+	if (pal)
+		Common::copy(pal, pal + PALETTE_SIZE, saved_palette);
+
 	for (int step = 1; step <= FADE_STEPS; ++step) {
 		// Set each palette RGB proportionately
 		for (srcP = &saved_palette[0], destP = &tempPal[0], count = 0;
diff --git a/engines/got/gfx/palette.h b/engines/got/gfx/palette.h
index eae392216fd..830254987a6 100644
--- a/engines/got/gfx/palette.h
+++ b/engines/got/gfx/palette.h
@@ -43,7 +43,7 @@ extern void xsetpal(byte color, byte R, byte G, byte B);
 extern void xsetpal(const byte *pal);
 extern void xgetpal(byte *pal, int num_colrs, int start_index);
 extern void fade_out();
-extern void fade_in();
+extern void fade_in(const byte *pal = nullptr);
 
 } // namespace Gfx
 } // namespace Got
diff --git a/engines/got/views/splash_screen.cpp b/engines/got/views/splash_screen.cpp
index 5e7ee66bc73..bf0142819a6 100644
--- a/engines/got/views/splash_screen.cpp
+++ b/engines/got/views/splash_screen.cpp
@@ -32,20 +32,17 @@ namespace Views {
 
 void SplashScreen::draw() {
 	if (_frameCtr == -1) {
-	_frameCtr = 0;
-	GfxSurface s = getSurface();
+		_frameCtr = 0;
+		GfxSurface s = getSurface();
 
-	// Display background. The rest of the logo animation will be
-	// done in the frame routines called from tick
-	s.clear();
-	s.blitFrom(_G(gfx)[92], Common::Point(0, 24));
+		// Display background. The rest of the logo animation will be
+		// done in the frame routines called from tick
+		s.clear();
+		s.blitFrom(_G(gfx)[92], Common::Point(0, 24));
 	}
 }
 
 bool SplashScreen::msgFocus(const FocusMessage &msg) {
-	Gfx::Palette63 pal = _G(gfx)[91];
-	Gfx::xsetpal(pal);
-
 	auto chunk = _G(gfx)[93];
 	int frameCount = READ_LE_UINT16(chunk._data);
 	assert(frameCount == SPLASH_FRAME_COUNT);
@@ -55,25 +52,34 @@ bool SplashScreen::msgFocus(const FocusMessage &msg) {
 	_frameCtr = -1;
 	_delayCtr = 0;
 
+	// This is the first screen shown, so start with black, and fade it in
+	byte blackPal[PALETTE_SIZE];
+	Common::fill(blackPal, blackPal + PALETTE_SIZE, 0);
+	Gfx::xsetpal(blackPal);
+
+	draw();
+	Gfx::Palette63 pal = _G(gfx)[91];
+	Gfx::fade_in(pal);
+
 	return true;
 }
 
 bool SplashScreen::tick() {
 	if (++_delayCtr == SPLASH_FRAME_INTERVAL) {
-	_delayCtr = 0;
-
-	if (++_frameCtr < SPLASH_FRAME_COUNT) {
-		GfxSurface s = getSurface();
-		byte *dest = (byte *)s.getBasePtr(0, 24);
-		executeFrame(_chunkPtr, dest);
-		s.markAllDirty();
-
-		_chunkPtr += READ_LE_UINT32(_chunkSize);
-		_chunkSize += 4;
-	} else if (_frameCtr == (SPLASH_FRAME_COUNT + 50)) {
-		// Switch to the opening screen showing the game name
-		replaceView("Opening", true, true);
-	}
+		_delayCtr = 0;
+
+		if (++_frameCtr < SPLASH_FRAME_COUNT) {
+			GfxSurface s = getSurface();
+			byte *dest = (byte *)s.getBasePtr(0, 24);
+			executeFrame(_chunkPtr, dest);
+			s.markAllDirty();
+
+			_chunkPtr += READ_LE_UINT32(_chunkSize);
+			_chunkSize += 4;
+		} else if (_frameCtr == (SPLASH_FRAME_COUNT + 50)) {
+			// Switch to the opening screen showing the game name
+			replaceView("Opening", true, true);
+		}
 	}
 
 	return true;


Commit: 98e45ad52427e37e2224dd33025486266981ae62
    https://github.com/scummvm/scummvm/commit/98e45ad52427e37e2224dd33025486266981ae62
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Background for opening screen

Changed paths:
    engines/got/events.cpp
    engines/got/views/opening.cpp
    engines/got/views/opening.h
    engines/got/views/splash_screen.cpp
    engines/got/views/splash_screen.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index fc9c9f10a06..15a9606cbc9 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -60,14 +60,17 @@ void Events::runGame() {
 	_screen = new Graphics::Screen();
 	Views::Views views;	// Loads all views in the structure
 
-	// Run the game
+	// Set up the initial game view
 	int saveSlot = ConfMan.getInt("save_slot");
 	if (saveSlot != -1) {
-		g_engine->loadGameState(saveSlot);
-	} else {
-		addView("SplashScreen");
+		if (g_engine->loadGameState(saveSlot).getCode() != Common::kNoError)
+			saveSlot = -1;
 	}
+	if (saveSlot == -1)
+//		addView("SplashScreen");
+		addView("Opening");
 
+	// Main game loop
 	Common::Event e;
 	while (!_views.empty() && !shouldQuit()) {
 		while (g_system->getEventManager()->pollEvent(e)) {
diff --git a/engines/got/views/opening.cpp b/engines/got/views/opening.cpp
index 6b6850424be..9c65a12bca2 100644
--- a/engines/got/views/opening.cpp
+++ b/engines/got/views/opening.cpp
@@ -25,12 +25,43 @@
 namespace Got {
 namespace Views {
 
+int ctr = 0;
+
 void Opening::draw() {
 	GfxSurface s = getSurface();
-	s.print(Common::Point(10, 10), "Opening screen", 255);
+	s.blitFrom(_surface, Common::Rect(0, 0, 320, 200), Common::Point(0, 0));
+}
+
+bool Opening::msgFocus(const FocusMessage &msg) {
+	const byte *src;
+	byte *dest;
+	int i;
+
+	Gfx::Palette63 pal = _G(gfx)[35];
+	Gfx::xsetpal(pal);
+
+	// TODO: Better understand the plane format. A proper screen seems to
+	// be okay if I use the resulting 0,0 to 320,200 of the surface
+	_surface.create(640, 400);
+	for (int chunkNum = 0; chunkNum < 4; ++chunkNum) {
+		auto g = _G(gfx)[36 + chunkNum];
+		src = _G(gfx)[36 + chunkNum]._data;
+		dest = (byte *)_surface.getBasePtr(chunkNum, 0);
+
+		for (i = 0; i < (640 * 400 / 4); ++i, ++src, dest += 4)
+			*dest = *src;
+	}
+
+	return true;
+}
+
+bool Opening::msgUnfocus(const UnfocusMessage &msg) {
+	_surface.clear();
+	return true;
 }
 
 bool Opening::tick() {
+	redraw();
 	return true;
 }
 
diff --git a/engines/got/views/opening.h b/engines/got/views/opening.h
index 9782460da25..f63bdf74339 100644
--- a/engines/got/views/opening.h
+++ b/engines/got/views/opening.h
@@ -28,10 +28,15 @@ namespace Got {
 namespace Views {
 
 class Opening : public View {
+private:
+	Graphics::ManagedSurface _surface;
+
 public:
 	Opening() : View("Opening") {}
 	virtual ~Opening() {}
 
+	bool msgFocus(const FocusMessage &msg) override;
+	bool msgUnfocus(const UnfocusMessage &msg) override;
 	void draw() override;
 	bool tick() override;
 };
diff --git a/engines/got/views/splash_screen.cpp b/engines/got/views/splash_screen.cpp
index bf0142819a6..d62e99b7782 100644
--- a/engines/got/views/splash_screen.cpp
+++ b/engines/got/views/splash_screen.cpp
@@ -64,6 +64,11 @@ bool SplashScreen::msgFocus(const FocusMessage &msg) {
 	return true;
 }
 
+bool SplashScreen::msgUnfocus(const UnfocusMessage &msg) {
+	fadeOut();
+	return true;
+}
+
 bool SplashScreen::tick() {
 	if (++_delayCtr == SPLASH_FRAME_INTERVAL) {
 		_delayCtr = 0;
diff --git a/engines/got/views/splash_screen.h b/engines/got/views/splash_screen.h
index ac409e491fc..a7aae675ced 100644
--- a/engines/got/views/splash_screen.h
+++ b/engines/got/views/splash_screen.h
@@ -40,6 +40,7 @@ public:
 	virtual ~SplashScreen() {}
 
 	bool msgFocus(const FocusMessage &msg) override;
+	bool msgUnfocus(const UnfocusMessage &msg) override;
 	void draw() override;
 	bool tick() override;
 };


Commit: 2c3f580d03a95dd461f54ff542b7bac166e78d41
    https://github.com/scummvm/scummvm/commit/2c3f580d03a95dd461f54ff542b7bac166e78d41
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Better decoding and rendering of opening background

The title screen is a 320x400 image. But since the entire
game is running at 320x240, the image will be resized
to fit.

Changed paths:
    engines/got/views/opening.cpp


diff --git a/engines/got/views/opening.cpp b/engines/got/views/opening.cpp
index 9c65a12bca2..154f46aa3b2 100644
--- a/engines/got/views/opening.cpp
+++ b/engines/got/views/opening.cpp
@@ -29,7 +29,7 @@ int ctr = 0;
 
 void Opening::draw() {
 	GfxSurface s = getSurface();
-	s.blitFrom(_surface, Common::Rect(0, 0, 320, 200), Common::Point(0, 0));
+	s.blitFrom(_surface, Common::Rect(0, 0, 320, 400), Common::Rect(0, 0, 320, 240));
 }
 
 bool Opening::msgFocus(const FocusMessage &msg) {
@@ -40,15 +40,12 @@ bool Opening::msgFocus(const FocusMessage &msg) {
 	Gfx::Palette63 pal = _G(gfx)[35];
 	Gfx::xsetpal(pal);
 
-	// TODO: Better understand the plane format. A proper screen seems to
-	// be okay if I use the resulting 0,0 to 320,200 of the surface
-	_surface.create(640, 400);
+	_surface.create(320, 400);
 	for (int chunkNum = 0; chunkNum < 4; ++chunkNum) {
-		auto g = _G(gfx)[36 + chunkNum];
 		src = _G(gfx)[36 + chunkNum]._data;
 		dest = (byte *)_surface.getBasePtr(chunkNum, 0);
 
-		for (i = 0; i < (640 * 400 / 4); ++i, ++src, dest += 4)
+		for (i = 0; i < (320 * 400 / 4); ++i, ++src, dest += 4)
 			*dest = *src;
 	}
 


Commit: 9d9cb5a5739bf9a22bab0e3daf74a7ec6b624182
    https://github.com/scummvm/scummvm/commit/9d9cb5a5739bf9a22bab0e3daf74a7ec6b624182
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Opening title, sound, and escape action

Changed paths:
    engines/got/events.h
    engines/got/gfx/palette.cpp
    engines/got/got.cpp
    engines/got/sound.cpp
    engines/got/sound.h
    engines/got/views/opening.cpp
    engines/got/views/opening.h
    engines/got/views/title.cpp
    engines/got/views/title.h
    engines/got/views/view.cpp
    engines/got/views/view.h


diff --git a/engines/got/events.h b/engines/got/events.h
index 56c21a5db46..9f9a16dc6aa 100644
--- a/engines/got/events.h
+++ b/engines/got/events.h
@@ -181,6 +181,13 @@ public:
 		return _bounds;
 	}
 
+	/**
+	 * Gets a view's name
+	 */
+	const Common::String &getName() const {
+		return _name;
+	}
+
 	/**
 	 * Returns a surface for drawing the element
 	 */
diff --git a/engines/got/gfx/palette.cpp b/engines/got/gfx/palette.cpp
index 0d578eb4fff..83c0ae2c310 100644
--- a/engines/got/gfx/palette.cpp
+++ b/engines/got/gfx/palette.cpp
@@ -111,6 +111,10 @@ void fade_in(const byte *pal) {
 	if (pal)
 		Common::copy(pal, pal + PALETTE_SIZE, saved_palette);
 
+	// Start with a black palette
+	Common::fill(tempPal, tempPal + PALETTE_SIZE, 0);
+	xsetpal(tempPal);
+
 	for (int step = 1; step <= FADE_STEPS; ++step) {
 		// Set each palette RGB proportionately
 		for (srcP = &saved_palette[0], destP = &tempPal[0], count = 0;
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 39213595afc..8e146b71b6a 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -47,6 +47,7 @@ GotEngine::GotEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(
 }
 
 GotEngine::~GotEngine() {
+	_mixer->stopAll();
 }
 
 uint32 GotEngine::getFeatures() const {
diff --git a/engines/got/sound.cpp b/engines/got/sound.cpp
index 9a146aff426..513df5ff7cc 100644
--- a/engines/got/sound.cpp
+++ b/engines/got/sound.cpp
@@ -57,7 +57,21 @@ void Sound::play_sound(int index, bool priority_override) {
 	// Play the new sound
 	Common::MemoryReadStream *stream = new Common::MemoryReadStream(
 		_soundData + _digiSounds[index].offset, _digiSounds[index].length);
-	Audio::AudioStream *audioStream = Audio::makeVOCStream(stream, Audio::FLAG_UNSIGNED);
+	Audio::AudioStream *audioStream = Audio::makeVOCStream(stream, Audio::FLAG_UNSIGNED,
+		DisposeAfterUse::YES);
+	g_engine->_mixer->playStream(Audio::Mixer::kSFXSoundType,
+		&_soundHandle, audioStream);
+}
+
+void Sound::play_sound(const Gfx::GraphicChunk &src) {
+	if (sound_playing())
+		g_engine->_mixer->stopHandle(_soundHandle);
+
+	// Play the new sound
+	Common::MemoryReadStream *stream = new Common::MemoryReadStream(
+		src._data, src._uncompressedSize);
+	Audio::AudioStream *audioStream = Audio::makeVOCStream(stream, Audio::FLAG_UNSIGNED,
+		DisposeAfterUse::YES);
 	g_engine->_mixer->playStream(Audio::Mixer::kSFXSoundType,
 		&_soundHandle, audioStream);
 }
@@ -209,6 +223,11 @@ void play_sound(int index, bool priority_override) {
 	_G(sound).play_sound(index, priority_override);
 }
 
+void play_sound(const Gfx::GraphicChunk &src) {
+	_G(sound).play_sound(src);
+}
+
+
 bool sound_playing() {
 	return _G(sound).sound_playing();
 }
diff --git a/engines/got/sound.h b/engines/got/sound.h
index 99f67fb221b..d8ffc748466 100644
--- a/engines/got/sound.h
+++ b/engines/got/sound.h
@@ -24,6 +24,7 @@
 
 #include "audio/mixer.h"
 #include "got/data/defines.h"
+#include "got/gfx/gfx_chunks.h"
 
 namespace Got {
 
@@ -70,6 +71,7 @@ public:
 	void load();
 
 	void play_sound(int index, bool priority_override);
+	void play_sound(const Gfx::GraphicChunk &src);
 	bool sound_playing() const;
 
 	void music_play(int num, bool override) {
@@ -83,6 +85,7 @@ public:
 };
 
 extern void play_sound(int index, bool priority_override);
+extern void play_sound(const Gfx::GraphicChunk &src);
 extern bool sound_playing();
 extern void music_play(int num, bool override);
 extern void music_play(const char *name, bool override);
diff --git a/engines/got/views/opening.cpp b/engines/got/views/opening.cpp
index 154f46aa3b2..a31a2d290a4 100644
--- a/engines/got/views/opening.cpp
+++ b/engines/got/views/opening.cpp
@@ -35,7 +35,6 @@ void Opening::draw() {
 bool Opening::msgFocus(const FocusMessage &msg) {
 	const byte *src;
 	byte *dest;
-	int i;
 
 	Gfx::Palette63 pal = _G(gfx)[35];
 	Gfx::xsetpal(pal);
@@ -45,20 +44,51 @@ bool Opening::msgFocus(const FocusMessage &msg) {
 		src = _G(gfx)[36 + chunkNum]._data;
 		dest = (byte *)_surface.getBasePtr(chunkNum, 0);
 
-		for (i = 0; i < (320 * 400 / 4); ++i, ++src, dest += 4)
+		for (int i = 0; i < (320 * 400 / 4); ++i, ++src, dest += 4)
 			*dest = *src;
 	}
 
 	return true;
 }
 
+void Opening::drawTitle() {
+	const byte *src;
+	byte *dest;
+
+	src = _G(gfx)[40]._data;
+
+	for (int pane = 0; pane < 4; ++pane) {
+		dest = (byte *)_surface.getBasePtr(pane, 0);
+
+		for (int i = 0; i < (320 * 80 / 4); ++i, ++src, dest += 4)
+			*dest = *src;
+	}
+}
+
 bool Opening::msgUnfocus(const UnfocusMessage &msg) {
 	_surface.clear();
 	return true;
 }
 
+bool Opening::msgAction(const ActionMessage &msg) {
+	if (msg._action == KEYBIND_ESCAPE) {
+		fadeOut();
+		replaceView("Title", true);
+		return true;
+	}
+
+	return false;
+}
+
 bool Opening::tick() {
-	redraw();
+	++_frameCtr;
+
+	if (_frameCtr == 20) {
+		drawTitle();
+		redraw();
+		play_sound(_G(gfx)[104]);
+	}
+
 	return true;
 }
 
diff --git a/engines/got/views/opening.h b/engines/got/views/opening.h
index f63bdf74339..87d991d7d86 100644
--- a/engines/got/views/opening.h
+++ b/engines/got/views/opening.h
@@ -30,6 +30,9 @@ namespace Views {
 class Opening : public View {
 private:
 	Graphics::ManagedSurface _surface;
+	int _frameCtr = 0;
+
+	void drawTitle();
 
 public:
 	Opening() : View("Opening") {}
@@ -37,6 +40,7 @@ public:
 
 	bool msgFocus(const FocusMessage &msg) override;
 	bool msgUnfocus(const UnfocusMessage &msg) override;
+	bool msgAction(const ActionMessage &msg) override;
 	void draw() override;
 	bool tick() override;
 };
diff --git a/engines/got/views/title.cpp b/engines/got/views/title.cpp
index b77acbacf39..ba853b54029 100644
--- a/engines/got/views/title.cpp
+++ b/engines/got/views/title.cpp
@@ -34,15 +34,21 @@ void Title::draw() {
 	}
 }
 
-bool Title::tick() {
-	if (isFocused()) {
+bool Title::msgFocus(const FocusMessage &msg) {
+	if (msg._priorView->getName() == "Opening") {
 		// When the title screen is shown, show the main menu
 		draw();
+		Gfx::load_palette();
+		fadeIn();
 		addView("MainMenu");
 	}
 
 	return true;
 }
 
+bool Title::tick() {
+	return true;
+}
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/title.h b/engines/got/views/title.h
index c74b93a8629..20391a6ebac 100644
--- a/engines/got/views/title.h
+++ b/engines/got/views/title.h
@@ -37,6 +37,7 @@ public:
 	Title() : View("Title") {}
 	virtual ~Title() {}
 
+	bool msgFocus(const FocusMessage &msg) override;
 	void draw() override;
 	bool tick() override;
 };
diff --git a/engines/got/views/view.cpp b/engines/got/views/view.cpp
index 2ba02700de8..3e5a2a53d6c 100644
--- a/engines/got/views/view.cpp
+++ b/engines/got/views/view.cpp
@@ -85,6 +85,10 @@ void View::play_sound(int index, bool priority_override) {
 	_G(sound).play_sound(index, priority_override);
 }
 
+void View::play_sound(const Gfx::GraphicChunk &src) {
+	_G(sound).play_sound(src);
+}
+
 void View::music_play(int num, bool override) {
 	_G(sound).music_play(num, override);
 }
diff --git a/engines/got/views/view.h b/engines/got/views/view.h
index abb61705c31..76b656a0746 100644
--- a/engines/got/views/view.h
+++ b/engines/got/views/view.h
@@ -23,6 +23,7 @@
 #define GOT_VIEWS_VIEW_H
 
 #include "got/events.h"
+#include "got/gfx/gfx_chunks.h"
 
 namespace Got {
 namespace Views {
@@ -54,6 +55,7 @@ private:
 
 protected:
 	void play_sound(int index, bool priority_override);
+	void play_sound(const Gfx::GraphicChunk &src);
 
 	void music_play(int num, bool override);
 	void music_play(const char *name, bool override);


Commit: c6d213fe49abe20b10335b54c87da8e57c32c011
    https://github.com/scummvm/scummvm/commit/c6d213fe49abe20b10335b54c87da8e57c32c011
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Add simple shaking of opening screen

Changed paths:
    engines/got/views/opening.cpp
    engines/got/views/opening.h


diff --git a/engines/got/views/opening.cpp b/engines/got/views/opening.cpp
index a31a2d290a4..b30626d2aa8 100644
--- a/engines/got/views/opening.cpp
+++ b/engines/got/views/opening.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "got/views/opening.h"
+#include "got/got.h"
 #include "got/vars.h"
 
 namespace Got {
@@ -29,7 +30,15 @@ int ctr = 0;
 
 void Opening::draw() {
 	GfxSurface s = getSurface();
-	s.blitFrom(_surface, Common::Rect(0, 0, 320, 400), Common::Rect(0, 0, 320, 240));
+
+	if (_shakeX == 0) {
+		s.blitFrom(_surface, Common::Rect(0, 0, 320, 400), Common::Rect(0, 0, 320, 240));
+	} else {
+		s.clear();
+		Common::Rect destRect(0, 0, 320, 240);
+		destRect.translate(_shakeX, 0);
+		s.blitFrom(_surface, Common::Rect(0, 0, 320, 400), destRect);
+	}
 }
 
 bool Opening::msgFocus(const FocusMessage &msg) {
@@ -87,6 +96,16 @@ bool Opening::tick() {
 		drawTitle();
 		redraw();
 		play_sound(_G(gfx)[104]);
+	} else if (_frameCtr < 40) {
+		if ((_frameCtr % 4) == 0) {
+			_shakeX = g_engine->getRandomNumber(19) - 10;
+			redraw();
+		}
+	} else if (_frameCtr == 41) {
+		_shakeX = 0;
+		redraw();
+	} else if (_frameCtr == 150) {
+		replaceView("Credits", true, true);
 	}
 
 	return true;
diff --git a/engines/got/views/opening.h b/engines/got/views/opening.h
index 87d991d7d86..b0123cf3e27 100644
--- a/engines/got/views/opening.h
+++ b/engines/got/views/opening.h
@@ -31,6 +31,7 @@ class Opening : public View {
 private:
 	Graphics::ManagedSurface _surface;
 	int _frameCtr = 0;
+	int _shakeX = 0;
 
 	void drawTitle();
 


Commit: 72812cccf0ec451a5f9675ecdaf806cf0d7ec546
    https://github.com/scummvm/scummvm/commit/72812cccf0ec451a5f9675ecdaf806cf0d7ec546
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Credits background

Changed paths:
    engines/got/events.cpp
    engines/got/views/credits.cpp
    engines/got/views/credits.h
    engines/got/views/opening.cpp
    engines/got/views/view.cpp
    engines/got/views/view.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 15a9606cbc9..f7d30962caa 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -68,7 +68,7 @@ void Events::runGame() {
 	}
 	if (saveSlot == -1)
 //		addView("SplashScreen");
-		addView("Opening");
+		addView("Credits");
 
 	// Main game loop
 	Common::Event e;
diff --git a/engines/got/views/credits.cpp b/engines/got/views/credits.cpp
index c79285b7cd6..a55dc864e23 100644
--- a/engines/got/views/credits.cpp
+++ b/engines/got/views/credits.cpp
@@ -25,9 +25,21 @@
 namespace Got {
 namespace Views {
 
+bool Credits::msgFocus(const FocusMessage &msg) {
+	draw();
+	Gfx::Palette63 pal = _G(gfx)[41];
+	fadeIn(pal);
+
+	return true;
+}
+
 void Credits::draw() {
 	GfxSurface s = getSurface();
-	s.print(Common::Point(10, 10), "Credits", 255);
+
+	// Draw scroll background
+	Graphics::ManagedSurface bg = _G(gfx)[42];
+	s.clear(*(byte *)bg.getPixels());
+	s.blitFrom(bg, Common::Point(0, 24));
 }
 
 bool Credits::tick() {
diff --git a/engines/got/views/credits.h b/engines/got/views/credits.h
index 48de73b4eb9..8d585ba514c 100644
--- a/engines/got/views/credits.h
+++ b/engines/got/views/credits.h
@@ -32,6 +32,7 @@ public:
 	Credits() : View("Credits") {}
 	virtual ~Credits() {}
 
+	bool msgFocus(const FocusMessage &msg) override;
 	void draw() override;
 	bool tick() override;
 };
diff --git a/engines/got/views/opening.cpp b/engines/got/views/opening.cpp
index b30626d2aa8..1a42b8c674d 100644
--- a/engines/got/views/opening.cpp
+++ b/engines/got/views/opening.cpp
@@ -105,6 +105,7 @@ bool Opening::tick() {
 		_shakeX = 0;
 		redraw();
 	} else if (_frameCtr == 150) {
+		fadeOut();
 		replaceView("Credits", true, true);
 	}
 
diff --git a/engines/got/views/view.cpp b/engines/got/views/view.cpp
index 3e5a2a53d6c..0b27042ebe4 100644
--- a/engines/got/views/view.cpp
+++ b/engines/got/views/view.cpp
@@ -117,8 +117,8 @@ void View::fadeOut() {
 	Gfx::fade_out();
 }
 
-void View::fadeIn() {
-	Gfx::fade_in();
+void View::fadeIn(const byte *pal) {
+	Gfx::fade_in(pal);
 }
 
 } // namespace Views
diff --git a/engines/got/views/view.h b/engines/got/views/view.h
index 76b656a0746..0e69b429b41 100644
--- a/engines/got/views/view.h
+++ b/engines/got/views/view.h
@@ -65,7 +65,7 @@ protected:
 	bool music_is_on() const;
 
 	void fadeOut();
-	void fadeIn();
+	void fadeIn(const byte *pal = nullptr);
 
 public:
 	View(const Common::String &name, UIElement *uiParent) :


Commit: 1d33418f24743b82c5092a57f973386404bcaa46
    https://github.com/scummvm/scummvm/commit/1d33418f24743b82c5092a57f973386404bcaa46
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Implemented credits view

Changed paths:
    engines/got/views/credits.cpp
    engines/got/views/credits.h
    engines/got/views/title.cpp


diff --git a/engines/got/views/credits.cpp b/engines/got/views/credits.cpp
index a55dc864e23..57881fffb1a 100644
--- a/engines/got/views/credits.cpp
+++ b/engines/got/views/credits.cpp
@@ -25,7 +25,15 @@
 namespace Got {
 namespace Views {
 
+#define CREDITS_COUNT 9
+#define FADE_FRAMES 15
+#define DISPLAY_TIME 15
+#define CREDIT_TIME (FADE_FRAMES * 2 + DISPLAY_TIME)
+
 bool Credits::msgFocus(const FocusMessage &msg) {
+	_delayCtr = 0;
+	_frameCtr = 0;
+
 	draw();
 	Gfx::Palette63 pal = _G(gfx)[41];
 	fadeIn(pal);
@@ -40,9 +48,79 @@ void Credits::draw() {
 	Graphics::ManagedSurface bg = _G(gfx)[42];
 	s.clear(*(byte *)bg.getPixels());
 	s.blitFrom(bg, Common::Point(0, 24));
+
+	int creditNum = _frameCtr / CREDIT_TIME;
+	int subNum = _frameCtr % CREDIT_TIME;
+
+	if (subNum >= (FADE_FRAMES + DISPLAY_TIME)) {
+		subNum = (FADE_FRAMES - 1) - (subNum - (FADE_FRAMES + DISPLAY_TIME));
+	} else if (subNum >= FADE_FRAMES) {
+		subNum = FADE_FRAMES - 1;
+	}
+
+	if (creditNum < CREDITS_COUNT) {
+		int gfxNum1 = 43 + creditNum;
+		int gfxNum2 = 67 + creditNum;
+		int gfxNum3 = 52 + subNum;
+		int gfxNum4 = 76 + subNum;
+
+		drawCredit(s, gfxNum1, gfxNum3, 16, 40 + 24);
+		drawCredit(s, gfxNum2, gfxNum4, 16, 40 + 24);
+	}
+
+	s.markAllDirty();
+}
+
+void Credits::drawCredit(GfxSurface &s, int gfxNum1, int gfxNum2, int x, int y) {
+	const Gfx::GraphicChunk &data = _G(gfx)[gfxNum1];
+	const Gfx::GraphicChunk &lookup = _G(gfx)[gfxNum2];
+	const byte *lines = data._data;
+	const byte *lineData = data._data + 2 * data._height;
+	byte *dest;
+	byte count;
+
+	assert(x >= 0 && (x + data._width) <= 320);
+	assert(y >= 0 && (y + data._height) <= 200);
+
+	for (int yCtr = 0; yCtr < data._height; ++yCtr) {
+		dest = (byte *)s.getBasePtr(x, y + yCtr);
+		uint16 lineParts = READ_LE_UINT16(lines);
+		lines += 2;
+
+		if (lineParts == 0)
+			// Nothing on line, move to next
+			continue;
+
+		for (; lineParts > 0; --lineParts) {
+			count = *lineData++;
+
+			if (count & 0x80) {
+				// Shade a range of pixels using lookup table
+				count &= 0x7f;
+				for (int i = 0; i < count; ++i, ++dest)
+					*dest = lookup._data[*dest];
+			} else {
+				dest += count;
+			}
+		}
+	}
 }
 
 bool Credits::tick() {
+	if (++_delayCtr >= 3) {
+		_delayCtr = 0;
+
+		if (_frameCtr == (CREDIT_TIME * CREDITS_COUNT) + 10) {
+			// TODO: The original switched to show the top high scores
+			// briefly, and then switches to the demo
+			fadeOut();
+			replaceView("Title", true);
+		} else {
+			++_frameCtr;
+			redraw();
+		}
+	}
+
 	return true;
 }
 
diff --git a/engines/got/views/credits.h b/engines/got/views/credits.h
index 8d585ba514c..2d9423ece1d 100644
--- a/engines/got/views/credits.h
+++ b/engines/got/views/credits.h
@@ -28,6 +28,12 @@ namespace Got {
 namespace Views {
 
 class Credits : public View {
+private:
+	int _delayCtr = 0;
+	int _frameCtr = 0;
+
+	void drawCredit(GfxSurface &s, int gfxNum1, int gfxNum2, int x, int y);
+
 public:
 	Credits() : View("Credits") {}
 	virtual ~Credits() {}
diff --git a/engines/got/views/title.cpp b/engines/got/views/title.cpp
index ba853b54029..d6f10b32b9b 100644
--- a/engines/got/views/title.cpp
+++ b/engines/got/views/title.cpp
@@ -35,13 +35,11 @@ void Title::draw() {
 }
 
 bool Title::msgFocus(const FocusMessage &msg) {
-	if (msg._priorView->getName() == "Opening") {
-		// When the title screen is shown, show the main menu
-		draw();
-		Gfx::load_palette();
-		fadeIn();
-		addView("MainMenu");
-	}
+	// When the title screen is shown, show the main menu
+	draw();
+	Gfx::load_palette();
+	fadeIn();
+	addView("MainMenu");
 
 	return true;
 }


Commit: dad8e86bd0947bd5ec191463c447d9c1544a1013
    https://github.com/scummvm/scummvm/commit/dad8e86bd0947bd5ec191463c447d9c1544a1013
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Escape key for Credits view

Changed paths:
    engines/got/events.cpp
    engines/got/views/credits.cpp
    engines/got/views/credits.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index f7d30962caa..bbf1d71f0c2 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -67,8 +67,7 @@ void Events::runGame() {
 			saveSlot = -1;
 	}
 	if (saveSlot == -1)
-//		addView("SplashScreen");
-		addView("Credits");
+		addView("SplashScreen");
 
 	// Main game loop
 	Common::Event e;
diff --git a/engines/got/views/credits.cpp b/engines/got/views/credits.cpp
index 57881fffb1a..91758b5402f 100644
--- a/engines/got/views/credits.cpp
+++ b/engines/got/views/credits.cpp
@@ -124,5 +124,15 @@ bool Credits::tick() {
 	return true;
 }
 
+bool Credits::msgAction(const ActionMessage &msg) {
+	if (msg._action == KEYBIND_ESCAPE) {
+		fadeOut();
+		replaceView("Title", true);
+		return true;
+	}
+
+	return false;
+}
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/credits.h b/engines/got/views/credits.h
index 2d9423ece1d..c7ed40851d9 100644
--- a/engines/got/views/credits.h
+++ b/engines/got/views/credits.h
@@ -39,6 +39,7 @@ public:
 	virtual ~Credits() {}
 
 	bool msgFocus(const FocusMessage &msg) override;
+	bool msgAction(const ActionMessage &msg) override;
 	void draw() override;
 	bool tick() override;
 };


Commit: 45041dab32affc3306732ef40371282453352c89
    https://github.com/scummvm/scummvm/commit/45041dab32affc3306732ef40371282453352c89
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Title screens fixes

Changed paths:
    engines/got/views/dialogs/main_menu.cpp
    engines/got/views/dialogs/quit.cpp
    engines/got/views/dialogs/quit.h
    engines/got/views/opening.cpp
    engines/got/views/title.cpp


diff --git a/engines/got/views/dialogs/main_menu.cpp b/engines/got/views/dialogs/main_menu.cpp
index 01ad211ce31..0f6e4d500c6 100644
--- a/engines/got/views/dialogs/main_menu.cpp
+++ b/engines/got/views/dialogs/main_menu.cpp
@@ -40,8 +40,7 @@ void MainMenu::closed() {
 void MainMenu::selected() {
 	switch (_selectedItem) {
 	case 0:
-		// FIXME: Dummy test of fading code
-		replaceView("QuitGame", true, true);
+		addView("SelectGame");
 		break;
 
 	case 4:
diff --git a/engines/got/views/dialogs/quit.cpp b/engines/got/views/dialogs/quit.cpp
index 31f1bc3e1f5..a4820407cbe 100644
--- a/engines/got/views/dialogs/quit.cpp
+++ b/engines/got/views/dialogs/quit.cpp
@@ -42,6 +42,10 @@ void Quit::selected() {
 	}
 }
 
+void Quit::closed() {
+	replaceView("Title", true);
+}
+
 } // namespace Dialogs
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/dialogs/quit.h b/engines/got/views/dialogs/quit.h
index 5ec3965a5e9..7d0f24d7aff 100644
--- a/engines/got/views/dialogs/quit.h
+++ b/engines/got/views/dialogs/quit.h
@@ -35,6 +35,7 @@ public:
 	}
 
 	void selected() override;
+	void closed() override;
 };
 
 } // namespace Dialogs
diff --git a/engines/got/views/opening.cpp b/engines/got/views/opening.cpp
index 1a42b8c674d..e39f276954e 100644
--- a/engines/got/views/opening.cpp
+++ b/engines/got/views/opening.cpp
@@ -46,7 +46,7 @@ bool Opening::msgFocus(const FocusMessage &msg) {
 	byte *dest;
 
 	Gfx::Palette63 pal = _G(gfx)[35];
-	Gfx::xsetpal(pal);
+	fadeIn(pal);
 
 	_surface.create(320, 400);
 	for (int chunkNum = 0; chunkNum < 4; ++chunkNum) {
diff --git a/engines/got/views/title.cpp b/engines/got/views/title.cpp
index d6f10b32b9b..541a8798715 100644
--- a/engines/got/views/title.cpp
+++ b/engines/got/views/title.cpp
@@ -35,10 +35,20 @@ void Title::draw() {
 }
 
 bool Title::msgFocus(const FocusMessage &msg) {
+	if (msg._priorView->getName() == "MainMenu")
+		return true;
+
 	// When the title screen is shown, show the main menu
-	draw();
-	Gfx::load_palette();
-	fadeIn();
+	if (msg._priorView->getName() == "Opening" ||
+			msg._priorView->getName() == "Credits") {
+		draw();
+		Gfx::load_palette();
+		fadeIn();
+	} else {
+		Gfx::load_palette();
+	}
+
+	// Add in the menu on top of this view
 	addView("MainMenu");
 
 	return true;


Commit: c62e25c658e4486927ba21fc1efdd913485e2542
    https://github.com/scummvm/scummvm/commit/c62e25c658e4486927ba21fc1efdd913485e2542
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Further startup title screen fixes

Changed paths:
  A engines/got/views/title_background.cpp
  A engines/got/views/title_background.h
  R engines/got/views/title.cpp
  R engines/got/views/title.h
    engines/got/module.mk
    engines/got/views/credits.cpp
    engines/got/views/dialogs/quit.cpp
    engines/got/views/dialogs/select_game.cpp
    engines/got/views/dialogs/select_game.h
    engines/got/views/opening.cpp
    engines/got/views/views.h


diff --git a/engines/got/module.mk b/engines/got/module.mk
index 21c5968877b..3de493ad2f6 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -44,7 +44,7 @@ MODULE_OBJS = \
 	views/part_title.o \
 	views/splash_screen.o \
 	views/story.o \
-	views/title.o \
+	views/title_background.o \
 	views/dialogs/dialog.o \
 	views/dialogs/select_option.o \
 	views/dialogs/ask.o \
diff --git a/engines/got/views/credits.cpp b/engines/got/views/credits.cpp
index 91758b5402f..a6ee731668b 100644
--- a/engines/got/views/credits.cpp
+++ b/engines/got/views/credits.cpp
@@ -114,7 +114,7 @@ bool Credits::tick() {
 			// TODO: The original switched to show the top high scores
 			// briefly, and then switches to the demo
 			fadeOut();
-			replaceView("Title", true);
+			send("TitleBackground", GameMessage("MAIN_MENU"));
 		} else {
 			++_frameCtr;
 			redraw();
@@ -127,7 +127,7 @@ bool Credits::tick() {
 bool Credits::msgAction(const ActionMessage &msg) {
 	if (msg._action == KEYBIND_ESCAPE) {
 		fadeOut();
-		replaceView("Title", true);
+		send("TitleBackground", GameMessage("MAIN_MENU"));
 		return true;
 	}
 
diff --git a/engines/got/views/dialogs/quit.cpp b/engines/got/views/dialogs/quit.cpp
index a4820407cbe..6888cbd83e4 100644
--- a/engines/got/views/dialogs/quit.cpp
+++ b/engines/got/views/dialogs/quit.cpp
@@ -35,7 +35,7 @@ void Quit::selected() {
 		g_engine->quitGame();
 		break;
 	case 1:
-		replaceView("Title", true);
+		addView("MainMenu");
 		break;
 	default:
 		break;
@@ -43,7 +43,7 @@ void Quit::selected() {
 }
 
 void Quit::closed() {
-	replaceView("Title", true);
+	addView("MainMenu");
 }
 
 } // namespace Dialogs
diff --git a/engines/got/views/dialogs/select_game.cpp b/engines/got/views/dialogs/select_game.cpp
index 36fcd6d9e5d..8c9614e8172 100644
--- a/engines/got/views/dialogs/select_game.cpp
+++ b/engines/got/views/dialogs/select_game.cpp
@@ -44,6 +44,10 @@ void SelectGame::selected() {
 	replaceView("Story", true, true);
 }
 
+void SelectGame::closed() {
+	addView("MainMenu");
+}
+
 } // namespace Dialogs
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/dialogs/select_game.h b/engines/got/views/dialogs/select_game.h
index 2897b45cb99..082855180d9 100644
--- a/engines/got/views/dialogs/select_game.h
+++ b/engines/got/views/dialogs/select_game.h
@@ -35,6 +35,7 @@ public:
 	}
 
 	void selected() override;
+	void closed() override;
 };
 
 } // namespace Dialogs
diff --git a/engines/got/views/opening.cpp b/engines/got/views/opening.cpp
index e39f276954e..fbe38c1aee5 100644
--- a/engines/got/views/opening.cpp
+++ b/engines/got/views/opening.cpp
@@ -82,7 +82,7 @@ bool Opening::msgUnfocus(const UnfocusMessage &msg) {
 bool Opening::msgAction(const ActionMessage &msg) {
 	if (msg._action == KEYBIND_ESCAPE) {
 		fadeOut();
-		replaceView("Title", true);
+		send("TitleBackground", GameMessage("MAIN_MENU"));
 		return true;
 	}
 
diff --git a/engines/got/views/title.cpp b/engines/got/views/title_background.cpp
similarity index 73%
rename from engines/got/views/title.cpp
rename to engines/got/views/title_background.cpp
index 541a8798715..0eaec7135ca 100644
--- a/engines/got/views/title.cpp
+++ b/engines/got/views/title_background.cpp
@@ -19,43 +19,33 @@
  *
  */
 
-#include "got/views/title.h"
+#include "got/views/title_background.h"
 #include "got/vars.h"
 
 namespace Got {
 namespace Views {
 
-void Title::draw() {
-	GfxSurface s = getSurface();
-
-	for (int col = 0, xp = 0; col < 10; ++col, xp += 32) {
-		for (int yp = 0; yp < 240; yp += 32)
-			s.blitFrom(_G(gfx)[26], Common::Point(xp, yp));
-	}
-}
-
-bool Title::msgFocus(const FocusMessage &msg) {
-	if (msg._priorView->getName() == "MainMenu")
-		return true;
-
-	// When the title screen is shown, show the main menu
-	if (msg._priorView->getName() == "Opening" ||
-			msg._priorView->getName() == "Credits") {
+bool TitleBackground::msgGame(const GameMessage &msg) {
+	if (msg._name == "MAIN_MENU") {
+		addView();
 		draw();
 		Gfx::load_palette();
 		fadeIn();
-	} else {
-		Gfx::load_palette();
-	}
 
-	// Add in the menu on top of this view
-	addView("MainMenu");
+		addView("MainMenu");
+		return true;
+	}
 
-	return true;
+	return false;
 }
 
-bool Title::tick() {
-	return true;
+void TitleBackground::draw() {
+	GfxSurface s = getSurface();
+
+	for (int col = 0, xp = 0; col < 10; ++col, xp += 32) {
+		for (int yp = 0; yp < 240; yp += 32)
+			s.blitFrom(_G(gfx)[26], Common::Point(xp, yp));
+	}
 }
 
 } // namespace Views
diff --git a/engines/got/views/title.h b/engines/got/views/title_background.h
similarity index 83%
rename from engines/got/views/title.h
rename to engines/got/views/title_background.h
index 20391a6ebac..95b505a58ed 100644
--- a/engines/got/views/title.h
+++ b/engines/got/views/title_background.h
@@ -19,8 +19,8 @@
  *
  */
 
-#ifndef GOT_VIEWS_TITLE_H
-#define GOT_VIEWS_TITLE_H
+#ifndef GOT_VIEWS_TITLE_BACKGROUND_H
+#define GOT_VIEWS_TITLE_BACKGROUND_H
 
 #include "graphics/managed_surface.h"
 #include "got/views/view.h"
@@ -32,14 +32,13 @@ namespace Views {
  * This view provides the green background for the
  * main menu and other dialogs on the title screen
  */
-class Title : public View {
+class TitleBackground : public View {
 public:
-	Title() : View("Title") {}
-	virtual ~Title() {}
+	TitleBackground() : View("TitleBackground") {}
+	virtual ~TitleBackground() {}
 
-	bool msgFocus(const FocusMessage &msg) override;
+	bool msgGame(const GameMessage &msg) override;
 	void draw() override;
-	bool tick() override;
 };
 
 } // namespace Views
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index 47f08aac693..953b9d2fce1 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -28,7 +28,7 @@
 #include "got/views/part_title.h"
 #include "got/views/splash_screen.h"
 #include "got/views/story.h"
-#include "got/views/title.h"
+#include "got/views/title_background.h"
 #include "got/views/dialogs/ask.h"
 #include "got/views/dialogs/main_menu.h"
 #include "got/views/dialogs/options_menu.h"
@@ -53,7 +53,7 @@ struct Views {
 	PartTitle _partTitle;
 	SplashScreen _splashScreen;
 	Story _story;
-	Title _title;
+	TitleBackground _titleBackground;
 
 	Dialogs::Ask _ask;
 	Dialogs::MainMenu _mainMenu;


Commit: 4e0d3d98b80d91033dc08a8dca000c724f29a54d
    https://github.com/scummvm/scummvm/commit/4e0d3d98b80d91033dc08a8dca000c724f29a54d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Include player name in ScummVM savegames

Changed paths:
    engines/got/console.cpp
    engines/got/got.cpp
    engines/got/vars.h


diff --git a/engines/got/console.cpp b/engines/got/console.cpp
index 13d8dc8f8dc..fc800c9bab0 100644
--- a/engines/got/console.cpp
+++ b/engines/got/console.cpp
@@ -76,8 +76,6 @@ bool Console::cmdLoad(int argc, const char **argv) {
 		debugPrintf("Could not open %s\n", filename.c_str());
 		return true;
 	} else {
-		f->skip(32); // Skip the 32 bytes title
-
 		Common::Serializer s(f, nullptr);
 		g_engine->syncGame(s);
 		delete f;
@@ -95,13 +93,6 @@ bool Console::cmdSave(int argc, const char **argv) {
 		debugPrintf("Could not create %s\n", filename.c_str());
 
 	} else {
-		// Write out dummy person name
-		char title[32];
-		Common::fill(title, title + 32, 0);
-		Common::strcpy_s(title, "ScummVM");
-
-		f->write(title, 32);
-
 		Common::Serializer s(nullptr, f);
 		g_engine->syncGame(s);
 
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 8e146b71b6a..aab8a9129b6 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -104,6 +104,13 @@ Common::Error GotEngine::loadGameStream(Common::SeekableReadStream *stream) {
 
 
 Common::Error GotEngine::syncGame(Common::Serializer &s) {
+	char title[32];
+	Common::fill(title, title + 32, 0);
+	Common::strcpy_s(title, _G(playerName).c_str());
+	s.syncBytes((byte *)title, 32);
+	if (s.isLoading())
+		_G(playerName) = title;
+
 	_G(setup).sync(s);
 	_G(thor_info).sync(s);
 	_G(sd_data).sync(s);
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 2544089d262..942fe6478c5 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -73,6 +73,7 @@ public:
 	void load();
 	void setArea(int areaNum);
 
+	Common::String _playerName = "ScummVM";
 	Gfx::GfxChunks _gfx;
 	Gfx::BgPics _bgPics;
 	Gfx::Font _font;


Commit: f4244049b27181f86819436c4c5dba509cbec905
    https://github.com/scummvm/scummvm/commit/f4244049b27181f86819436c4c5dba509cbec905
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fading fixes for title screens

Changed paths:
    engines/got/views/opening.cpp
    engines/got/views/splash_screen.cpp


diff --git a/engines/got/views/opening.cpp b/engines/got/views/opening.cpp
index fbe38c1aee5..2e7bf054ec5 100644
--- a/engines/got/views/opening.cpp
+++ b/engines/got/views/opening.cpp
@@ -45,9 +45,6 @@ bool Opening::msgFocus(const FocusMessage &msg) {
 	const byte *src;
 	byte *dest;
 
-	Gfx::Palette63 pal = _G(gfx)[35];
-	fadeIn(pal);
-
 	_surface.create(320, 400);
 	for (int chunkNum = 0; chunkNum < 4; ++chunkNum) {
 		src = _G(gfx)[36 + chunkNum]._data;
@@ -57,6 +54,11 @@ bool Opening::msgFocus(const FocusMessage &msg) {
 			*dest = *src;
 	}
 
+	// Fade in the screen
+	Gfx::Palette63 pal = _G(gfx)[35];
+	draw();
+	fadeIn(pal);
+
 	return true;
 }
 
@@ -106,7 +108,7 @@ bool Opening::tick() {
 		redraw();
 	} else if (_frameCtr == 150) {
 		fadeOut();
-		replaceView("Credits", true, true);
+		replaceView("Credits", true);
 	}
 
 	return true;
diff --git a/engines/got/views/splash_screen.cpp b/engines/got/views/splash_screen.cpp
index d62e99b7782..ce70ceec349 100644
--- a/engines/got/views/splash_screen.cpp
+++ b/engines/got/views/splash_screen.cpp
@@ -83,7 +83,7 @@ bool SplashScreen::tick() {
 			_chunkSize += 4;
 		} else if (_frameCtr == (SPLASH_FRAME_COUNT + 50)) {
 			// Switch to the opening screen showing the game name
-			replaceView("Opening", true, true);
+			replaceView("Opening", true);
 		}
 	}
 


Commit: 0a9270e051d25a8c0280e2c81db8a250b26c7da8
    https://github.com/scummvm/scummvm/commit/0a9270e051d25a8c0280e2c81db8a250b26c7da8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added cheat for infinite health/magic/jewels

Changed paths:
    engines/got/console.cpp
    engines/got/console.h
    engines/got/vars.h
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/console.cpp b/engines/got/console.cpp
index fc800c9bab0..48623fc9941 100644
--- a/engines/got/console.cpp
+++ b/engines/got/console.cpp
@@ -39,6 +39,7 @@ Console::Console() : GUI::Debugger() {
 	registerCmd("load", WRAP_METHOD(Console, cmdLoad));
 	registerCmd("save", WRAP_METHOD(Console, cmdSave));
 	registerCmd("magic", WRAP_METHOD(Console, cmdMagic));
+	registerCmd("freeze", WRAP_METHOD(Console, cmdFreeze));
 }
 
 Console::~Console() {
@@ -110,4 +111,24 @@ bool Console::cmdMagic(int argc, const char **argv) {
 	return false;
 }
 
+bool Console::cmdFreeze(int argc, const char **argv) {
+	if (argc != 2) {
+		debugPrintf("freeze ['health', 'magic', 'gems']\n");
+	} else if (!strcmp(argv[1], "health")) {
+		_G(cheats).freezeHealth = !_G(cheats).freezeHealth;
+		debugPrintf("Health is %s\n", _G(cheats).freezeHealth ? "frozen" : "unfrozen");
+	} else if (!strcmp(argv[1], "magic")) {
+		debugPrintf("Magic is %s\n", _G(cheats).freezeHealth ? "frozen" : "unfrozen");
+	} else if (!strcmp(argv[1], "jewels")) {
+		_G(cheats).freezeJewels = !_G(cheats).freezeJewels;
+		debugPrintf("Jewels are %s\n", _G(cheats).freezeJewels ? "frozen" : "unfrozen");
+	} else if (!strcmp(argv[1], "all")) {
+		_G(cheats).freezeHealth = _G(cheats).freezeMagic =
+			_G(cheats).freezeJewels = !_G(cheats).freezeHealth;
+		debugPrintf("All are %s\n", _G(cheats).freezeHealth ? "frozen" : "unfrozen");
+	}
+
+	return true;
+}
+
 } // namespace Got
diff --git a/engines/got/console.h b/engines/got/console.h
index 6849c926773..0ccd0d14d72 100644
--- a/engines/got/console.h
+++ b/engines/got/console.h
@@ -35,6 +35,7 @@ private:
 	bool cmdLoad(int argc, const char **argv);
 	bool cmdSave(int argc, const char **argv);
 	bool cmdMagic(int argc, const char **argv);
+	bool cmdFreeze(int argc, const char **argv);
 
 public:
 	Console();
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 942fe6478c5..a2fad9c428c 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -64,6 +64,11 @@ enum TransitionDir {
 	DIR_LEFT, DIR_RIGHT, DIR_UP, DIR_DOWN
 };
 
+struct Cheats {
+	bool freezeHealth = false;
+	bool freezeMagic = false;
+	bool freezeJewels = false;
+};
 
 class Vars {
 public:
@@ -86,6 +91,7 @@ public:
 	Scripts _scripts;
 	GameMode _gameMode = MODE_NORMAL;
 	TransitionDir _transitionDir = DIR_LEFT;
+	Cheats _cheats;
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
 	uint _display_page = 0, _draw_page = 0;
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 5616aa59c5c..e68a0775fd5 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -111,6 +111,7 @@ bool GameContent::tick() {
 		moveActors();
 		use_item();
 		updateActors();
+		checkForCheats();
 		break;
 
 	case MODE_THOR_DIES:
@@ -404,5 +405,14 @@ void GameContent::thorDead() {
 	set_thor_vars();
 }
 
+void GameContent::checkForCheats() {
+	if (_G(cheats).freezeHealth)
+		_G(thor)->health = 150;
+	if (_G(cheats).freezeMagic)
+		_G(thor_info).magic = 150;
+	if (_G(cheats).freezeJewels)
+		_G(thor_info).jewels = 999;
+}
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index b89ada551c2..3d281fb721a 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -48,6 +48,7 @@ private:
 	void thorDies();
 	void spinThor();
 	void thorDead();
+	void checkForCheats();
 
 public:
 	GameContent();


Commit: 297eeacc7ffa56834dee216157dde479d1d76316
    https://github.com/scummvm/scummvm/commit/297eeacc7ffa56834dee216157dde479d1d76316
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Change memcpy to C++ implicit copying

Changed paths:
    engines/got/game/move.cpp
    engines/got/game/object.cpp
    engines/got/gfx/image.cpp


diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index 5edbe71c9ea..53f3c9ff7f3 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -200,7 +200,8 @@ int _actor_shoots(ACTOR *actr, int dir) {
 	for (i = MAX_ENEMIES + 3; i < MAX_ACTORS; i++) {
 		if ((!_G(actor)[i].used) && (!_G(actor)[i].dead)) {
 			act = &_G(actor)[i];
-			memcpy(act, &_G(shot)[t], sizeof(ACTOR));
+			*act = _G(shot)[t];
+
 			if (actr->size_y < act->size_y) cy = actr->y - ((act->size_y - actr->size_y) / 2);
 			else cy = actr->y + ((actr->size_y - act->size_y) / 2);
 			if (actr->size_x < act->size_x) cx = actr->x - ((act->size_x - actr->size_x) / 2);
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index f8be9dec6a4..47707360cf0 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -371,7 +371,8 @@ int use_tornado(int flag) {
 				_G(magic_cnt) = 0;
 				add_magic(-10);
 				setup_magic_item(0);
-				memcpy(&_G(actor)[2], &_G(magic_item)[0], sizeof(ACTOR));
+				_G(actor)[2] = _G(magic_item)[0];
+
 				setup_actor(&_G(actor)[2], 2, 0, _G(thor)->x, _G(thor)->y);
 				_G(actor)[2].last_dir = _G(thor)->dir;
 				_G(actor)[2].move = 16;
diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index a257a75934a..0ad5a99577e 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -92,7 +92,7 @@ int load_standard_actors() {
 	_G(ami_buff) = _G(abuff);
 
 	load_actor(0, 100 + _G(thor_info).armor);   // Load Thor
-	memcpy(&_G(actor)[0], (_G(tmp_buff) + 5120), 40);
+	_G(actor)[0].loadFixed(_G(tmp_buff) + 5120);
 	setup_actor(&_G(actor)[0], 0, 0, 100, 100);
 	_G(thor) = &_G(actor)[0];
 
@@ -106,7 +106,7 @@ int load_standard_actors() {
 	_G(thor_y2) = _G(thor)->y + 14;
 
 	load_actor(0, 103 + _G(thor_info).armor);   // Load hammer
-	memcpy(&_G(actor)[1], (_G(tmp_buff) + 5120), 40);
+	_G(actor)[1].loadFixed(_G(tmp_buff) + 5120);
 	setup_actor(&_G(actor)[1], 1, 0, 100, 100);
 	_G(actor)[1].used = 0;
 	_G(hammer) = &_G(actor)[1];
@@ -255,9 +255,9 @@ int actor_visible(int invis_num) {
 	for (i = 0; i < MAX_ENEMIES; i++) {
 		if (_G(scrn).actor_invis[i] == invis_num) {
 			if (_G(etype)[i] >= 0 && !_G(actor)[i + 3].used) {
-				memcpy(&_G(actor)[i + 3], &_G(enemy)[_G(etype)[i]], sizeof(ACTOR));
+				_G(actor)[i + 3] = _G(enemy)[_G(etype)[i]];
+
 				d = _G(scrn).actor_dir[i];
-				//       _G(scrn).actor_type[i] &= 0x3f;
 				setup_actor(&_G(actor)[i + 3], i + 3, d, (_G(scrn).actor_loc[i] % 20) * 16,
 					(_G(scrn).actor_loc[i] / 20) * 16);
 				_G(actor)[i + 3].init_dir = _G(scrn).actor_dir[i];


Commit: a29113c1be41e904905b60a59579f9c8a1410e96
    https://github.com/scummvm/scummvm/commit/a29113c1be41e904905b60a59579f9c8a1410e96
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Remove dedundant defines

Changed paths:
    engines/got/data/defines.h


diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index 46f73567ed2..7c0f11cd2e4 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -35,45 +35,6 @@ namespace Got {
 #define REPEAT(a) for(rep=0;rep<a;rep++)
 #define IN_RANGE(v,l,h) (v>=l && v<=h)
 
-struct ACTOR_NFO {				//size=40
-	byte move = 0;                  //movement pattern (0=none)
-	byte width = 0;                 //physical width
-	byte height = 0;                //physical height
-	byte directions = 0;            //1,2 or 4 (1=uni-directional)
-	byte frames = 0;                //# frames per direction
-	byte frame_speed = 0;           //# cycles between frame changes
-	byte frame_sequence[4] = {};    //sequence
-	byte speed = 0;                 //move every Nth cycle
-	byte size_x = 0;                //non-physical padding on X coor
-	byte size_y = 0;                //non-phsyical padding on Y coor
-	byte strength = 0;              //hit strength
-	byte health = 0;                //
-	byte num_moves = 0;             //# of moves every <speed> cycles
-	byte shot_type = 0;             //actor # of shot
-	byte shot_pattern = 0;          //func number to decide to shoot
-	byte shots_allowed = 0;         //# shots allowed on screen
-	byte solid = 0;                 //1=solid (not ghost,etc)
-	byte flying = 0;                //
-	byte rating = 0;                //rnd(100) < rating = jewel
-	byte type = 0;                  //actor (0=thor,1=hammer,2=enemy,3=shot)
-	byte name[9] = {};              //actors name
-	byte func_num = 0;              //special function when thor touches
-	byte func_pass = 0;             //value to pass to func
-	byte future1[6] = {};
-};
-
-struct ACTOR_DATA {                 //5200
-	byte pic[16][256] = {};         //4096
-	byte shot[4][256] = {};         //1024
-	ACTOR_NFO actor_info = {};      //40
-	ACTOR_NFO shot_info = {};       //40
-};
-
-struct PIC_HEADER {
-	byte width = 0;
-	byte height = 0;
-};
-
 struct HEADER {
 	long offset = 0;
 	long length = 0;
@@ -88,11 +49,6 @@ struct HEADER {
 // Defines
 
 #define PAGES 0u
-//#define PAGE0 3840u
-//#define PAGE1 19200u
-//#define PAGE2 34560u
-//#define PAGE3 49920u
-
 #define PAGE0 3840u
 #define PAGE1 19280u
 #define PAGE2 34720u


Commit: 418a35b957982589b13bea8160b0fd804907b096
    https://github.com/scummvm/scummvm/commit/418a35b957982589b13bea8160b0fd804907b096
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Implement loading enemy shot graphics loading

Changed paths:
    engines/got/gfx/image.cpp


diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index 0ad5a99577e..fb04cd3dc9f 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -224,28 +224,32 @@ int load_enemy(int type) {
 	make_actor_surface(&_G(enemy)[e]);
 	_G(enemy_type)[e] = type;
 	_G(enemy)[e].shot_type = 0;
-#ifdef TODO
+
 	if (_G(enemy)[e].shots_allowed) {
 		_G(enemy)[e].shot_type = e + 1;
-		enm = (ACTOR *)(_G(tmp_buff) + 5160);
-		memcpy(&_G(shot)[e], enm, sizeof(ACTOR_NFO));
-
-		for (d = 0; d < _G(shot)[e].directions; d++) {
-			for (f = 0; f < _G(shot)[e].frames; f++) {
-				if (_G(shot)[e].directions < _G(shot)[e].frames)
-					make_mask(&_G(shot)[e].pic[d][f], _G(latch_mem),
-						&_G(tmp_buff)[4096 + (256 * ((d * 4) + f))], 16, 16);
-				else
-					make_mask(&_G(shot)[e].pic[f][d], _G(latch_mem),
-						&_G(tmp_buff)[4096 + (256 * ((f * 4) + d))], 16, 16);
-
-				_G(latch_mem) += 144;
-				if (_G(latch_mem) > 65421u)
-					error("Too Many Actor Frames");
+
+		// Set up shot info
+		_G(shot)[e].loadFixed(_G(tmp_buff) + 5160);
+
+		// Loop to set up graphics
+		for (int d = 0; d < _G(shot)[e].directions; d++) {
+			for (int f = 0; f < _G(shot)[e].frames; f++) {
+				if (_G(shot)[e].directions < _G(shot)[e].frames) {
+					Graphics::ManagedSurface &s = _G(shot)[e].pic[d][f];
+					if (s.empty())
+						s.create(16, 16);
+					const byte *src = (_G(shot)[e].directions < _G(shot)[e].frames) ?
+						&_G(tmp_buff)[4096 + (256 * ((d * 4) + f))] :
+						&_G(tmp_buff)[4096 + (256 * ((f * 4) + d))];
+					Common::copy(src, src + 16 * 16, (byte *)s.getPixels());
+
+					// Use the top-left corner pixel as the transparency color
+					s.setTransparentColor(*src);
+				}
 			}
 		}
 	}
-#endif
+
 	return e;
 }
 


Commit: 542f99ebc191cf2dcbd83061c139f0efa01b52cd
    https://github.com/scummvm/scummvm/commit/542f99ebc191cf2dcbd83061c139f0efa01b52cd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Remove deprecated latch_mem

Changed paths:
    engines/got/gfx/image.cpp
    engines/got/vars.h


diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index fb04cd3dc9f..b7e922d1518 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -87,7 +87,6 @@ void make_actor_surface(ACTOR *actr) {
 }
 
 int load_standard_actors() {
-	_G(latch_mem) = 50160u;
 	_G(mask_buff) = _G(mask_buff_start);
 	_G(ami_buff) = _G(abuff);
 
@@ -151,7 +150,6 @@ int load_standard_actors() {
 
 	_G(enemy_mb) = _G(mask_buff);
 	_G(enemy_ami) = _G(ami_buff);
-	_G(enemy_lm) = _G(latch_mem);
 
 	return 1;
 }
@@ -164,7 +162,6 @@ void show_enemies() {
 	for (i = 0; i < MAX_ENEMIES; i++)
 		_G(enemy_type)[i] = 0;
 
-	_G(latch_mem) = _G(enemy_lm);
 	_G(mask_buff) = _G(enemy_mb);
 	_G(ami_buff) = _G(enemy_ami);
 
diff --git a/engines/got/vars.h b/engines/got/vars.h
index a2fad9c428c..5808769775e 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -212,9 +212,7 @@ public:
 	int _current_level = 23;
 	int _new_level = 0;
 	int _new_level_tile = 0, _current_area = 0;
-	uint _latch_mem = 0;
 	byte *_enemy_mb = nullptr;
-	uint _enemy_lm = 0;
 	byte *_enemy_ami = nullptr;
 	char _sd_header[128] = {};
 	char _play_speed = 0;


Commit: 880601cec12798f2d9dede3a2f6a58eb58ff7693
    https://github.com/scummvm/scummvm/commit/880601cec12798f2d9dede3a2f6a58eb58ff7693
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix underground bats having the wrong transparency

Did a hack to use whichever color is used in multiple corners
of the actor graphic frames

Changed paths:
    engines/got/gfx/image.cpp


diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index b7e922d1518..3f640c973d9 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -28,8 +28,20 @@
 
 namespace Got {
 
-void setup_actor(ACTOR *actr, char num, char dir, int x, int y) {
+// Get the transparency color by seeing which corner pixels are used more.
+// TODO: There's probably a cleaner way to do this, but I really can't
+// understand the original's convoluted creation of masks. By all accounts,
+// xdisplay_actors doesn't seem to do transparency at all
+static byte getTransparentColor(const Graphics::ManagedSurface &src) {
+	assert(src.w == 16 && src.h == 16);
+	byte tl = *(const byte *)src.getBasePtr(0, 0);
+	byte tr = *(const byte *)src.getBasePtr(15, 0);
+	byte br = *(const byte *)src.getBasePtr(15, 15);
+
+	return (tr == br) ? tr : tl;
+}
 
+void setup_actor(ACTOR *actr, char num, char dir, int x, int y) {
 	actr->next = 0;                    // Next frame to be shown
 	actr->frame_count = actr->frame_speed;
 	actr->dir = dir;                   // Direction of travel
@@ -79,9 +91,7 @@ void make_actor_surface(ACTOR *actr) {
 				s.create(16, 16);
 			const byte *src = &_G(tmp_buff)[256 * ((d * 4) + f)];
 			Common::copy(src, src + 16 * 16, (byte *)s.getPixels());
-
-			// Use the top-left corner pixel as the transparency color
-			s.setTransparentColor(*src);
+			s.setTransparentColor(getTransparentColor(s));
 		}
 	}
 }
@@ -239,9 +249,7 @@ int load_enemy(int type) {
 						&_G(tmp_buff)[4096 + (256 * ((d * 4) + f))] :
 						&_G(tmp_buff)[4096 + (256 * ((f * 4) + d))];
 					Common::copy(src, src + 16 * 16, (byte *)s.getPixels());
-
-					// Use the top-left corner pixel as the transparency color
-					s.setTransparentColor(*src);
+					s.setTransparentColor(getTransparentColor(s));
 				}
 			}
 		}


Commit: d0b2e0fb84db7baf220c950d43ab3ae063b86d76
    https://github.com/scummvm/scummvm/commit/d0b2e0fb84db7baf220c950d43ab3ae063b86d76
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Implement phased scene transitions

Changed paths:
    engines/got/game/back.cpp
    engines/got/vars.h
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index 679a7ef590e..fc3e40e0dc2 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -119,9 +119,8 @@ void show_level(int new_level) {
 		_G(transitionDir) = DIR_DOWN;
 		break;
 	default:
-		// TODO: Original had weird as hell random delay calculation.
-		// Not sure that it's really necessary
-		show_level_done();
+		_G(gameMode) = MODE_AREA_CHANGE;
+		_G(transitionDir) = DIR_PHASED;
 		break;
 	}
 }
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 5808769775e..84d71fca9c1 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -61,7 +61,7 @@ enum GameMode {
 };
 
 enum TransitionDir {
-	DIR_LEFT, DIR_RIGHT, DIR_UP, DIR_DOWN
+	DIR_LEFT, DIR_RIGHT, DIR_UP, DIR_DOWN, DIR_PHASED
 };
 
 struct Cheats {
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index e68a0775fd5..bec134e8f92 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -86,6 +86,17 @@ void GameContent::draw() {
 			win.blitFrom(s, Common::Rect(0, 0, 320, _transitionPos),
 				Common::Point(0, 192 - _transitionPos));
 			break;
+		case DIR_PHASED:
+			win.blitFrom(_surface);		// Copy old surface
+
+			// Copy the randomly chosen blocks over from new scene
+			for (int i = 0; i < 240; ++i) {
+				int x = (i * 16) % 320;
+				int y = ((i * 16) / 320) * 16;
+				if (_phased[i])
+					win.blitFrom(s, Common::Rect(x, y, x + 16, y + 16), Common::Point(x, y));
+			}
+			break;
 		default:
 			break;
 		}
@@ -297,6 +308,26 @@ void GameContent::checkForAreaChange() {
 			if (_transitionPos == 192)
 				_G(gameMode) = MODE_NORMAL;
 			break;
+		case DIR_PHASED:
+			_transitionPos += 10;
+			if (_transitionPos == 240) {
+				_G(gameMode) = MODE_NORMAL;
+				Common::fill(_phased, _phased + 240, false);
+			} else {
+				// The screen is subdivided into 240 16x16 blocks. Picks ones
+				// randomly to copy over from the new screen
+				for (int i = 0; i < 10; ++i) {
+					for (;;) {
+						int idx = g_events->getRandomNumber(239);
+						if (!_phased[idx]) {
+							_phased[idx] = true;
+							break;
+						}
+					}
+				}
+			}
+			break;
+
 		default:
 			break;
 		}
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index 3d281fb721a..2627558ae24 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -34,6 +34,7 @@ private:
 	Common::Point _moveDelta;
 	int _transitionPos = 0;
 	int _deathCtr = 0;
+	bool _phased[240] = {};
 
 	void drawBackground(GfxSurface &s);
 	void drawObjects(GfxSurface &s);


Commit: d32b028be47edeb82d275e39ce81e9e5f47c8f8d
    https://github.com/scummvm/scummvm/commit/d32b028be47edeb82d275e39ce81e9e5f47c8f8d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Further fix showing sparkles at correct pos

Changed paths:
    engines/got/views/game_content.cpp


diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index bec134e8f92..eb38cc5f308 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -183,8 +183,8 @@ void GameContent::drawActors(GfxSurface &s) {
 	for (int actor_num = 0; actor_num <= MAX_ACTORS; ) {
 		// Check for blinking flag
 		if (actor_ptr->used && !(actor_ptr->show & 2)) {
-			actor_ptr->last_x[0] = actor_ptr->x;
-			actor_ptr->last_y[0] = actor_ptr->y;
+			actor_ptr->last_x[_G(pge)] = actor_ptr->x;
+			actor_ptr->last_y[_G(pge)] = actor_ptr->y;
 
 			const Graphics::ManagedSurface &frame = actor_ptr->pic[actor_ptr->dir]
 				[actor_ptr->frame_sequence[actor_ptr->next]];


Commit: 1d49e2e091d0c9d600895898fac5b1a396b03977
    https://github.com/scummvm/scummvm/commit/1d49e2e091d0c9d600895898fac5b1a396b03977
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Add Return as an alternate for SELECT action

Changed paths:
    engines/got/metaengine.cpp
    engines/got/views/dialogs/select_item.cpp
    engines/got/views/dialogs/select_item.h
    engines/got/views/dialogs/select_option.cpp
    engines/got/views/dialogs/select_option.h


diff --git a/engines/got/metaengine.cpp b/engines/got/metaengine.cpp
index ee36854087b..11a0e140a13 100644
--- a/engines/got/metaengine.cpp
+++ b/engines/got/metaengine.cpp
@@ -101,6 +101,8 @@ Common::Array<Common::Keymap *> GotMetaEngine::initKeymaps(const char *target) c
 		act->addDefaultInputMapping(r->_key);
 		if (r->_joy)
 			act->addDefaultInputMapping(r->_joy);
+		if (r->_action == Got::KEYBIND_SELECT)
+			act->addDefaultInputMapping("RETURN");
 
 		keyMap->addAction(act);
 	}
diff --git a/engines/got/views/dialogs/select_item.cpp b/engines/got/views/dialogs/select_item.cpp
index 5d7b7f5cbae..071eca98984 100644
--- a/engines/got/views/dialogs/select_item.cpp
+++ b/engines/got/views/dialogs/select_item.cpp
@@ -97,17 +97,6 @@ bool SelectItem::msgFocus(const FocusMessage &msg) {
 	return true;
 }
 
-bool SelectItem::msgKeypress(const KeypressMessage &msg) {
-	if (_G(thor_info).inventory == 0 ||
-			msg.keycode == Common::KEYCODE_SPACE ||
-			msg.keycode == Common::KEYCODE_RETURN) {
-		close();
-		return true;
-	}
-
-	return false;
-}
-
 bool SelectItem::msgAction(const ActionMessage &msg) {
 	int b;
 
diff --git a/engines/got/views/dialogs/select_item.h b/engines/got/views/dialogs/select_item.h
index d3ffaa3d243..4994ec2f8c3 100644
--- a/engines/got/views/dialogs/select_item.h
+++ b/engines/got/views/dialogs/select_item.h
@@ -40,7 +40,6 @@ public:
 
 	void draw() override;
 	bool msgFocus(const FocusMessage &msg) override;
-	bool msgKeypress(const KeypressMessage &msg) override;
 	bool msgAction(const ActionMessage &msg) override;
 };
 
diff --git a/engines/got/views/dialogs/select_option.cpp b/engines/got/views/dialogs/select_option.cpp
index 623af93f776..b8a19c57a7c 100644
--- a/engines/got/views/dialogs/select_option.cpp
+++ b/engines/got/views/dialogs/select_option.cpp
@@ -129,15 +129,6 @@ bool SelectOption::msgAction(const ActionMessage &msg) {
 	return true;
 }
 
-bool SelectOption::msgKeypress(const KeypressMessage &msg) {
-	if (msg.keycode == Common::KEYCODE_RETURN) {
-		_smackCtr = 1;
-		return true;
-	}
-
-	return false;
-}
-
 bool SelectOption::tick() {
 	if (++_hammerFrame == 4)
 		_hammerFrame = 0;
diff --git a/engines/got/views/dialogs/select_option.h b/engines/got/views/dialogs/select_option.h
index 02fa2d06575..0524d0cc7a8 100644
--- a/engines/got/views/dialogs/select_option.h
+++ b/engines/got/views/dialogs/select_option.h
@@ -61,7 +61,6 @@ public:
 		return true;
 	}
 	bool msgAction(const ActionMessage &msg) override;
-	bool msgKeypress(const KeypressMessage &msg) override;
 	void draw() override;
 	bool tick() override;
 };


Commit: f4fa5356776846720226a350a94fc2f8ddec2fa4
    https://github.com/scummvm/scummvm/commit/f4fa5356776846720226a350a94fc2f8ddec2fa4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Be more permissive for loading than for saving

Changed paths:
    engines/got/got.cpp
    engines/got/got.h


diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index aab8a9129b6..9cf424de2e2 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -168,10 +168,18 @@ void GotEngine::savegameLoaded() {
 	setup_load();
 }
 
+bool GotEngine::canLoadGameStateCurrently(Common::U32String *msg) {
+	if (_G(key_flag)[key_magic])
+		return false;
+
+	// Only allow if not in the middle of area transition, dying, etc.
+	return _G(gameMode) == MODE_NORMAL;
+}
+
 bool GotEngine::canSaveGameStateCurrently(Common::U32String *msg) {
 	if (_G(key_flag)[key_magic] || _G(tornado_used) || _G(lightning_used) ||
 			_G(thunder_flag) || _G(hourglass_flag) || _G(thor)->num_moves > 1 ||
-			_G(shield_on))
+			_G(shield_on) || _G(game_over))
 		return false;
 
 	// Only allow if not in the middle of area transition, dying, etc.
diff --git a/engines/got/got.h b/engines/got/got.h
index 3faaa395253..8013cc564e7 100644
--- a/engines/got/got.h
+++ b/engines/got/got.h
@@ -89,10 +89,8 @@ public:
 		    (f == kSupportsReturnToLauncher);
 	};
 
+	bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
 	bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
-	bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override {
-		return canSaveGameStateCurrently();
-	}
 
 	/**
 	 * Uses a serializer to allow implementing savegame


Commit: d82cc58cfc5186f9b9b9bfa4d03ea68fed8de41d
    https://github.com/scummvm/scummvm/commit/d82cc58cfc5186f9b9b9bfa4d03ea68fed8de41d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Callbacks for script ending

Changed paths:
    engines/got/game/back.cpp
    engines/got/game/back.h
    engines/got/game/boss1.cpp
    engines/got/game/boss1.h
    engines/got/game/script.cpp
    engines/got/game/script.h
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index fc3e40e0dc2..d9f8c96e719 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -42,6 +42,8 @@ const char *item_name[] = {
 	"Amulet of Protection","Thunder Power"
 };
 
+static const char *odinEndMessage;
+
 void show_level(int new_level) {
 	int save_d;
 
@@ -147,13 +149,24 @@ void show_level_done() {
 	music_play(_G(level_type), 0);
 }
 
-void odin_speaks(int index, int item) {
-	execute_script((long)index, _G(odin));
-
+static void odin_speaks_end() {
+	// In case Thor is now dead, flag as such
 	if (!_G(thor)->health) {
 		_G(thor)->show = 0;
 		_G(exit_flag) = 2;
 	}
+
+	// If there's an end message, pass it on to the view hierarchy.
+	// This is used in cases like the game end where multiple
+	// odin_speaks are done in sequence
+	if (odinEndMessage)
+		g_events->send(GameMessage(odinEndMessage));
+}
+
+void odin_speaks(int index, int item, const char *endMessage) {
+	odinEndMessage = endMessage;
+
+	execute_script((long)index, _G(odin), odin_speaks_end);
 }
 
 
diff --git a/engines/got/game/back.h b/engines/got/game/back.h
index c23f3ffb046..6072da766a9 100644
--- a/engines/got/game/back.h
+++ b/engines/got/game/back.h
@@ -38,7 +38,7 @@ extern const char *item_name[];
 */
 extern void show_level(int new_level);
 extern void show_level_done();
-extern void odin_speaks(int index, int item);
+extern void odin_speaks(int index, int item, const char *endMessage = nullptr);
 extern int switch_icons();
 extern int rotate_arrows();
 extern void kill_enemies(int iy, int ix);
diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index b46838ec37e..527b437b2e3 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -20,16 +20,18 @@
  */
 
 #include "got/game/boss1.h"
+#include "got/game/back.h"
 #include "got/game/move.h"
 #include "got/game/move_patterns.h"
 #include "got/game/panel.h"
+#include "got/game/status.h"
+#include "got/gfx/image.h"
 #include "got/vars.h"
 #include "got/events.h"
 #include "got/sound.h"
 
 namespace Got {
 
-// boss - snake
 int boss1_movement(ACTOR *actr) {
 	int d, x1, y1, f;
 
@@ -256,25 +258,23 @@ int boss_dead1(void) {
 }
 
 void closing_sequence1() {
-#ifdef TODO
-	LEVEL far *lvl;
-	int rep;
-
 	music_play(4, 1);
-	odin_speaks(1001, 13);
-	thor_info.armor = 1;
+	odin_speaks(1001, 13, "CLOSING1_2");
+}
+
+void closing_sequence1_2() {
+	_G(thor_info).armor = 1;
 	load_new_thor();
 	_G(thor)->dir = 1;
 	_G(thor)->next = 0;
-	xerase_actors(actor, display_page);
-	xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], display_page);
 	fill_score(20);
 	score_for_inv();
 
 	fill_health();
 	fill_magic();
 	odin_speaks(1002, 0);
-
+#ifdef TODO
+	int rep;
 	REPEAT(16) scrn.actor_type[rep] = 0;
 	_G(boss_dead) = 0;
 	_G(setup)._G(boss_dead)[0] = 1;
@@ -292,9 +292,6 @@ void closing_sequence1() {
 	lvl = (LEVEL far *) (sd_data + (59 * 512));
 	lvl->icon[6][18] = 148;
 	lvl->icon[6][19] = 202;
-	exit_flag = 0;
-#else
-	error("closing_sequence1");
 #endif
 }
 
diff --git a/engines/got/game/boss1.h b/engines/got/game/boss1.h
index cb4c0e49b4e..6e622d591ed 100644
--- a/engines/got/game/boss1.h
+++ b/engines/got/game/boss1.h
@@ -26,11 +26,14 @@
 
 namespace Got {
 
+// boss 1 - Snake (Jormangund )
 extern int boss1_movement(ACTOR *actr);
 extern void check_boss1_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num);
 extern void boss_level1();
 extern int boss_dead1();
 extern void closing_sequence1();
+extern void closing_sequence1_2();
+extern void closing_sequence1_3();
 
 } // namespace Got
 
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index eb3fb3cd8e7..5226b70a55b 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -93,8 +93,9 @@ Scripts::ScrFunction Scripts::scr_func[5] = {
 
 Scripts *g_scripts;
 
-void execute_script(long index, const Gfx::Pics &speakerIcon) {
-	g_scripts->execute_script(index, speakerIcon);
+void execute_script(long index, const Gfx::Pics &speakerIcon,
+		ScriptEndFn endFn) {
+	g_scripts->execute_script(index, speakerIcon, endFn);
 }
 
 Scripts::Scripts() {
@@ -105,11 +106,13 @@ Scripts::~Scripts() {
 	g_scripts = nullptr;
 }
 
-void Scripts::execute_script(long index, const Gfx::Pics &speakerIcon) {
+void Scripts::execute_script(long index, const Gfx::Pics &speakerIcon,
+		ScriptEndFn endFn) {
 	// Firstly disable any on-screen actors
 	for (int i = 0; i < MAX_ACTORS; i++)
 		_G(actor)[i].show = 0;
 
+	_endFn = endFn;
 	scr_index = index;
 	scr_pic = speakerIcon;
 
@@ -180,6 +183,9 @@ void Scripts::script_exit() {
 		free(buffer);
 		buffer = nullptr;
 	}
+
+	if (_endFn)
+		_endFn();
 }
 
 int Scripts::skip_colon() {
diff --git a/engines/got/game/script.h b/engines/got/game/script.h
index e3b92a1d95b..6a7d788e4fd 100644
--- a/engines/got/game/script.h
+++ b/engines/got/game/script.h
@@ -27,8 +27,11 @@
 
 namespace Got {
 
+typedef void (*ScriptEndFn)();
+
 class Scripts {
 private:
+	ScriptEndFn _endFn = nullptr;
 	long  num_var[26] = {};        // numeric variables
 	char  str_var[26][81] = {};    // string vars
 	char  line_label[32][9] = {};  // line label look up table
@@ -104,7 +107,8 @@ public:
 	Scripts();
 	~Scripts();
 
-	void execute_script(long index, const Gfx::Pics &speakerIcon);
+	void execute_script(long index, const Gfx::Pics &speakerIcon,
+		ScriptEndFn endFn = nullptr);
 
 	void pause() {
 		_paused = true;
@@ -117,7 +121,8 @@ public:
 	void setAskResponse(int option);
 };
 
-extern void execute_script(long index, const Gfx::Pics &speakerIcon);
+extern void execute_script(long index, const Gfx::Pics &speakerIcon,
+	ScriptEndFn endFn = nullptr);
 
 } // namespace Got
 
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index eb38cc5f308..def6269861d 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -21,6 +21,7 @@
 
 #include "got/views/game_content.h"
 #include "got/game/back.h"
+#include "got/game/boss1.h"
 #include "got/game/move.h"
 #include "got/game/move_patterns.h"
 #include "got/game/object.h"
@@ -122,6 +123,7 @@ bool GameContent::tick() {
 		moveActors();
 		use_item();
 		updateActors();
+		checkForBossDead();
 		checkForCheats();
 		break;
 
@@ -292,6 +294,30 @@ void GameContent::updateActors() {
 	}
 }
 
+void GameContent::checkForBossDead() {
+	int loop;
+
+	if (_G(boss_dead)) {
+		for (loop = 3; loop < 7; loop++) {
+			if (_G(actor)[loop].used)
+				break;
+		}
+
+		if (loop == 7) {
+			_G(boss_dead) = false;
+
+			//xerase_actors(actor, display_page);
+			//xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], display_page);
+			_G(exit_flag) = 0;
+
+			if (_G(boss_active) == 1) {
+				closing_sequence1();
+				_G(boss_active) = 0;
+			}
+		}
+	}
+}
+
 void GameContent::checkForAreaChange() {
 	if (_G(gameMode) == MODE_AREA_CHANGE) {
 		// Area transition is already in progress
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index 2627558ae24..eb2a8deda1d 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -44,6 +44,7 @@ private:
 	void checkForItem();
 	void moveActors();
 	void updateActors();
+	void checkForBossDead();
 	void checkForAreaChange();
 	void areaChanged();
 	void thorDies();


Commit: ff2e9c0a36d34a9009a83dd5b3b232a9734b7cdf
    https://github.com/scummvm/scummvm/commit/ff2e9c0a36d34a9009a83dd5b3b232a9734b7cdf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix add_health when Thor's health runs out

Changed paths:
    engines/got/game/status.cpp


diff --git a/engines/got/game/status.cpp b/engines/got/game/status.cpp
index f7b4694cc23..eb5bfb840d2 100644
--- a/engines/got/game/status.cpp
+++ b/engines/got/game/status.cpp
@@ -41,7 +41,7 @@ void add_health(int num) {
 	_G(thor)->health = CLIP(_G(thor)->health + num, 0, 150);
 
 	if (_G(thor)->health < 1)
-		g_events->replaceView("ThorDies");
+		g_events->send(GameMessage("THOR_DIES"));
 }
 
 void add_keys(int num) {


Commit: 7ef9c60746cec0950351c1d06847f387cdb29a14
    https://github.com/scummvm/scummvm/commit/7ef9c60746cec0950351c1d06847f387cdb29a14
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Tentative implementation of part 1 endgame

Changed paths:
    engines/got/game/boss1.cpp
    engines/got/game/boss1.h
    engines/got/game/status.cpp
    engines/got/game/status.h
    engines/got/vars.h
    engines/got/views/game_content.cpp
    engines/got/views/game_status.cpp
    engines/got/views/game_status.h


diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index 527b437b2e3..51eb07fcc84 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -267,20 +267,25 @@ void closing_sequence1_2() {
 	load_new_thor();
 	_G(thor)->dir = 1;
 	_G(thor)->next = 0;
-	fill_score(20);
+	fill_score(20, "CLOSING1_3");
+}
+
+void closing_sequence1_3() {
 	score_for_inv();
 
 	fill_health();
 	fill_magic();
-	odin_speaks(1002, 0);
-#ifdef TODO
+	odin_speaks(1002, 0, "CLOSING1_4");
+}
+
+void closing_sequence1_4() {
 	int rep;
-	REPEAT(16) scrn.actor_type[rep] = 0;
+	REPEAT(16) _G(scrn).actor_type[rep] = 0;
 	_G(boss_dead) = 0;
-	_G(setup)._G(boss_dead)[0] = 1;
-	game_over = 1;
+	_G(setup).boss_dead[0] = 1;
+	_G(game_over) = 1;
 	_G(boss_active) = 0;
-	scrn.type = 4;
+	_G(scrn).type = 4;
 	show_level(BOSS_LEVEL1);
 
 	play_sound(ANGEL, 1);
@@ -289,10 +294,11 @@ void closing_sequence1_2() {
 	actor_visible(1);
 	actor_visible(2);
 
-	lvl = (LEVEL far *) (sd_data + (59 * 512));
-	lvl->icon[6][18] = 148;
-	lvl->icon[6][19] = 202;
-#endif
+	LEVEL lvl;
+	lvl.load(_G(sd_data) + (59 * 512));
+	lvl.icon[6][18] = 148;
+	lvl.icon[6][19] = 202;
+	lvl.save(_G(sd_data) + (59 * 512));
 }
 
 } // namespace Got
diff --git a/engines/got/game/boss1.h b/engines/got/game/boss1.h
index 6e622d591ed..371a764e3f2 100644
--- a/engines/got/game/boss1.h
+++ b/engines/got/game/boss1.h
@@ -34,6 +34,7 @@ extern int boss_dead1();
 extern void closing_sequence1();
 extern void closing_sequence1_2();
 extern void closing_sequence1_3();
+extern void closing_sequence1_4();
 
 } // namespace Got
 
diff --git a/engines/got/game/status.cpp b/engines/got/game/status.cpp
index eb5bfb840d2..e0cb3a93b1f 100644
--- a/engines/got/game/status.cpp
+++ b/engines/got/game/status.cpp
@@ -56,17 +56,11 @@ void fill_magic() {
 	add_magic(150);
 }
 
-void fill_score(int num) {
-#ifndef TODO
-	error("TODO: fill_score");
-#else
-	while (num) {
-		num--;
-		_G(sound).play_sound(WOOP, 1);
-		add_score(1000);
-		g_events->delay(8);
-	}
-#endif
+void fill_score(int num, const char *endMessage) {
+	GameMessage msg("FILL_SCORE");
+	msg._stringValue = endMessage;
+	msg._value = num;
+	g_events->send(msg);
 }
 
 void score_for_inv() {
@@ -92,6 +86,8 @@ void score_for_inv() {
 		add_score(10);
 		pause(8);
 	}
+#else
+	error("TODO: score_for_inv");
 #endif
 }
 
diff --git a/engines/got/game/status.h b/engines/got/game/status.h
index 66d20b80d09..a07ccd6de0a 100644
--- a/engines/got/game/status.h
+++ b/engines/got/game/status.h
@@ -33,7 +33,7 @@ extern void add_health(int num);
 extern void add_keys(int num);
 extern void fill_health();
 extern void fill_magic();
-extern void fill_score(int num);
+extern void fill_score(int num, const char *endMessage = nullptr);
 extern void score_for_inv();
 
 } // namespace Got
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 84d71fca9c1..243f6b93553 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -56,8 +56,8 @@ enum Key {
 };
 
 enum GameMode {
-	MODE_NORMAL = 0, MODE_AREA_CHANGE = 1, MODE_THUNDER = 2,
-	MODE_THOR_DIES = 3
+	MODE_NORMAL, MODE_AREA_CHANGE, MODE_THUNDER,
+	MODE_THOR_DIES, MODE_ADD_SCORE
 };
 
 enum TransitionDir {
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index def6269861d..8fc0ad6c5c4 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -104,15 +104,22 @@ void GameContent::draw() {
 	}
 }
 
+#define MSG(STR, METHOD) else if (msg._name == STR) { METHOD(); return true; }
+
 bool GameContent::msgGame(const GameMessage &msg) {
 	if (msg._name == "THOR_DIES") {
 		thorDies();
 		return true;
 	}
+	MSG("CLOSING1_2", closing_sequence1_2)
+	MSG("CLOSING1_3", closing_sequence1_3)
+	MSG("CLOSING1_4", closing_sequence1_4)
 
 	return false;
 }
 
+#undef MSG
+
 bool GameContent::tick() {
 	checkThunderShake();
 
diff --git a/engines/got/views/game_status.cpp b/engines/got/views/game_status.cpp
index 1622e86b3ac..71a524e37b4 100644
--- a/engines/got/views/game_status.cpp
+++ b/engines/got/views/game_status.cpp
@@ -20,12 +20,14 @@
  */
 
 #include "got/views/game_status.h"
+#include "got/game/status.h"
 #include "got/vars.h"
 
 namespace Got {
 namespace Views {
 
 #define STAT_COLOR 206
+#define SCORE_INTERVAL 5
 
 void GameStatus::draw() {
 	GfxSurface s = getSurface();
@@ -105,5 +107,33 @@ void GameStatus::displayItem(GfxSurface &s) {
 	}
 }
 
+bool GameStatus::msgGame(const GameMessage &msg) {
+	if (msg._name == "FILL_SCORE") {
+		_G(gameMode) = MODE_ADD_SCORE;
+		_scoreCountdown = msg._value * SCORE_INTERVAL;
+		_endMessage = msg._stringValue;
+		return true;
+	}
+
+	return false;
+}
+
+bool GameStatus::tick() {
+	if (_scoreCountdown > 0) {
+		if ((_scoreCountdown % SCORE_INTERVAL) == 0) {
+			_G(sound).play_sound(WOOP, 1);
+			add_score(1000);
+		}
+
+		if (--_scoreCountdown == 0) {
+			_G(gameMode) = MODE_NORMAL;
+			if (!_endMessage.empty())
+				g_events->send(GameMessage(_endMessage));
+		}
+	}
+
+	return false;
+}
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/game_status.h b/engines/got/views/game_status.h
index ecb8b8c245d..d48c2095c97 100644
--- a/engines/got/views/game_status.h
+++ b/engines/got/views/game_status.h
@@ -29,6 +29,9 @@ namespace Views {
 
 class GameStatus : public View {
 private:
+	int _scoreCountdown = 0;
+	Common::String _endMessage;
+
 	void displayHealth(GfxSurface &s);
 	void displayMagic(GfxSurface &s);
 	void displayJewels(GfxSurface &s);
@@ -41,6 +44,8 @@ public:
 	virtual ~GameStatus() {}
 
 	void draw() override;
+	bool msgGame(const GameMessage &msg) override;
+	bool tick() override;
 };
 
 } // namespace Views


Commit: debfe267f0546d2f8f1f6eaba38be528881e2530
    https://github.com/scummvm/scummvm/commit/debfe267f0546d2f8f1f6eaba38be528881e2530
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Renaming fields of Script class

Changed paths:
    engines/got/game/script.cpp
    engines/got/game/script.h


diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 5226b70a55b..1078d2a881c 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -113,11 +113,11 @@ void Scripts::execute_script(long index, const Gfx::Pics &speakerIcon,
 		_G(actor)[i].show = 0;
 
 	_endFn = endFn;
-	scr_index = index;
-	scr_pic = speakerIcon;
+	_scrIndex = index;
+	_scrPic = speakerIcon;
 
-	Common::fill(num_var, num_var + 26, 0);
-	Common::fill((char *)str_var, (char *)str_var + 81 * 26, 0);
+	Common::fill(_numVar, _numVar + 26, 0);
+	Common::fill((char *)_strVar, (char *)_strVar + 81 * 26, 0);
 	runScript();
 }
 
@@ -125,15 +125,15 @@ void Scripts::runScript(bool firstTime) {
 	int i;
 
 	// Clear line label buffer, line ptrs, and the gosub stack
-	Common::fill((char *)line_label, (char *)line_label + 32 * 9, 0);
-	Common::fill(line_ptr, line_ptr + 32, (char *)nullptr);
-	Common::fill(gosub_stack, gosub_stack + 32, (char *)nullptr);
-	gosub_ptr = 0;
+	Common::fill((char *)_lineLabel, (char *)_lineLabel + 32 * 9, 0);
+	Common::fill(_linePtr, _linePtr + 32, (char *)nullptr);
+	Common::fill(_gosubStack, _gosubStack + 32, (char *)nullptr);
+	_gosubPtr = 0;
 
-	Common::fill(for_var, for_var + 11, 0);
-	Common::fill(for_val, for_val + 11, 0);
-	Common::fill(for_stack, for_stack + 11, (char *)nullptr);
-	for_ptr = 0;
+	Common::fill(_forVar, _forVar + 11, 0);
+	Common::fill(_forVal, _forVal + 11, 0);
+	Common::fill(_forStack, _forStack + 11, (char *)nullptr);
+	_forPtr = 0;
 
 	i = read_script_file();
 	if (i != 0) {
@@ -145,7 +145,7 @@ void Scripts::runScript(bool firstTime) {
 	if (firstTime)
 		script_entry();
 
-	buff_ptr = buffer;
+	_buffPtr = _buffer;
 	scriptLoop();
 }
 
@@ -163,8 +163,8 @@ void Scripts::scriptLoop() {
 		} else if (ret > 0) {
 			ret = exec_command(ret);
 			if (ret == -100) {         // RUN command
-				if (buffer)
-					free(buffer);
+				if (_buffer)
+					free(_buffer);
 
 				runScript(false);
 				return;
@@ -179,9 +179,9 @@ void Scripts::scriptLoop() {
 }
 
 void Scripts::script_exit() {
-	if (buffer) {
-		free(buffer);
-		buffer = nullptr;
+	if (_buffer) {
+		free(_buffer);
+		_buffer = nullptr;
 	}
 
 	if (_endFn)
@@ -189,9 +189,9 @@ void Scripts::script_exit() {
 }
 
 int Scripts::skip_colon() {
-	while (*buff_ptr == 0 || *buff_ptr == ':') {
-		buff_ptr++;
-		if (buff_ptr > buff_end) return 0;
+	while (*_buffPtr == 0 || *_buffPtr == ':') {
+		_buffPtr++;
+		if (_buffPtr > _buffEnd) return 0;
 	}
 
 	return 1;
@@ -208,31 +208,31 @@ int Scripts::get_command() {
 			break;           // Lookup command
 
 		len = strlen(SCR_COMMAND[i]);
-		if (!strncmp(buff_ptr, SCR_COMMAND[i], len)) {
-			buff_ptr += len;
+		if (!strncmp(_buffPtr, SCR_COMMAND[i], len)) {
+			_buffPtr += len;
 			return i;
 		}
 
 		i++;
 	}
 
-	if (Common::isAlpha(*buff_ptr)) {
-		if (*(buff_ptr + 1) == '=') {           // Num var assignment
-			i = (*buff_ptr) - 65;
-			buff_ptr += 2;
+	if (Common::isAlpha(*_buffPtr)) {
+		if (*(_buffPtr + 1) == '=') {           // Num var assignment
+			i = (*_buffPtr) - 65;
+			_buffPtr += 2;
 			ret = calc_value();
 			if (!ret) return -2;
 			else {
-				num_var[i] = lvalue; return 0;
+				_numVar[i] = _lValue; return 0;
 			}
-		} else if (*(buff_ptr + 1) == '$' && *(buff_ptr + 2) == '=') {
-			i = (*buff_ptr) - 65;
-			buff_ptr += 3;
+		} else if (*(_buffPtr + 1) == '$' && *(_buffPtr + 2) == '=') {
+			i = (*_buffPtr) - 65;
+			_buffPtr += 3;
 			ret = calc_string(0);                 // String var assignment
 			if (ret == 0) return -2;
 			else if (ret == -1) return -3;
-			if (strlen(temps) > 80) return -3;
-			Common::strcpy_s(str_var[i], temps);
+			if (strlen(_tempS) > 80) return -3;
+			Common::strcpy_s(_strVar[i], _tempS);
 			return 0;
 		}
 	}
@@ -250,57 +250,57 @@ int Scripts::calc_string(int mode) {
 	if (!skip_colon()) return 0;
 
 strloop:
-	if (*buff_ptr == '"') {
+	if (*_buffPtr == '"') {
 		get_str();
-		if (strlen(varstr) + strlen(temps) < 255)
-			Common::strcat_s(varstr, temps);
+		if (strlen(varstr) + strlen(_tempS) < 255)
+			Common::strcat_s(varstr, _tempS);
 		goto nextstr;
 	}
-	if (Common::isAlpha(*buff_ptr)) {
-		if (*(buff_ptr + 1) == '$') {
-			varnum = (*buff_ptr) - 65;
-			if (strlen(varstr) + strlen(str_var[varnum]) < 255)
-				Common::strcat_s(varstr, str_var[varnum]);
-			buff_ptr += 2;
+	if (Common::isAlpha(*_buffPtr)) {
+		if (*(_buffPtr + 1) == '$') {
+			varnum = (*_buffPtr) - 65;
+			if (strlen(varstr) + strlen(_strVar[varnum]) < 255)
+				Common::strcat_s(varstr, _strVar[varnum]);
+			_buffPtr += 2;
 			goto nextstr;
 		}
 	}
 	return 0;
 
 nextstr:
-	if (*buff_ptr == 0 || *buff_ptr == 58) {
-		buff_ptr++;
+	if (*_buffPtr == 0 || *_buffPtr == 58) {
+		_buffPtr++;
 		goto strdone;
 	}
-	if (*buff_ptr == ',' && mode == 1) goto strdone;
+	if (*_buffPtr == ',' && mode == 1) goto strdone;
 
-	if (*buff_ptr == '+') {
-		buff_ptr++;
+	if (*_buffPtr == '+') {
+		_buffPtr++;
 		goto strloop;
 	}
 	return 0;
 
 strdone:
 	if (strlen(varstr) > 255) return -1;
-	Common::strcpy_s(temps, (char *) varstr);
+	Common::strcpy_s(_tempS, (char *) varstr);
 	return 1;
 }
 
 void Scripts::get_str() {
 	int t;
 
-	buff_ptr++;
+	_buffPtr++;
 	t = 0;
 
 	while (1) {
-		if (*buff_ptr == '"' || *buff_ptr == 0) {
-			temps[t] = 0;
-			if (*buff_ptr == '"') buff_ptr++;
+		if (*_buffPtr == '"' || *_buffPtr == 0) {
+			_tempS[t] = 0;
+			if (*_buffPtr == '"') _buffPtr++;
 			return;
 		}
 
-		temps[t++] = *buff_ptr;
-		buff_ptr++;
+		_tempS[t++] = *_buffPtr;
+		_buffPtr++;
 	}
 }
 
@@ -316,20 +316,20 @@ int Scripts::calc_value() {
 		if (!get_next_val()) return 0;
 		switch (exptype) {
 		case 0:
-			tmpval2 = tmpval2 * ltemp;
+			tmpval2 = tmpval2 * _lTemp;
 			break;
 		case 1:
-			tmpval2 = tmpval2 + ltemp;
+			tmpval2 = tmpval2 + _lTemp;
 			break;
 		case 2:
-			tmpval2 = tmpval2 - ltemp;
+			tmpval2 = tmpval2 - _lTemp;
 			break;
 		case 3:
-			if (ltemp != 0) tmpval2 = tmpval2 / ltemp;
+			if (_lTemp != 0) tmpval2 = tmpval2 / _lTemp;
 			break;
 		}
 
-		ch = *buff_ptr;
+		ch = *_buffPtr;
 		switch (ch) {
 		case 42:
 			exptype = 0;                       /* multiply */
@@ -344,11 +344,11 @@ int Scripts::calc_value() {
 			exptype = 3;                       /* divide */
 			break;
 		default:
-			lvalue = tmpval2;
+			_lValue = tmpval2;
 			return 1;
 		}
 
-		buff_ptr++;
+		_buffPtr++;
 	}
 }
 
@@ -357,13 +357,13 @@ int Scripts::get_next_val() {
 	char tmpstr[25];
 	int t;
 
-	ch = *buff_ptr;
+	ch = *_buffPtr;
 	if (ch == 0 || ch == ':') return 0;
 	if (ch == 64) return get_internal_variable();
 
 	if (Common::isAlpha(ch)) {
-		buff_ptr++;
-		ltemp = num_var[ch - 65];
+		_buffPtr++;
+		_lTemp = _numVar[ch - 65];
 		return 1;
 	}
 
@@ -371,15 +371,15 @@ int Scripts::get_next_val() {
 	if (strchr("0123456789-", ch)) {
 		tmpstr[0] = ch;
 		t++;
-		buff_ptr++;
-		while (strchr("0123456789", *buff_ptr) && *buff_ptr != 0) {
-			tmpstr[t] = *buff_ptr;
-			buff_ptr++;
+		_buffPtr++;
+		while (strchr("0123456789", *_buffPtr) && *_buffPtr != 0) {
+			tmpstr[t] = *_buffPtr;
+			_buffPtr++;
 			t++;
 		}
 		tmpstr[t] = 0;
 		if (t > 10) return 0;
-		ltemp = atol(tmpstr);
+		_lTemp = atol(tmpstr);
 		return 1;
 	}
 
@@ -395,30 +395,30 @@ int Scripts::get_internal_variable() {
 	while (1) {
 		if (!INTERNAL_VARIABLE[i]) return 0;         // Lookup internal variable
 		len = strlen(INTERNAL_VARIABLE[i]);
-		if (!strncmp(buff_ptr, INTERNAL_VARIABLE[i], len)) {
-			buff_ptr += len;
+		if (!strncmp(_buffPtr, INTERNAL_VARIABLE[i], len)) {
+			_buffPtr += len;
 			break;
 		}
 		i++;
 	}
 	switch (i) {
 	case 0:
-		ltemp = _G(thor_info).jewels;
+		_lTemp = _G(thor_info).jewels;
 		break;
 	case 1:
-		ltemp = _G(thor)->health;
+		_lTemp = _G(thor)->health;
 		break;
 	case 2:
-		ltemp = _G(thor_info).magic;
+		_lTemp = _G(thor_info).magic;
 		break;
 	case 3:
-		ltemp = _G(thor_info).score;
+		_lTemp = _G(thor_info).score;
 		break;
 	case 4:
-		ltemp = _G(current_level);
+		_lTemp = _G(current_level);
 		break;
 	case 5:
-		ltemp = _G(thor_info).keys;
+		_lTemp = _G(thor_info).keys;
 		break;
 	case 6:
 	case 7:
@@ -436,12 +436,12 @@ int Scripts::get_internal_variable() {
 	case 19:
 	case 20:
 	case 21:
-		ltemp = (long)(i - 5l);
+		_lTemp = (long)(i - 5l);
 		break;
 	case 22:
 		if (!calc_value())
 			return 0;
-		i = (int)lvalue;
+		i = (int)_lValue;
 		if (i < 1 || i>64)
 			return 0;
 
@@ -450,19 +450,19 @@ int Scripts::get_internal_variable() {
 		b = 1;
 		b = b << (i % 8);
 		if (*sp & b)
-			ltemp = 1;
+			_lTemp = 1;
 		else
-			ltemp = 0;
+			_lTemp = 0;
 		break;
 	case 23:
-		if (_G(thor_info).inventory & 64) ltemp = _G(thor_info).object;
-		else ltemp = 0;
+		if (_G(thor_info).inventory & 64) _lTemp = _G(thor_info).object;
+		else _lTemp = 0;
 		break;
 	case 24:
-		ltemp = _G(scrn).icon[(_G(thor)->y + 8) / 16][(_G(thor)->x + 7) / 16];
+		_lTemp = _G(scrn).icon[(_G(thor)->y + 8) / 16][(_G(thor)->x + 7) / 16];
 		break;
 	case 25:
-		ltemp = (((_G(thor)->y + 8) / 16) * 20) + ((_G(thor)->x + 7) / 16);
+		_lTemp = (((_G(thor)->y + 8) / 16) * 20) + ((_G(thor)->x + 7) / 16);
 		break;
 	default:
 		return 0;
@@ -501,12 +501,12 @@ int Scripts::read_script_file() {
 	Common::String str;
 	char tmps[255];
 
-	buffer = (char *)malloc(SCR_BUFF_SIZE);
-	if (!buffer) {
+	_buffer = (char *)malloc(SCR_BUFF_SIZE);
+	if (!_buffer) {
 		ret = 1; goto done;
 	};
-	buff_ptr = buffer;
-	Common::fill(buffer, buffer + SCR_BUFF_SIZE, 0);
+	_buffPtr = _buffer;
+	Common::fill(_buffer, _buffer + SCR_BUFF_SIZE, 0);
 
 	sbuff = (char *)malloc(25000l);
 	if (!sbuff) {
@@ -519,7 +519,7 @@ int Scripts::read_script_file() {
 		ret = 6; goto done;
 	}
 
-	str = Common::String::format("|%ld", scr_index);
+	str = Common::String::format("|%ld", _scrIndex);
 	Common::strcpy_s(temp_buff, str.c_str());
 
 	while (1) {
@@ -530,12 +530,12 @@ int Scripts::read_script_file() {
 		}
 		if (!strcmp(tmps, temp_buff)) break;
 	}
-	num_labels = 0;
+	_numLabels = 0;
 	while (1) {
 		cnt = get_line(sb, (char *)tmps);
 		if (!strcmp(tmps, "|STOP")) {
-			if (buff_ptr != buffer) {
-				buff_end = buff_ptr; ret = 0; goto done;
+			if (_buffPtr != _buffer) {
+				_buffEnd = _buffPtr; ret = 0; goto done;
 			}
 			ret = 2;
 			goto done;
@@ -543,8 +543,8 @@ int Scripts::read_script_file() {
 		sb += cnt;
 		len = strlen(tmps);
 		if (len < 2) {
-			*buff_ptr = 0;
-			buff_ptr++;
+			*_buffPtr = 0;
+			_buffPtr++;
 			continue;
 		}
 		quote_flag = 0;
@@ -569,20 +569,20 @@ int Scripts::read_script_file() {
 		len = strlen(temp_buff);
 		if (len < 10 && temp_buff[len - 1] == ':') {       //line label
 			temp_buff[len - 1] = 0;
-			line_ptr[num_labels] = buff_ptr;
-			Common::strcpy_s(line_label[num_labels++], (char *) temp_buff);
-			if (num_labels > 31) {
+			_linePtr[_numLabels] = _buffPtr;
+			Common::strcpy_s(_lineLabel[_numLabels++], (char *) temp_buff);
+			if (_numLabels > 31) {
 				ret = 3; goto done;
 			}
-			*buff_ptr = 0;
-			buff_ptr++;
+			*_buffPtr = 0;
+			_buffPtr++;
 			continue;
 		}
 
-		Common::strcpy_s(buff_ptr, SCR_BUFF_SIZE, temp_buff);
-		buff_ptr += strlen(temp_buff);
-		*buff_ptr = 0;
-		buff_ptr++;
+		Common::strcpy_s(_buffPtr, SCR_BUFF_SIZE, temp_buff);
+		_buffPtr += strlen(temp_buff);
+		*_buffPtr = 0;
+		_buffPtr++;
 	}
 
 done:
@@ -597,11 +597,11 @@ void Scripts::script_error(int err_num) {
 	char *tb;
 
 	line_num = 1;
-	tb = buffer;
+	tb = _buffer;
 
 	while (1) {
 		if (*tb == 0) line_num++;
-		if (tb >= buff_ptr) break;
+		if (tb >= _buffPtr) break;
 		tb++;
 	}
 
@@ -616,16 +616,16 @@ int Scripts::cmd_goto() {
 	char s[255];
 	char *p;
 
-	Common::strcpy_s(s, buff_ptr);
+	Common::strcpy_s(s, _buffPtr);
 	p = strchr(s, ':');
 	if (p) *p = 0;
 
-	for (i = 0; i < num_labels; i++) {
+	for (i = 0; i < _numLabels; i++) {
 		len = strlen(s);
 		if (len == 0) break;
-		if (!strcmp(s, line_label[i])) {
-			new_ptr = line_ptr[i];
-			buff_ptr += len;
+		if (!strcmp(s, _lineLabel[i])) {
+			_newPtr = _linePtr[i];
+			_buffPtr += len;
 			return 0;
 		}
 	}
@@ -637,19 +637,19 @@ int Scripts::cmd_if() {
 	char exptype, ch;
 
 	if (!calc_value()) return 5;
-	tmpval1 = lvalue;
-	exptype = *buff_ptr;
-	buff_ptr++;
+	tmpval1 = _lValue;
+	exptype = *_buffPtr;
+	_buffPtr++;
 
-	ch = *buff_ptr;
+	ch = *_buffPtr;
 	if (ch == 60 || ch == 61 || ch == 62) {
-		if (exptype == *buff_ptr) return 5;
-		exptype += *buff_ptr;
-		buff_ptr++;
+		if (exptype == *_buffPtr) return 5;
+		exptype += *_buffPtr;
+		_buffPtr++;
 	}
 	if (!calc_value()) return 5;
-	tmpval2 = lvalue;
-	buff_ptr += 4;
+	tmpval2 = _lValue;
+	_buffPtr += 4;
 	switch (exptype) {
 	case 60:                              /* less than */
 		if (tmpval1 < tmpval2) goto iftrue;
@@ -674,10 +674,10 @@ int Scripts::cmd_if() {
 	}
 
 iffalse:
-	while (*buff_ptr != 0) buff_ptr++;
-	while (*buff_ptr == 0) buff_ptr++;
+	while (*_buffPtr != 0) _buffPtr++;
+	while (*_buffPtr == 0) _buffPtr++;
 
-	if (!strncmp(buff_ptr, "ELSE", 4)) buff_ptr += 4;
+	if (!strncmp(_buffPtr, "ELSE", 4)) _buffPtr += 4;
 
 iftrue:
 	return 0;
@@ -685,8 +685,8 @@ iftrue:
 
 int Scripts::cmd_run() {
 	if (!calc_value()) return 5;
-	buff_ptr++;
-	scr_index = lvalue;
+	_buffPtr++;
+	_scrIndex = _lValue;
 	return -100;
 }
 
@@ -694,39 +694,39 @@ int Scripts::cmd_addjewels() {
 	if (!calc_value())
 		return 5;
 
-	buff_ptr++;
+	_buffPtr++;
 
-	add_jewels(lvalue);
+	add_jewels(_lValue);
 	return 0;
 }
 
 int Scripts::cmd_addhealth() {
 	if (!calc_value()) return 5;
-	buff_ptr++;
-	add_health((int)lvalue);
+	_buffPtr++;
+	add_health((int)_lValue);
 	return 0;
 }
 
 int Scripts::cmd_addmagic() {
 	if (!calc_value()) return 5;
-	buff_ptr++;
-	add_magic((int)lvalue);
+	_buffPtr++;
+	add_magic((int)_lValue);
 	return 0;
 }
 
 int Scripts::cmd_addkeys() {
 
 	if (!calc_value()) return 5;
-	buff_ptr++;
-	add_keys((int)lvalue);
+	_buffPtr++;
+	add_keys((int)_lValue);
 	return 0;
 }
 
 int Scripts::cmd_addscore() {
 
 	if (!calc_value()) return 5;
-	buff_ptr++;
-	add_score((int)lvalue);
+	_buffPtr++;
+	add_score((int)_lValue);
 	return 0;
 }
 
@@ -736,8 +736,8 @@ int Scripts::cmd_say(int mode, int type) {
 
 	if (mode) {
 		if (!calc_value()) return 5;
-		buff_ptr++;
-		obj = (int)lvalue;
+		_buffPtr++;
+		obj = (int)_lValue;
 		if (obj < 0 || obj>32) return 6;
 		if (obj) obj += 10;
 	} else obj = 0;
@@ -746,15 +746,15 @@ int Scripts::cmd_say(int mode, int type) {
 	p = (char *)_G(tmp_buff);
 
 	while (calc_string(0)) {
-		Common::strcpy_s(p, TMP_SIZE, temps);
-		p += strlen(temps);
+		Common::strcpy_s(p, TMP_SIZE, _tempS);
+		p += strlen(_tempS);
 		*(p) = 10;
 		p++;
 	}
 	*(p - 1) = 0;
 
 	pause();
-	Views::Dialogs::Say::show(obj, scr_pic, type);
+	Views::Dialogs::Say::show(obj, _scrPic, type);
 
 	return 0;
 }
@@ -770,11 +770,11 @@ int Scripts::cmd_ask() {
 	if (!skip_colon())
 		return 5;
 
-	if (Common::isAlpha(*buff_ptr)) {
-		v = *buff_ptr - 65;
-		buff_ptr++;
-		if (*buff_ptr != ',') return 5;
-		buff_ptr++;
+	if (Common::isAlpha(*_buffPtr)) {
+		v = *_buffPtr - 65;
+		_buffPtr++;
+		if (*_buffPtr != ',') return 5;
+		_buffPtr++;
 	} else {
 		return 5;
 	}
@@ -782,16 +782,16 @@ int Scripts::cmd_ask() {
 	if (!calc_string(1))
 		return 5;
 
-	strncpy(title, temps, 41);
+	strncpy(title, _tempS, 41);
 	title[40] = 0;
 
-	if (*buff_ptr == ',') {
-		buff_ptr++;
+	if (*_buffPtr == ',') {
+		_buffPtr++;
 		if (!calc_value())
 			return 5;
 
-		buff_ptr++;
-		p = lvalue;
+		_buffPtr++;
+		p = _lValue;
 	} else {
 		return 5;
 	}
@@ -799,7 +799,7 @@ int Scripts::cmd_ask() {
 	_askVar = v;
 
 	while (calc_string(0)) {
-		Common::strcpy_s(opt, temps);
+		Common::strcpy_s(opt, _tempS);
 		opts.push_back(opt);
 
 		if (opts.size() > 9)
@@ -817,15 +817,15 @@ int Scripts::cmd_ask() {
 }
 
 void Scripts::setAskResponse(int option) {
-	num_var[_askVar] = option;
+	_numVar[_askVar] = option;
 	resume();
 }
 
 int Scripts::cmd_sound() {
 	if (!calc_value()) return 5;
-	buff_ptr++;
-	if (lvalue < 1 || lvalue>16) return 6;
-	play_sound((int)lvalue - 1, 1);
+	_buffPtr++;
+	if (_lValue < 1 || _lValue>16) return 6;
+	play_sound((int)_lValue - 1, 1);
 	return 0;
 }
 
@@ -833,13 +833,13 @@ int Scripts::cmd_settile() {
 	int screen, pos, tile;
 
 	if (!calc_value()) return 5;
-	buff_ptr++;
-	screen = (int)lvalue;
+	_buffPtr++;
+	screen = (int)_lValue;
 	if (!calc_value()) return 5;
-	buff_ptr++;
-	pos = (int)lvalue;
+	_buffPtr++;
+	pos = (int)_lValue;
 	if (!calc_value()) return 5;
-	tile = (int)lvalue;
+	tile = (int)_lValue;
 	if (screen < 0 || screen>119) return 6;
 	if (pos < 0 || pos>239) return 6;
 	if (tile < 0 || tile>230) return 6;
@@ -860,7 +860,7 @@ int Scripts::cmd_itemgive() {
 
 	if (!calc_value()) return 5;
 	buff_ptr++;
-	i = (int)lvalue;
+	i = (int)_lValue;
 	if (i < 1 || i > 15) return 6;
 
 	_G(thor_info).inventory |= 64;
@@ -886,7 +886,7 @@ int Scripts::cmd_setflag() {
 
 	if (!calc_value())
 		return 5;
-	i = (int)lvalue;
+	i = (int)_lValue;
 	if (i < 1 || i>64)
 		return 6;
 
@@ -902,56 +902,56 @@ int Scripts::cmd_ltoa() {
 	int sv;
 
 	if (!calc_value()) return 5;
-	buff_ptr++;
+	_buffPtr++;
 
-	if (Common::isAlpha(*buff_ptr)) {
-		if (*(buff_ptr + 1) == '$') {
-			sv = (*buff_ptr) - 65;
-			buff_ptr += 2;
+	if (Common::isAlpha(*_buffPtr)) {
+		if (*(_buffPtr + 1) == '$') {
+			sv = (*_buffPtr) - 65;
+			_buffPtr += 2;
 		} else return 5;
 	} else return 5;
 
-	Common::String str = Common::String::format("%ld", lvalue);
-	Common::strcpy_s(str_var[sv], str.c_str());
+	Common::String str = Common::String::format("%ld", _lValue);
+	Common::strcpy_s(_strVar[sv], str.c_str());
 	return 0;
 }
 
 int Scripts::cmd_pause() {
 	if (!calc_value())
 		return 5;
-	buff_ptr++;
-	if (lvalue < 1 || lvalue>65535l)
+	_buffPtr++;
+	if (_lValue < 1 || _lValue>65535l)
 		return 6;
 
-	Got::pause((int)lvalue);
+	Got::pause((int)_lValue);
 	return 0;
 }
 
 int Scripts::cmd_visible() {
 	if (!calc_value()) return 5;
-	buff_ptr++;
-	if (lvalue < 1 || lvalue>16) return 6;
+	_buffPtr++;
+	if (_lValue < 1 || _lValue>16) return 6;
 
-	actor_visible((int)lvalue);
+	actor_visible((int)_lValue);
 	return 0;
 }
 
 int Scripts::cmd_random() {
 	int v, r;
 
-	if (Common::isAlpha(*buff_ptr)) {
-		v = *buff_ptr - 65;
-		buff_ptr++;
-		if (*buff_ptr != ',') return 5;
-		buff_ptr++;
+	if (Common::isAlpha(*_buffPtr)) {
+		v = *_buffPtr - 65;
+		_buffPtr++;
+		if (*_buffPtr != ',') return 5;
+		_buffPtr++;
 	} else return 5;
 
 	if (!calc_value()) return 5;
-	buff_ptr++;
-	r = (int)lvalue;
+	_buffPtr++;
+	r = (int)_lValue;
 	if (r < 1 || r>1000) return 6;
 
-	num_var[v] = g_events->getRandomNumber(r - 1);
+	_numVar[v] = g_events->getRandomNumber(r - 1);
 	return 0;
 }
 
@@ -974,8 +974,8 @@ void Scripts::scr_func2() {
 	int r;
 
 	r = g_events->getRandomNumber(5);
-	Common::strcpy_s(str_var[0], 81, OFFENSE[r]);
-	Common::strcpy_s(str_var[1], 81, REASON[r]);
+	Common::strcpy_s(_strVar[0], 81, OFFENSE[r]);
+	Common::strcpy_s(_strVar[1], 81, REASON[r]);
 }
 
 void Scripts::scr_func3() {
@@ -999,7 +999,7 @@ void Scripts::scr_func3() {
 #endif
 		return;
 	}
-	num_var[0] = 1;
+	_numVar[0] = 1;
 	play_sound(WOOP, 1);
 	if (_G(current_level) == 106 && p == 69) {
 		place_tile(x, y, 220);
@@ -1049,11 +1049,11 @@ void Scripts::scr_func5() {
 
 int Scripts::cmd_exec() {
 	if (!calc_value()) return 5;
-	buff_ptr++;
-	if (lvalue < 1 || lvalue>10)
+	_buffPtr++;
+	if (_lValue < 1 || _lValue>10)
 		return 6;
 
-	(this->*scr_func[lvalue - 1])();
+	(this->*scr_func[_lValue - 1])();
 	return 0;
 }
 
@@ -1067,62 +1067,62 @@ int Scripts::exec_command(int num) {
 		return 0;
 	case 2:                          // goto
 		ret = cmd_goto();
-		if (!ret) buff_ptr = new_ptr;
+		if (!ret) _buffPtr = _newPtr;
 		break;
 	case 3:                          // gosub
 		ret = cmd_goto();
 		if (!ret) {
-			gosub_ptr++;
-			if (gosub_ptr > 31) {
+			_gosubPtr++;
+			if (_gosubPtr > 31) {
 				ret = 10; break;
 			}
-			gosub_stack[gosub_ptr] = buff_ptr;
-			buff_ptr = new_ptr;
+			_gosubStack[_gosubPtr] = _buffPtr;
+			_buffPtr = _newPtr;
 		}
 		break;
 	case 4:                         //return
-		if (!gosub_ptr) {
+		if (!_gosubPtr) {
 			ret = 9; break;
 		}
-		buff_ptr = gosub_stack[gosub_ptr--];
+		_buffPtr = _gosubStack[_gosubPtr--];
 		break;
 	case 5:                         //for
-		for_ptr++;
-		if (for_ptr > 10) {
+		_forPtr++;
+		if (_forPtr > 10) {
 			ret = 10; break;
 		}
-		ch = *buff_ptr;
+		ch = *_buffPtr;
 		if (!Common::isAlpha(ch)) {
 			ret = 5; break;
 		}
 		ch -= 65;
-		for_var[for_ptr] = ch;
-		buff_ptr += 2;
+		_forVar[_forPtr] = ch;
+		_buffPtr += 2;
 		if (!calc_value()) {
 			ret = 5; break;
 		}
-		num_var[for_var[for_ptr]] = lvalue;
-		buff_ptr += 2;
+		_numVar[_forVar[_forPtr]] = _lValue;
+		_buffPtr += 2;
 		if (!calc_value()) {
 			ret = 5; break;
 		}
-		for_val[for_ptr] = lvalue;
-		for_stack[for_ptr] = buff_ptr;
+		_forVal[_forPtr] = _lValue;
+		_forStack[_forPtr] = _buffPtr;
 		break;
 	case 6:                         //next
-		if (!for_ptr) {
+		if (!_forPtr) {
 			ret = 11; break;
 		}
-		num_var[for_var[for_ptr]] = num_var[for_var[for_ptr]] + 1;
-		if (num_var[for_var[for_ptr]] <= for_val[for_ptr])
-			buff_ptr = for_stack[for_ptr];
-		else for_ptr--;
+		_numVar[_forVar[_forPtr]] = _numVar[_forVar[_forPtr]] + 1;
+		if (_numVar[_forVar[_forPtr]] <= _forVal[_forPtr])
+			_buffPtr = _forStack[_forPtr];
+		else _forPtr--;
 		break;
 	case 7:                         // if
 		ret = cmd_if();
 		break;
 	case 8:                         // else
-		while (*buff_ptr != 0) buff_ptr++;
+		while (*_buffPtr != 0) _buffPtr++;
 		break;
 	case 9:                         // run
 		ret = cmd_run();
diff --git a/engines/got/game/script.h b/engines/got/game/script.h
index 6a7d788e4fd..513342a5f2d 100644
--- a/engines/got/game/script.h
+++ b/engines/got/game/script.h
@@ -32,26 +32,26 @@ typedef void (*ScriptEndFn)();
 class Scripts {
 private:
 	ScriptEndFn _endFn = nullptr;
-	long  num_var[26] = {};        // numeric variables
-	char  str_var[26][81] = {};    // string vars
-	char  line_label[32][9] = {};  // line label look up table
-	char  *line_ptr[32] = {};      // line label pointers
-	char  *new_ptr = nullptr;
-	int   num_labels = 0;          // number of labels
-	char  *gosub_stack[32] = {};   // stack for GOSUB return addresses
-	int   gosub_ptr = 0;           // GOSUB stack pointer
-	char  *for_stack[10] = {};     // FOR stack
-	long  for_val[10] = {};        // current FOR value
-	int8  for_var[10] = {};        // ending FOR value (target var)
-	int8  for_ptr = 0;	           // FOR stack pointer
-	char  *buff_ptr = nullptr;     // pointer to current command
-	char  *buff_end = nullptr;	   // pointer to end of buffer
-	char  *buffer = nullptr;       // buffer space (alloc'ed)
-	long  scr_index = 0;
-	Gfx::Pics scr_pic;
-	long  lvalue = 0;
-	long  ltemp = 0;
-	char  temps[255] = {};
+	long  _numVar[26] = {};        // numeric variables
+	char  _strVar[26][81] = {};    // string vars
+	char  _lineLabel[32][9] = {};  // line label look up table
+	char  *_linePtr[32] = {};      // line label pointers
+	char  *_newPtr = nullptr;
+	int   _numLabels = 0;          // number of labels
+	char  *_gosubStack[32] = {};   // stack for GOSUB return addresses
+	int   _gosubPtr = 0;           // GOSUB stack pointer
+	char  *_forStack[10] = {};     // FOR stack
+	long  _forVal[10] = {};        // current FOR value
+	int8  _forVar[10] = {};        // ending FOR value (target var)
+	int8  _forPtr = 0;	           // FOR stack pointer
+	char  *_buffPtr = nullptr;     // pointer to current command
+	char  *_buffEnd = nullptr;	   // pointer to end of buffer
+	char  *_buffer = nullptr;      // buffer space (alloc'ed)
+	long  _scrIndex = 0;
+	Gfx::Pics _scrPic;
+	long  _lValue = 0;
+	long  _lTemp = 0;
+	char  _tempS[255] = {};
 	bool _paused = false;
 	int _askVar = -1;
 


Commit: 6ac49971789202921129ac1479d84a7fdabf63ec
    https://github.com/scummvm/scummvm/commit/6ac49971789202921129ac1479d84a7fdabf63ec
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added level console command

Changed paths:
    engines/got/console.cpp
    engines/got/console.h


diff --git a/engines/got/console.cpp b/engines/got/console.cpp
index 48623fc9941..c8f962ef25e 100644
--- a/engines/got/console.cpp
+++ b/engines/got/console.cpp
@@ -40,6 +40,7 @@ Console::Console() : GUI::Debugger() {
 	registerCmd("save", WRAP_METHOD(Console, cmdSave));
 	registerCmd("magic", WRAP_METHOD(Console, cmdMagic));
 	registerCmd("freeze", WRAP_METHOD(Console, cmdFreeze));
+	registerCmd("level", WRAP_METHOD(Console, cmdLevel));
 }
 
 Console::~Console() {
@@ -131,4 +132,15 @@ bool Console::cmdFreeze(int argc, const char **argv) {
 	return true;
 }
 
+bool Console::cmdLevel(int argc, const char **argv) {
+	if (argc != 2) {
+		debugPrintf("level <num>\n");
+		return true;
+	} else {
+		_G(new_level) = atoi(argv[1]);
+		_G(warp_flag) = true;
+		return false;
+	}
+}
+
 } // namespace Got
diff --git a/engines/got/console.h b/engines/got/console.h
index 0ccd0d14d72..55499464026 100644
--- a/engines/got/console.h
+++ b/engines/got/console.h
@@ -36,6 +36,7 @@ private:
 	bool cmdSave(int argc, const char **argv);
 	bool cmdMagic(int argc, const char **argv);
 	bool cmdFreeze(int argc, const char **argv);
+	bool cmdLevel(int argc, const char **argv);
 
 public:
 	Console();


Commit: a7e9e78cbc92db24a731efaaf4bfed8500d24625
    https://github.com/scummvm/scummvm/commit/a7e9e78cbc92db24a731efaaf4bfed8500d24625
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Startup/save fixes for demo mode

Changed paths:
    engines/got/POTFILES
    engines/got/events.cpp
    engines/got/events.h
    engines/got/game/move.cpp
    engines/got/got.cpp


diff --git a/engines/got/POTFILES b/engines/got/POTFILES
index f7765bbd556..24f5ac05162 100644
--- a/engines/got/POTFILES
+++ b/engines/got/POTFILES
@@ -1 +1,2 @@
 engines/got/metaengine.cpp
+engines/got/got.cpp
diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index bbf1d71f0c2..c120c8ebe9e 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -67,7 +67,7 @@ void Events::runGame() {
 			saveSlot = -1;
 	}
 	if (saveSlot == -1)
-		addView("SplashScreen");
+		addView(isDemo() ? "Game" : "SplashScreen");
 
 	// Main game loop
 	Common::Event e;
diff --git a/engines/got/events.h b/engines/got/events.h
index 9f9a16dc6aa..1d55cf05e2d 100644
--- a/engines/got/events.h
+++ b/engines/got/events.h
@@ -305,6 +305,8 @@ public:
 	Events();
 	virtual ~Events();
 
+	virtual bool isDemo() const = 0;
+
 	/**
 	 * Main game loop
 	 */
@@ -354,6 +356,14 @@ public:
 			_views[_views.size() - 2];
 	}
 
+	/**
+	 * Returns the first view in the stack
+	 */
+	UIElement *firstView() const {
+		assert(!_views.empty());
+		return _views[0];
+	}
+
 	/**
 	 * Returns true if a view of a given name is present
 	 * at all in the visible view stack
diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index 53f3c9ff7f3..37599a93499 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -25,6 +25,7 @@
 #include "got/game/shot_movement.h"
 #include "got/game/shot_pattern.h"
 #include "got/game/status.h"
+#include "got/events.h"
 #include "got/vars.h"
 
 namespace Got {
@@ -143,14 +144,13 @@ void thor_damaged(ACTOR *actr) {
 			_G(thor)->vunerable = 40;
 			_G(thor)->show = 0;
 			_G(thor)->health = 0;
-			//display_health();
 			_G(exit_flag) = 2;
+			g_events->send(GameMessage("THOR_DIES"));
 		} else if (damage) {
 			_G(thor)->vunerable = 40;
 			_G(sound).play_sound(OW, 0);
 			_G(thor)->show = 10;
 			_G(thor)->health -= damage;
-			//display_health();
 		}
 	}
 }
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 9cf424de2e2..3ba6ff25f32 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -24,6 +24,7 @@
 #include "common/debug-channels.h"
 #include "common/events.h"
 #include "common/system.h"
+#include "common/translation.h"
 #include "engines/util.h"
 #include "graphics/paletteman.h"
 #include "got/got.h"
@@ -169,6 +170,11 @@ void GotEngine::savegameLoaded() {
 }
 
 bool GotEngine::canLoadGameStateCurrently(Common::U32String *msg) {
+	if (_G(demo)) {
+		*msg = _("Savegames are not available in demo mode");
+		return false;
+	}
+
 	if (_G(key_flag)[key_magic])
 		return false;
 
@@ -177,6 +183,15 @@ bool GotEngine::canLoadGameStateCurrently(Common::U32String *msg) {
 }
 
 bool GotEngine::canSaveGameStateCurrently(Common::U32String *msg) {
+	if (_G(demo)) {
+		*msg = _("Savegames are not available in demo mode");
+		return false;
+	}
+
+	// Don't allowing saving when not in-game
+	if (firstView()->getName() != "Game")
+		return false;
+
 	if (_G(key_flag)[key_magic] || _G(tornado_used) || _G(lightning_used) ||
 			_G(thunder_flag) || _G(hourglass_flag) || _G(thor)->num_moves > 1 ||
 			_G(shield_on) || _G(game_over))


Commit: 1454c1bba50da4e00f84830182f263934819e852
    https://github.com/scummvm/scummvm/commit/1454c1bba50da4e00f84830182f263934819e852
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Startup cleanups for going in-game demo vs non-demo

Changed paths:
    engines/got/events.cpp
    engines/got/game/init.cpp
    engines/got/game/init.h
    engines/got/got.cpp
    engines/got/vars.cpp
    engines/got/vars.h
    engines/got/views/dialogs/main_menu.cpp
    engines/got/views/dialogs/save_game.cpp
    engines/got/views/dialogs/select_game.cpp


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index c120c8ebe9e..c5a0f6a8543 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -77,7 +77,7 @@ void Events::runGame() {
 					e.type == Common::EVENT_RETURN_TO_LAUNCHER) {
 				_views.clear();
 				break;
-			} else {
+			} else if (!_G(demo)) {
 				processEvent(e);
 			}
 		}
diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index cd1a51bcf18..7b8d972a1a7 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -32,14 +32,7 @@
 
 namespace Got {
 
-int setup_level() {
-	_G(bgPics).setArea(_G(area));
-	_G(sd_data).setArea(_G(area));
-
-	return 1;
-}
-
-int setup_player() {
+void setup_player() {
 	memset(&_G(thor_info), 0, sizeof(_G(thor_info)));
 	_G(thor_info).inventory = 0;
 	if (_G(area) > 1) _G(thor_info).inventory |= APPLE_MAGIC + LIGHTNING_MAGIC;
@@ -62,28 +55,14 @@ int setup_player() {
 	_G(thor_info).last_icon = (6 * 20) + 8;
 	_G(thor_info).last_screen = 23;
 	_G(thor)->dir = 1;
-
-	return 1;
 }
 
-void initialize() {
+void initialize_game() {
 	load_standard_actors();
-	if (!setup_player())
-		error("setup_player failed");
-	if (!setup_level())
-		error("setup_level failed");
-
-	// Handle loading demo key
-	if (_G(rdemo)) {
-		Common::File f;
-		if (f.open("demo.got"))
-			f.read(_G(demo_key), DEMO_LEN);
-	}
-
-	if (_G(record))
-		Common::fill(_G(demo_key), _G(demo_key) + DEMO_LEN, 0);
+	setup_player();
 
-	if (_G(demo) || _G(record)) {
+	if (_G(demo)) {
+		g_vars->setArea(1);
 		_G(thor)->health = 100;
 		_G(thor_info).magic = 100;
 		_G(thor_info).jewels = 463;
@@ -92,6 +71,12 @@ void initialize() {
 		_G(thor_info).inventory = 1 + 2;
 		_G(current_level) = 54;
 		_G(thor_info).item = 2;
+
+		File f("DEMO");
+		_G(demoKeys).clear();
+		for (int i = 0; i < DEMO_LEN; ++i)
+			_G(demoKeys).push(f.readByte());
+
 	}
 
 	_G(thor)->speed_count = 6;
@@ -130,8 +115,9 @@ void initialize() {
 	_G(auto_load) = 0;
 
 	_G(startup) = false;
-	if (_G(record))
-		memset(_G(demo_key), 0, DEMO_LEN);
+}
+
+void deinitialize_game() {
 }
 
 int setup_boss(int num) {
diff --git a/engines/got/game/init.h b/engines/got/game/init.h
index 3ce3867a818..0c4c583e122 100644
--- a/engines/got/game/init.h
+++ b/engines/got/game/init.h
@@ -29,7 +29,8 @@ namespace Got {
 /**
  * Handles in-game initialization the first time
  */
-extern void initialize();
+extern void initialize_game();
+extern void deinitialize_game();
 extern int setup_boss(int num);
 
 } // namespace Got
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 3ba6ff25f32..ec1840dec70 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -76,7 +76,8 @@ Common::Error GotEngine::run() {
 	_vars.load();
 
 	// General initialization
-	initialize();
+	if (_G(demo))
+		initialize_game();
 	syncSoundSettings();
 
 	runGame();
@@ -128,6 +129,8 @@ void GotEngine::savegameLoaded() {
 		area = 1;
 
 	g_vars->setArea(area);
+	if (firstView()->getName() != "Game")
+		initialize_game();
 
 	_G(current_area) = _G(thor_info).last_screen;
 
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 21c27417635..60b2ce53e8c 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -57,20 +57,6 @@ void Vars::load() {
 		_rdemo = ConfMan.getBool("rdemo");
 	}
 
-	if (_demo || _record) {
-		if (_record)
-			_demo = 0;
-
-		_area = 1;
-		_setup.area = 1;
-		_cash1_inform = 1;
-		_cash2_inform = 1;
-		_door_inform = 1;
-		_magic_inform = 1;
-		_carry_inform = 1;
-		_story_flag = 0;
-	}
-
 	if (_current_level != 23)
 		_story_flag = 0;
 
@@ -88,7 +74,6 @@ void Vars::load() {
 	_mask_buff_start = _mask_buff;
  
 	res_read("RANDOM", _rnd_array);
-	res_read("DEMO", _demo_key);
 
 	Gfx::load_palette();
 }
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 243f6b93553..c543f0ca09d 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -23,6 +23,7 @@
 #define GOT_VARS_H
 
 #include "common/events.h"
+#include "common/queue.h"
 #include "graphics/screen.h"
 #include "got/data/defines.h"
 #include "got/data/sd_data.h"
@@ -92,6 +93,7 @@ public:
 	GameMode _gameMode = MODE_NORMAL;
 	TransitionDir _transitionDir = DIR_LEFT;
 	Cheats _cheats;
+	Common::Queue<byte> _demoKeys;
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
 	uint _display_page = 0, _draw_page = 0;
@@ -192,9 +194,7 @@ public:
 	int  _boss_active = 0;
 	int8 _story_flag = 1;
 	int8 *_scr = nullptr;
-	char _demo_key[DEMO_LEN] = {};
-	int  _demo_cnt = 0;
-	bool _demo = false, _record = false;
+	bool _demo = false;
 	int8 _demo_enable = 1;
 	int  _rnd_index = 0;
 	int  _rnd_array[100] = {};
diff --git a/engines/got/views/dialogs/main_menu.cpp b/engines/got/views/dialogs/main_menu.cpp
index 0f6e4d500c6..a9cb73ebdf4 100644
--- a/engines/got/views/dialogs/main_menu.cpp
+++ b/engines/got/views/dialogs/main_menu.cpp
@@ -20,6 +20,8 @@
  */
 
 #include "got/views/dialogs/main_menu.h"
+#include "got/game/init.h"
+#include "got/vars.h"
 
 namespace Got {
 namespace Views {
@@ -40,9 +42,16 @@ void MainMenu::closed() {
 void MainMenu::selected() {
 	switch (_selectedItem) {
 	case 0:
+		_G(demo) = false;
 		addView("SelectGame");
 		break;
 
+	case 3:
+		_G(demo) = true;
+		initialize_game();
+		replaceView("Game", true, true);
+		break;
+
 	case 4:
 		addView("Quit");
 		break;
diff --git a/engines/got/views/dialogs/save_game.cpp b/engines/got/views/dialogs/save_game.cpp
index 3e717a457c8..a3234cf9ed9 100644
--- a/engines/got/views/dialogs/save_game.cpp
+++ b/engines/got/views/dialogs/save_game.cpp
@@ -46,7 +46,7 @@ void SaveGame::selected() {
 	if (_isQuit)
 		g_engine->quitGame();
 	else
-		replaceView("Title", true, true);
+		replaceView("TitleBackground", true, true);
 }
 
 } // namespace Dialogs
diff --git a/engines/got/views/dialogs/select_game.cpp b/engines/got/views/dialogs/select_game.cpp
index 8c9614e8172..a1e63a54e8c 100644
--- a/engines/got/views/dialogs/select_game.cpp
+++ b/engines/got/views/dialogs/select_game.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "got/views/dialogs/select_game.h"
+#include "got/game/init.h"
 #include "got/got.h"
 
 namespace Got {
@@ -41,6 +42,7 @@ void SelectGame::selected() {
 	g_vars->setArea(_selectedItem + 1);
 
 	// Switch to the story view for the selected game area
+	initialize_game();
 	replaceView("Story", true, true);
 }
 


Commit: 7ee9ffb1b97ac4bf7b83dc407d580b19ebbc27a9
    https://github.com/scummvm/scummvm/commit/7ee9ffb1b97ac4bf7b83dc407d580b19ebbc27a9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: In progress demo mode automatic key injection

Changed paths:
    engines/got/events.cpp
    engines/got/events.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index c5a0f6a8543..aebbe885e6c 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -115,6 +115,16 @@ void Events::nextFrame() {
 	_G(pge) = _G(pge) ^ 1;
 	_G(shot_ok) = true;
 
+	// In demo mode, handle the next key
+	if (_G(demo) && _G(gameMode) == MODE_NORMAL) {
+		if (_G(demoKeys).empty()) {
+			_views.clear();
+			return;
+		} else {
+			processDemoEvent(_G(demoKeys).pop());
+		}
+	}
+
 	// Do tick action to the views to handle gameplay logic
 	tick();
 
@@ -200,6 +210,45 @@ void Events::processEvent(Common::Event &ev) {
 	}
 }
 
+void Events::processDemoEvent(byte ev) {
+	bool flag = ev & 0x80;
+	ev &= 0x7f;
+
+	int action = -1;
+	switch (ev) {
+	case 0:
+		return;
+	case 72:
+		ev = key_up;
+		action = KEYBIND_UP;
+		break;
+	case 80:
+		ev = key_down;
+		break;
+	case 75:
+		ev = key_left;
+		break;
+	case 77:
+		ev = key_right;
+		break;
+	case 56:
+		ev = key_fire;
+		action = KEYBIND_FIRE;
+		break;
+	case 29:
+		ev = key_magic;
+		action = KEYBIND_MAGIC;
+		break;
+	default:
+		break;
+	}
+
+	_G(key_flag)[ev] = flag;
+
+	if (flag && action != -1)
+		msgAction(ActionMessage(action));
+}
+
 int Events::actionToKeyFlag(int action) const {
 	return (action == KEYBIND_ESCAPE) ? Common::KEYCODE_ESCAPE :
 		(int)action;
diff --git a/engines/got/events.h b/engines/got/events.h
index 1d55cf05e2d..48cf1b48566 100644
--- a/engines/got/events.h
+++ b/engines/got/events.h
@@ -273,12 +273,17 @@ private:
 	int actionToKeyFlag(int action) const;
 	void rotatePalette();
 
-protected:
 	/**
 	 * Process an event
 	 */
 	void processEvent(Common::Event &ev);
 
+	/**
+	 * Process a demo event
+	 */
+	void processDemoEvent(byte ev);
+
+protected:
 	/**
 	 * Returns true if the game should quit
 	 */


Commit: a72628e20c5fb706e2585be0c5e46c5d157b7dac
    https://github.com/scummvm/scummvm/commit/a72628e20c5fb706e2585be0c5e46c5d157b7dac
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix loading savegames directly from launcher

Changed paths:
    engines/got/events.h
    engines/got/got.cpp


diff --git a/engines/got/events.h b/engines/got/events.h
index 48cf1b48566..67aad22f3db 100644
--- a/engines/got/events.h
+++ b/engines/got/events.h
@@ -365,8 +365,7 @@ public:
 	 * Returns the first view in the stack
 	 */
 	UIElement *firstView() const {
-		assert(!_views.empty());
-		return _views[0];
+		return _views.empty() ? nullptr : _views[0];
 	}
 
 	/**
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index ec1840dec70..2add43e5568 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -114,6 +114,12 @@ Common::Error GotEngine::syncGame(Common::Serializer &s) {
 		_G(playerName) = title;
 
 	_G(setup).sync(s);
+
+	// For savegames loaded directly from the ScummVM launcher,
+	// take care of initializing game defaults before rest of loading
+	if (s.isLoading() && (!firstView() || firstView()->getName() != "Game"))
+		initialize_game();
+
 	_G(thor_info).sync(s);
 	_G(sd_data).sync(s);
 
@@ -129,8 +135,6 @@ void GotEngine::savegameLoaded() {
 		area = 1;
 
 	g_vars->setArea(area);
-	if (firstView()->getName() != "Game")
-		initialize_game();
 
 	_G(current_area) = _G(thor_info).last_screen;
 
@@ -192,7 +196,7 @@ bool GotEngine::canSaveGameStateCurrently(Common::U32String *msg) {
 	}
 
 	// Don't allowing saving when not in-game
-	if (firstView()->getName() != "Game")
+	if (!firstView() || firstView()->getName() != "Game")
 		return false;
 
 	if (_G(key_flag)[key_magic] || _G(tornado_used) || _G(lightning_used) ||


Commit: cfd46d6a74926766fa744c0b83b228fbab5913a5
    https://github.com/scummvm/scummvm/commit/cfd46d6a74926766fa744c0b83b228fbab5913a5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix crash getting enchanted apple

Changed paths:
    engines/got/game/status.cpp


diff --git a/engines/got/game/status.cpp b/engines/got/game/status.cpp
index e0cb3a93b1f..64d49517f5d 100644
--- a/engines/got/game/status.cpp
+++ b/engines/got/game/status.cpp
@@ -58,9 +58,10 @@ void fill_magic() {
 
 void fill_score(int num, const char *endMessage) {
 	GameMessage msg("FILL_SCORE");
-	msg._stringValue = endMessage;
+	if (endMessage)
+		msg._stringValue = endMessage;
 	msg._value = num;
-	g_events->send(msg);
+	g_events->send("GameStatus", msg);
 }
 
 void score_for_inv() {


Commit: d5e3254e6ecb4b1b5ad2d499b8e7c245016d71ac
    https://github.com/scummvm/scummvm/commit/d5e3254e6ecb4b1b5ad2d499b8e7c245016d71ac
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Magic keybinding fixes

Changed paths:
    engines/got/metaengine.cpp
    engines/got/vars.h
    engines/got/views/game.cpp


diff --git a/engines/got/metaengine.cpp b/engines/got/metaengine.cpp
index 11a0e140a13..00377fc68c1 100644
--- a/engines/got/metaengine.cpp
+++ b/engines/got/metaengine.cpp
@@ -57,7 +57,7 @@ static const KeybindingRecord GAME_KEYS[] = {
 	{ KEYBIND_DOWN, "DOWN", _s("Down"), "DOWN", "JOY_DOWN"},
 	{ KEYBIND_LEFT, "LEFT", _s("Left"), "LEFT", "JOY_LEFT"},
 	{ KEYBIND_RIGHT, "RIGHT", _s("Right"), "RIGHT", "JOY_RIGHT"},
-	{ KEYBIND_FIRE, "FIRE", _s("Magic"), "LALT", "JOY_A" },
+	{ KEYBIND_FIRE, "FIRE", _s("Fire"), "LALT", "JOY_A" },
 	{ KEYBIND_MAGIC, "MAGIC", _s("Magic"), "LCTRL", "JOY_B" },
 	{ KEYBIND_SELECT, "SELECT", _s("Select"), "SPACE", "JOY_X" },
 	// I18N: ESC key
@@ -103,6 +103,8 @@ Common::Array<Common::Keymap *> GotMetaEngine::initKeymaps(const char *target) c
 			act->addDefaultInputMapping(r->_joy);
 		if (r->_action == Got::KEYBIND_SELECT)
 			act->addDefaultInputMapping("RETURN");
+		if (r->_action == Got::KEYBIND_MAGIC)
+			act->allowKbdRepeats();
 
 		keyMap->addAction(act);
 	}
diff --git a/engines/got/vars.h b/engines/got/vars.h
index c543f0ca09d..0317d3e1492 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -52,7 +52,7 @@ enum Key {
 	key_left = KEYBIND_LEFT,
 	key_right = KEYBIND_RIGHT,
 	key_fire = KEYBIND_FIRE, 
-	key_magic = KEYBIND_ESCAPE,
+	key_magic = KEYBIND_MAGIC,
 	key_select = KEYBIND_SELECT
 };
 
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index d6b80776293..6d123fc5464 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -23,6 +23,7 @@
 #include "got/game/back.h"
 #include "got/game/init.h"
 #include "got/game/move.h"
+#include "got/game/object.h"
 #include "got/metaengine.h"
 #include "got/vars.h"
 


Commit: 15ee6c071dbc1f29d3fec9c179d8fe616cadb6ec
    https://github.com/scummvm/scummvm/commit/15ee6c071dbc1f29d3fec9c179d8fe616cadb6ec
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Cleanup of magic using apple

Changed paths:
    engines/got/events.cpp
    engines/got/game/object.cpp
    engines/got/metaengine.cpp
    engines/got/vars.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index aebbe885e6c..d01623ecc01 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -114,6 +114,7 @@ void Events::nextFrame() {
 	_G(rand2) = getRandomNumber(99);
 	_G(pge) = _G(pge) ^ 1;
 	_G(shot_ok) = true;
+	_G(magic_cnt)++;
 
 	// In demo mode, handle the next key
 	if (_G(demo) && _G(gameMode) == MODE_NORMAL) {
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index 47707360cf0..ce15c8335a6 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -227,13 +227,16 @@ int use_apple(int flag) {
 			_G(magic_cnt) = 0;
 			add_magic(-2);
 			add_health(1);
-			if (!sound_playing()) play_sound(ANGEL, 0);
+			if (!sound_playing())
+				play_sound(ANGEL, 0);
 		}
 		_G(apple_flag) = 1;
 		return 1;
+
 	} else {
 		_G(apple_flag) = 0;
-		if (flag) not_enough_magic();
+		if (flag)
+			not_enough_magic();
 	}
 	return 0;
 }
@@ -410,7 +413,6 @@ int use_object(int flag) {
 }
 
 void use_item() {
-	static int flag = 0;
 	int kf, ret = 0, mf;
 
 	kf = _G(key_flag)[key_magic];
@@ -446,11 +448,14 @@ void use_item() {
 
 	}
 	if (kf) {
-		if ((!ret) && (!flag)) {
-			if (mf) play_sound(BRAAPP, 0);
-			flag = 1;
+		if ((!ret) && (!_G(useItemFlag))) {
+			if (mf)
+				play_sound(BRAAPP, 0);
+			_G(useItemFlag) = true;
 		}
-	} else flag = 0;
+	} else {
+		_G(useItemFlag) = false;
+	}
 }
 
 void place_pixel(int dir, int num) {
@@ -579,8 +584,9 @@ void throw_lightning() {
 }
 
 void not_enough_magic() {
-	if (!_G(magic_inform)) odin_speaks(2006, 0);
-	//xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], draw_page);
+	if (!_G(magic_inform))
+		odin_speaks(2006, 0);
+
 	_G(magic_inform) = 1;
 }
 
diff --git a/engines/got/metaengine.cpp b/engines/got/metaengine.cpp
index 00377fc68c1..bbbe3d2efd9 100644
--- a/engines/got/metaengine.cpp
+++ b/engines/got/metaengine.cpp
@@ -103,8 +103,6 @@ Common::Array<Common::Keymap *> GotMetaEngine::initKeymaps(const char *target) c
 			act->addDefaultInputMapping(r->_joy);
 		if (r->_action == Got::KEYBIND_SELECT)
 			act->addDefaultInputMapping("RETURN");
-		if (r->_action == Got::KEYBIND_MAGIC)
-			act->allowKbdRepeats();
 
 		keyMap->addAction(act);
 	}
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 0317d3e1492..97f74fa3ee0 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -94,6 +94,7 @@ public:
 	TransitionDir _transitionDir = DIR_LEFT;
 	Cheats _cheats;
 	Common::Queue<byte> _demoKeys;
+	bool _useItemFlag = false;
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
 	uint _display_page = 0, _draw_page = 0;


Commit: a0f7887884d8ea240b23ddeeece7d031ea1fe3fb
    https://github.com/scummvm/scummvm/commit/a0f7887884d8ea240b23ddeeece7d031ea1fe3fb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Workaround for Ctrl+F5 triggering indefinite magic

The Left Control key is mapped by default to use magic
so long as it's held down. Unfortunately, Ctrl+F5 is
also the key for the GMM. I was having issues with,
for example, opening the GMM and loading a savegame
where the end action for magic wouldn't fire, and it
would keep draining magic away. Now, I use the
pauseEngineIntern to explicitly disable all key flags
when the GMM is opened, ensuring magic is turned off.

Changed paths:
    engines/got/got.cpp
    engines/got/got.h
    engines/got/vars.cpp
    engines/got/vars.h


diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 2add43e5568..32f68b8bbdb 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -182,9 +182,6 @@ bool GotEngine::canLoadGameStateCurrently(Common::U32String *msg) {
 		return false;
 	}
 
-	if (_G(key_flag)[key_magic])
-		return false;
-
 	// Only allow if not in the middle of area transition, dying, etc.
 	return _G(gameMode) == MODE_NORMAL;
 }
@@ -199,7 +196,7 @@ bool GotEngine::canSaveGameStateCurrently(Common::U32String *msg) {
 	if (!firstView() || firstView()->getName() != "Game")
 		return false;
 
-	if (_G(key_flag)[key_magic] || _G(tornado_used) || _G(lightning_used) ||
+	if (_G(tornado_used) || _G(lightning_used) ||
 			_G(thunder_flag) || _G(hourglass_flag) || _G(thor)->num_moves > 1 ||
 			_G(shield_on) || _G(game_over))
 		return false;
@@ -219,4 +216,9 @@ void GotEngine::syncSoundSettings() {
 		ConfMan.getBool("music_mute") || allSoundIsMuted);
 }
 
+void GotEngine::pauseEngineIntern(bool pause) {
+	g_vars->clearKeyFlags();
+	Engine::pauseEngineIntern(pause);
+}
+
 } // End of namespace Got
diff --git a/engines/got/got.h b/engines/got/got.h
index 8013cc564e7..b2bad0defd8 100644
--- a/engines/got/got.h
+++ b/engines/got/got.h
@@ -102,6 +102,7 @@ public:
 	Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
 
 	void syncSoundSettings() override;
+	void pauseEngineIntern(bool pause) override;
 };
 
 extern GotEngine *g_engine;
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 60b2ce53e8c..24fd1da4ebc 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -110,4 +110,8 @@ void Vars::setArea(int areaNum) {
 	}
 }
 
+void Vars::clearKeyFlags() {
+	Common::fill(_key_flag, _key_flag + 100, 0);
+}
+
 } // namespace Got
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 97f74fa3ee0..7934c3ede7e 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -78,6 +78,7 @@ public:
 
 	void load();
 	void setArea(int areaNum);
+	void clearKeyFlags();
 
 	Common::String _playerName = "ScummVM";
 	Gfx::GfxChunks _gfx;


Commit: ae0ecc47b4975ebb12af8fd2c6adfdcd5015d329
    https://github.com/scummvm/scummvm/commit/ae0ecc47b4975ebb12af8fd2c6adfdcd5015d329
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix Say dialog handling ~ at very start of page

Changed paths:
    engines/got/views/dialogs/say.cpp


diff --git a/engines/got/views/dialogs/say.cpp b/engines/got/views/dialogs/say.cpp
index 965a8b586dd..a205c403c1b 100644
--- a/engines/got/views/dialogs/say.cpp
+++ b/engines/got/views/dialogs/say.cpp
@@ -151,7 +151,7 @@ bool Say::tick() {
 		_contentCtr = 0;
 		const char *contentEnd = _content + ++_contentLength;
 
-		if (*contentEnd == '~' && Common::isXDigit(*(contentEnd + 1)))
+		if (*(contentEnd - 1) == '~' && Common::isXDigit(*contentEnd))
 			++_contentLength;
 
 		if (!*contentEnd) {


Commit: b00c03bd5202b091a111a89886874918dcb1fd06
    https://github.com/scummvm/scummvm/commit/b00c03bd5202b091a111a89886874918dcb1fd06
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Better implementation of sprite transparency

I finally figured out that the original code had both
colors 0 and 15 as transparent for some reason. Now
sprite loading automatically converts 15 pixels to 0,
and sets 0 as the transparent color, allowing for
them to be properly rendered.

Changed paths:
    engines/got/gfx/image.cpp


diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index 3f640c973d9..c1e7d13f405 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -28,17 +28,16 @@
 
 namespace Got {
 
-// Get the transparency color by seeing which corner pixels are used more.
-// TODO: There's probably a cleaner way to do this, but I really can't
-// understand the original's convoluted creation of masks. By all accounts,
-// xdisplay_actors doesn't seem to do transparency at all
-static byte getTransparentColor(const Graphics::ManagedSurface &src) {
-	assert(src.w == 16 && src.h == 16);
-	byte tl = *(const byte *)src.getBasePtr(0, 0);
-	byte tr = *(const byte *)src.getBasePtr(15, 0);
-	byte br = *(const byte *)src.getBasePtr(15, 15);
-
-	return (tr == br) ? tr : tl;
+static void createSurface(Graphics::ManagedSurface &s, const byte *src) {
+	s.create(16, 16);
+
+	// Both 0 and 15 are transparent colors, so as we load the
+	// surface, standard on a single color
+	byte *dest = (byte *)s.getPixels();
+	for (int i = 0; i < 16 * 16; ++i, ++src, ++dest)
+		*dest = (*src == 15) ? 0 : *src;
+
+	s.setTransparentColor(0);
 }
 
 void setup_actor(ACTOR *actr, char num, char dir, int x, int y) {
@@ -87,11 +86,8 @@ void make_actor_surface(ACTOR *actr) {
 	for (d = 0; d < actr->directions; d++) {
 		for (f = 0; f < actr->frames; f++) {
 			Graphics::ManagedSurface &s = actr->pic[d][f];
-			if (s.empty())
-				s.create(16, 16);
 			const byte *src = &_G(tmp_buff)[256 * ((d * 4) + f)];
-			Common::copy(src, src + 16 * 16, (byte *)s.getPixels());
-			s.setTransparentColor(getTransparentColor(s));
+			createSurface(s, src);
 		}
 	}
 }
@@ -243,13 +239,10 @@ int load_enemy(int type) {
 			for (int f = 0; f < _G(shot)[e].frames; f++) {
 				if (_G(shot)[e].directions < _G(shot)[e].frames) {
 					Graphics::ManagedSurface &s = _G(shot)[e].pic[d][f];
-					if (s.empty())
-						s.create(16, 16);
 					const byte *src = (_G(shot)[e].directions < _G(shot)[e].frames) ?
 						&_G(tmp_buff)[4096 + (256 * ((d * 4) + f))] :
 						&_G(tmp_buff)[4096 + (256 * ((f * 4) + d))];
-					Common::copy(src, src + 16 * 16, (byte *)s.getPixels());
-					s.setTransparentColor(getTransparentColor(s));
+					createSurface(s, src);
 				}
 			}
 		}


Commit: 0270df43b75935f43edd7a74e9e543d8c272776f
    https://github.com/scummvm/scummvm/commit/0270df43b75935f43edd7a74e9e543d8c272776f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Only resume running scripts after ask/say fully closed

Previously in a case where a Say display was followed by
an Ask dialog, the script was resumed as the Say dialog
was closing, which caused a wobbly as the Ask dialog tried
to open. Now, the Say dialog is allowed to fully close,
and the main event loop detects if the script is pending
to resume, and only run it then.

Changed paths:
    engines/got/events.cpp
    engines/got/game/script.h


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index d01623ecc01..3f809eee260 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -126,6 +126,9 @@ void Events::nextFrame() {
 		}
 	}
 
+	// Check if any script needs resuming
+	_G(scripts).runIfResuming();
+
 	// Do tick action to the views to handle gameplay logic
 	tick();
 
diff --git a/engines/got/game/script.h b/engines/got/game/script.h
index 513342a5f2d..49ea96f7dde 100644
--- a/engines/got/game/script.h
+++ b/engines/got/game/script.h
@@ -29,6 +29,10 @@ namespace Got {
 
 typedef void (*ScriptEndFn)();
 
+enum ScriptPause {
+	SCRIPT_READY, SCRIPT_PAUSED, SCRIPT_RESUMING
+};
+
 class Scripts {
 private:
 	ScriptEndFn _endFn = nullptr;
@@ -52,7 +56,7 @@ private:
 	long  _lValue = 0;
 	long  _lTemp = 0;
 	char  _tempS[255] = {};
-	bool _paused = false;
+	ScriptPause _paused = SCRIPT_READY;
 	int _askVar = -1;
 
 private:
@@ -111,14 +115,19 @@ public:
 		ScriptEndFn endFn = nullptr);
 
 	void pause() {
-		_paused = true;
+		_paused = SCRIPT_PAUSED;
 	}
 	void resume() {
-		_paused = false;
-		scriptLoop();
+		_paused = SCRIPT_RESUMING;
 	}
 
 	void setAskResponse(int option);
+	void runIfResuming() {
+		if (_paused == SCRIPT_RESUMING) {
+			_paused = SCRIPT_READY;
+			scriptLoop();
+		}
+	}
 };
 
 extern void execute_script(long index, const Gfx::Pics &speakerIcon,


Commit: e39e3e9e12460d071796a497fc8384c90ee40fdb
    https://github.com/scummvm/scummvm/commit/e39e3e9e12460d071796a497fc8384c90ee40fdb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix object_name field for loaded savegames

Changed paths:
    engines/got/data/thor_info.cpp
    engines/got/game/back.cpp
    engines/got/game/back.h
    engines/got/game/object.cpp


diff --git a/engines/got/data/thor_info.cpp b/engines/got/data/thor_info.cpp
index d0ce3ff10f4..de41bdeeb2c 100644
--- a/engines/got/data/thor_info.cpp
+++ b/engines/got/data/thor_info.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "got/data/thor_info.h"
+#include "got/game/back.h"
 
 namespace Got {
 
@@ -52,6 +53,11 @@ void THOR_INFO::sync(Common::Serializer &s) {
 
 	s.syncAsByte(armor);
 	s.syncBytes(future, 65);
+
+	if (s.isLoading()) {
+		object_name = (object == 0) ? nullptr : OBJECT_NAMES[object - 1];
+		last_object_name = (last_object == 0) ? nullptr : OBJECT_NAMES[last_object - 1];
+	}
 }
 
 } // namespace Got
diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index d9f8c96e719..31e6b3adda4 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -30,13 +30,13 @@
 
 namespace Got {
 
-const char *object_names[] = {
+const char *OBJECT_NAMES[] = {
 	"Shrub","Child's Doll","UNUSED","FUTURE",
 	"FUTURE","FUTURE","FUTURE","FUTURE","FUTURE",
 	"FUTURE","FUTURE","FUTURE","FUTURE","FUTURE",
 	"FUTURE"
 };
-const char *item_name[] = {
+const char *ITEM_NAMES[] = {
 	"Enchanted Apple","Lightning Power",
 	"Winged Boots","Wind Power",
 	"Amulet of Protection","Thunder Power"
diff --git a/engines/got/game/back.h b/engines/got/game/back.h
index 6072da766a9..38e74ad0879 100644
--- a/engines/got/game/back.h
+++ b/engines/got/game/back.h
@@ -26,8 +26,8 @@
 
 namespace Got {
 
-extern const char *object_names[];
-extern const char *item_name[];
+extern const char *OBJECT_NAMES[];
+extern const char *ITEM_NAMES[];
 
 
 /**
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index ce15c8335a6..29e6d8330b8 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -123,7 +123,7 @@ void pick_up_object(int p) {
 		_G(thor_info).item = 7;
 		_G(thor_info).object = _G(object_map)[p] - 11;
 		display_item();
-		_G(thor_info).object_name = object_names[_G(thor_info).object - 1];
+		_G(thor_info).object_name = OBJECT_NAMES[_G(thor_info).object - 1];
 		odin_speaks((_G(object_map)[p] - 12) + 501, _G(object_map)[p] - 1);
 		break;
 	case 27:


Commit: fd13b2175f43218a472513ec6c23d57a831bcae1
    https://github.com/scummvm/scummvm/commit/fd13b2175f43218a472513ec6c23d57a831bcae1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix loading of enemy projectile graphics

Changed paths:
    engines/got/gfx/image.cpp


diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index c1e7d13f405..cc05f6c1f37 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -239,9 +239,11 @@ int load_enemy(int type) {
 			for (int f = 0; f < _G(shot)[e].frames; f++) {
 				if (_G(shot)[e].directions < _G(shot)[e].frames) {
 					Graphics::ManagedSurface &s = _G(shot)[e].pic[d][f];
-					const byte *src = (_G(shot)[e].directions < _G(shot)[e].frames) ?
-						&_G(tmp_buff)[4096 + (256 * ((d * 4) + f))] :
-						&_G(tmp_buff)[4096 + (256 * ((f * 4) + d))];
+					const byte *src = &_G(tmp_buff)[4096 + (256 * ((d * 4) + f))];
+					createSurface(s, src);
+				} else {
+					Graphics::ManagedSurface &s = _G(shot)[e].pic[f][d];
+					const byte *src = &_G(tmp_buff)[4096 + (256 * ((f * 4) + d))];
 					createSurface(s, src);
 				}
 			}


Commit: c2a2b834fe8d11aba175eafa11fc3c7c22efd5ae
    https://github.com/scummvm/scummvm/commit/c2a2b834fe8d11aba175eafa11fc3c7c22efd5ae
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix console freezing magic

Changed paths:
    engines/got/console.cpp


diff --git a/engines/got/console.cpp b/engines/got/console.cpp
index c8f962ef25e..46918f26a3c 100644
--- a/engines/got/console.cpp
+++ b/engines/got/console.cpp
@@ -119,7 +119,8 @@ bool Console::cmdFreeze(int argc, const char **argv) {
 		_G(cheats).freezeHealth = !_G(cheats).freezeHealth;
 		debugPrintf("Health is %s\n", _G(cheats).freezeHealth ? "frozen" : "unfrozen");
 	} else if (!strcmp(argv[1], "magic")) {
-		debugPrintf("Magic is %s\n", _G(cheats).freezeHealth ? "frozen" : "unfrozen");
+		_G(cheats).freezeMagic = !_G(cheats).freezeMagic;
+		debugPrintf("Magic is %s\n", _G(cheats).freezeMagic ? "frozen" : "unfrozen");
 	} else if (!strcmp(argv[1], "jewels")) {
 		_G(cheats).freezeJewels = !_G(cheats).freezeJewels;
 		debugPrintf("Jewels are %s\n", _G(cheats).freezeJewels ? "frozen" : "unfrozen");


Commit: d7fdfe62524888e9fc70a72f8b8c6181e8140344
    https://github.com/scummvm/scummvm/commit/d7fdfe62524888e9fc70a72f8b8c6181e8140344
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Throw lightning implemented

Changed paths:
    engines/got/game/object.cpp
    engines/got/got.cpp
    engines/got/vars.h
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index 29e6d8330b8..4e15cc416d3 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -31,7 +31,6 @@
 
 namespace Got {
 
-void throw_lightning();
 void not_enough_magic();
 void cannot_carry_more();
 
@@ -357,7 +356,7 @@ int use_lightning(int flag) {
 	if (flag) {
 		if (_G(thor_info).magic > 14) {
 			add_magic(-15);
-			throw_lightning();
+			g_events->send("Game", GameMessage("THROW_LIGHTNING"));
 		} else {
 			not_enough_magic();
 			return 0;
@@ -458,131 +457,6 @@ void use_item() {
 	}
 }
 
-void place_pixel(int dir, int num) {
-#ifdef TODO
-	switch (dir) {
-	case 0:
-		_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] - 1;
-		_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] +
-			(1 - (g_events->getRandomNumber(2)));
-		break;
-	case 1:
-		if (g_events->getRandomNumber(1)) {
-			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + 1;
-			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
-		} else {
-			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] - 1;
-			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
-		}
-		break;
-	case 2:
-		_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + 1;
-		_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + (1 - (g_events->getRandomNumber(2)));
-		break;
-	case 3:
-		if (g_events->getRandomNumber(1)) {
-			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + 1;
-			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
-		} else {
-			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + 1;
-			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
-		}
-		break;
-	case 4:
-		_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + 1;
-		_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + (1 - (g_events->getRandomNumber(2)));
-		break;
-	case 5:
-		if (g_events->getRandomNumber(1)) {
-			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] - 1;
-			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
-		} else {
-			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + 1;
-			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
-		}
-		break;
-	case 6:
-		_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] - 1;
-		_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + (1 - (g_events->getRandomNumber(2)));
-		break;
-	case 7:
-		if (g_events->getRandomNumber(1)) {
-			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] - 1;
-			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
-		} else {
-			_G(pixel_y)[dir][num] = _G(pixel_y)[dir][num - 1] - 1;
-			_G(pixel_x)[dir][num] = _G(pixel_x)[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
-		}
-		break;
-	default:
-		return;
-	}
-	if (point_within(_G(pixel_x)[dir][num], _G(pixel_y)[dir][num], 0, 0, 319, 191)) {
-		_G(pixel_p)[dir][num] = xpoint(_G(pixel_x)[dir][num], _G(pixel_y)[dir][num], draw_page);
-		xpset(_G(pixel_x)[dir][num], _G(pixel_y)[dir][num], draw_page, _G(pixel_c)[dir]);
-	}
-#else
-	error("TODO: place_pixel");
-#endif
-}
-
-void replace_pixel(int dir, int num) {
-#ifdef TODO
-	if (point_within(_G(pixel_x)[dir][num], _G(pixel_y)[dir][num], 0, 0, 319, 191)) {
-		xpset(_G(pixel_x)[dir][num], _G(pixel_y)[dir][num], draw_page, _G(pixel_p)[dir][num]);
-	}
-#else
-	error("TODO: replace_pixel");
-#endif
-}
-
-void throw_lightning() {
-#ifdef TODO
-	int i, r, loop, x, y, ax, ay;
-
-	for (i = 0; i < MAX_ACTORS; i++) _G(actor)[i].show = 0;
-
-	xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], draw_page);
-	xshowpage(draw_page);
-	play_sound(ELECTRIC, 1);
-	for (loop = 0; loop < 10; loop++) {
-		for (i = 0; i < 8; i++) {
-			_G(pixel_x)[i][0] = _G(thor)->x + 7;
-			_G(pixel_y)[i][0] = _G(thor)->y + 7;
-			_G(pixel_c)[i] = 14 + g_events->getRandomNumber(1);
-		}
-		for (r = 0; r < 8; r++) {
-			for (i = 1; i < 25; i++) {
-				place_pixel(r, i);
-			}
-		}
-		timer_cnt = 0;
-		while (timer_cnt < 3);
-		for (r = 7; r >= 0; r--) {
-			for (i = 1; i < 25; i++) {
-				replace_pixel(r, i);
-			}
-		}
-		timer_cnt = 0;
-		while (timer_cnt < 3);
-	}
-	x = _G(thor)->x + 7;
-	y = _G(thor)->y + 7;
-	for (i = 3; i < MAX_ACTORS; i++) {
-		if (!_G(actor)[i].used) continue;
-		ax = _G(actor)[i].x + (_G(actor)[i].size_x / 2);
-		ay = _G(actor)[i].y + (_G(actor)[i].size_y / 2);
-		if ((abs(ax - x) < 30) && (abs(ay - y) < 30)) {
-			_G(actor)[i].magic_hit = 1;
-			_G(actor)[i].vunerable = 0;
-			actor_damaged(&_G(actor)[i], 254);
-		}
-	}
-#else
-	error("TODO: throw lightning");
-#endif
-}
-
 void not_enough_magic() {
 	if (!_G(magic_inform))
 		odin_speaks(2006, 0);
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 32f68b8bbdb..02ae30c2252 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -218,6 +218,7 @@ void GotEngine::syncSoundSettings() {
 
 void GotEngine::pauseEngineIntern(bool pause) {
 	g_vars->clearKeyFlags();
+
 	Engine::pauseEngineIntern(pause);
 }
 
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 7934c3ede7e..c5a0bd2a190 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -58,7 +58,7 @@ enum Key {
 
 enum GameMode {
 	MODE_NORMAL, MODE_AREA_CHANGE, MODE_THUNDER,
-	MODE_THOR_DIES, MODE_ADD_SCORE
+	MODE_THOR_DIES, MODE_ADD_SCORE, MODE_LIGHTNING
 };
 
 enum TransitionDir {
@@ -223,10 +223,6 @@ public:
 	byte *_ami_store1 = nullptr, *_ami_store2 = nullptr;
 	byte *_mask_store1 = nullptr, *_mask_store2 = nullptr;
 	bool _thor_special_flag = false;
-	int  _pixel_x[8][25] = {};
-	int  _pixel_y[8][25] = {};
-	byte _pixel_p[8][25] = {};
-	byte _pixel_c[8] = {};
 };
 
 #define _G(X) (g_vars->_##X)
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 8fc0ad6c5c4..fbdb0070045 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -57,6 +57,9 @@ void GameContent::draw() {
 		GfxSurface win = getSurface();
 		win.clear();
 		win.blitFrom(s, _moveDelta);
+	} else if (_G(gameMode) == MODE_LIGHTNING) {
+		drawLightning(s);
+
 	} else if (_G(gameMode) == MODE_AREA_CHANGE) {
 		// Draw parts of the new scene along with parts of the old one
 		// as it's scrolled off-screen
@@ -107,10 +110,11 @@ void GameContent::draw() {
 #define MSG(STR, METHOD) else if (msg._name == STR) { METHOD(); return true; }
 
 bool GameContent::msgGame(const GameMessage &msg) {
-	if (msg._name == "THOR_DIES") {
-		thorDies();
+	if (msg._name == "THROW_LIGHTNING") {
+		throwLightning();
 		return true;
 	}
+	MSG("THOR_DIES", thorDies)
 	MSG("CLOSING1_2", closing_sequence1_2)
 	MSG("CLOSING1_3", closing_sequence1_3)
 	MSG("CLOSING1_4", closing_sequence1_4)
@@ -145,6 +149,12 @@ bool GameContent::tick() {
 		}
 		break;
 
+	case MODE_LIGHTNING:
+		if (--_lightningCtr == 0) {
+			lightningCountdownDone();
+		}
+		break;
+
 	default:
 		break;
 	}
@@ -478,5 +488,118 @@ void GameContent::checkForCheats() {
 		_G(thor_info).jewels = 999;
 }
 
+
+void GameContent::placePixel(GfxSurface &s, int dir, int num) {
+	switch (dir) {
+	case 0:
+		_pixelY[dir][num] = _pixelY[dir][num - 1] - 1;
+		_pixelX[dir][num] = _pixelX[dir][num - 1] +
+			(1 - (g_events->getRandomNumber(2)));
+		break;
+	case 1:
+		if (g_events->getRandomNumber(1)) {
+			_pixelX[dir][num] = _pixelX[dir][num - 1] + 1;
+			_pixelY[dir][num] = _pixelY[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
+		} else {
+			_pixelY[dir][num] = _pixelY[dir][num - 1] - 1;
+			_pixelX[dir][num] = _pixelX[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
+		}
+		break;
+	case 2:
+		_pixelX[dir][num] = _pixelX[dir][num - 1] + 1;
+		_pixelY[dir][num] = _pixelY[dir][num - 1] + (1 - (g_events->getRandomNumber(2)));
+		break;
+	case 3:
+		if (g_events->getRandomNumber(1)) {
+			_pixelX[dir][num] = _pixelX[dir][num - 1] + 1;
+			_pixelY[dir][num] = _pixelY[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
+		} else {
+			_pixelY[dir][num] = _pixelY[dir][num - 1] + 1;
+			_pixelX[dir][num] = _pixelX[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
+		}
+		break;
+	case 4:
+		_pixelY[dir][num] = _pixelY[dir][num - 1] + 1;
+		_pixelX[dir][num] = _pixelX[dir][num - 1] + (1 - (g_events->getRandomNumber(2)));
+		break;
+	case 5:
+		if (g_events->getRandomNumber(1)) {
+			_pixelX[dir][num] = _pixelX[dir][num - 1] - 1;
+			_pixelY[dir][num] = _pixelY[dir][num - 1] + (1 - (g_events->getRandomNumber(1)));
+		} else {
+			_pixelY[dir][num] = _pixelY[dir][num - 1] + 1;
+			_pixelX[dir][num] = _pixelX[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
+		}
+		break;
+	case 6:
+		_pixelX[dir][num] = _pixelX[dir][num - 1] - 1;
+		_pixelY[dir][num] = _pixelY[dir][num - 1] + (1 - (g_events->getRandomNumber(2)));
+		break;
+	case 7:
+		if (g_events->getRandomNumber(1)) {
+			_pixelX[dir][num] = _pixelX[dir][num - 1] - 1;
+			_pixelY[dir][num] = _pixelY[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
+		} else {
+			_pixelY[dir][num] = _pixelY[dir][num - 1] - 1;
+			_pixelX[dir][num] = _pixelX[dir][num - 1] + (0 - (g_events->getRandomNumber(1)));
+		}
+		break;
+	default:
+		return;
+	}
+
+	if (point_within(_pixelX[dir][num], _pixelY[dir][num], 0, 0, 319, 191)) {
+		byte *pixel = (byte *)s.getBasePtr(_pixelX[dir][num],
+			_pixelY[dir][num]);
+		*pixel = _pixelC[dir];
+	}
+}
+
+void GameContent::throwLightning() {
+	_G(gameMode) = MODE_LIGHTNING;
+	_lightningCtr = 20;
+
+	for (int i = 0; i < MAX_ACTORS; i++)
+		_G(actor)[i].show = 0;
+
+	play_sound(ELECTRIC, 1);
+}
+
+void GameContent::drawLightning(GfxSurface &s) {
+	for (int i = 0; i < 8; i++) {
+		_pixelX[i][0] = _G(thor)->x + 7;
+		_pixelY[i][0] = _G(thor)->y + 7;
+		_pixelC[i] = 14 + g_events->getRandomNumber(1);
+	}
+
+	for (int r = 0; r < 8; r++) {
+		for (int i = 1; i < 25; i++) {
+			placePixel(s, r, i);
+		}
+	}
+}
+
+void GameContent::lightningCountdownDone() {
+	int x, y, i, ax, ay;
+	_G(gameMode) = MODE_NORMAL;
+
+	x = _G(thor)->x + 7;
+	y = _G(thor)->y + 7;
+
+	for (i = 3; i < MAX_ACTORS; i++) {
+		if (!_G(actor)[i].used)
+			continue;
+
+		ax = _G(actor)[i].x + (_G(actor)[i].size_x / 2);
+		ay = _G(actor)[i].y + (_G(actor)[i].size_y / 2);
+
+		if ((ABS(ax - x) < 30) && (ABS(ay - y) < 30)) {
+			_G(actor)[i].magic_hit = 1;
+			_G(actor)[i].vunerable = 0;
+			actor_damaged(&_G(actor)[i], 254);
+		}
+	}
+}
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index eb2a8deda1d..c11f66dcb6c 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -35,10 +35,17 @@ private:
 	int _transitionPos = 0;
 	int _deathCtr = 0;
 	bool _phased[240] = {};
+	int _lightningCtr = 0;
+	int  _pixelX[8][25] = {};
+	int  _pixelY[8][25] = {};
+	byte _pixelP[8][25] = {};
+	byte _pixelC[8] = {};
 
 	void drawBackground(GfxSurface &s);
 	void drawObjects(GfxSurface &s);
 	void drawActors(GfxSurface &s);
+	void drawLightning(GfxSurface &s);
+	void placePixel(GfxSurface &s, int dir, int num);
 	void checkThunderShake();
 	void checkSwitchFlag();
 	void checkForItem();
@@ -51,6 +58,8 @@ private:
 	void spinThor();
 	void thorDead();
 	void checkForCheats();
+	void throwLightning();
+	void lightningCountdownDone();
 
 public:
 	GameContent();


Commit: 4a530c7e25b9088293291a0e04b6d16029eef8e1
    https://github.com/scummvm/scummvm/commit/4a530c7e25b9088293291a0e04b6d16029eef8e1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix saving yet again

Lightning power gets triggered by Ctrl key, so using Ctrl+F5
to open GMM requires turning the triggered mode off

Changed paths:
    engines/got/got.cpp
    engines/got/views/dialogs/options_menu.cpp


diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 02ae30c2252..9cf9d53109f 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -218,6 +218,8 @@ void GotEngine::syncSoundSettings() {
 
 void GotEngine::pauseEngineIntern(bool pause) {
 	g_vars->clearKeyFlags();
+	if (_G(gameMode) == MODE_LIGHTNING)
+		_G(gameMode) = MODE_NORMAL;
 
 	Engine::pauseEngineIntern(pause);
 }
diff --git a/engines/got/views/dialogs/options_menu.cpp b/engines/got/views/dialogs/options_menu.cpp
index 5d2ca35e8ee..2721af77aef 100644
--- a/engines/got/views/dialogs/options_menu.cpp
+++ b/engines/got/views/dialogs/options_menu.cpp
@@ -46,11 +46,9 @@ void OptionsMenu::selected() {
 		// skill level
 		break;
 	case 2:
-		close();
 		g_engine->saveGameDialog();
 		break;
 	case 3:
-		close();
 		g_engine->loadGameDialog();
 		break;
 	case 4:


Commit: 8b2f503361e1a7ecdbdddd7a5085d4a0cc8c1606
    https://github.com/scummvm/scummvm/commit/8b2f503361e1a7ecdbdddd7a5085d4a0cc8c1606
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix under-run error in script parser

Changed paths:
    engines/got/game/script.cpp


diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 1078d2a881c..1ee2639e815 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -567,7 +567,7 @@ int Scripts::read_script_file() {
 		temp_buff[p] = 0;
 
 		len = strlen(temp_buff);
-		if (len < 10 && temp_buff[len - 1] == ':') {       //line label
+		if (len > 0 && len < 10 && temp_buff[len - 1] == ':') {       //line label
 			temp_buff[len - 1] = 0;
 			_linePtr[_numLabels] = _buffPtr;
 			Common::strcpy_s(_lineLabel[_numLabels++], (char *) temp_buff);


Commit: 7ae8ce87ca30ee23803791dcc7470fe5b5d71402
    https://github.com/scummvm/scummvm/commit/7ae8ce87ca30ee23803791dcc7470fe5b5d71402
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Flying console command

Changed paths:
    engines/got/console.cpp
    engines/got/console.h
    engines/got/game/move_patterns.cpp


diff --git a/engines/got/console.cpp b/engines/got/console.cpp
index 46918f26a3c..6d9cc67ead3 100644
--- a/engines/got/console.cpp
+++ b/engines/got/console.cpp
@@ -41,6 +41,7 @@ Console::Console() : GUI::Debugger() {
 	registerCmd("magic", WRAP_METHOD(Console, cmdMagic));
 	registerCmd("freeze", WRAP_METHOD(Console, cmdFreeze));
 	registerCmd("level", WRAP_METHOD(Console, cmdLevel));
+	registerCmd("flying", WRAP_METHOD(Console, cmdFlying));
 }
 
 Console::~Console() {
@@ -144,4 +145,10 @@ bool Console::cmdLevel(int argc, const char **argv) {
 	}
 }
 
+bool Console::cmdFlying(int argc, const char **argv) {
+	_G(thor)->flying = !_G(thor)->flying;
+	debugPrintf("Flying is %s\n", _G(thor)->flying ? "on" : "off");
+	return true;
+}
+
 } // namespace Got
diff --git a/engines/got/console.h b/engines/got/console.h
index 55499464026..1b61d8d76e6 100644
--- a/engines/got/console.h
+++ b/engines/got/console.h
@@ -37,6 +37,7 @@ private:
 	bool cmdMagic(int argc, const char **argv);
 	bool cmdFreeze(int argc, const char **argv);
 	bool cmdLevel(int argc, const char **argv);
+	bool cmdFlying(int argc, const char **argv);
 
 public:
 	Console();
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 669eeaf8095..80541da9680 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -229,8 +229,8 @@ int check_move0(int x, int y, ACTOR *actr) {
 	else x2 = (x + 10) >> 4;
 	y2 = (y + 15) >> 4;
 
-	// check for solid or fly over
-	if ((_G(cheat) + _G(key_flag)[_ONE]) < 2) {
+	// Check for cheat flying mode
+	if (!actr->flying) {
 		icn1 = _G(scrn).icon[y1][x1];
 		icn2 = _G(scrn).icon[y2][x1];
 		icn3 = _G(scrn).icon[y1][x2];


Commit: ba1ee75b195f3c1e81ef5911b32740edb1d37f88
    https://github.com/scummvm/scummvm/commit/ba1ee75b195f3c1e81ef5911b32740edb1d37f88
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Hooking up boss 1 logic

Changed paths:
  A engines/got/gfx/panel.h
  R engines/got/game/panel.cpp
  R engines/got/game/panel.h
    engines/got/game/back.cpp
    engines/got/game/boss1.cpp
    engines/got/game/boss1.h
    engines/got/game/init.cpp
    engines/got/game/move_patterns.cpp
    engines/got/game/object.cpp
    engines/got/game/script.cpp
    engines/got/module.mk
    engines/got/vars.h
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index 31e6b3adda4..46e66358945 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -21,10 +21,11 @@
 
 #include "common/file.h"
 #include "got/game/back.h"
+#include "got/game/boss1.h"
 #include "got/game/move.h"
-#include "got/game/panel.h"
 #include "got/game/script.h"
 #include "got/gfx/image.h"
+#include "got/gfx/panel.h"
 #include "got/events.h"
 #include "got/vars.h"
 
@@ -146,7 +147,18 @@ void show_level_done() {
 
 	_G(last_setup) = _G(setup);
 
-	music_play(_G(level_type), 0);
+	bool f = true;
+	if (GAME1 && _G(new_level) == BOSS_LEVEL1) {
+		if (!_G(setup).boss_dead[0]) {
+			if (!_G(auto_load))
+				boss_level1();
+			f = false;
+		}
+	}
+	if (_G(startup))
+		f = false;
+	if (f)
+		music_play(_G(level_type), 0);
 }
 
 static void odin_speaks_end() {
diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index 51eb07fcc84..e939ae22e9d 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -21,11 +21,12 @@
 
 #include "got/game/boss1.h"
 #include "got/game/back.h"
+#include "got/game/init.h"
 #include "got/game/move.h"
 #include "got/game/move_patterns.h"
-#include "got/game/panel.h"
 #include "got/game/status.h"
 #include "got/gfx/image.h"
+#include "got/gfx/panel.h"
 #include "got/vars.h"
 #include "got/events.h"
 #include "got/sound.h"
@@ -206,17 +207,12 @@ void check_boss1_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
 }
 
 void boss_level1() {
-#ifdef TODO
 	setup_boss(1);
 	_G(boss_active) = 1;
-	boss_status(-1);
 	music_pause();
 	play_sound(BOSS11, 1);
-	pause(120);
+	g_events->send("Game", GameMessage("PAUSE", 40));
 	music_play(5, 1);
-#else
-	error("boss_level1");
-#endif
 }
 
 int boss_dead1(void) {
@@ -252,8 +248,10 @@ int boss_dead1(void) {
 		play_sound(EXPLODE, 1);
 		_G(boss_dead)++;
 		for (rep = 7; rep < MAX_ACTORS; rep++)
-			if (_G(actor)[rep].used) actor_destroyed(&_G(actor)[rep]);
+			if (_G(actor)[rep].used)
+				actor_destroyed(&_G(actor)[rep]);
 	}
+
 	return _G(actor)[3].last_dir;
 }
 
diff --git a/engines/got/game/boss1.h b/engines/got/game/boss1.h
index 371a764e3f2..2c016d6a6ce 100644
--- a/engines/got/game/boss1.h
+++ b/engines/got/game/boss1.h
@@ -26,7 +26,7 @@
 
 namespace Got {
 
-// boss 1 - Snake (Jormangund )
+// boss 1 - Snake (Jormangund)
 extern int boss1_movement(ACTOR *actr);
 extern void check_boss1_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num);
 extern void boss_level1();
diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index 7b8d972a1a7..45d4015e856 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -90,24 +90,6 @@ void initialize_game() {
 
 	show_level(_G(current_level));
 
-	if (_G(auto_load)) {
-		if (load_game(0)) {
-			setup_load();
-		}
-		_G(auto_load) = 0;
-		if (GAME1 && _G(current_area) == 59 && !_G(setup).game_over) {
-			_G(auto_load) = 1;
-#ifdef TODO
-			fade_in();
-			boss_level1();
-#else
-			error("TODO: boss_level1");
-#endif
-		}
-	} else if (!_G(cheat)) {
-//		key_flag[ESC] = 1;
-	}
-
 	if (!_G(auto_load)) {
 //		fade_in();
 		_G(sound).music_play(_G(level_type), 1);
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 80541da9680..64a6c8bfee4 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -24,7 +24,7 @@
 #include "got/game/boss1.h"
 #include "got/game/move.h"
 #include "got/game/object.h"
-#include "got/game/panel.h"
+#include "got/gfx/panel.h"
 #include "got/game/script.h"
 #include "got/game/special_tile.h"
 #include "got/events.h"
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index 4e15cc416d3..96a4a8be762 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -22,7 +22,7 @@
 #include "got/game/object.h"
 #include "got/game/back.h"
 #include "got/game/move.h"
-#include "got/game/panel.h"
+#include "got/gfx/panel.h"
 #include "got/game/status.h"
 #include "got/data/flags.h"
 #include "got/gfx/image.h"
diff --git a/engines/got/game/panel.cpp b/engines/got/game/panel.cpp
deleted file mode 100644
index 231ec78566a..00000000000
--- a/engines/got/game/panel.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "common/textconsole.h"
-#include "got/game/panel.h"
-
-namespace Got {
-
-void boss_status(int health) {
-	error("TODO: boss_status");
-}
-
-} // namespace Got
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 1ee2639e815..f9ee3ec7a4e 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -24,9 +24,9 @@
 #include "got/game/back.h"
 #include "got/game/main.h"
 #include "got/game/object.h"
-#include "got/game/panel.h"
 #include "got/game/status.h"
 #include "got/gfx/image.h"
+#include "got/gfx/panel.h"
 #include "got/utils/file.h"
 #include "got/views/dialogs/ask.h"
 #include "got/views/dialogs/say.h"
diff --git a/engines/got/game/panel.h b/engines/got/gfx/panel.h
similarity index 97%
rename from engines/got/game/panel.h
rename to engines/got/gfx/panel.h
index 7b2c02f057f..335cc1ce3b9 100644
--- a/engines/got/game/panel.h
+++ b/engines/got/gfx/panel.h
@@ -34,6 +34,7 @@ inline void display_item() {}
 inline void display_health() {}
 inline void display_magic() {}
 inline void d_restore() {}
+inline void boss_status(int health) {}
 
 } // namespace Got
 
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 3de493ad2f6..9d9b0bc8108 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -20,7 +20,6 @@ MODULE_OBJS = \
 	game/move.o \
 	game/move_patterns.o \
 	game/object.o \
-	game/panel.o \
 	game/script.o \
 	game/shot_movement.o \
 	game/shot_pattern.o \
diff --git a/engines/got/vars.h b/engines/got/vars.h
index c5a0bd2a190..740f799316a 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -58,7 +58,8 @@ enum Key {
 
 enum GameMode {
 	MODE_NORMAL, MODE_AREA_CHANGE, MODE_THUNDER,
-	MODE_THOR_DIES, MODE_ADD_SCORE, MODE_LIGHTNING
+	MODE_THOR_DIES, MODE_ADD_SCORE, MODE_LIGHTNING,
+	MODE_PAUSE
 };
 
 enum TransitionDir {
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index fbdb0070045..393a8dc7901 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -52,6 +52,9 @@ void GameContent::draw() {
 	drawObjects(s);
 	drawActors(s);
 
+	if (_G(current_level) == BOSS_LEVEL1)
+		drawBoss1Health(s);
+
 	// If we're shaking the screen, render the content with the shake X/Y
 	if (_G(gameMode) == MODE_THUNDER) {
 		GfxSurface win = getSurface();
@@ -110,10 +113,12 @@ void GameContent::draw() {
 #define MSG(STR, METHOD) else if (msg._name == STR) { METHOD(); return true; }
 
 bool GameContent::msgGame(const GameMessage &msg) {
-	if (msg._name == "THROW_LIGHTNING") {
-		throwLightning();
+	if (msg._name == "BOSS_PAUSE") {
+		_G(gameMode) = MODE_PAUSE;
+		_pauseCtr = msg._value;
 		return true;
 	}
+	MSG("THROW_LIGHTNING", throwLightning)
 	MSG("THOR_DIES", thorDies)
 	MSG("CLOSING1_2", closing_sequence1_2)
 	MSG("CLOSING1_3", closing_sequence1_3)
@@ -155,6 +160,11 @@ bool GameContent::tick() {
 		}
 		break;
 
+	case MODE_PAUSE:
+		if (--_pauseCtr == 0)
+			_G(gameMode) = MODE_NORMAL;
+		break;
+
 	default:
 		break;
 	}
@@ -226,6 +236,27 @@ void GameContent::drawActors(GfxSurface &s) {
 		s.blitFrom(_G(objects)[10], Common::Point(_G(thor)->x, _G(thor)->y));
 }
 
+void GameContent::drawBoss1Health(GfxSurface &s) {
+	int rep, i, c;
+
+	int health = _G(actor)[3].health;
+
+	s.fillRect(Common::Rect(304, 2, 317, 81), 0);
+	s.fillRect(Common::Rect(305, 3, 316, 80), 28);
+	s.fillRect(Common::Rect(306, 4, 315, 79), 26);
+	s.fillRect(Common::Rect(307, 5, 314, 78), 24);
+
+	for (i = 10; i > 0; i--) {
+		if (i * 10 > health)
+			c = 0;
+		else
+			c = 32;
+
+		s.fillRect(Common::Rect(308, 7 + (7 * (10 - i)),
+			313, 13 + (7 * (10 - i))), c);
+	}
+}
+
 void GameContent::checkThunderShake() {
 	if (_G(thunder_flag)) {
 		_G(gameMode) = MODE_THUNDER;
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index c11f66dcb6c..fdc7a586bdb 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -40,10 +40,12 @@ private:
 	int  _pixelY[8][25] = {};
 	byte _pixelP[8][25] = {};
 	byte _pixelC[8] = {};
+	int _pauseCtr = 0;
 
 	void drawBackground(GfxSurface &s);
 	void drawObjects(GfxSurface &s);
 	void drawActors(GfxSurface &s);
+	void drawBoss1Health(GfxSurface &s);
 	void drawLightning(GfxSurface &s);
 	void placePixel(GfxSurface &s, int dir, int num);
 	void checkThunderShake();


Commit: 7568cecd1af08466ea8816877908a5b3172a81dd
    https://github.com/scummvm/scummvm/commit/7568cecd1af08466ea8816877908a5b3172a81dd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fixes for area 1 closing sequence

Changed paths:
    engines/got/game/boss1.cpp
    engines/got/vars.h
    engines/got/views/game.cpp
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h
    engines/got/views/title_background.cpp


diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index e939ae22e9d..7cd052c7bc6 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -256,8 +256,9 @@ int boss_dead1(void) {
 }
 
 void closing_sequence1() {
+	_G(game_over) = 1;
 	music_play(4, 1);
-	odin_speaks(1001, 13, "CLOSING1_2");
+	odin_speaks(1001, 13, "CLOSING");
 }
 
 void closing_sequence1_2() {
@@ -265,15 +266,13 @@ void closing_sequence1_2() {
 	load_new_thor();
 	_G(thor)->dir = 1;
 	_G(thor)->next = 0;
-	fill_score(20, "CLOSING1_3");
+	fill_score(20, "CLOSING");
 }
 
 void closing_sequence1_3() {
-	score_for_inv();
-
 	fill_health();
 	fill_magic();
-	odin_speaks(1002, 0, "CLOSING1_4");
+	odin_speaks(1002, 0, "CLOSING");
 }
 
 void closing_sequence1_4() {
@@ -281,7 +280,6 @@ void closing_sequence1_4() {
 	REPEAT(16) _G(scrn).actor_type[rep] = 0;
 	_G(boss_dead) = 0;
 	_G(setup).boss_dead[0] = 1;
-	_G(game_over) = 1;
 	_G(boss_active) = 0;
 	_G(scrn).type = 4;
 	show_level(BOSS_LEVEL1);
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 740f799316a..820ec7223ce 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -59,7 +59,7 @@ enum Key {
 enum GameMode {
 	MODE_NORMAL, MODE_AREA_CHANGE, MODE_THUNDER,
 	MODE_THOR_DIES, MODE_ADD_SCORE, MODE_LIGHTNING,
-	MODE_PAUSE
+	MODE_PAUSE, MODE_SCORE_INV
 };
 
 enum TransitionDir {
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 6d123fc5464..8302b9f34e6 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -26,6 +26,7 @@
 #include "got/game/object.h"
 #include "got/metaengine.h"
 #include "got/vars.h"
+#include "got/game/boss1.h"
 
 namespace Got {
 namespace Views {
@@ -46,6 +47,12 @@ bool Game::msgKeypress(const KeypressMessage &msg) {
 		odin_speaks(2008, -1);
 		return true;
 
+	case Common::KEYCODE_f:
+		// Hack used for testing end-game sequence
+		if (_G(current_level) == BOSS_LEVEL1)
+			closing_sequence1();
+		break;
+
 	case Common::KEYCODE_s:
 		g_engine->saveGameDialog();
 		break;
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 393a8dc7901..e755bc0fc7c 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -25,6 +25,7 @@
 #include "got/game/move.h"
 #include "got/game/move_patterns.h"
 #include "got/game/object.h"
+#include "got/game/status.h"
 #include "got/gfx/image.h"
 #include "got/vars.h"
 
@@ -117,12 +118,14 @@ bool GameContent::msgGame(const GameMessage &msg) {
 		_G(gameMode) = MODE_PAUSE;
 		_pauseCtr = msg._value;
 		return true;
+	} else if (msg._name == "SCORE_INV") {
+		_G(gameMode) = MODE_SCORE_INV;
+		_pauseCtr = 0;
+		return true;
 	}
 	MSG("THROW_LIGHTNING", throwLightning)
 	MSG("THOR_DIES", thorDies)
-	MSG("CLOSING1_2", closing_sequence1_2)
-	MSG("CLOSING1_3", closing_sequence1_3)
-	MSG("CLOSING1_4", closing_sequence1_4)
+	MSG("CLOSING", closingSequence)
 
 	return false;
 }
@@ -165,6 +168,36 @@ bool GameContent::tick() {
 			_G(gameMode) = MODE_NORMAL;
 		break;
 
+	case MODE_SCORE_INV:
+		if (--_pauseCtr <= 0) {
+			_pauseCtr = 5;
+
+			if (_G(thor)->health > 0) {
+				_G(thor)->health--;
+				play_sound(WOOP, 1);
+				add_health(-1);
+				add_score(10);
+
+			} else if (_G(thor_info).magic > 0) {
+				_G(thor_info).magic--;
+				play_sound(WOOP, 1);
+				add_magic(-1);
+				add_score(10);
+
+			} else if (_G(thor_info).jewels) {
+				_G(thor_info).jewels--;
+				play_sound(WOOP, 1);
+				add_jewels(-1);
+				add_score(10);
+
+			} else {
+				_G(gameMode) = MODE_NORMAL;
+				_pauseCtr = 0;
+				send(GameMessage("CLOSING"));
+			}
+		}
+		break;
+
 	default:
 		break;
 	}
@@ -237,7 +270,7 @@ void GameContent::drawActors(GfxSurface &s) {
 }
 
 void GameContent::drawBoss1Health(GfxSurface &s) {
-	int rep, i, c;
+	int i, c;
 
 	int health = _G(actor)[3].health;
 
@@ -323,7 +356,7 @@ void GameContent::moveActors() {
 			if (i == 0)
 				set_thor_vars();
 
-			if (_G(new_level) != _G(current_level))
+			if (_G(new_level) != _G(current_level))				
 				return;
 		}
 	}
@@ -412,6 +445,14 @@ void GameContent::checkForAreaChange() {
 		}
 
 	} else if (_G(new_level) != _G(current_level)) {
+		// Check for leaving level after defeating end boss
+		if (_G(current_level) == BOSS_LEVEL1) {
+			// TODO: Implement high score view original had, and show it
+			fadeOut();
+			send("TitleBackground", GameMessage("MAIN_MENU"));
+			return;
+		}
+
 		// Area transition beginning
 		_G(thor)->show = 0;
 		_G(thor)->used = 0;
@@ -430,6 +471,9 @@ void GameContent::checkForAreaChange() {
 }
 
 void GameContent::thorDies() {
+	if (_G(gameMode) == MODE_SCORE_INV)
+		return;
+
 	// Stop any actors on-screen from moving
 	for (int li = 0; li < MAX_ACTORS; li++)
 		_G(actor)[li].show = 0;
@@ -632,5 +676,30 @@ void GameContent::lightningCountdownDone() {
 	}
 }
 
+void GameContent::closingSequence() {
+	switch (++_closingStateCtr) {
+	case 1:
+		// Convert health/magic/jewels to score
+		_G(gameMode) = MODE_SCORE_INV;
+		break;
+
+	case 2:
+		closing_sequence1_2();
+		break;
+
+	case 3:
+		closing_sequence1_3();
+		break;
+
+	case 4:
+		_closingStateCtr = 0;
+		closing_sequence1_4();
+		break;
+
+	default:
+		break;
+	}
+}
+
 } // namespace Views
 } // namespace Got
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index fdc7a586bdb..8f14db56de8 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -41,6 +41,7 @@ private:
 	byte _pixelP[8][25] = {};
 	byte _pixelC[8] = {};
 	int _pauseCtr = 0;
+	int _closingStateCtr = 0;
 
 	void drawBackground(GfxSurface &s);
 	void drawObjects(GfxSurface &s);
@@ -62,6 +63,7 @@ private:
 	void checkForCheats();
 	void throwLightning();
 	void lightningCountdownDone();
+	void closingSequence();
 
 public:
 	GameContent();
diff --git a/engines/got/views/title_background.cpp b/engines/got/views/title_background.cpp
index 0eaec7135ca..ea7f9eb1486 100644
--- a/engines/got/views/title_background.cpp
+++ b/engines/got/views/title_background.cpp
@@ -27,7 +27,7 @@ namespace Views {
 
 bool TitleBackground::msgGame(const GameMessage &msg) {
 	if (msg._name == "MAIN_MENU") {
-		addView();
+		replaceView("TitleBackground", true);
 		draw();
 		Gfx::load_palette();
 		fadeIn();


Commit: 071f33e1fb0e40b64360f6a703d52fe86ab95e9b
    https://github.com/scummvm/scummvm/commit/071f33e1fb0e40b64360f6a703d52fe86ab95e9b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Ignore insta-kills if cheat invulnerability is on

Changed paths:
    engines/got/game/move.cpp


diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index 37599a93499..242c3864354 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -133,7 +133,11 @@ void thor_damaged(ACTOR *actr) {
 	int damage;
 
 	actr->hit_thor = 1;
-//	if (cheat) if (key_flag[_FOUR]) return;
+
+	// If we're invincible, ignore any damage
+	if (_G(cheats).freezeHealth)
+		return;
+
 	damage = actr->strength;
 	if (damage != 255) {
 		if (!_G(setup).skill) damage /= 2;


Commit: 56845f76e8d8fd5b5253d0f9b41ab0a025ad9f56
    https://github.com/scummvm/scummvm/commit/56845f76e8d8fd5b5253d0f9b41ab0a025ad9f56
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix returning to main menu from Quit Game dialog

Changed paths:
    engines/got/views/dialogs/save_game.cpp


diff --git a/engines/got/views/dialogs/save_game.cpp b/engines/got/views/dialogs/save_game.cpp
index a3234cf9ed9..a88e32b96c0 100644
--- a/engines/got/views/dialogs/save_game.cpp
+++ b/engines/got/views/dialogs/save_game.cpp
@@ -43,10 +43,12 @@ void SaveGame::selected() {
 	if (_selectedItem == 0)
 		g_engine->saveGameDialog();
 
-	if (_isQuit)
+	if (_isQuit) {
 		g_engine->quitGame();
-	else
-		replaceView("TitleBackground", true, true);
+	} else {
+		fadeOut();
+		send("TitleBackground", GameMessage("MAIN_MENU"));
+	}
 }
 
 } // namespace Dialogs


Commit: c1c12926fc0f94b2a2c74fd6885dcd9e7b4ae04b
    https://github.com/scummvm/scummvm/commit/c1c12926fc0f94b2a2c74fd6885dcd9e7b4ae04b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Add starting positions for part 2 & 3

Changed paths:
    engines/got/game/init.cpp


diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index 45d4015e856..dec0828ea54 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -46,8 +46,6 @@ void setup_player() {
 	_G(thor_info).last_item = 0;
 	_G(thor_info).object = 0;
 	_G(thor_info).object_name = nullptr;
-	_G(thor)->x = 152;
-	_G(thor)->y = 96;
 	_G(thor)->last_x[0] = _G(thor)->x;
 	_G(thor)->last_x[1] = _G(thor)->x;
 	_G(thor)->last_y[0] = _G(thor)->y;
@@ -55,6 +53,23 @@ void setup_player() {
 	_G(thor_info).last_icon = (6 * 20) + 8;
 	_G(thor_info).last_screen = 23;
 	_G(thor)->dir = 1;
+
+	switch (_G(area)) {
+	case 1:
+		_G(thor)->x = 152;
+		_G(thor)->y = 96;
+		break;
+	case 2:
+		_G(thor)->x = 32;
+		_G(thor)->y = 32;
+		break;
+	case 3:
+		_G(thor)->x = 272;
+		_G(thor)->y = 80;
+		break;
+	default:
+		break;
+	}
 }
 
 void initialize_game() {


Commit: 0e33103ff69154233b09aaa108c3ecc6b578cc92
    https://github.com/scummvm/scummvm/commit/0e33103ff69154233b09aaa108c3ecc6b578cc92
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Default magic spells for each area

Changed paths:
    engines/got/data/defines.h
    engines/got/game/init.cpp
    engines/got/views/game_content.cpp


diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index 7c0f11cd2e4..f6686ff4d4c 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -164,17 +164,12 @@ enum {
 
 #define NUM_OBJECTS 32
 
-#define APPLE_MAGIC     1
-#define HOURGLASS_MAGIC 2
-#define LIGHTNING_MAGIC 4
-
-#define BOOTS_MAGIC    8
-#define BOMB_MAGIC     16
-#define WIND_MAGIC     32
-
-#define QUESTION_MAGIC 64
-#define SHIELD_MAGIC   128
-#define THUNDER_MAGIC  256
+#define APPLE_MAGIC      1
+#define LIGHTNING_MAGIC  2
+#define BOOTS_MAGIC      4
+#define WIND_MAGIC       8
+#define SHIELD_MAGIC    16
+#define THUNDER_MAGIC   32
 
 #define BOSS_LEVEL1  59
 #define BOSS_LEVEL21 200
diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index dec0828ea54..1c8b3a3a85b 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -35,8 +35,10 @@ namespace Got {
 void setup_player() {
 	memset(&_G(thor_info), 0, sizeof(_G(thor_info)));
 	_G(thor_info).inventory = 0;
-	if (_G(area) > 1) _G(thor_info).inventory |= APPLE_MAGIC + LIGHTNING_MAGIC;
-	if (_G(area) > 2) _G(thor_info).inventory |= BOOTS_MAGIC + WIND_MAGIC;
+	if (_G(area) > 1)
+		_G(thor_info).inventory |= APPLE_MAGIC + LIGHTNING_MAGIC;
+	if (_G(area) > 2)
+		_G(thor_info).inventory |= BOOTS_MAGIC + WIND_MAGIC;
 
 	_G(thor)->health = 150;
 	_G(thor_info).magic = 0;
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index e755bc0fc7c..da9ec98968b 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -346,7 +346,7 @@ void GameContent::moveActors() {
 	for (int i = 0; i < MAX_ACTORS; i++) {
 		if (_G(actor)[i].used) {
 			if (_G(hourglass_flag))
-				if ((i > 2) && (!_G(pge)) && (!(_G(actor)[i].magic_hurts & HOURGLASS_MAGIC)))
+				if ((i > 2) && (!_G(pge)) && (!(_G(actor)[i].magic_hurts & LIGHTNING_MAGIC)))
 					continue;
 
 			_G(actor)[i].move_count = _G(actor)[i].num_moves;


Commit: d74625f69eda79248725583ef5f4eb8e7b9732de
    https://github.com/scummvm/scummvm/commit/d74625f69eda79248725583ef5f4eb8e7b9732de
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix palette after GMM loading from splash screen

Changed paths:
    engines/got/views/game.cpp
    engines/got/views/game.h


diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 8302b9f34e6..686cd562309 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -38,6 +38,11 @@ Game::Game() : View("Game") {
 	_status.setBounds(Common::Rect(0, 240 - 48, 320, 240));
 }
 
+bool Game::msgFocus(const FocusMessage &msg) {
+	Gfx::load_palette();
+	return View::msgFocus(msg);
+}
+
 bool Game::msgKeypress(const KeypressMessage &msg) {
 	if (_G(gameMode) != MODE_NORMAL)
 		return false;
diff --git a/engines/got/views/game.h b/engines/got/views/game.h
index b3cac3eabeb..018959f299b 100644
--- a/engines/got/views/game.h
+++ b/engines/got/views/game.h
@@ -38,6 +38,7 @@ public:
 	Game();
 	virtual ~Game() {}
 
+	bool msgFocus(const FocusMessage &msg) override;
 	bool msgKeypress(const KeypressMessage &msg) override;
 	bool msgAction(const ActionMessage &msg) override;
 	bool tick() override;


Commit: 65053af633ce79fbe02f82e56326e4e9b9b14e82
    https://github.com/scummvm/scummvm/commit/65053af633ce79fbe02f82e56326e4e9b9b14e82
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix area for savegames in areas 2/3

Changed paths:
    engines/got/vars.cpp


diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 24fd1da4ebc..a0cc6bb13df 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -88,6 +88,7 @@ Vars::~Vars() {
 void Vars::setArea(int areaNum) {
 	if (areaNum != _area) {
 		_area = areaNum;
+		_setup.area = areaNum;
 		_sd_data.setArea(areaNum);
 		_bgPics.setArea(areaNum);
 


Commit: d9e9836ec314e209934eb4dd18b8e83c37053d9c
    https://github.com/scummvm/scummvm/commit/d9e9836ec314e209934eb4dd18b8e83c37053d9c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Parts 2 and 3 have full magic at the start

Changed paths:
    engines/got/game/init.cpp


diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index 1c8b3a3a85b..15d01b3190b 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -41,7 +41,7 @@ void setup_player() {
 		_G(thor_info).inventory |= BOOTS_MAGIC + WIND_MAGIC;
 
 	_G(thor)->health = 150;
-	_G(thor_info).magic = 0;
+	_G(thor_info).magic = _G(area) > 1 ? 150 : 0;
 	_G(thor_info).jewels = 0;
 	_G(thor_info).score = 0;
 	_G(thor_info).keys = 0;


Commit: 3082dab7087ee3adabd44d8968d8b33ca1a2e13f
    https://github.com/scummvm/scummvm/commit/3082dab7087ee3adabd44d8968d8b33ca1a2e13f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Implement wind power magic

Changed paths:
    engines/got/gfx/image.cpp


diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index cc05f6c1f37..fe7fba2e404 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -274,26 +274,12 @@ int actor_visible(int invis_num) {
 }
 
 void setup_magic_item(int item) {
-#ifdef TODO
 	int i;
-	byte *ami;
-	byte *mb;
-
-
-	mb = _G(mask_buff);
-	_G(mask_buff) = _G(magic_mask_buff);
-
-	ami = _G(ami_buff);
-	_G(ami_buff) = _G(magic_ami);
 
 	for (i = 0; i < 4; i++) {
-		make_mask(&_G(magic_item)[item].pic[i / 4][i % 4], 55200u + (144 * i), &_G(magic_pic)[item][256 * i], 16, 16);
+		createSurface(_G(magic_item)[item].pic[i / 4][i % 4],
+			&_G(magic_pic)[item][256 * i]);
 	}
-	_G(ami_buff) = ami;
-	_G(mask_buff) = mb;
-#else
-	error("TODO: setup_magic_item");
-#endif
 }
 
 void load_new_thor() {


Commit: ecfacdb482fa76009c700368800237ae2e75f567
    https://github.com/scummvm/scummvm/commit/ecfacdb482fa76009c700368800237ae2e75f567
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Remove deprecated image mask buffers

Changed paths:
    engines/got/gfx/image.cpp
    engines/got/vars.cpp
    engines/got/vars.h


diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index fe7fba2e404..0a702c2d90c 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -93,16 +93,11 @@ void make_actor_surface(ACTOR *actr) {
 }
 
 int load_standard_actors() {
-	_G(mask_buff) = _G(mask_buff_start);
-	_G(ami_buff) = _G(abuff);
-
 	load_actor(0, 100 + _G(thor_info).armor);   // Load Thor
 	_G(actor)[0].loadFixed(_G(tmp_buff) + 5120);
 	setup_actor(&_G(actor)[0], 0, 0, 100, 100);
 	_G(thor) = &_G(actor)[0];
 
-	_G(ami_store1) = _G(ami_buff);
-	_G(mask_store1) = _G(mask_buff);
 	make_actor_surface(&_G(actor)[0]);
 
 	_G(thor_x1) = _G(thor)->x + 2;
@@ -116,8 +111,6 @@ int load_standard_actors() {
 	_G(actor)[1].used = 0;
 	_G(hammer) = &_G(actor)[1];
 
-	_G(ami_store2) = _G(ami_buff);
-	_G(mask_store2) = _G(mask_buff);
 	make_actor_surface(&_G(actor)[1]);
 
 	load_actor(0, 106);   // Load sparkle
@@ -149,14 +142,9 @@ int load_standard_actors() {
 	_G(magic_item)[1].used = 0;
 
 	_G(actor)[2].used = 0;
-	_G(magic_ami) = _G(ami_buff);
-	_G(magic_mask_buff) = _G(mask_buff);
 
 	make_actor_surface(&_G(magic_item)[0]);
 
-	_G(enemy_mb) = _G(mask_buff);
-	_G(enemy_ami) = _G(ami_buff);
-
 	return 1;
 }
 
@@ -168,9 +156,6 @@ void show_enemies() {
 	for (i = 0; i < MAX_ENEMIES; i++)
 		_G(enemy_type)[i] = 0;
 
-	_G(mask_buff) = _G(enemy_mb);
-	_G(ami_buff) = _G(enemy_ami);
-
 	for (i = 0; i < MAX_ENEMIES; i++) {
 		if (_G(scrn).actor_type[i] > 0) {
 			r = load_enemy(_G(scrn).actor_type[i]);
@@ -283,22 +268,9 @@ void setup_magic_item(int item) {
 }
 
 void load_new_thor() {
-	byte *ami;
-	byte *mb;
-
-	mb = _G(mask_buff);
-	ami = _G(ami_buff);
-
-	_G(mask_buff) = _G(mask_store1);
-	_G(ami_buff) = _G(ami_store1);
-
-	load_actor(0, 100 + _G(thor_info).armor);   // Load thor
+	load_actor(0, 100 + _G(thor_info).armor);   // Load Thor
 
-	// TODO: Confirm if this is an okay replacement for original mask code
 	make_actor_surface(&_G(actor)[0]);
-
-	_G(ami_buff) = ami;
-	_G(mask_buff) = mb;
 }
 
 } // namespace Got
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index a0cc6bb13df..b02592914be 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -70,8 +70,6 @@ void Vars::load() {
 	_setup.skill = 1;
 
 	_tmp_buff = new byte[TMP_SIZE];
-	_mask_buff = new byte[15300];
-	_mask_buff_start = _mask_buff;
  
 	res_read("RANDOM", _rnd_array);
 
@@ -82,7 +80,6 @@ Vars::~Vars() {
 	g_vars = nullptr;
 
 	delete[] _tmp_buff;
-	delete[] _mask_buff;
 }
 
 void Vars::setArea(int areaNum) {
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 820ec7223ce..67f44188104 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -143,10 +143,6 @@ public:
 	byte *_tmp_buff = nullptr;
 	int _reps = 0;
 
-	byte *_mask_buff = nullptr;
-	byte *_mask_buff_start = nullptr;
-	byte _abuff[AMI_LEN] = {};
-	byte *_ami_buff = nullptr;
 	ACTOR _actor[MAX_ACTORS] = {};   //current actors
 	ACTOR _enemy[MAX_ENEMIES] = {};  //current enemies
 	ACTOR _shot[MAX_ENEMIES] = {};   //current shots
@@ -215,14 +211,8 @@ public:
 	int _current_level = 23;
 	int _new_level = 0;
 	int _new_level_tile = 0, _current_area = 0;
-	byte *_enemy_mb = nullptr;
-	byte *_enemy_ami = nullptr;
 	char _sd_header[128] = {};
 	char _play_speed = 0;
-	byte *_magic_ami = nullptr;
-	byte *_magic_mask_buff = nullptr;
-	byte *_ami_store1 = nullptr, *_ami_store2 = nullptr;
-	byte *_mask_store1 = nullptr, *_mask_store2 = nullptr;
 	bool _thor_special_flag = false;
 };
 


Commit: acb2013a5761ccb29ab4b9c8e7173ec97f7804bf
    https://github.com/scummvm/scummvm/commit/acb2013a5761ccb29ab4b9c8e7173ec97f7804bf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: More magic disablement after using Ctrl+F5

Changed paths:
    engines/got/got.cpp


diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 9cf9d53109f..71b5f72b85e 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -32,6 +32,7 @@
 #include "got/console.h"
 #include "got/game/init.h"
 #include "got/game/main.h"
+#include "got/game/move.h"
 #include "got/gfx/image.h"
 #include "got/utils/res_archive.h"
 #include "got/views/game_content.h"
@@ -221,6 +222,16 @@ void GotEngine::pauseEngineIntern(bool pause) {
 	if (_G(gameMode) == MODE_LIGHTNING)
 		_G(gameMode) = MODE_NORMAL;
 
+	if (_G(tornado_used)) {
+		_G(tornado_used) = false;
+		actor_destroyed(&_G(actor)[2]);
+	}
+
+	_G(lightning_used) = false;
+	_G(thunder_flag) = false;
+	_G(hourglass_flag) = false;
+	_G(shield_on) = false;
+
 	Engine::pauseEngineIntern(pause);
 }
 


Commit: 38e6cb1d6a5435d27140ef2d9ef61b907e8f8fc5
    https://github.com/scummvm/scummvm/commit/38e6cb1d6a5435d27140ef2d9ef61b907e8f8fc5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Kill Thor if spiked by a stake

Changed paths:
    engines/got/game/back.cpp


diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index 46e66358945..390f06d4afe 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -263,9 +263,10 @@ void kill_enemies(int iy, int ix) {
 	return;
 
 dead:
-	_G(thor)->health = 0;
-	//display_health();
-	_G(exit_flag) = 2;
+	if (!_G(cheats).freezeHealth) {
+		_G(thor)->health = 0;
+		g_events->send(GameMessage("THOR_DIES"));
+	}
 }
 
 void remove_objects(int y, int x) {


Commit: 74d7b657438a134a9589356cbcffc825e11fdad2
    https://github.com/scummvm/scummvm/commit/74d7b657438a134a9589356cbcffc825e11fdad2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Only count room 59 as boss room for part 1

Changed paths:
    engines/got/views/game.cpp
    engines/got/views/game_content.cpp


diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 686cd562309..7aab6cf3497 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -54,7 +54,7 @@ bool Game::msgKeypress(const KeypressMessage &msg) {
 
 	case Common::KEYCODE_f:
 		// Hack used for testing end-game sequence
-		if (_G(current_level) == BOSS_LEVEL1)
+		if (GAME1 && _G(current_level) == BOSS_LEVEL1)
 			closing_sequence1();
 		break;
 
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index da9ec98968b..0b5db031647 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -53,7 +53,7 @@ void GameContent::draw() {
 	drawObjects(s);
 	drawActors(s);
 
-	if (_G(current_level) == BOSS_LEVEL1)
+	if (GAME1 && _G(current_level) == BOSS_LEVEL1)
 		drawBoss1Health(s);
 
 	// If we're shaking the screen, render the content with the shake X/Y
@@ -446,7 +446,7 @@ void GameContent::checkForAreaChange() {
 
 	} else if (_G(new_level) != _G(current_level)) {
 		// Check for leaving level after defeating end boss
-		if (_G(current_level) == BOSS_LEVEL1) {
+		if (GAME1 && _G(current_level) == BOSS_LEVEL1) {
 			// TODO: Implement high score view original had, and show it
 			fadeOut();
 			send("TitleBackground", GameMessage("MAIN_MENU"));


Commit: 483257d9a05dd93f9b2b6c5e4207f5a2dd847e50
    https://github.com/scummvm/scummvm/commit/483257d9a05dd93f9b2b6c5e4207f5a2dd847e50
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Yet more can save fixes

Changed paths:
    engines/got/got.cpp


diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 71b5f72b85e..afd6bb22c01 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -194,12 +194,7 @@ bool GotEngine::canSaveGameStateCurrently(Common::U32String *msg) {
 	}
 
 	// Don't allowing saving when not in-game
-	if (!firstView() || firstView()->getName() != "Game")
-		return false;
-
-	if (_G(tornado_used) || _G(lightning_used) ||
-			_G(thunder_flag) || _G(hourglass_flag) || _G(thor)->num_moves > 1 ||
-			_G(shield_on) || _G(game_over))
+	if (!firstView() || firstView()->getName() != "Game" || _G(game_over))
 		return false;
 
 	// Only allow if not in the middle of area transition, dying, etc.


Commit: c3228c293cd3a171512a62f44ab8bc6e6047dc4a
    https://github.com/scummvm/scummvm/commit/c3228c293cd3a171512a62f44ab8bc6e6047dc4a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Simplify scrn load/saving

Changed paths:
    engines/got/data/level.cpp
    engines/got/data/level.h
    engines/got/data/sd_data.cpp
    engines/got/data/sd_data.h
    engines/got/game/back.cpp
    engines/got/game/boss1.cpp
    engines/got/game/init.cpp
    engines/got/game/main.cpp
    engines/got/game/script.cpp
    engines/got/vars.h
    engines/got/views/game_content.cpp


diff --git a/engines/got/data/level.cpp b/engines/got/data/level.cpp
index 49edf3fd0fc..239358f7871 100644
--- a/engines/got/data/level.cpp
+++ b/engines/got/data/level.cpp
@@ -22,6 +22,7 @@
 #include "common/algorithm.h"
 #include "common/memstream.h"
 #include "got/data/defines.h"
+#include "got/vars.h"
 
 namespace Got {
 
@@ -53,24 +54,16 @@ void LEVEL::sync(Common::Serializer &s) {
 	s.syncBytes(future, 3);
 }
 
-void LEVEL::load(Common::SeekableReadStream *src) {
-	Common::Serializer s(src, nullptr);
+void LEVEL::load(int level) {
+	Common::MemoryReadStream src(_G(sd_data)[level], 512);
+	Common::Serializer s(&src, nullptr);
 	sync(s);
 }
 
-void LEVEL::save(Common::WriteStream *dest) {
-	Common::Serializer s(nullptr, dest);
+void LEVEL::save(int level) {
+	Common::MemoryWriteStream dest(_G(sd_data)[level], 512);
+	Common::Serializer s(nullptr, &dest);
 	sync(s);
 }
 
-void LEVEL::load(const byte *src) {
-	Common::MemoryReadStream stream(src, 512);
-	load(&stream);
-}
-
-void LEVEL::save(byte *dest) {
-	Common::MemoryWriteStream stream(dest, 512);
-	save(&stream);
-}
-
 } // namespace Got
diff --git a/engines/got/data/level.h b/engines/got/data/level.h
index c7e2211b4fc..fdb83fc54bc 100644
--- a/engines/got/data/level.h
+++ b/engines/got/data/level.h
@@ -29,6 +29,9 @@ namespace Got {
 #define OBJECTS_COUNT 30
 
 struct LEVEL {                    // size=512
+private:
+	void sync(Common::Serializer &s);
+public:
 	byte icon[12][20] = {};       // 0   grid of icons
 	byte bg_color = 0;            // 240 background color
 	byte type = 0;                // 241 music
@@ -48,11 +51,15 @@ struct LEVEL {                    // size=512
 	byte actor_dir[16] = {};      // initial dir
 	byte future[3] = {};          // 473
 
-	void sync(Common::Serializer &s);
-	void load(Common::SeekableReadStream *src);
-	void save(Common::WriteStream * dest);
-	void load(const byte *src);
-	void save(byte *dest);
+	/**
+	 * Loads level data from the global sd_data for the given level
+	 */
+	void load(int level);
+
+	/**
+	 * Saves the level data to the global sd_data 
+	 */
+	void save(int level);
 };
 
 } // namespace Got
diff --git a/engines/got/data/sd_data.cpp b/engines/got/data/sd_data.cpp
index 38009b99c56..2d47751d9cb 100644
--- a/engines/got/data/sd_data.cpp
+++ b/engines/got/data/sd_data.cpp
@@ -51,16 +51,4 @@ void SdData::sync(Common::Serializer &s) {
 	s.syncBytes(_data, SD_DATA_SIZE);
 }
 
-void SdData::load(int level, LEVEL *dest) {
-	byte *addr = getLevelAddr(level);
-	Common::MemoryReadStream inStream(addr, 512);
-	dest->load(&inStream);
-}
-
-void SdData::save(int level, LEVEL *src) {
-	byte *addr = getLevelAddr(level);
-	Common::MemoryWriteStream outStream(addr, 512);
-	src->save(&outStream);
-}
-
 } // namespace Got
diff --git a/engines/got/data/sd_data.h b/engines/got/data/sd_data.h
index 208763e8e15..934c482ccec 100644
--- a/engines/got/data/sd_data.h
+++ b/engines/got/data/sd_data.h
@@ -32,9 +32,6 @@ private:
 	byte *_data;
 	int _area = 1;
 
-	byte *getLevelAddr(int level) const {
-		return _data + level * 512;
-	}
 public:
 	SdData();
 	~SdData();
@@ -46,14 +43,9 @@ public:
 	void setArea(int area);
 
 	void sync(Common::Serializer &s);
-	void load(int level, LEVEL *dest);
-	void save(int level, LEVEL *src);
 
-	operator const byte *() const {
-		return _data;
-	}
-	operator byte *() {
-		return _data;
+	byte *operator[](int level) const {
+		return _data + level * 512;
 	}
 };
 
diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index 390f06d4afe..129bc912e31 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -61,10 +61,9 @@ void show_level(int new_level) {
 	// This doesn't make sense, because that would put the ending in the middle of static_y.
 	// Plus, it follows with an entire copy of scrn into sd_data anyway, so the first
 	// move seems entirely redundant.
-	_G(sd_data).save(_G(current_level), &_G(scrn));
-	_G(sd_data).load(_G(new_level), &_G(scrn));
+	_G(scrn).save(_G(current_level));
+	_G(scrn).load(_G(new_level));
 
-	_G(scrnp) = (byte *)&_G(scrn);
 	_G(level_type) = _G(scrn).type;
 
 	_G(thor)->next = 0;
diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index 7cd052c7bc6..f2799ff6f72 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -291,10 +291,10 @@ void closing_sequence1_4() {
 	actor_visible(2);
 
 	LEVEL lvl;
-	lvl.load(_G(sd_data) + (59 * 512));
+	lvl.load(59);
 	lvl.icon[6][18] = 148;
 	lvl.icon[6][19] = 202;
-	lvl.save(_G(sd_data) + (59 * 512));
+	lvl.save(59);
 }
 
 } // namespace Got
diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index 15d01b3190b..0ab6fc20bf8 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -98,13 +98,9 @@ void initialize_game() {
 
 	_G(thor)->speed_count = 6;
 
-	_G(new_level) = _G(current_level);
-
 	// Load level data
-	Common::MemoryReadStream levelStream(
-		_G(sd_data) + _G(new_level) * 512, 512);
-	_G(scrn).load(&levelStream);
-
+	_G(new_level) = _G(current_level);
+	_G(scrn).load(_G(current_level));
 	show_level(_G(current_level));
 
 	if (!_G(auto_load)) {
diff --git a/engines/got/game/main.cpp b/engines/got/game/main.cpp
index af0faf7d0e8..a86cb4a6ec3 100644
--- a/engines/got/game/main.cpp
+++ b/engines/got/game/main.cpp
@@ -61,8 +61,7 @@ void setup_load() {
 	_G(actor)[2].used = 0;
 	_G(thor)->speed_count = 6;
 
-	Common::MemoryReadStream stream(_G(sd_data) + (_G(new_level) * 512), 512);
-	_G(scrn).load(&stream);
+	_G(scrn).load(_G(new_level));
 
 	_G(current_level) = _G(new_level);
 	show_level(_G(new_level));
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index f9ee3ec7a4e..19a81ae8e12 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -847,9 +847,9 @@ int Scripts::cmd_settile() {
 		place_tile(pos % 20, pos / 20, tile);
 	} else {
 		LEVEL tmp;
-		tmp.load(_G(sd_data) + (screen * 512));
+		tmp.load(screen);
 		tmp.icon[pos / 20][pos % 20] = tile;
-		tmp.save(_G(sd_data) + (screen * 512));
+		tmp.save(screen);
 	}
 	return 0;
 }
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 67f44188104..d0b33f74992 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -136,7 +136,6 @@ public:
 	int8 _area = 1;
 
 	LEVEL _scrn;
-	byte *_scrnp = nullptr;
 
 	SETUP _setup;
 	SETUP _last_setup;
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 0b5db031647..fb8d434502b 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -545,7 +545,7 @@ void GameContent::thorDead() {
 	_G(thor)->used = 1;
 
 	// Load saved data for new level back into scrn
-	_G(scrn).load(_G(sd_data) + (_G(new_level) * 512));
+	_G(scrn).load(_G(new_level));
 
 	_G(gameMode) = MODE_NORMAL;
 	_deathCtr = 0;


Commit: 7b9a9cf67d8170992a72e3632171e3a626d7e2a7
    https://github.com/scummvm/scummvm/commit/7b9a9cf67d8170992a72e3632171e3a626d7e2a7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Loading, correct area must be set before sd_data loaded

Changed paths:
    engines/got/got.cpp


diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index afd6bb22c01..d2f9faccf5e 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -116,10 +116,18 @@ Common::Error GotEngine::syncGame(Common::Serializer &s) {
 
 	_G(setup).sync(s);
 
-	// For savegames loaded directly from the ScummVM launcher,
-	// take care of initializing game defaults before rest of loading
-	if (s.isLoading() && (!firstView() || firstView()->getName() != "Game"))
-		initialize_game();
+	if (s.isLoading()) {
+		// For savegames loaded directly from the ScummVM launcher,
+		// take care of initializing game defaults before rest of loading
+		if (!firstView() || firstView()->getName() != "Game")
+			initialize_game();
+
+		int area = _G(setup).area;
+		if (area == 0)
+			area = 1;
+
+		g_vars->setArea(area);
+	}
 
 	_G(thor_info).sync(s);
 	_G(sd_data).sync(s);
@@ -131,12 +139,6 @@ Common::Error GotEngine::syncGame(Common::Serializer &s) {
 }
 
 void GotEngine::savegameLoaded() {
-	int area = _G(setup).area;
-	if (area == 0)
-		area = 1;
-
-	g_vars->setArea(area);
-
 	_G(current_area) = _G(thor_info).last_screen;
 
 	_G(thor)->x = (_G(thor_info).last_icon % 20) * 16;


Commit: 146274c587f4e8d681b11b4ce139c152372de231
    https://github.com/scummvm/scummvm/commit/146274c587f4e8d681b11b4ce139c152372de231
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Implement part 2 slipping movement

Changed paths:
    engines/got/console.cpp
    engines/got/game/back.cpp
    engines/got/game/move_patterns.cpp
    engines/got/game/special_tile.cpp
    engines/got/vars.h


diff --git a/engines/got/console.cpp b/engines/got/console.cpp
index 6d9cc67ead3..0607a32d4d3 100644
--- a/engines/got/console.cpp
+++ b/engines/got/console.cpp
@@ -136,7 +136,7 @@ bool Console::cmdFreeze(int argc, const char **argv) {
 
 bool Console::cmdLevel(int argc, const char **argv) {
 	if (argc != 2) {
-		debugPrintf("level <num>\n");
+		debugPrintf("Current level = %d\n", _G(current_level));
 		return true;
 	} else {
 		_G(new_level) = atoi(argv[1]);
diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index 129bc912e31..0ba61decc5a 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -52,6 +52,7 @@ void show_level(int new_level) {
 	if (!_G(shield_on))
 		_G(actor)[2].used = 0;
 	_G(bomb_flag) = 0;
+	_G(slipping) = false;
 
 	save_d = _G(thor)->dir;
 	if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154)
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 64a6c8bfee4..b0c201bf0e6 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -229,6 +229,8 @@ int check_move0(int x, int y, ACTOR *actr) {
 	else x2 = (x + 10) >> 4;
 	y2 = (y + 15) >> 4;
 
+	_G(slip_flag) = 0;
+
 	// Check for cheat flying mode
 	if (!actr->flying) {
 		icn1 = _G(scrn).icon[y1][x1];
@@ -269,6 +271,17 @@ int check_move0(int x, int y, ACTOR *actr) {
 		if (icn4 > TILE_SPECIAL) if (!special_tile_thor(y2, x2, icn4)) return 0;
 	}
 
+	if (!_G(slip_flag)) {
+		_G(slipping) = 0;
+		_G(slip_cnt) = 0;
+	}
+	if (_G(slip_flag) && !_G(slipping))
+		_G(slip_cnt)++;
+	if (_G(slip_cnt) > 8)
+		_G(slipping) = 1;
+	_G(slip_flag) = 0;
+
+
 	x1 = x + 1;
 	y1 = y + 8;
 	if (_G(thor)->dir > 1) x2 = x + 12;
@@ -610,6 +623,19 @@ int movement_zero(ACTOR *actr) {       //player control
 	y = actr->y;
 	_G(diag_flag) = 0;
 	if (actr->move_counter) actr->move_counter--;
+
+	if (_G(slipping)) {
+		if (_G(slip_cnt) == 8) play_sound(FALL, 1);
+		y += 2;
+		_G(slip_cnt)--;
+		if (!_G(slip_cnt))
+			_G(slipping) = false;
+
+		check_thor_move(x, y, actr);
+		_G(thor)->speed_count = 4;
+		return d;
+	}
+
 	if (_G(key_flag)[key_up] && _G(key_flag)[key_left]) {
 		d = 2;
 		actr->dir = d;
diff --git a/engines/got/game/special_tile.cpp b/engines/got/game/special_tile.cpp
index 8296fc0b13a..9c397722c16 100644
--- a/engines/got/game/special_tile.cpp
+++ b/engines/got/game/special_tile.cpp
@@ -42,6 +42,11 @@ int special_tile_thor(int x, int y, int icon) {
 	case 203:
 		return 0;
 	case 204:
+		if (GAME2) {
+			if (!_G(setup).f19)
+				_G(slip_flag) = true;
+			return 1;
+		}
 		return 0;
 	case 205:
 		if (!_G(diag) && _G(thor)->dir != 1)
diff --git a/engines/got/vars.h b/engines/got/vars.h
index d0b33f74992..eeecb208464 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -97,6 +97,9 @@ public:
 	Cheats _cheats;
 	Common::Queue<byte> _demoKeys;
 	bool _useItemFlag = false;
+	bool _slip_flag = false;
+	bool _slipping = false;
+	int _slip_cnt = 0;
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
 	uint _display_page = 0, _draw_page = 0;


Commit: 496e01633f629cef4b9955e1a15cc212da26f579
    https://github.com/scummvm/scummvm/commit/496e01633f629cef4b9955e1a15cc212da26f579
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added game-specific special tile logic

Changed paths:
    engines/got/game/special_tile.cpp


diff --git a/engines/got/game/special_tile.cpp b/engines/got/game/special_tile.cpp
index 9c397722c16..414dd236563 100644
--- a/engines/got/game/special_tile.cpp
+++ b/engines/got/game/special_tile.cpp
@@ -21,12 +21,15 @@
 
 #include "got/game/special_tile.h"
 #include "got/game/back.h"
+#include "got/game/object.h"
+#include "got/gfx/image.h"
 #include "got/vars.h"
 
 namespace Got {
 
 int open_door1(int y, int x);
 int cash_door1(int y, int x, int amount);
+void erase_door(int x, int y);
 
 int special_tile_thor(int x, int y, int icon) {
 	int cx, cy, f;
@@ -36,16 +39,42 @@ int special_tile_thor(int x, int y, int icon) {
 	case 201:
 		return open_door1(x, y);
 	case 202:
+		if (GAME3) {
+			if (_G(thor_info).inventory & 64) {
+				if (_G(thor_info).object == 4) {
+					erase_door(y, x);
+					delete_object();
+					return 1;
+				}
+			}
+			return 0;
+		}
+
 		if (_G(thor)->x > 300)
-			_G(end_tile) = 1;     // ending bridge
+			_G(end_tile) = 1;     // Ending bridge
 		return 1;
 	case 203:
+		if (!GAME1) {
+			if ((_G(thor_info).inventory & 64) && _G(thor_info).object == 5) {
+				odin_speaks(2012, 0);
+				delete_object();
+				_G(setup).f10 = 1;
+			} else if (!_G(setup).f10) {
+				odin_speaks(2011, 0);
+				_G(setup).f10 = 1;
+			}
+			return 1;
+		}
 		return 0;
 	case 204:
 		if (GAME2) {
 			if (!_G(setup).f19)
 				_G(slip_flag) = true;
 			return 1;
+		} else if (GAME3) {
+			if (_G(thor)->x < 4)
+				_G(end_tile) = 1;
+			return 1;
 		}
 		return 0;
 	case 205:
@@ -69,16 +98,51 @@ int special_tile_thor(int x, int y, int icon) {
 	case 210:
 		return cash_door1(x, y, 100);
 	case 211:
-		place_tile(y, x, 79);
-		_G(exit_flag) = 2;
+		if (GAME1) {
+			place_tile(y, x, 79);
+			_G(exit_flag) = 2;
+		} else if (GAME2) {
+			if (_G(thor)->dir == 0 && _G(setup).f29 && _G(setup).f21 && !_G(setup).f22) {
+				actor_visible(1);
+				actor_visible(2);
+				actor_visible(3);
+				actor_visible(4);
+				actor_visible(5);
+				Common::fill(_G(scrn).actor_invis, _G(scrn).actor_invis + 16, 0);
+				_G(thunder_flag) = 60;
+				play_sound(THUNDER, 1);
+				_G(setup).f22 = 1;
+			}
+		}
 		return 1;
 	case 212:
 	case 213:
 		return 0;
-	case 214:        //teleport tiles
+	case 214:        // Teleport tiles
 	case 215:
 	case 216:
 	case 217:
+		if ((GAME2 && icon == 217) || GAME3) {
+			cx = (_G(thor_x1) + 7) / 16;
+			cy = (_G(thor_real_y1) + 8) / 16;
+			if (_G(scrn).icon[cy][cx] == icon) {
+				_G(thor)->vunerable = STAMINA;
+				play_sound(WOOP, 0);
+
+				int nt = _G(scrn).new_level_loc[icon - 214];
+				int display_page = _G(pge);
+				int draw_page = _G(pge) ^ 1;
+
+				_G(thor)->last_x[display_page] = _G(thor)->x;
+				_G(thor)->last_y[display_page] = _G(thor)->y;
+				_G(thor)->x = (nt % 20) * 16;
+				_G(thor)->y = ((nt / 20) * 16) - 2;
+				_G(thor)->last_x[draw_page] = _G(thor)->x;
+				_G(thor)->last_y[draw_page] = _G(thor)->y;
+				return 0;
+			}
+			return 1;
+		}
 		return 0;
 	case 218:
 	case 219:


Commit: e8989c684532224d894cdd3da595eccbb465769f
    https://github.com/scummvm/scummvm/commit/e8989c684532224d894cdd3da595eccbb465769f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix adding dynamic objects and displaying them

This fixes a bug where digging with the shovel wasn't
displaying the resulting objects, so the Hypno-Stone
couldn't be obtained.

Changed paths:
    engines/got/game/back.cpp
    engines/got/game/object.cpp
    engines/got/game/object.h
    engines/got/game/script.cpp
    engines/got/views/game_content.cpp


diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index 0ba61decc5a..cae878a59ee 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -23,6 +23,7 @@
 #include "got/game/back.h"
 #include "got/game/boss1.h"
 #include "got/game/move.h"
+#include "got/game/object.h"
 #include "got/game/script.h"
 #include "got/gfx/image.h"
 #include "got/gfx/panel.h"
@@ -68,10 +69,8 @@ void show_level(int new_level) {
 	_G(level_type) = _G(scrn).type;
 
 	_G(thor)->next = 0;
-	//xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], PAGE2);
 
-	//build_screen(draw_page);
-	//show_objects(new_level, draw_page);
+	show_objects();
 	show_enemies();
 
 	if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154) _G(thor)->dir = 0;
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index 96a4a8be762..6c1dd87ba89 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -34,6 +34,21 @@ namespace Got {
 void not_enough_magic();
 void cannot_carry_more();
 
+void show_objects() {
+	int i, p;
+
+	Common::fill(_G(object_map), _G(object_map) + TILES_COUNT, 0);
+	Common::fill(_G(object_index), _G(object_index) + TILES_COUNT, 0);
+
+	for (i = 0; i < OBJECTS_COUNT; i++) {
+		if (_G(scrn).static_obj[i]) {
+			p = _G(scrn).static_x[i] + (_G(scrn).static_y[i] * TILES_X);
+			_G(object_index)[p] = i;
+			_G(object_map)[p] = _G(scrn).static_obj[i];
+		}
+	}
+}
+
 void pick_up_object(int p) {
 	int r, x, y, s;
 
diff --git a/engines/got/game/object.h b/engines/got/game/object.h
index 175c38773cb..d38de415e22 100644
--- a/engines/got/game/object.h
+++ b/engines/got/game/object.h
@@ -26,6 +26,7 @@
 
 namespace Got {
 
+extern void show_objects();
 extern void pick_up_object(int p);
 extern int drop_object(ACTOR *actr);
 extern int _drop_obj(ACTOR *actr, int o);
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 19a81ae8e12..d4b4caafc1f 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -984,34 +984,29 @@ void Scripts::scr_func3() {
 	p = (((_G(thor)->y + 8) / 16) * 20) + ((_G(thor)->x + 7) / 16);
 	y = p / 20;
 	x = p % 20;
+
 	if (y < 0 || x < 0 || y>11 || x>19) {
 		play_sound(BRAAPP, 1);
-#if 0
-		while (_G(key_flag)[key_magic])
-			rotate_pal();
-#endif
+		_G(key_flag)[key_magic] = false;
 		return;
 	}
 	if (_G(scrn).icon[y][x] < 174 || _G(scrn).icon[y][x]>178) {
 		play_sound(BRAAPP, 1);
-#if 0
-		while (_G(key_flag)[key_magic]) rotate_pal();
-#endif
+		_G(key_flag)[key_magic] = false;
 		return;
 	}
+
 	_numVar[0] = 1;
 	play_sound(WOOP, 1);
 	if (_G(current_level) == 106 && p == 69) {
 		place_tile(x, y, 220);
-#if 0
-		while (_G(key_flag)[key_magic]) rotate_pal();
-#endif
+		_G(key_flag)[key_magic] = false;
 		return;
 	}
-#if 0
-	while (_G(key_flag)[key_magic]) rotate_pal();
-#endif
+
+	_G(key_flag)[key_magic] = false;
 	place_tile(x, y, 191);
+
 	if ((g_events->getRandomNumber(99)) < 25 ||
 		(_G(current_level) == 13 && p == 150 && !_G(setup).f26 && _G(setup).f28)) {
 		if (!_G(object_map)[p] && _G(scrn).icon[y][x] >= 140) {  // nothing there and solid
@@ -1020,17 +1015,8 @@ void Scripts::scr_func3() {
 				o = 20;
 
 			_G(object_map)[p] = o;
-			_G(object_index)[p] = 31;  //actor is 3-15
-			x = (p % 20) * 16;
-			y = (p / 20) * 16;
-#ifdef TODO
-			xfput(x, y, PAGE2, (char *) objects[o - 1]);
-			xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, draw_page, 320, 320);
-			xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, display_page, 320, 320);
-			pause(30);
-#else
-			error("TODO: display/wait");
-#endif
+			_G(object_index)[p] = 31;  // actor is 3-15
+			//pause(30);
 		}
 	}
 }
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index fb8d434502b..d5defe6e530 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -220,20 +220,14 @@ void GameContent::drawBackground(GfxSurface &s) {
 }
 
 void GameContent::drawObjects(GfxSurface &s) {
-	int i, p;
+	for (int y = 0; y < TILES_Y; ++y) {
+		for (int x = 0; x < TILES_X; ++x) {
+			int p = (y * TILES_X) + x;
 
-	Common::fill(_G(object_map), _G(object_map) + TILES_COUNT, 0);
-	Common::fill(_G(object_index), _G(object_index) + TILES_COUNT, 0);
-
-	for (i = 0; i < OBJECTS_COUNT; i++) {
-		if (_G(scrn).static_obj[i]) {
-			s.blitFrom(_G(objects)[_G(scrn).static_obj[i] - 1],
-				Common::Point(_G(scrn).static_x[i] * TILE_SIZE,
-					_G(scrn).static_y[i] * TILE_SIZE));
-
-			p = _G(scrn).static_x[i] + (_G(scrn).static_y[i] * TILES_X);
-			_G(object_index)[p] = i;
-			_G(object_map)[p] = _G(scrn).static_obj[i];
+			if (_G(object_index)[p]) {
+				s.blitFrom(_G(objects)[_G(object_map)[p] - 1],
+					Common::Point(x * TILE_SIZE, y * TILE_SIZE));
+			}
 		}
 	}
 }


Commit: 1c781daf9f9131bd99434580331178a7ff4f4ce4
    https://github.com/scummvm/scummvm/commit/1c781daf9f9131bd99434580331178a7ff4f4ce4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix static object 0 not showing

Changed paths:
    engines/got/views/game_content.cpp


diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index d5defe6e530..47c394f5bfa 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -224,7 +224,7 @@ void GameContent::drawObjects(GfxSurface &s) {
 		for (int x = 0; x < TILES_X; ++x) {
 			int p = (y * TILES_X) + x;
 
-			if (_G(object_index)[p]) {
+			if (_G(object_map)[p]) {
 				s.blitFrom(_G(objects)[_G(object_map)[p] - 1],
 					Common::Point(x * TILE_SIZE, y * TILE_SIZE));
 			}


Commit: 1f953f85e1dac61ef35d779aaa33c7fea04267cd
    https://github.com/scummvm/scummvm/commit/1f953f85e1dac61ef35d779aaa33c7fea04267cd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Add boss 2 health bar

Changed paths:
    engines/got/data/defines.h
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h


diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index f6686ff4d4c..e2262d115ef 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -171,9 +171,9 @@ enum {
 #define SHIELD_MAGIC    16
 #define THUNDER_MAGIC   32
 
-#define BOSS_LEVEL1  59
-#define BOSS_LEVEL21 200
-#define BOSS_LEVEL22 118
+#define BOSS_LEVEL1 59
+#define BOSS_LEVEL2 60
+#define BOSS_LEVEL3 999
 
 //#define DEBUG 1
 //#define IDE 1
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 47c394f5bfa..099501eaca1 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -53,8 +53,9 @@ void GameContent::draw() {
 	drawObjects(s);
 	drawActors(s);
 
-	if (GAME1 && _G(current_level) == BOSS_LEVEL1)
-		drawBoss1Health(s);
+	if ((GAME1 && _G(current_level) == BOSS_LEVEL1) ||
+		(GAME2 && _G(current_level) == BOSS_LEVEL2))
+		drawBossHealth(s);
 
 	// If we're shaking the screen, render the content with the shake X/Y
 	if (_G(gameMode) == MODE_THUNDER) {
@@ -263,7 +264,7 @@ void GameContent::drawActors(GfxSurface &s) {
 		s.blitFrom(_G(objects)[10], Common::Point(_G(thor)->x, _G(thor)->y));
 }
 
-void GameContent::drawBoss1Health(GfxSurface &s) {
+void GameContent::drawBossHealth(GfxSurface &s) {
 	int i, c;
 
 	int health = _G(actor)[3].health;
diff --git a/engines/got/views/game_content.h b/engines/got/views/game_content.h
index 8f14db56de8..f0be3797ff3 100644
--- a/engines/got/views/game_content.h
+++ b/engines/got/views/game_content.h
@@ -46,7 +46,7 @@ private:
 	void drawBackground(GfxSurface &s);
 	void drawObjects(GfxSurface &s);
 	void drawActors(GfxSurface &s);
-	void drawBoss1Health(GfxSurface &s);
+	void drawBossHealth(GfxSurface &s);
 	void drawLightning(GfxSurface &s);
 	void placePixel(GfxSurface &s, int dir, int num);
 	void checkThunderShake();


Commit: ff48ca3c7d06a4f9e4f79e1e86f822c7f6277921
    https://github.com/scummvm/scummvm/commit/ff48ca3c7d06a4f9e4f79e1e86f822c7f6277921
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Hooking up boss 2 logic

Changed paths:
  A engines/got/game/boss2.cpp
  A engines/got/game/boss2.h
    engines/got/game/back.cpp
    engines/got/game/boss1.cpp
    engines/got/game/boss1.h
    engines/got/game/move_patterns.cpp
    engines/got/module.mk
    engines/got/vars.h
    engines/got/views/game.cpp
    engines/got/views/game_content.cpp


diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index cae878a59ee..d1398ada4ed 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -22,6 +22,7 @@
 #include "common/file.h"
 #include "got/game/back.h"
 #include "got/game/boss1.h"
+#include "got/game/boss2.h"
 #include "got/game/move.h"
 #include "got/game/object.h"
 #include "got/game/script.h"
@@ -154,6 +155,14 @@ void show_level_done() {
 			f = false;
 		}
 	}
+	if (GAME2 && _G(new_level) == BOSS_LEVEL2) {
+		if (!_G(setup).boss_dead[1]) {
+			if (!_G(auto_load))
+				boss_level2();
+			f = false;
+		}
+	}
+
 	if (_G(startup))
 		f = false;
 	if (f)
diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index f2799ff6f72..521f6dc65fd 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -33,11 +33,13 @@
 
 namespace Got {
 
+static int boss1_dead();
+
 int boss1_movement(ACTOR *actr) {
 	int d, x1, y1, f;
 
 	if (_G(boss_dead))
-		return boss_dead1();
+		return boss1_dead();
 
 	d = actr->last_dir;
 	if (actr->edge_counter) {
@@ -215,7 +217,7 @@ void boss_level1() {
 	music_play(5, 1);
 }
 
-int boss_dead1(void) {
+static int boss1_dead() {
 	int rep, n, x, y, r, x1, y1;
 
 	_G(hourglass_flag) = 0;
diff --git a/engines/got/game/boss1.h b/engines/got/game/boss1.h
index 2c016d6a6ce..0274e92c202 100644
--- a/engines/got/game/boss1.h
+++ b/engines/got/game/boss1.h
@@ -26,11 +26,10 @@
 
 namespace Got {
 
-// boss 1 - Snake (Jormangund)
+// Boss 1 - Snake (Jormangund)
 extern int boss1_movement(ACTOR *actr);
 extern void check_boss1_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num);
 extern void boss_level1();
-extern int boss_dead1();
 extern void closing_sequence1();
 extern void closing_sequence1_2();
 extern void closing_sequence1_3();
diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
new file mode 100644
index 00000000000..454abf512f8
--- /dev/null
+++ b/engines/got/game/boss2.cpp
@@ -0,0 +1,422 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/game/boss2.h"
+#include "got/game/back.h"
+#include "got/game/init.h"
+#include "got/game/move.h"
+#include "got/game/move_patterns.h"
+#include "got/game/status.h"
+#include "got/gfx/image.h"
+#include "got/gfx/panel.h"
+#include "got/vars.h"
+#include "got/events.h"
+#include "got/sound.h"
+
+namespace Got {
+static const byte exp[] = {
+	 61, 62, 65, 66, 69, 70, 73, 74, 77, 78,
+	 81, 82, 85, 86, 89, 90, 93, 94, 97, 98,
+	101,102,105,106,109,110,113,114,117,118,
+	121,122,125,126,129,130,133,134,137,138,
+	141,142,145,146,149,150,153,154,157,158,
+	161,162,165,166,169,170,173,174,177,178
+};
+static byte expf[60];
+static byte num_skulls;  // Hehe
+static byte num_spikes;
+static bool drop_flag;
+static byte su[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
+
+static int boss2a_movement(ACTOR *actr);
+static int boss2b_movement(ACTOR *actr);
+static int boss2_die();
+static void boss_set(int d, int x, int y);
+
+int boss2_movement(ACTOR *actr) {
+	int d, f, x;
+
+	switch (_G(setup).skill) {
+	case 0:
+		num_skulls = 3;
+		num_spikes = 5;
+		break;
+	case 1:
+		num_skulls = 6;
+		num_spikes = 8;
+		break;
+	case 2:
+		num_skulls = 9;
+		num_spikes = 11;
+		break;
+	}
+	if (_G(boss_dead))
+		return boss2_die();
+
+	if (actr->i1) {
+		if (actr->i1 == 1) return boss2a_movement(actr);
+		else return boss2b_movement(actr);
+	}
+	d = actr->last_dir;
+
+	//if(overlap(actr->x+2,actr->y+8,actr->x+30,actr->y+30,
+	//          _G(thor)->x,_G(thor)->y+4,_G(thor)->x+15,_G(thor)->y+15))
+	//  thor_damaged(actr);
+
+	x = actr->x;
+
+	f = 0;
+	if (actr->temp6) actr->temp6--;
+	if (!actr->temp6) {
+		drop_flag = false;
+		if (actr->temp5) actr->temp5--;
+		if (!actr->temp5) f = 1;
+		else {
+			if (d == 2) {
+				if (x > 18) actr->x -= 2;
+				else f = 1;
+			} else if (d == 3) {
+				if (x < 272) actr->x += 2;
+				else f = 1;
+			}
+		}
+		if (f) {
+			actr->temp5 = _G(rand1) + 60;
+			if (d == 2) d = 3;
+			else d = 2;
+		}
+	}
+
+	actr->frame_count--;
+	if (actr->frame_count <= 0) {
+		actr->next++;
+		if (actr->next > 2) actr->next = 0;
+		actr->frame_count = actr->frame_speed;
+	}
+	x = actr->x;
+	if (actr->num_shots < num_skulls && !drop_flag) {
+		if (x == 48 || x == 112 || x == 176 || x == 240) {
+			drop_flag = true;
+			_G(actor)[3].temp6 = 40;
+			//    actr->next=3;
+			actor_always_shoots(actr, 1);
+			play_sound(FALL, 0);
+			_G(actor)[actr->shot_actor].x = actr->x + 12;
+			_G(actor)[actr->shot_actor].y = actr->y + 32;
+			_G(actor)[actr->shot_actor].temp2 = 0;
+			_G(actor)[actr->shot_actor].temp3 = 4;
+			_G(actor)[actr->shot_actor].temp4 = 4;
+		}
+	}
+
+	boss_set(d, x, actr->y);
+
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+static void boss_set(int d, int x, int y) {
+	_G(actor)[4].next = _G(actor)[3].next;
+	_G(actor)[5].next = _G(actor)[3].next;
+	_G(actor)[6].next = _G(actor)[3].next;
+	_G(actor)[3].last_dir = d;
+	_G(actor)[4].last_dir = d;
+	_G(actor)[5].last_dir = d;
+	_G(actor)[6].last_dir = d;
+	_G(actor)[4].x = x + 16;
+	_G(actor)[4].y = y;
+	_G(actor)[5].x = x;
+	_G(actor)[5].y = y + 16;
+	_G(actor)[6].x = x + 16;
+	_G(actor)[6].y = y + 16;
+}
+
+void check_boss2_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
+	int rep;
+
+	if ((!_G(actor)[3].vunerable)) {
+		actor_damaged(&_G(actor)[3], _G(hammer)->strength);
+		_G(actor)[3].health -= 10;
+		if (_G(actor)[3].health == 50) {
+			play_sound(BOSS12, 1);
+#if 0
+			timer_cnt = 0;
+			while (timer_cnt < 120);
+#else
+			g_events->send("Game", GameMessage("PAUSE", 40));
+#endif
+			_G(actor)[3].i1 = 1;
+			_G(actor)[3].i2 = 0;
+			memset(expf, 0, 60);
+			for (rep = 7; rep < MAX_ACTORS; rep++)
+				if (_G(actor)[rep].used)
+					actor_destroyed(&_G(actor)[rep]);
+			_G(actor)[3].num_shots = 0;
+		} else play_sound(BOSS13, 1);
+		_G(actor)[3].speed_count = 75;
+		boss_status(_G(actor)[3].health);
+		_G(actor)[3].vunerable = 75;
+		_G(actor)[3].next = 1;
+		for (rep = 4; rep < 7; rep++) {
+			_G(actor)[rep].next = 1;
+			_G(actor)[rep].speed_count = 50;
+		}
+		if (_G(actor)[3].health == 0) {
+			_G(boss_dead) = 1;
+			for (rep = 7; rep < MAX_ACTORS; rep++)
+				if (_G(actor)[rep].used)
+					actor_destroyed(&_G(actor)[rep]);
+		}
+	}
+	x1 = x1;
+	y1 = y1;
+	x2 = x2;
+	y2 = y2;
+	actr = actr;
+	act_num = act_num;
+}
+
+void boss_level2() {
+	setup_boss(2);
+	_G(boss_active) = 1;
+	boss_status(-1);
+	music_pause();
+	play_sound(BOSS11, 1);
+	_G(timer_cnt) = 0;
+
+	drop_flag = false;
+	Common::fill(su, su + 18, 0);
+
+	g_events->send("Game", GameMessage("PAUSE", 40));
+	music_play(7, 1);
+}
+
+static int boss2_die() {
+	int rep, n, x, y, r, x1, y1;
+
+	_G(hourglass_flag) = 0;
+	_G(thunder_flag) = 0;
+	if (_G(boss_dead) == 1) {
+		REPEAT(4) {
+			x1 = _G(actor)[3 + rep].last_x[_G(pge)];
+			y1 = _G(actor)[3 + rep].last_y[_G(pge)];
+			x = _G(actor)[3 + rep].x;
+			y = _G(actor)[3 + rep].y;
+			n = _G(actor)[3 + rep].actor_num;
+			r = _G(actor)[3 + rep].rating;
+
+			_G(actor)[3 + rep] = _G(explosion);
+
+			_G(actor)[3 + rep].actor_num = n;
+			_G(actor)[3 + rep].rating = r;
+			_G(actor)[3 + rep].x = x;
+			_G(actor)[3 + rep].y = y;
+			_G(actor)[3 + rep].last_x[_G(pge)] = x1;
+			_G(actor)[3 + rep].last_x[_G(pge) ^ 1] = x;
+			_G(actor)[3 + rep].last_y[_G(pge)] = y1;
+			_G(actor)[3 + rep].last_y[_G(pge) ^ 1] = y;
+			_G(actor)[3 + rep].used = 1;
+			_G(actor)[3 + rep].vunerable = 255;
+			_G(actor)[3 + rep].move = 6;
+			_G(actor)[3 + rep].next = rep;
+			_G(actor)[3 + rep].speed = g_events->getRandomNumber(6, 8);
+			_G(actor)[3 + rep].num_shots = (10 - _G(actor)[3 + rep].speed) * 10;
+			_G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
+		}
+
+		play_sound(EXPLODE, 1);
+		_G(boss_dead)++;
+	}
+
+	return _G(actor)[3].last_dir;
+}
+
+// Boss - skull (explode)
+static int boss2a_movement(ACTOR *actr) {
+	int an, x, y, r;
+
+	next_frame(actr);
+	_G(actor)[4].next = actr->next;
+	_G(actor)[5].next = actr->next;
+	_G(actor)[6].next = actr->next;
+	actr->vunerable = 20;
+	if (actr->num_shots) return 0;
+	if (_G(actor)[5].num_shots) return 0;
+
+	play_sound(EXPLODE, 1);
+	actor_always_shoots(&_G(actor)[5], 0);
+	an = _G(actor)[5].shot_actor;
+	_G(actor)[an].move = 9;
+
+	r = _G(rand1) % 60;
+	while (expf[r]) {
+		r++;
+		if (r > 59) r = 0;
+	}
+	expf[r] = 1;
+	x = (exp[r] % 20) * 16;
+	y = (exp[r] / 20) * 16;
+	_G(actor)[an].x = x;
+	_G(actor)[an].y = y;
+
+#if 0
+	xfput(x, y, display_page, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
+	xfput(x, y, draw_page, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
+	xfput(x, y, PAGE2, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
+#endif
+	_G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
+
+	_G(actor)[3].i2++;
+	if (_G(actor)[3].i2 > 59) {
+		_G(actor)[3].i1 = 2;
+		_G(actor)[3].i2 = 0;
+		_G(actor)[3].num_moves = 3;
+	}
+
+	return 0;
+}
+
+// Boss - skull - shake
+static int boss2b_movement(ACTOR *actr) {
+	int rep, an, hx, hy, d;
+
+	if (_G(hammer)->used && _G(hammer)->move != 5) {
+		hx = _G(hammer)->x;
+		hy = _G(hammer)->y;
+		for (rep = 7; rep < 15; rep++) {
+			if (!_G(actor)[rep].used) continue;
+			if (overlap(hx + 1, hy + 1, hx + 10, hy + 10, _G(actor)[rep].x, _G(actor)[rep].y,
+				_G(actor)[rep].x + _G(actor)[rep].size_x - 1, _G(actor)[rep].y + _G(actor)[rep].size_y - 1)) {
+				_G(hammer)->move = 5;
+				d = reverse_direction(_G(hammer));
+				_G(hammer)->dir = d;
+				break;
+			}
+		}
+	}
+	if (actr->i4) {
+		actr->i4--;
+		if (!actr->i4) _G(thunder_flag) = 0;
+	}
+	if (!actr->i2) {
+		if (actr->x < 144) actr->x += 2;
+		else if (actr->x > 144) actr->x -= 2;
+		else {
+			actr->i2 = 1;
+			actr->i3 = 0;
+		}
+		goto done;
+	}
+	if (_G(actor)[4].num_shots) goto done;
+
+	if (!actr->i3) {
+		actr->i3 = g_events->getRandomNumber(2, 3);
+	}
+
+	if (actr->i3 == 2) actr->x -= 2;
+	else actr->x += 2;
+
+	if (actr->x < 20 || actr->x>270) {
+		_G(thunder_flag) = 100;
+		actr->i4 = 50;
+		play_sound(EXPLODE, 1);
+		actr->i2 = 0;
+		hx = _G(thor)->x;
+
+		Common::fill(su, su + 18, 0);
+		actor_always_shoots(&_G(actor)[4], 1);
+		an = _G(actor)[4].shot_actor;
+		hx = (_G(thor)->x / 16);
+		_G(actor)[an].x = _G(thor)->x;  //hx*16;
+		_G(actor)[an].y = g_events->getRandomNumber(15);
+
+		su[hx] = 1;
+		_G(actor)[an].next = g_events->getRandomNumber(3);
+		REPEAT(num_spikes) {
+			while (1) {
+				hx = g_events->getRandomNumber(17);
+				if (!su[hx]) break;
+			}
+			su[hx] = 1;
+			actor_always_shoots(&_G(actor)[4], 1);
+			an = _G(actor)[4].shot_actor;
+			_G(actor)[an].next = g_events->getRandomNumber(3);
+			_G(actor)[an].x = 16 + hx * 16;
+			_G(actor)[an].y = g_events->getRandomNumber(15);
+		}
+	}
+
+done:
+	next_frame(actr);
+	boss_set(actr->dir, actr->x, actr->y);
+	return 0;
+}
+
+void closing_sequence2() {
+	music_play(6, 1);
+	odin_speaks(1001, 0, "CLOSING");
+}
+
+void closing_sequence2_2() {
+	_G(thor_info).armor = 10;
+	load_new_thor();
+	_G(thor)->dir = 1;
+	_G(thor)->next = 0;
+
+	fill_score(20, "CLOSING");
+}
+
+void closing_sequence2_3() {
+	fill_health();
+	fill_magic();
+	odin_speaks(1002, 0, "CLOSING");
+}
+
+void closing_sequence2_4() {
+	LEVEL lvl;
+	int rep;
+
+	REPEAT(16) _G(scrn).actor_type[rep] = 0;
+	_G(boss_dead) = 0;
+	_G(setup).boss_dead[1] = 1;
+	_G(game_over) = 1;
+	_G(boss_active) = 0;
+	_G(scrn).type = 6;
+	//	_G(game_is_over) = 1;
+	show_level(BOSS_LEVEL2);
+
+	play_sound(ANGEL, 1);
+	place_tile(18, 10, 152);
+	place_tile(19, 10, 202);
+	actor_visible(1);
+	actor_visible(2);
+	_G(actor)[7].x = 288;
+	_G(actor)[7].y = 160;
+	_G(actor)[8].x = 304;
+	_G(actor)[8].y = 160;
+
+	lvl.load(BOSS_LEVEL2);
+	lvl.icon[6][18] = 152;
+	lvl.icon[6][19] = 202;
+	lvl.save(BOSS_LEVEL2);
+}
+
+} // namespace Got
diff --git a/engines/got/game/boss2.h b/engines/got/game/boss2.h
new file mode 100644
index 00000000000..db6731726cf
--- /dev/null
+++ b/engines/got/game/boss2.h
@@ -0,0 +1,40 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GAME_BOSS2_H
+#define GOT_GAME_BOSS2_H
+
+#include "got/data/defines.h"
+
+namespace Got {
+
+// Boss 2 - Skull (Nognir)
+extern int boss2_movement(ACTOR *actr);
+extern void check_boss2_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num);
+extern void boss_level2();
+extern void closing_sequence2();
+extern void closing_sequence2_2();
+extern void closing_sequence2_3();
+extern void closing_sequence2_4();
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index b0c201bf0e6..085e2e12f3d 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -22,6 +22,7 @@
 #include "got/game/move_patterns.h"
 #include "got/game/back.h"
 #include "got/game/boss1.h"
+#include "got/game/boss2.h"
 #include "got/game/move.h"
 #include "got/game/object.h"
 #include "got/gfx/panel.h"
@@ -146,6 +147,7 @@ int special_movement_seven(ACTOR *actr);
 int special_movement_eight(ACTOR *actr);
 int special_movement_nine(ACTOR *actr);
 int special_movement_ten(ACTOR *actr);
+int special_movement_eleven(ACTOR *actr);
 
 int (*special_movement_func[])(ACTOR *actr) = {
 	NULL,
@@ -158,11 +160,12 @@ int (*special_movement_func[])(ACTOR *actr) = {
 	special_movement_seven,
 	special_movement_eight,
 	special_movement_nine,
-	special_movement_ten
+	special_movement_ten,
+	special_movement_eleven
 };
 
 
-// check thor move
+// Check Thor move
 int check_move0(int x, int y, ACTOR *actr) {
 	int x1, x2, y1, y2;
 	int x3, x4, y3, y4;
@@ -325,7 +328,8 @@ int check_move0(int x, int y, ACTOR *actr) {
 	return 1;
 }
 
-int check_move1(int x, int y, ACTOR *actr) {   //check hammer move
+// Check hammer move
+int check_move1(int x, int y, ACTOR *actr) {   
 	int  x1, x2, y1, y2, i;
 	int  x3, y3, x4, y4;
 	int  icn, f;
@@ -377,13 +381,20 @@ int check_move1(int x, int y, ACTOR *actr) {   //check hammer move
 
 		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
 			if (_G(boss_active)) {
-				switch (_G(boss_active)) {
+				switch (_G(area)) {
 				case 1:
 					check_boss1_hit(act, x1, y1, x2, y2, i);
 					break;
+				case 2:
+					check_boss2_hit(act, x1, y1, x2, y2, i);
+					break;
+				default:
+					error("TODO: area 3");
+					break;
 				}
 			} else {
-				if (act->solid == 2 && (actr->move == 16 || actr->move == 17)) return 0;
+				if (act->solid == 2 && (actr->move == 16 || actr->move == 17))
+					return 0;
 				actor_damaged(act, actr->strength);
 			}
 			f++;
@@ -395,7 +406,8 @@ int check_move1(int x, int y, ACTOR *actr) {   //check hammer move
 	return 1;
 }
 
-int check_move2(int x, int y, ACTOR *actr) {   //check enemy move
+// Check enemy move
+int check_move2(int x, int y, ACTOR *actr) {
 	int x1, x2, y1, y2, i;
 	int x3, y3, x4, y4;
 	int icn;
@@ -469,7 +481,8 @@ int check_move2(int x, int y, ACTOR *actr) {   //check enemy move
 	return 1;
 }
 
-int check_move3(int x, int y, ACTOR *actr) {   //check enemy shot move
+// Check enemy shot move
+int check_move3(int x, int y, ACTOR *actr) {
 	int x1, x2, y1, y2;
 	int x3, x4, y3, y4, i;
 	byte icn1, icn2, icn3, icn4;
@@ -530,8 +543,8 @@ int check_move3(int x, int y, ACTOR *actr) {   //check enemy shot move
 	return 1;
 }
 
-int check_move4(int x, int y, ACTOR *actr) {   //flying enemies
-
+// Flying enemies
+int check_move4(int x, int y, ACTOR *actr) {
 	if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175) return 0;
 	if (overlap(x, y, x + actr->size_x - 1, y + actr->size_y - 1,
 		_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
@@ -606,7 +619,8 @@ int  check_thor_move(int x, int y, ACTOR *actr) {
 	return 0;
 }
 
-int movement_zero(ACTOR *actr) {       //player control
+// Player control
+int movement_zero(ACTOR *actr) {
 	int d, x, y, od;
 	d = actr->dir;
 	od = d;
@@ -791,7 +805,8 @@ int check_special_move1(int x, int y, ACTOR *actr) {
 
 //*==========================================================================
 
-int special_movement_one(ACTOR *actr) {   //block
+// Block
+int special_movement_one(ACTOR *actr) {
 	int d, x1, y1, sd;
 
 	if (_G(diag_flag)) return 0;
@@ -836,7 +851,8 @@ int special_movement_one(ACTOR *actr) {   //block
 	return 1;
 }
 
-int special_movement_two(ACTOR *actr) {   //angle
+// Angle
+int special_movement_two(ACTOR *actr) {
 	int x1, y1, x2, y2, i;
 	int x3, y3, x4, y4;
 	ACTOR *act;
@@ -874,10 +890,12 @@ int special_movement_two(ACTOR *actr) {   //angle
 	return 1;
 }
 
-int special_movement_three(ACTOR *actr) {  //yellow globe
+// Yellow globe
+int special_movement_three(ACTOR *actr) {
 	long lind;
 
-	if (_G(thunder_flag)) return 0;
+	if (_G(thunder_flag))
+		return 0;
 
 	lind = (long)_G(current_level);
 	lind = lind * 1000;
@@ -887,18 +905,17 @@ int special_movement_three(ACTOR *actr) {  //yellow globe
 	return 0;
 }
 
-int special_movement_four(ACTOR *actr) {   //peg switch
-
+// Peg switch
+int special_movement_four(ACTOR *actr) {
 	if (actr->shot_cnt != 0) return 0;
 	actr->shot_cnt = 30;
 	actr = actr;
 	_G(switch_flag) = 1;
 	return 0;
 }
-void kill_enemies(int ix, int iy);
-void remove_objects(int iy, int ix);
 
-int special_movement_five(ACTOR *actr) {    //boulder roll
+// Boulder roll
+int special_movement_five(ACTOR *actr) {
 	int d;
 
 	d = _G(thor)->dir;
@@ -930,13 +947,11 @@ int special_movement_five(ACTOR *actr) {    //boulder roll
 }
 
 int special_movement_six(ACTOR *actr) {
-
 	thor_damaged(actr);
 	return 0;
 }
 
 int special_movement_seven(ACTOR *actr) {
-
 	if (actr->shot_cnt != 0) return 0;
 	actr->shot_cnt = 30;
 	actr = actr;
@@ -945,7 +960,6 @@ int special_movement_seven(ACTOR *actr) {
 }
 
 int special_movement_eight(ACTOR *actr) {
-
 	if (_G(thor)->dir < 2 || _G(diag_flag)) return 0;
 	actr->last_dir = _G(thor)->dir;
 	actr->move = 14;
@@ -953,7 +967,6 @@ int special_movement_eight(ACTOR *actr) {
 }
 
 int special_movement_nine(ACTOR *actr) {
-
 	if (_G(thor)->dir > 1 || _G(diag_flag)) return 0;
 	actr->last_dir = _G(thor)->dir;
 	actr->move = 14;
@@ -961,26 +974,50 @@ int special_movement_nine(ACTOR *actr) {
 }
 
 int special_movement_ten(ACTOR *actr) {
+	byte &actor_ctr = GAME1 ? actr->temp6 : actr->talk_counter;
 
-	if (actr->temp6) {
-		actr->temp6--;
+	if (actor_ctr) {
+		actor_ctr--;
 		return 0;
 	}
-	if (_G(thunder_flag)) return 0;
-	if (!actr->temp6) {
-		actr->temp6 = 10;
+
+	if (_G(thunder_flag))
+		return 0;
+
+	if (!actor_ctr) {
+		actor_ctr = 10;
 		actor_speaks(actr, 0 - actr->pass_value, 0);
 	}
+
 	return 0;
 }
 
-int movement_one(ACTOR *actr) {    //no movement - frame cycle
+// Red guard
+int special_movement_eleven(ACTOR *actr) {
+	int t;
+
+	if (actr->talk_counter) {
+		actr->talk_counter--;
+		return 0;
+	}
 
+	t = actr->type;
+	actr->type = 4;
+	actor_speaks(actr, 0, 0);
+	actr->type = t;
+	actr->talk_counter = 10;
+
+	return 0;
+}
+
+// No movement - frame cycle
+int movement_one(ACTOR *actr) {
 	next_frame(actr);
 	return actr->dir;
 }
 
-int movement_two(ACTOR *actr) {     //hammer only
+// Hammer only
+int movement_two(ACTOR *actr) {
 	int d, x1, y1;
 
 	d = actr->last_dir;
@@ -1020,7 +1057,8 @@ int movement_two(ACTOR *actr) {     //hammer only
 	return d;
 }
 
-int movement_three(ACTOR *actr) {         //walk-bump-random turn
+// Walk-bump-random turn
+int movement_three(ACTOR *actr) {
 	int d, x1, y1;
 
 	d = actr->last_dir;
@@ -1059,7 +1097,8 @@ int movement_three(ACTOR *actr) {         //walk-bump-random turn
 	return d;
 }
 
-int movement_four(ACTOR *actr) {         //simple tracking
+// Simple tracking
+int movement_four(ACTOR *actr) {
 	int d, x1, y1, f;
 
 	d = actr->last_dir;
@@ -1198,8 +1237,8 @@ int movement_five(ACTOR *actr) {
 	return d;
 }
 
-int movement_six(ACTOR *actr) {   //explosion only
-
+// Explosion only
+int movement_six(ACTOR *actr) {
 	if (actr->num_shots > 0) {
 		actr->next++;
 		if (actr->next > 2) {
@@ -1210,16 +1249,18 @@ int movement_six(ACTOR *actr) {   //explosion only
 	} else {
 		actr->dead = 2;
 		actr->used = 0;
-		if (!_G(boss_dead)) if (actr->type == 2)
-			drop_object(actr);
+		if (!_G(boss_dead) && !_G(endgame))
+			if (actr->type == 2)
+				drop_object(actr);
 
 	}
+
 	next_frame(actr);
 	return 0;
 }
 
-int movement_seven(ACTOR *actr) {         //walk-bump-random turn (pause also)
-
+// Walk-bump-random turn (pause also)
+int movement_seven(ACTOR *actr) {
 	if (actr->next == 0 && actr->frame_count == actr->frame_speed) {
 		actr->speed_count = 12;
 		actr->last_dir = g_events->getRandomNumber(3);
@@ -1227,8 +1268,8 @@ int movement_seven(ACTOR *actr) {         //walk-bump-random turn (pause also)
 	return movement_three(actr);
 }
 
-int movement_eight(ACTOR *actr) {         //follow thor
-
+// Follow thor
+int movement_eight(ACTOR *actr) {
 	if (_G(thor)->x > 0) actr->x = _G(thor)->x - 1;
 	else actr->x = _G(thor)->x;
 	actr->y = _G(thor)->y;
@@ -1236,7 +1277,8 @@ int movement_eight(ACTOR *actr) {         //follow thor
 	return 0;
 }
 
-int movement_nine(ACTOR *actr) {         //4-way straight (random length) change
+// 4-way straight (random length) change
+int movement_nine(ACTOR *actr) {
 	int d, x1, y1, f;
 
 	d = actr->last_dir;
@@ -1276,7 +1318,8 @@ int movement_nine(ACTOR *actr) {         //4-way straight (random length) change
 	return d;
 }
 
-int movement_ten(ACTOR *actr) {         //vert straight (random length) change
+// Vert straight (random length) change
+int movement_ten(ACTOR *actr) {
 	int d, x1, y1, f;
 
 	d = actr->last_dir;
@@ -1320,7 +1363,8 @@ int movement_ten(ACTOR *actr) {         //vert straight (random length) change
 	return d;
 }
 
-int movement_eleven(ACTOR *actr) {         //horz only (bats)
+// Horz only (bats)
+int movement_eleven(ACTOR *actr) {
 	int d;
 
 	d = actr->last_dir;
@@ -1358,7 +1402,8 @@ int movement_eleven(ACTOR *actr) {         //horz only (bats)
 	return d;
 }
 
-int movement_twelve(ACTOR *actr) {         //horz straight until bump
+// Horz straight until bump
+int movement_twelve(ACTOR *actr) {
 	int d;
 
 	d = actr->last_dir;
@@ -1381,7 +1426,8 @@ int movement_twelve(ACTOR *actr) {         //horz straight until bump
 	return d;
 }
 
-int movement_thirteen(ACTOR *actr) {         //pause-seek (mushroom)
+// Pause-seek (mushroom)
+int movement_thirteen(ACTOR *actr) {
 	int d;
 
 	d = actr->last_dir;
@@ -1406,7 +1452,8 @@ int movement_thirteen(ACTOR *actr) {         //pause-seek (mushroom)
 	return d;
 }
 
-int movement_fourteen(ACTOR *actr) {         //move-bump-stop (boulder)
+// Move-bump-stop (boulder)
+int movement_fourteen(ACTOR *actr) {
 	int d, x1, y1;
 
 	d = actr->last_dir;
@@ -1450,12 +1497,13 @@ int movement_fourteen(ACTOR *actr) {         //move-bump-stop (boulder)
 	return d;
 }
 
-int movement_fifteen(ACTOR *actr) {    //no movement - no frame cycle
-
+// No movement - no frame cycle
+int movement_fifteen(ACTOR *actr) {
 	return actr->dir;
 }
 
-int movement_sixteen(ACTOR *actr) {     //tornado 1
+// Tornado 1
+int movement_sixteen(ACTOR *actr) {
 	int d, x1, y1;
 
 	d = actr->last_dir;
@@ -1487,7 +1535,8 @@ int movement_sixteen(ACTOR *actr) {     //tornado 1
 	return d;
 }
 
-int movement_seventeen(ACTOR *actr) {         //tornado 2
+// Tornado 2
+int movement_seventeen(ACTOR *actr) {
 	int d;
 
 	d = actr->last_dir;
@@ -1524,7 +1573,8 @@ int movement_seventeen(ACTOR *actr) {         //tornado 2
 	return d;
 }
 
-int movement_eighteen(ACTOR *actr) {    //no movement - frame cycle
+// No movement - frame cycle
+int movement_eighteen(ACTOR *actr) {
 	int d;
 
 	if (actr->temp5) {
@@ -1565,22 +1615,26 @@ int movement_eighteen(ACTOR *actr) {    //no movement - frame cycle
 	return d;
 }
 
-int movement_nineteen(ACTOR *actr) {    //no movement - frame cycle
-
+// No movement - frame cycle
+int movement_nineteen(ACTOR *actr) {
 	return movement_seven(actr);
 }
 
-int movement_twenty(ACTOR *actr) {    //boss - snake
+int movement_twenty(ACTOR *actr) {
+	if (GAME1)
+		// Boss - snake
+		return boss1_movement(actr);
 
-	return boss1_movement(actr);
+	return movement_one(actr);
 }
 
-int movement_twentyone(ACTOR *actr) {    //no movement - frame cycle
-
+// No movement - frame cycle
+int movement_twentyone(ACTOR *actr) {
 	return movement_three(actr);
 }
 
-int movement_twentytwo(ACTOR *actr) {    //spear
+// Spear
+int movement_twentytwo(ACTOR *actr) {    
 	int d;
 
 	d = actr->last_dir;
@@ -1663,7 +1717,8 @@ redo:
 	return d;
 }
 
-int movement_twentythree(ACTOR *actr) {    //spinball counter-clockwise
+// Spinball counter-clockwise
+int movement_twentythree(ACTOR *actr) {
 	int d;
 
 	d = actr->last_dir;
@@ -1754,7 +1809,8 @@ int movement_twentythree(ACTOR *actr) {    //spinball counter-clockwise
 	return d;
 }
 
-int movement_twentyfour(ACTOR *actr) {    //spinball  clockwise
+// Spinball  clockwise
+int movement_twentyfour(ACTOR *actr) {
 	int d;
 
 	d = actr->last_dir;
@@ -1845,7 +1901,8 @@ int movement_twentyfour(ACTOR *actr) {    //spinball  clockwise
 	return d;
 }
 
-int movement_twentyfive(ACTOR *actr) {         //acid puddle
+// Acid puddle
+int movement_twentyfive(ACTOR *actr) {
 	int i, ret;
 
 	if (actr->temp2) {
@@ -1868,12 +1925,16 @@ int movement_twentyfive(ACTOR *actr) {         //acid puddle
 	return movement_three(actr);
 }
 
-int movement_twentysix(ACTOR *actr) {         //
+int movement_twentysix(ACTOR *actr) {
+	if (GAME2)
+		return boss2_movement(actr);
 
 	return movement_one(actr);
 }
 
-int movement_twentyseven(ACTOR *actr) {         //
+int movement_twentyseven(ACTOR *actr) {
+	if (GAME2)
+		return boss2_movement(actr);
 
 	return movement_one(actr);
 }
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 9d9b0bc8108..9524c8b5e1c 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -14,6 +14,7 @@ MODULE_OBJS = \
 	data/setup.o \
 	data/thor_info.o \
 	game/boss1.o \
+	game/boss2.o \
 	game/back.o \
 	game/init.o \
 	game/main.o \
diff --git a/engines/got/vars.h b/engines/got/vars.h
index eeecb208464..901e77d8f35 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -160,7 +160,8 @@ public:
 	ACTOR _explosion;
 	ACTOR _sparkle;
 	THOR_INFO _thor_info;
-	int _boss_dead = 0;
+	bool _boss_dead = false;
+	bool _endgame = false;
 
 	int _warp_flag = 0;
 
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 7aab6cf3497..5b018449b6a 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -27,6 +27,7 @@
 #include "got/metaengine.h"
 #include "got/vars.h"
 #include "got/game/boss1.h"
+#include "got/game/boss2.h"
 
 namespace Got {
 namespace Views {
@@ -56,6 +57,8 @@ bool Game::msgKeypress(const KeypressMessage &msg) {
 		// Hack used for testing end-game sequence
 		if (GAME1 && _G(current_level) == BOSS_LEVEL1)
 			closing_sequence1();
+		else if (GAME2 && _G(current_level) == BOSS_LEVEL2)
+			closing_sequence2();
 		break;
 
 	case Common::KEYCODE_s:
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 099501eaca1..aa450bdf28d 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -22,6 +22,7 @@
 #include "got/views/game_content.h"
 #include "got/game/back.h"
 #include "got/game/boss1.h"
+#include "got/game/boss2.h"
 #include "got/game/move.h"
 #include "got/game/move_patterns.h"
 #include "got/game/object.h"
@@ -115,7 +116,7 @@ void GameContent::draw() {
 #define MSG(STR, METHOD) else if (msg._name == STR) { METHOD(); return true; }
 
 bool GameContent::msgGame(const GameMessage &msg) {
-	if (msg._name == "BOSS_PAUSE") {
+	if (msg._name == "PAUSE") {
 		_G(gameMode) = MODE_PAUSE;
 		_pauseCtr = msg._value;
 		return true;
@@ -672,6 +673,8 @@ void GameContent::lightningCountdownDone() {
 }
 
 void GameContent::closingSequence() {
+	const int area = _G(area);
+
 	switch (++_closingStateCtr) {
 	case 1:
 		// Convert health/magic/jewels to score
@@ -679,16 +682,44 @@ void GameContent::closingSequence() {
 		break;
 
 	case 2:
-		closing_sequence1_2();
+		switch (area) {
+		case 1:
+			closing_sequence1_2();
+			break;
+		case 2:
+			closing_sequence2_2();
+			break;
+		default:
+			break;
+		}
 		break;
 
 	case 3:
-		closing_sequence1_3();
+		switch (area) {
+		case 1:
+			closing_sequence1_3();
+			break;
+		case 2:
+			closing_sequence2_3();
+			break;
+		default:
+			break;
+		}
 		break;
 
 	case 4:
 		_closingStateCtr = 0;
-		closing_sequence1_4();
+
+		switch (area) {
+		case 1:
+			closing_sequence1_4();
+			break;
+		case 2:
+			closing_sequence2_4();
+			break;
+		default:
+			break;
+		}
 		break;
 
 	default:


Commit: a4d02a1cbc48678d6de04283d6f98d46d2c077ed
    https://github.com/scummvm/scummvm/commit/a4d02a1cbc48678d6de04283d6f98d46d2c077ed
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Handle Bifrost ending the way the original did it

Changed paths:
    engines/got/game/special_tile.cpp
    engines/got/views/game_content.cpp


diff --git a/engines/got/game/special_tile.cpp b/engines/got/game/special_tile.cpp
index 414dd236563..04873bd9411 100644
--- a/engines/got/game/special_tile.cpp
+++ b/engines/got/game/special_tile.cpp
@@ -23,6 +23,7 @@
 #include "got/game/back.h"
 #include "got/game/object.h"
 #include "got/gfx/image.h"
+#include "got/events.h"
 #include "got/vars.h"
 
 namespace Got {
@@ -50,8 +51,14 @@ int special_tile_thor(int x, int y, int icon) {
 			return 0;
 		}
 
-		if (_G(thor)->x > 300)
-			_G(end_tile) = 1;     // Ending bridge
+		if (_G(thor)->x > 300 && g_events->focusedView()->getName() == "Game") {
+			// Ending bridge
+			_G(end_tile) = 1;
+
+			// TODO: Show high score table rather than going straight to main menu
+			Gfx::fade_out();
+			g_events->send("TitleBackground", GameMessage("MAIN_MENU"));
+		}
 		return 1;
 	case 203:
 		if (!GAME1) {
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index aa450bdf28d..39db606ab41 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -441,14 +441,6 @@ void GameContent::checkForAreaChange() {
 		}
 
 	} else if (_G(new_level) != _G(current_level)) {
-		// Check for leaving level after defeating end boss
-		if (GAME1 && _G(current_level) == BOSS_LEVEL1) {
-			// TODO: Implement high score view original had, and show it
-			fadeOut();
-			send("TitleBackground", GameMessage("MAIN_MENU"));
-			return;
-		}
-
 		// Area transition beginning
 		_G(thor)->show = 0;
 		_G(thor)->used = 0;


Commit: 402eda6b16c67ba2bd0dcef852f085d35155dd4b
    https://github.com/scummvm/scummvm/commit/402eda6b16c67ba2bd0dcef852f085d35155dd4b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Allow actions during boss 2 fight thunder

Changed paths:
    engines/got/views/game.cpp
    engines/got/views/game_content.cpp


diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 5b018449b6a..1cf7ad7983a 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -45,7 +45,7 @@ bool Game::msgFocus(const FocusMessage &msg) {
 }
 
 bool Game::msgKeypress(const KeypressMessage &msg) {
-	if (_G(gameMode) != MODE_NORMAL)
+	if (_G(gameMode) != MODE_NORMAL && _G(gameMode) != MODE_THUNDER)
 		return false;
 
 	switch (msg.keycode) {
@@ -77,7 +77,7 @@ bool Game::msgKeypress(const KeypressMessage &msg) {
 }
 
 bool Game::msgAction(const ActionMessage &msg) {
-	if (_G(gameMode) != MODE_NORMAL)
+	if (_G(gameMode) != MODE_NORMAL && _G(gameMode) != MODE_THUNDER)
 		return false;
 
 	switch (msg._action) {
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 39db606ab41..1fca0da632b 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -139,6 +139,7 @@ bool GameContent::tick() {
 
 	switch (_G(gameMode)) {
 	case MODE_NORMAL:
+	case MODE_THUNDER:
 		checkSwitchFlag();
 		checkForItem();
 		moveActors();


Commit: 3316ff6dafe1ee69332d54555b6ed8585196f04a
    https://github.com/scummvm/scummvm/commit/3316ff6dafe1ee69332d54555b6ed8585196f04a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Properly reset state variables when starting new area

Changed paths:
    engines/got/game/init.cpp


diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index 0ab6fc20bf8..41800cc62c7 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -107,9 +107,12 @@ void initialize_game() {
 //		fade_in();
 		_G(sound).music_play(_G(level_type), 1);
 	}
-	_G(auto_load) = 0;
 
+	_G(auto_load) = false;
 	_G(startup) = false;
+	_G(end_tile) = false;
+	_G(boss_dead) = false;
+	_G(game_over) = false;
 }
 
 void deinitialize_game() {


Commit: cd42ea6fb7ba107a150440e3e5789da094b41c1e
    https://github.com/scummvm/scummvm/commit/cd42ea6fb7ba107a150440e3e5789da094b41c1e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Hooking up part 3 boss and game logic

Changed paths:
  A engines/got/game/boss3.cpp
  A engines/got/game/boss3.h
    engines/got/game/boss2.cpp
    engines/got/game/init.cpp
    engines/got/game/move_patterns.cpp
    engines/got/got.cpp
    engines/got/module.mk
    engines/got/vars.cpp
    engines/got/vars.h


diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index 454abf512f8..8382a517a20 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -32,6 +32,7 @@
 #include "got/sound.h"
 
 namespace Got {
+
 static const byte exp[] = {
 	 61, 62, 65, 66, 69, 70, 73, 74, 77, 78,
 	 81, 82, 85, 86, 89, 90, 93, 94, 97, 98,
diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
new file mode 100644
index 00000000000..3c6ec30ed89
--- /dev/null
+++ b/engines/got/game/boss3.cpp
@@ -0,0 +1,651 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "got/game/boss3.h"
+#include "got/game/back.h"
+#include "got/game/init.h"
+#include "got/game/move.h"
+#include "got/game/move_patterns.h"
+#include "got/game/status.h"
+#include "got/gfx/image.h"
+#include "got/gfx/panel.h"
+#include "got/vars.h"
+#include "got/events.h"
+#include "got/sound.h"
+
+namespace Got {
+
+#define LFC 10
+
+int  boss_mode;
+int  num_pods, num_pods1;
+byte pod_speed;
+byte exp[4][8] = {
+			{126,127,128,129,130,131,132,133},
+			{146,147,148,149,150,151,152,153},
+			{166,167,168,169,170,171,172,173},
+			{186,187,188,189,190,191,192,193} };
+
+byte expf[4][8];
+byte exprow;
+byte expcnt;
+
+static int boss_die();
+static void check_boss_hit();
+static void boss_change_mode();
+
+static void set_boss(ACTOR *actr) {
+	_G(actor)[4].next = actr->next;
+	_G(actor)[5].next = actr->next;
+	_G(actor)[6].next = actr->next;
+
+	_G(actor)[4].last_dir = actr->dir;
+	_G(actor)[5].last_dir = actr->dir;
+	_G(actor)[6].last_dir = actr->dir;
+	_G(actor)[4].dir = actr->dir;
+	_G(actor)[5].dir = actr->dir;
+	_G(actor)[6].dir = actr->dir;
+
+	_G(actor)[4].x = actr->x + 16;
+	_G(actor)[4].y = actr->y;
+	_G(actor)[5].x = actr->x;
+	_G(actor)[5].y = actr->y + 16;
+	_G(actor)[6].x = actr->x + 16;
+	_G(actor)[6].y = actr->y + 16;
+}
+
+// Boss - loki-2
+static int boss_movement_one(ACTOR *actr) {
+	int rx, ry, i, numPods = 0;
+
+	actr->num_moves = 2;
+	pod_speed = 2;
+
+	switch (_G(setup).skill) {
+	case 0:
+		numPods = 3;
+		break;
+	case 1:
+		numPods = 5;
+		break;
+	case 2:
+		numPods = 8;
+		break;
+	}
+
+	if (!actr->temp1) {
+		// Disappear
+		actr->dir = 1;
+		actr->frame_count = LFC;
+		actr->next = 0;
+		actr->temp1 = 1;
+		actr->i6 = 1;
+		actr->solid |= 128;
+		_G(actor)[4].solid |= 128;
+		_G(actor)[5].solid |= 128;
+		_G(actor)[6].solid |= 128;
+		play_sound(EXPLODE, 1);
+		goto done;
+	}
+	if (actr->i6) {
+		// Fade out
+		actr->frame_count--;
+		if (actr->frame_count <= 0) {
+			actr->next++;
+			if (actr->next > 2) {
+				actr->i6 = 0;
+				actr->temp3 = 160;
+			}
+			actr->frame_count = 3;
+		}
+		goto done1;
+	}
+	if (actr->temp3 > 1) {
+		actr->temp3--;
+		goto done1;
+	} else if (actr->temp3) {
+		for (i = 0; i < num_pods1; i++)
+			if (_G(actor)[19 + i].used)
+				goto done1;
+
+		while (1) {
+			rx = g_events->getRandomNumber(255) + 16;
+			ry = g_events->getRandomNumber(143);
+			if (!overlap(rx, ry, rx + 32, ry + 32, _G(thor_x1), _G(thor_y1),
+					_G(thor_x2), _G(thor_y2)))
+				break;
+		}
+
+		actr->x = rx;
+		actr->y = ry;
+		actr->frame_count = LFC;
+		actr->temp4 = 40;
+		actr->temp3 = 0;
+		play_sound(EXPLODE, 1);
+		goto done1;
+	}
+
+	if (actr->temp4) {
+		// Fade in
+		actr->frame_count--;
+		if (actr->frame_count <= 0) {
+			actr->next--;
+			if (actr->next > 254) {
+				actr->next = 0;
+				actr->dir = 0;
+				actr->temp4 = 0;
+				actr->temp5 = 80;
+				actr->solid &= 0x7f;
+				_G(actor)[4].solid &= 0x7f;
+				_G(actor)[5].solid &= 0x7f;
+				_G(actor)[6].solid &= 0x7f;
+			}
+
+			actr->frame_count = 3;
+		}
+		goto done1;
+	}
+
+	if (actr->temp5) {
+		// Shoot
+		actr->temp5--;
+		if (actr->temp5 == 20) {
+			actr->next = 3;
+			goto done1;
+		}
+		if (!actr->temp5) {
+			if (_G(actor)[4].num_shots < _G(actor)[4].shots_allowed) {
+				actor_always_shoots(&_G(actor)[4], 0);
+				_G(actor)[_G(actor)[4].shot_actor].num_moves = pod_speed;
+				_G(actor)[_G(actor)[4].shot_actor].x = actr->x + 8;
+				_G(actor)[_G(actor)[4].shot_actor].y = actr->y + 16;
+				_G(actor)[_G(actor)[4].shot_actor].temp5 = 0;
+				for (i = 0; i < numPods; i++) memcpy(&_G(actor)[20 + i], &_G(actor)[19], 256);
+				num_pods1 = numPods;
+				actr->temp1 = 0;
+			}
+		}
+
+		if (actr->temp5 < 31)
+			goto done1;
+	}
+
+done:
+	actr->frame_count--;
+	if (actr->frame_count <= 0) {
+		actr->next++;
+		if (actr->next > 2)
+			actr->next = 0;
+		actr->frame_count = LFC;
+	}
+done1:
+	set_boss(actr);
+	return actr->dir;
+}
+
+// Boss - Loki-1
+int boss3_movement(ACTOR *actr) {
+	int d, x1, y1, f, ox, oy;
+
+	if (actr->temp2)
+		actr->temp2--;
+	if (_G(boss_dead))
+		return boss_die();
+	check_boss_hit();
+
+	if (!boss_mode) return boss_movement_one(actr);
+	num_pods1 = 10;
+	switch (_G(setup).skill) {
+	case 0:
+		actr->num_moves = 3;
+		actr->speed = 2;
+		break;
+	case 1:
+		actr->num_moves = 2;
+		actr->speed = 1;
+		break;
+	case 2:
+		actr->num_moves = 5;
+		actr->speed = 2;
+		break;
+	}
+
+	d = actr->last_dir;
+	actr->temp3++;
+
+	f = 0;
+	if (actr->temp4) {
+		actr->temp4--;
+		if (!actr->temp4) {
+			actr->temp3 = 0;
+			_G(actor)[3].frame_speed = 4;
+			_G(actor)[3].dir = 0;
+			_G(actor)[3].last_dir = 0;
+			_G(actor)[3].next = 3;
+			_G(actor)[4].dir = 0;
+			_G(actor)[4].last_dir = 0;
+			_G(actor)[4].next = 3;
+		}
+		goto skip_move;
+	}
+
+	if (actr->edge_counter) actr->edge_counter--;
+	else goto new_dir;
+
+	if (overlap(actr->x + 2, actr->y + 8, actr->x + 30, actr->y + 30,
+		_G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15))
+		thor_damaged(actr);
+
+	ox = actr->x;
+	oy = actr->y;
+	switch (actr->temp5) {
+	case 0:
+		x1 = _G(actor)[3].x;
+		y1 = _G(actor)[3].y - 2;
+		if (!check_move2(x1, y1, &_G(actor)[3])) {
+			f = 1;
+			break;
+		}
+		if (!check_move2(x1 + 16, y1, &_G(actor)[4])) f = 1;
+		actr->y = oy - 2;
+		break;
+	case 1:
+		x1 = _G(actor)[5].x;
+		y1 = _G(actor)[5].y + 2;
+		if (!check_move2(x1, y1, &_G(actor)[5])) {
+			f = 1;
+			break;
+		}
+		if (!check_move2(x1 + 16, y1, &_G(actor)[6])) f = 1;
+		actr->y = oy + 2;
+		break;
+	case 2:
+		x1 = _G(actor)[3].x - 2;
+		y1 = _G(actor)[3].y;
+		if (!check_move2(x1, y1, &_G(actor)[3])) {
+			f = 1;
+			break;
+		}
+		if (!check_move2(x1, y1 + 16, &_G(actor)[5])) f = 1;
+		actr->x = ox - 2;
+		break;
+	case 3:
+		x1 = _G(actor)[4].x + 2;
+		y1 = _G(actor)[4].y;
+		if (!check_move2(x1, y1, &_G(actor)[4])) {
+			f = 1;
+			break;
+		}
+		if (!check_move2(x1, y1 + 16, &_G(actor)[6])) f = 1;
+		actr->x = ox + 2;
+		break;
+	case 4:               //ul
+		x1 = _G(actor)[3].x - 2;
+		y1 = _G(actor)[3].y - 2;
+		if (!check_move2(x1, y1, &_G(actor)[3])) {
+			f = 1;
+			break;
+		}
+		actr->x = ox - 2;
+		actr->y = oy - 2;
+		break;
+	case 5:
+		x1 = _G(actor)[4].x + 2;
+		y1 = _G(actor)[4].y - 2;
+		if (!check_move2(x1, y1, &_G(actor)[4])) {
+			f = 1;
+			break;
+		}
+		actr->x = ox + 2;
+		actr->y = oy - 2;
+		break;
+	case 6:
+		x1 = _G(actor)[6].x + 2;
+		y1 = _G(actor)[6].y + 2;
+		if (!check_move2(x1, y1, &_G(actor)[6])) {
+			f = 1;
+			break;
+		}
+		actr->x = ox + 2;
+		actr->y = oy + 2;
+		break;
+	case 7:
+		x1 = _G(actor)[5].x - 2;
+		y1 = _G(actor)[5].y + 2;
+		if (!check_move2(x1, y1, &_G(actor)[5])) {
+			f = 1;
+			break;
+		}
+		actr->x = ox - 2;
+		actr->y = oy + 2;
+		break;
+	}
+	actr->frame_count--;
+	if (actr->frame_count <= 0) {
+		actr->next++;
+		if (actr->next > 2) actr->next = 0;
+		actr->frame_count = 30;
+	}
+
+skip_move:
+
+	set_boss(actr);
+	if (!f) goto done;
+
+new_dir:
+	if (actr->temp3 < 120) goto new_dir1;
+	_G(actor)[3].frame_speed = 8;
+	_G(actor)[3].next = 3;
+	_G(actor)[4].next = 3;
+	actr->temp4 = 120;
+	actor_always_shoots(actr, 0);
+	_G(actor)[actr->shot_actor].x = actr->x + 8;
+	_G(actor)[actr->shot_actor].y = actr->y - 8;
+	_G(actor)[actr->shot_actor].temp1 = g_events->getRandomNumber(90, 189);
+	_G(actor)[actr->shot_actor].temp5 = 30;
+	_G(actor)[actr->shot_actor].speed = 2;
+	play_sound(BOSS12, 1);
+
+new_dir1:
+	actr->temp5 = _G(rand1) % 8;
+	actr->edge_counter = _G(rand2) + 60;
+
+done:
+	if (actr->directions == 1) return 0;
+	return d;
+}
+
+static void check_boss_hit() {
+	int rep;
+
+	if (_G(actor)[3].solid & 128) {
+		for (rep = 3; rep < 7; rep++) _G(actor)[rep].magic_hit = 0;
+		return;
+	}
+	if (_G(actor)[3].magic_hit || _G(actor)[4].magic_hit ||
+		_G(actor)[5].magic_hit || _G(actor)[6].magic_hit) {
+		if (!_G(actor)[3].temp2) {
+			actor_damaged(&_G(actor)[3], 10);
+
+			if (_G(cheat) && _G(key_flag)[_Z])
+				_G(actor)[3].health -= 50;
+			else
+				_G(actor)[3].health -= 10;
+			_G(actor)[3].speed_count = 50;
+
+			boss_status(_G(actor)[3].health);
+			_G(actor)[3].vunerable = 50;
+			play_sound(BOSS13, 1);
+
+			for (rep = 4; rep < 7; rep++) {
+				_G(actor)[rep].magic_hit = 0;
+				_G(actor)[rep].next = 1;
+				_G(actor)[rep].speed_count = 50;
+			}
+
+			if (_G(actor)[3].health == 0) {
+				_G(boss_dead) = 1;
+				for (rep = 7; rep < MAX_ACTORS; rep++)
+					if (_G(actor)[rep].used)
+						actor_destroyed(&_G(actor)[rep]);
+			}
+
+			if (_G(actor)[3].health == 50) {
+				boss_change_mode();
+				_G(actor)[3].temp1 = 0;
+				_G(actor)[3].temp2 = 0;
+				_G(actor)[3].temp3 = 0;
+				_G(actor)[3].temp4 = 0;
+				_G(actor)[3].temp5 = 0;
+				_G(actor)[3].i6 = 0;
+				_G(actor)[3].speed_count = 2;
+			} else {
+				_G(actor)[3].temp2 = 40;
+			}
+		}
+		for (rep = 3; rep < 7; rep++)
+			_G(actor)[rep].magic_hit = 0;
+	}
+}
+
+static void boss_change_mode() {
+	if (!_G(boss_intro2)) {
+		Gfx::Pics loki("FACE18", 262);
+		execute_script(1003, loki);
+		d_restore();
+		_G(boss_intro2) = true;
+	}
+	boss_mode = 0;
+}
+
+void boss_level3() {
+	setup_boss(3);
+	_G(boss_active) = 1;
+	boss_status(-1);
+	music_pause();
+	play_sound(BOSS11, 1);
+	_G(timer_cnt) = 0;
+
+	g_events->send("Game", GameMessage("PAUSE", 40));
+
+	if (!_G(boss_intro1)) {
+		Gfx::Pics loki("FACE18", 262);
+		execute_script(1002, loki);
+		d_restore();
+		_G(boss_intro1) = true;
+	}
+
+	music_play(7, 1);
+	_G(apple_drop) = 0;
+	boss_mode = 1;
+}
+
+static int boss_die() {
+	int rep, n, x, y, r, x1, y1;
+
+	if (_G(boss_dead) == 1) {
+		REPEAT(4) {
+			x1 = _G(actor)[3 + rep].last_x[_G(pge)];
+			y1 = _G(actor)[3 + rep].last_y[_G(pge)];
+			x = _G(actor)[3 + rep].x;
+			y = _G(actor)[3 + rep].y;
+			n = _G(actor)[3 + rep].actor_num;
+			r = _G(actor)[3 + rep].rating;
+
+			_G(actor)[3 + rep] = _G(explosion);
+
+			_G(actor)[3 + rep].actor_num = n;
+			_G(actor)[3 + rep].rating = r;
+			_G(actor)[3 + rep].x = x;
+			_G(actor)[3 + rep].y = y;
+			_G(actor)[3 + rep].last_x[_G(pge)] = x1;
+			_G(actor)[3 + rep].last_x[_G(pge) ^ 1] = x;
+			_G(actor)[3 + rep].last_y[_G(pge)] = y1;
+			_G(actor)[3 + rep].last_y[_G(pge) ^ 1] = y;
+			_G(actor)[3 + rep].used = 1;
+			_G(actor)[3 + rep].vunerable = 255;
+			_G(actor)[3 + rep].move = 6;
+			_G(actor)[3 + rep].next = rep;
+			_G(actor)[3 + rep].speed = g_events->getRandomNumber(6, 8);
+			_G(actor)[3 + rep].num_shots = (10 - _G(actor)[3 + rep].speed) * 10;
+			_G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
+		}
+
+		play_sound(EXPLODE, 1);
+		_G(boss_dead)++;
+	}
+
+	return _G(actor)[3].last_dir;
+}
+
+void closing_sequence3() {
+	music_play(6, 1);
+	odin_speaks(1001, 0, "CLOSING");
+}
+
+void closing_sequence3_2() {
+	fill_score(20, "CLOSING");
+}
+
+void closing_sequence3_3() {
+	int rep;
+
+	fill_health();
+	fill_magic();
+
+	REPEAT(16) _G(scrn).actor_type[rep] = 0;
+	_G(boss_dead) = 0;
+	_G(setup).boss_dead[2] = 1;
+	_G(game_over) = 1;
+	_G(boss_active) = 0;
+	_G(scrn).type = 6;
+	show_level(BOSS_LEVEL3);
+
+	_G(exit_flag) = 0;
+	music_pause();
+
+	Gfx::fade_out();
+	_G(new_level) = 106;
+	_G(thor)->x = 152;
+	_G(thor)->y = 160;
+	_G(thor)->dir = 1;
+	//_G(game_is_over) = 1;
+}
+
+void ending_screen() {
+#ifdef TODO
+	int i;
+
+	for (i = 3; i < MAX_ACTORS; i++) _G(actor)[i].move = 1;
+	fade_in();
+	music_play(6, 1);
+	_G(timer_cnt) = 0;
+	while (_G(timer_cnt) < 180) rotate_pal();
+	memset(expf, 0, 32);
+	_G(endgame) = 1;
+	exprow = 0;
+	expcnt = 0;
+	memcpy(&_G(actor)[34], &explosion, sizeof(ACTOR));
+	_G(actor)[34].used = 0;
+	_G(actor)[34].speed = 2;
+	_G(actor)[34].speed_count = _G(actor)[34].speed;
+	_G(actor)[34].num_shots = 3;  //used to reverse explosion
+	_G(actor)[34].vunerable = 255;
+	_G(actor)[34].i2 = 6;
+#else
+	error("TODO: ending_screen");
+#endif
+}
+
+// Explode
+int endgame_one() {
+	int x, y, r;
+
+	if (_G(actor)[34].i2) {
+		_G(actor)[34].i2--;
+		return 0;
+	}
+
+	_G(actor)[34].i2 = 6;
+	play_sound(EXPLODE, 1);
+
+	r = _G(rand1) % 32;
+	while (expf[r / 8][r % 8]) {
+		r++;
+		if (r > 31) r = 0;
+	}
+	expf[r / 8][r % 8] = 1;
+	x = (exp[r / 8][r % 8] % 20) * 16;
+	y = (exp[r / 8][r % 8] / 20) * 16;
+	_G(actor)[34].x = x;
+	_G(actor)[34].y = y;
+	_G(actor)[34].used = 1;
+	_G(actor)[34].next = 0;
+	_G(actor)[34].num_shots = 3;
+
+	_G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
+
+	_G(endgame)++;
+	if (_G(endgame) > 32) {
+		_G(actor)[34].used = 0;
+		_G(endgame) = 0;
+	}
+	return 1;
+}
+
+// Explode
+int endgame_movement() {
+	int x, y, r;
+
+	if (!_G(endgame)) return 0;
+	if (expcnt > 3) {
+		endgame_one();
+		return 0;
+	}
+	if (_G(actor)[34].i2) {
+		_G(actor)[34].i2--;
+		return 0;
+	}
+	_G(actor)[34].i2 = 6;
+	play_sound(EXPLODE, 1);
+
+	r = _G(rand1) % 8;
+	while (expf[exprow][r]) {
+		r++;
+		if (r > 7) r = 0;
+	}
+	expf[exprow][r] = 1;
+	x = (exp[exprow][r] % 20) * 16;
+	y = (exp[exprow][r] / 20) * 16;
+	_G(actor)[34].x = x;
+	_G(actor)[34].y = y;
+	_G(actor)[34].used = 1;
+	_G(actor)[34].next = 0;
+	_G(actor)[34].num_shots = 3;
+
+	_G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
+	_G(scrn).icon[(y / 16) - 4][x / 16] = _G(scrn).bg_color;
+
+	_G(endgame)++;
+	if (_G(endgame) > 8) {
+		_G(endgame) = 1;
+		exprow++;
+		expcnt++;
+		if (expcnt > 3) {
+			memset(expf, 0, 32);
+		}
+#if TODO
+		xget(96, (2 + (exprow - 1)) * 16, 224, (6 + (exprow - 1)) * 16, PAGE0, lzss_buff, 0);
+		xfarput(96, (3 + (exprow - 1)) * 16, PAGE0, lzss_buff);
+		xfarput(96, (3 + (exprow - 1)) * 16, PAGE1, lzss_buff);
+		xfarput(96, (3 + (exprow - 1)) * 16, PAGE2, lzss_buff);
+		xget(96, 16, 224, 32, PAGE0, lzss_buff, 0);
+		xfarput(96, (2 + (exprow - 1)) * 16, PAGE0, lzss_buff);
+		xfarput(96, (2 + (exprow - 1)) * 16, PAGE1, lzss_buff);
+		xfarput(96, (2 + (exprow - 1)) * 16, PAGE2, lzss_buff);
+#else
+		error("TODO: endgame_movement");
+#endif
+	}
+	return 1;
+}
+
+} // namespace Got
diff --git a/engines/got/game/boss3.h b/engines/got/game/boss3.h
new file mode 100644
index 00000000000..86c16a7fcc2
--- /dev/null
+++ b/engines/got/game/boss3.h
@@ -0,0 +1,39 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_GAME_BOSS3_H
+#define GOT_GAME_BOSS3_H
+
+#include "got/data/defines.h"
+
+namespace Got {
+
+// Boss 3 - Loki
+extern int boss3_movement(ACTOR *actr);
+extern void boss_level3();
+extern void closing_sequence3();
+extern void closing_sequence3_2();
+extern void closing_sequence3_3();
+extern void closing_sequence3_4();
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index 41800cc62c7..2ad6b8b1803 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -108,11 +108,8 @@ void initialize_game() {
 		_G(sound).music_play(_G(level_type), 1);
 	}
 
-	_G(auto_load) = false;
+	g_vars->resetEndgameFlags();
 	_G(startup) = false;
-	_G(end_tile) = false;
-	_G(boss_dead) = false;
-	_G(game_over) = false;
 }
 
 void deinitialize_game() {
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 085e2e12f3d..f3688fc2d78 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -23,6 +23,7 @@
 #include "got/game/back.h"
 #include "got/game/boss1.h"
 #include "got/game/boss2.h"
+#include "got/game/boss3.h"
 #include "got/game/move.h"
 #include "got/game/object.h"
 #include "got/gfx/panel.h"
@@ -380,7 +381,7 @@ int check_move1(int x, int y, ACTOR *actr) {
 		y4 = act->y + act->size_y - 1;
 
 		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
-			if (_G(boss_active)) {
+			if (_G(boss_active) && !GAME3) {
 				switch (_G(area)) {
 				case 1:
 					check_boss1_hit(act, x1, y1, x2, y2, i);
@@ -389,7 +390,7 @@ int check_move1(int x, int y, ACTOR *actr) {
 					check_boss2_hit(act, x1, y1, x2, y2, i);
 					break;
 				default:
-					error("TODO: area 3");
+					// Area 3 boss Loki isn't checked here
 					break;
 				}
 			} else {
@@ -1928,6 +1929,8 @@ int movement_twentyfive(ACTOR *actr) {
 int movement_twentysix(ACTOR *actr) {
 	if (GAME2)
 		return boss2_movement(actr);
+	if (GAME3)
+		return boss3_movement(actr);
 
 	return movement_one(actr);
 }
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index d2f9faccf5e..9c2e30cf018 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -154,6 +154,8 @@ void GotEngine::savegameLoaded() {
 	_G(thor)->speed_count = 6;
 	load_new_thor();
 
+	g_vars->resetEndgameFlags();
+
 	if (!_G(music_flag))
 		_G(setup).music = 0;
 	if (!_G(sound_flag))
diff --git a/engines/got/module.mk b/engines/got/module.mk
index 9524c8b5e1c..bad43cada34 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -15,6 +15,7 @@ MODULE_OBJS = \
 	data/thor_info.o \
 	game/boss1.o \
 	game/boss2.o \
+	game/boss3.o \
 	game/back.o \
 	game/init.o \
 	game/main.o \
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index b02592914be..99912f05dc8 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -112,4 +112,12 @@ void Vars::clearKeyFlags() {
 	Common::fill(_key_flag, _key_flag + 100, 0);
 }
 
+void Vars::resetEndgameFlags() {
+	_auto_load = false;
+	_end_tile = false;
+	_boss_dead = false;
+	_game_over = false;
+	_boss_intro1 = _boss_intro2 = false;
+}
+
 } // namespace Got
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 901e77d8f35..2034f1be3e1 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -80,6 +80,7 @@ public:
 	void load();
 	void setArea(int areaNum);
 	void clearKeyFlags();
+	void resetEndgameFlags();
 
 	Common::String _playerName = "ScummVM";
 	Gfx::GfxChunks _gfx;
@@ -100,6 +101,7 @@ public:
 	bool _slip_flag = false;
 	bool _slipping = false;
 	int _slip_cnt = 0;
+	bool _boss_intro1 = false, _boss_intro2 = false;
 
 	uint _page[3] = { PAGE0,PAGE1,PAGE2 };
 	uint _display_page = 0, _draw_page = 0;
@@ -161,7 +163,7 @@ public:
 	ACTOR _sparkle;
 	THOR_INFO _thor_info;
 	bool _boss_dead = false;
-	bool _endgame = false;
+	byte _endgame = 0;
 
 	int _warp_flag = 0;
 


Commit: b51f535e5452a61fb22ebeab1eb8e7078b522c99
    https://github.com/scummvm/scummvm/commit/b51f535e5452a61fb22ebeab1eb8e7078b522c99
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Implement shield magic

Changed paths:
    engines/got/game/object.cpp
    engines/got/gfx/image.cpp
    engines/got/got.cpp


diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index 6c1dd87ba89..d1616af07e7 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -329,9 +329,8 @@ int use_boots(int flag) {
 }
 
 int use_shield(int flag) {
-	int f;
+	bool f = false;
 
-	f = 0;
 	if (flag) {
 		if (_G(thor_info).magic) {
 			if (!_G(shield_on)) {
@@ -340,29 +339,33 @@ int use_shield(int flag) {
 				setup_magic_item(1);
 
 				_G(actor)[2] = _G(magic_item)[1];
-
 				setup_actor(&_G(actor)[2], 2, 0, _G(thor)->x, _G(thor)->y);
 				_G(actor)[2].speed_count = 1;
 				_G(actor)[2].speed = 1;
-				_G(shield_on) = 1;
+				_G(shield_on) = true;
 			} else if (_G(magic_cnt) > 8) {
 				_G(magic_cnt) = 0;
 				add_magic(-1);
 			}
+
 			return 1;
+
 		} else {
-			f = 1;
+			f = true;
 			not_enough_magic();
 		}
+	} else {
+		f = true;
+	}
 
-	} else f = 1;
-	if (f == 1) {
+	if (f) {
 		if (_G(shield_on)) {
 			_G(actor)[2].dead = 2;
 			_G(actor)[2].used = 0;
-			_G(shield_on) = 0;
+			_G(shield_on) = false;
 		}
 	}
+
 	return 0;
 }
 
diff --git a/engines/got/gfx/image.cpp b/engines/got/gfx/image.cpp
index 0a702c2d90c..d02ab403d0b 100644
--- a/engines/got/gfx/image.cpp
+++ b/engines/got/gfx/image.cpp
@@ -113,28 +113,30 @@ int load_standard_actors() {
 
 	make_actor_surface(&_G(actor)[1]);
 
-	load_actor(0, 106);   // Load sparkle
+	// Load sparkle
+	load_actor(0, 106);
 	_G(sparkle).loadFixed(_G(tmp_buff) + 5120);
 	setup_actor(&_G(sparkle), 20, 0, 100, 100);
 	_G(sparkle).used = 0;
 	make_actor_surface(&_G(sparkle));
 
-	load_actor(0, 107);   // Load explosion
+	// Load explosion
+	load_actor(0, 107);
 	_G(explosion).loadFixed(_G(tmp_buff) + 5120);
 	setup_actor(&_G(explosion), 21, 0, 100, 100);
 	_G(explosion).used = 0;
 	make_actor_surface(&_G(explosion));
 
-	load_actor(0, 108);   // Load tornado
-
+	// Load tornado
+	load_actor(0, 108);
 	_G(magic_item)[0].loadFixed((const byte *)_G(tmp_buff) + 5120);
 	Common::copy(_G(tmp_buff), _G(tmp_buff) + 1024, _G(magic_pic)[0]);
 
 	setup_actor(&_G(magic_item)[0], 20, 0, 0, 0);
 	_G(magic_item)[0].used = 0;
 
-	load_actor(0, 1099);   // Load shield
-
+	// Load shield
+	load_actor(0, 109);
 	_G(magic_item)[1].loadFixed((const byte *)_G(tmp_buff) + 5120);
 	Common::copy(_G(tmp_buff), _G(tmp_buff) + 1024, _G(magic_pic)[1]);
 
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 9c2e30cf018..af2f5caf3c3 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -226,10 +226,15 @@ void GotEngine::pauseEngineIntern(bool pause) {
 		actor_destroyed(&_G(actor)[2]);
 	}
 
+	if (_G(shield_on)) {
+		_G(actor)[2].dead = 2;
+		_G(actor)[2].used = 0;
+		_G(shield_on) = false;
+	}
+
 	_G(lightning_used) = false;
 	_G(thunder_flag) = false;
 	_G(hourglass_flag) = false;
-	_G(shield_on) = false;
 
 	Engine::pauseEngineIntern(pause);
 }


Commit: c6a99b40933ec69e8e118ed579c34b7039b13142
    https://github.com/scummvm/scummvm/commit/c6a99b40933ec69e8e118ed579c34b7039b13142
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fixes for getting arrested

Changed paths:
    engines/got/game/move.cpp
    engines/got/game/script.cpp


diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index 242c3864354..d01d755d940 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -138,6 +138,20 @@ void thor_damaged(ACTOR *actr) {
 	if (_G(cheats).freezeHealth)
 		return;
 
+	if (GAME3 && actr->func_num == 11) {
+		if (actr->talk_counter) {
+			actr->talk_counter--;
+			return;
+		}
+
+		int t = actr->type;
+		actr->type = 4;
+		actor_speaks(actr, 0, 0);
+		actr->type = t;
+		actr->talk_counter = 30;
+		return;
+	}
+
 	damage = actr->strength;
 	if (damage != 255) {
 		if (!_G(setup).skill) damage /= 2;
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index d4b4caafc1f..820574365d4 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -957,7 +957,7 @@ int Scripts::cmd_random() {
 
 void Scripts::scr_func1() {
 	play_sound(FALL, 1);
-	if (_G(key_flag)[_FOUR]) return;
+
 	_G(new_level) = 109;
 	_G(new_level_tile) = 215;
 	_G(thor)->x = (_G(new_level_tile) % 20) * 16;


Commit: 81af9bd23da21ec12ec136293ee327f666da16c4
    https://github.com/scummvm/scummvm/commit/81af9bd23da21ec12ec136293ee327f666da16c4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Implemented cmd_itemgive

Changed paths:
    engines/got/game/script.cpp


diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 820574365d4..48cadbc38ce 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -855,23 +855,21 @@ int Scripts::cmd_settile() {
 }
 
 int Scripts::cmd_itemgive() {
-#ifdef TODO
 	int i;
 
-	if (!calc_value()) return 5;
-	buff_ptr++;
+	if (!calc_value())
+		return 5;
+
+	_buffPtr++;
 	i = (int)_lValue;
 	if (i < 1 || i > 15) return 6;
 
 	_G(thor_info).inventory |= 64;
 	_G(thor_info).item = 7;
 	_G(thor_info).object = i;
-	display_item();
-	_G(thor_info).object_name = object_names[_G(thor_info).object - 1];
+	_G(thor_info).object_name = OBJECT_NAMES[_G(thor_info).object - 1];
+
 	return 0;
-#else
-	error("TODO: cmd_itemgive");
-#endif
 }
 
 int Scripts::cmd_itemtake() {


Commit: e635d1e3874a4d49786a198e2e08a0316176f20b
    https://github.com/scummvm/scummvm/commit/e635d1e3874a4d49786a198e2e08a0316176f20b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Add Loki shot patterns, pattern cleanups

Changed paths:
    engines/got/game/shot_movement.cpp


diff --git a/engines/got/game/shot_movement.cpp b/engines/got/game/shot_movement.cpp
index 391cb4f0825..7cbbd1348cf 100644
--- a/engines/got/game/shot_movement.cpp
+++ b/engines/got/game/shot_movement.cpp
@@ -40,6 +40,8 @@ int shot_movement_eight(ACTOR *actr);
 int shot_movement_nine(ACTOR *actr);
 int shot_movement_ten(ACTOR *actr);
 int shot_movement_eleven(ACTOR *actr);
+int shot_movement_twelve(ACTOR *actr);
+int shot_movement_thirteen(ACTOR *actr);
 
 int (*const shot_movement_func[]) (ACTOR *actr) = {
   shot_movement_none,
@@ -53,7 +55,9 @@ int (*const shot_movement_func[]) (ACTOR *actr) = {
   shot_movement_eight,
   shot_movement_nine,
   shot_movement_ten,
-  shot_movement_eleven
+  shot_movement_eleven,
+  shot_movement_twelve,
+  shot_movement_thirteen
 };
 
 void next_shot_frame(ACTOR *actr) {
@@ -73,7 +77,7 @@ void next_shot_frame(ACTOR *actr) {
 	}
 }
 
-// boss - snake
+// Boss - snake
 int shot_movement_none(ACTOR *actr) {   
 	actr->temp3--;
 	if (!actr->temp3) {
@@ -164,7 +168,8 @@ int shot_movement_two(ACTOR *actr) {
 	return d;
 }
 
-int shot_movement_three(ACTOR *actr) {       //serpent fire
+// Serpent fire
+int shot_movement_three(ACTOR *actr) {
 	int d;
 
 	d = actr->last_dir;
@@ -196,7 +201,8 @@ int shot_movement_three(ACTOR *actr) {       //serpent fire
 	return d;
 }
 
-int shot_movement_four(ACTOR *actr) {          //wraith balls
+// Wraith balls
+int shot_movement_four(ACTOR *actr) {
 	int x1, y1, xd, yd, d;
 
 	if (actr->temp1) {
@@ -314,15 +320,15 @@ int shot_movement_four(ACTOR *actr) {          //wraith balls
 	return d;
 }
 
-int shot_movement_five(ACTOR *actr) {   //no move, frame cycle
-
+// No move, frame cycle
+int shot_movement_five(ACTOR *actr) {
 	next_shot_frame(actr);
 	if (actr->directions == 1) return 0;
 	return actr->last_dir;
 }
 
-int shot_movement_six(ACTOR *actr) {   //wraith spots
-
+// Wraith spots
+int shot_movement_six(ACTOR *actr) {
 	actr->temp1--;
 	if (!actr->temp1) {
 		actor_destroyed(actr);
@@ -340,8 +346,9 @@ int shot_movement_six(ACTOR *actr) {   //wraith spots
 #define XC actr->i6
 #define IV 100
 #define IC 50
-int shot_movement_seven(ACTOR *actr) {   //skull drop
 
+// Skull drop
+int shot_movement_seven(ACTOR *actr) {
 	if (actr->temp3) {
 		actr->temp3--;
 		goto done;
@@ -376,7 +383,8 @@ done:
 	return actr->last_dir;
 }
 
-int shot_movement_eight(ACTOR *actr) {   //skull bounce
+// Skull bounce
+int shot_movement_eight(ACTOR *actr) {
 	int x, y;
 
 	x = actr->x;
@@ -432,8 +440,8 @@ int shot_movement_eight(ACTOR *actr) {   //skull bounce
 	return actr->last_dir;
 }
 
-int shot_movement_nine(ACTOR *actr) {   //skull explode
-
+// Skull explode
+int shot_movement_nine(ACTOR *actr) {
 	actr->next++;
 	if (actr->next == 3) {
 		_G(actor)[actr->creator].num_shots--;
@@ -444,7 +452,8 @@ int shot_movement_nine(ACTOR *actr) {   //skull explode
 	return actr->last_dir;
 }
 
-int shot_movement_ten(ACTOR *actr) {  //skull - stalagtite
+// Skull - stalagtites
+int shot_movement_ten(ACTOR *actr) {
 	int f;
 
 	f = 0;
@@ -473,7 +482,6 @@ int shot_movement_ten(ACTOR *actr) {  //skull - stalagtite
 #define CNT actr->i6
 
 void calc_angle(int x1, int y1, int x2, int y2, ACTOR *actr) {
-
 	if (x1 < x2) {
 		XA = -2;
 		XD = x2 - x1;
@@ -501,7 +509,8 @@ void calc_angle(int x1, int y1, int x2, int y2, ACTOR *actr) {
 	CNT = 0;
 }
 
-int shot_movement_eleven(ACTOR *actr) {  //angle throw
+// Angle throw
+int shot_movement_eleven(ACTOR *actr) {
 	int x1, y1;
 
 	x1 = actr->x;
@@ -537,4 +546,113 @@ int shot_movement_eleven(ACTOR *actr) {  //angle throw
 	return actr->last_dir;
 }
 
+// Angle throw Loki
+int shot_movement_twelve(ACTOR *actr) {
+	int x1, y1;
+
+	x1 = actr->x;
+	y1 = actr->y;
+
+	if (!actr->temp5) {
+		calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actr);
+		actr->temp5 = 1;
+	}
+
+	if (DIR) {
+		y1 += YA;
+		CNT += XD;
+		if (CNT >= YD) {
+			x1 += XA;
+			CNT -= YD;
+		}
+	} else {
+		x1 += XA;
+		CNT += YD;
+		if (CNT >= XD) {
+			y1 += YA;
+			CNT -= XD;
+		}
+	}
+
+	if (x1 < 16 || x1>287 || y1 < 16 || y1>159) {
+		calc_angle(g_events->getRandomNumber(319),
+			g_events->getRandomNumber(191), x1, y1, actr);
+		actr->move = 13;
+		actr->temp4 = 240;
+		actr->next = 2;
+	} else {
+		if (overlap(x1 + 2, y1 + 2, x1 + 14, y1 + 14, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
+			thor_damaged(actr);
+		}
+		actr->x = x1;
+		actr->y = y1;
+	}
+	actr->frame_count--;
+	if (actr->frame_count <= 0) {
+		actr->next++;
+		if (actr->next > 1) actr->next = 0;
+		actr->frame_count = actr->frame_speed;
+	}
+	if (actr->directions == 1) return 0;
+	return actr->last_dir;
+}
+
+// Angle throw Loki-2
+int shot_movement_thirteen(ACTOR *actr) {
+	int x1, y1;
+
+	x1 = actr->x;
+	y1 = actr->y;
+
+	if (!actr->temp5) {
+		calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actr);
+		actr->temp5 = 1;
+	}
+
+	if (DIR) {
+		y1 += YA;
+		CNT += XD;
+		if (CNT >= YD) {
+			x1 += XA;
+			CNT -= YD;
+		}
+	} else {
+		x1 += XA;
+		CNT += YD;
+		if (CNT >= XD) {
+			y1 += YA;
+			CNT -= XD;
+		}
+	}
+	if (actr->temp4) actr->temp4--;
+	if (!actr->temp4) {
+		if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+		actor_destroyed(actr);
+		_G(apple_drop)++;
+		if (_G(apple_drop) > 4) {
+			if (_drop_obj(actr, 5)) _G(apple_drop) = 0;
+			else _G(apple_drop) = 4;
+		} else _drop_obj(actr, 4);
+		return 0;
+	}
+	if (x1 < 16 || x1>287 || y1 < 16 || y1>159) {
+		if (x1 < 16 || x1>287) XA = 0 - XA;
+		else YA = 0 - YA;
+	} else {
+		if (overlap(x1 + 4, y1 + 4, x1 + 12, y1 + 12, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
+			thor_damaged(actr);
+		}
+		actr->x = x1;
+		actr->y = y1;
+	}
+	actr->frame_count--;
+	if (actr->frame_count <= 0) {
+		actr->next++;
+		if (actr->next > 3) actr->next = 2;
+		actr->frame_count = actr->frame_speed;
+	}
+	if (actr->directions == 1) return 0;
+	return actr->last_dir;
+}
+
 } // namespace Got


Commit: 3f7c7b4e19e90ce3ef3382d5fb243821af43dc85
    https://github.com/scummvm/scummvm/commit/3f7c7b4e19e90ce3ef3382d5fb243821af43dc85
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Various endgame fixes

Changed paths:
    engines/got/data/defines.h
    engines/got/game/back.cpp
    engines/got/game/boss3.cpp
    engines/got/game/boss3.h
    engines/got/game/move_patterns.cpp
    engines/got/game/special_tile.cpp
    engines/got/vars.h
    engines/got/views/game.cpp
    engines/got/views/game_content.cpp


diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index e2262d115ef..0bbbf7e133e 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -173,7 +173,8 @@ enum {
 
 #define BOSS_LEVEL1 59
 #define BOSS_LEVEL2 60
-#define BOSS_LEVEL3 999
+#define BOSS_LEVEL3 95
+#define ENDING_SCREEN 106
 
 //#define DEBUG 1
 //#define IDE 1
diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index d1398ada4ed..90d4b2c7143 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -23,6 +23,7 @@
 #include "got/game/back.h"
 #include "got/game/boss1.h"
 #include "got/game/boss2.h"
+#include "got/game/boss3.h"
 #include "got/game/move.h"
 #include "got/game/object.h"
 #include "got/game/script.h"
@@ -162,6 +163,19 @@ void show_level_done() {
 			f = false;
 		}
 	}
+	if (GAME3) {
+		if (_G(new_level) == BOSS_LEVEL3) {
+			if (!_G(setup).boss_dead[2]) {
+				if (!_G(auto_load))
+					boss_level3();
+				f = 0;
+			}
+		}
+		if (_G(current_level) == ENDING_SCREEN) {
+			ending_screen();
+			f = 0;
+		}
+	}
 
 	if (_G(startup))
 		f = false;
diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index 3c6ec30ed89..b0b16359716 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -35,18 +35,17 @@ namespace Got {
 
 #define LFC 10
 
-int  boss_mode;
-int  num_pods, num_pods1;
-byte pod_speed;
-byte exp[4][8] = {
+static int  boss_mode;
+static int  num_pods, num_pods1;
+static byte pod_speed;
+static const byte exp[4][8] = {
 			{126,127,128,129,130,131,132,133},
 			{146,147,148,149,150,151,152,153},
 			{166,167,168,169,170,171,172,173},
 			{186,187,188,189,190,191,192,193} };
 
-byte expf[4][8];
-byte exprow;
-byte expcnt;
+static byte expf[4][8];
+static byte expcnt;
 
 static int boss_die();
 static void check_boss_hit();
@@ -72,7 +71,7 @@ static void set_boss(ACTOR *actr) {
 	_G(actor)[6].y = actr->y + 16;
 }
 
-// Boss - loki-2
+// Boss - Loki-2
 static int boss_movement_one(ACTOR *actr) {
 	int rx, ry, i, numPods = 0;
 
@@ -522,37 +521,33 @@ void closing_sequence3_3() {
 	_G(exit_flag) = 0;
 	music_pause();
 
-	Gfx::fade_out();
-	_G(new_level) = 106;
+	_G(new_level) = ENDING_SCREEN;
 	_G(thor)->x = 152;
 	_G(thor)->y = 160;
 	_G(thor)->dir = 1;
-	//_G(game_is_over) = 1;
 }
 
 void ending_screen() {
-#ifdef TODO
 	int i;
 
-	for (i = 3; i < MAX_ACTORS; i++) _G(actor)[i].move = 1;
-	fade_in();
+	for (i = 3; i < MAX_ACTORS; i++)
+		_G(actor)[i].move = 1;
 	music_play(6, 1);
 	_G(timer_cnt) = 0;
-	while (_G(timer_cnt) < 180) rotate_pal();
+
 	memset(expf, 0, 32);
 	_G(endgame) = 1;
-	exprow = 0;
+
+	_G(exprow) = 0;
 	expcnt = 0;
-	memcpy(&_G(actor)[34], &explosion, sizeof(ACTOR));
+
+	_G(actor)[34] = _G(explosion);
 	_G(actor)[34].used = 0;
 	_G(actor)[34].speed = 2;
 	_G(actor)[34].speed_count = _G(actor)[34].speed;
-	_G(actor)[34].num_shots = 3;  //used to reverse explosion
+	_G(actor)[34].num_shots = 3;  // Used to reverse explosion
 	_G(actor)[34].vunerable = 255;
 	_G(actor)[34].i2 = 6;
-#else
-	error("TODO: ending_screen");
-#endif
 }
 
 // Explode
@@ -595,7 +590,8 @@ int endgame_one() {
 int endgame_movement() {
 	int x, y, r;
 
-	if (!_G(endgame)) return 0;
+	if (!_G(endgame))
+		return 0;
 	if (expcnt > 3) {
 		endgame_one();
 		return 0;
@@ -608,13 +604,13 @@ int endgame_movement() {
 	play_sound(EXPLODE, 1);
 
 	r = _G(rand1) % 8;
-	while (expf[exprow][r]) {
+	while (expf[_G(exprow)][r]) {
 		r++;
 		if (r > 7) r = 0;
 	}
-	expf[exprow][r] = 1;
-	x = (exp[exprow][r] % 20) * 16;
-	y = (exp[exprow][r] / 20) * 16;
+	expf[_G(exprow)][r] = 1;
+	x = (exp[_G(exprow)][r] % 20) * 16;
+	y = (exp[_G(exprow)][r] / 20) * 16;
 	_G(actor)[34].x = x;
 	_G(actor)[34].y = y;
 	_G(actor)[34].used = 1;
@@ -627,24 +623,13 @@ int endgame_movement() {
 	_G(endgame)++;
 	if (_G(endgame) > 8) {
 		_G(endgame) = 1;
-		exprow++;
+		_G(exprow)++;
 		expcnt++;
 		if (expcnt > 3) {
 			memset(expf, 0, 32);
 		}
-#if TODO
-		xget(96, (2 + (exprow - 1)) * 16, 224, (6 + (exprow - 1)) * 16, PAGE0, lzss_buff, 0);
-		xfarput(96, (3 + (exprow - 1)) * 16, PAGE0, lzss_buff);
-		xfarput(96, (3 + (exprow - 1)) * 16, PAGE1, lzss_buff);
-		xfarput(96, (3 + (exprow - 1)) * 16, PAGE2, lzss_buff);
-		xget(96, 16, 224, 32, PAGE0, lzss_buff, 0);
-		xfarput(96, (2 + (exprow - 1)) * 16, PAGE0, lzss_buff);
-		xfarput(96, (2 + (exprow - 1)) * 16, PAGE1, lzss_buff);
-		xfarput(96, (2 + (exprow - 1)) * 16, PAGE2, lzss_buff);
-#else
-		error("TODO: endgame_movement");
-#endif
 	}
+
 	return 1;
 }
 
diff --git a/engines/got/game/boss3.h b/engines/got/game/boss3.h
index 86c16a7fcc2..58594c69e53 100644
--- a/engines/got/game/boss3.h
+++ b/engines/got/game/boss3.h
@@ -29,10 +29,11 @@ namespace Got {
 // Boss 3 - Loki
 extern int boss3_movement(ACTOR *actr);
 extern void boss_level3();
+extern void ending_screen();
 extern void closing_sequence3();
 extern void closing_sequence3_2();
 extern void closing_sequence3_3();
-extern void closing_sequence3_4();
+extern int endgame_movement();
 
 } // namespace Got
 
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index f3688fc2d78..d89f9e8f77e 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -272,7 +272,9 @@ int check_move0(int x, int y, ACTOR *actr) {
 			if (!special_tile_thor(y1, x2, icn3)) return 0;
 			icn4 = _G(scrn).icon[y2][x2];
 		}
-		if (icn4 > TILE_SPECIAL) if (!special_tile_thor(y2, x2, icn4)) return 0;
+		if (icn4 > TILE_SPECIAL) {
+			if (!special_tile_thor(y2, x2, icn4)) return 0;
+		}
 	}
 
 	if (!_G(slip_flag)) {
diff --git a/engines/got/game/special_tile.cpp b/engines/got/game/special_tile.cpp
index 04873bd9411..e021678524c 100644
--- a/engines/got/game/special_tile.cpp
+++ b/engines/got/game/special_tile.cpp
@@ -51,14 +51,9 @@ int special_tile_thor(int x, int y, int icon) {
 			return 0;
 		}
 
-		if (_G(thor)->x > 300 && g_events->focusedView()->getName() == "Game") {
+		if (_G(thor)->x > 300)
 			// Ending bridge
 			_G(end_tile) = 1;
-
-			// TODO: Show high score table rather than going straight to main menu
-			Gfx::fade_out();
-			g_events->send("TitleBackground", GameMessage("MAIN_MENU"));
-		}
 		return 1;
 	case 203:
 		if (!GAME1) {
@@ -120,6 +115,9 @@ int special_tile_thor(int x, int y, int icon) {
 				play_sound(THUNDER, 1);
 				_G(setup).f22 = 1;
 			}
+		} else {
+			// Game 3
+			return 0;
 		}
 		return 1;
 	case 212:
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 2034f1be3e1..03a01d616ec 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -219,6 +219,7 @@ public:
 	char _sd_header[128] = {};
 	char _play_speed = 0;
 	bool _thor_special_flag = false;
+	byte _exprow = 0;
 };
 
 #define _G(X) (g_vars->_##X)
diff --git a/engines/got/views/game.cpp b/engines/got/views/game.cpp
index 1cf7ad7983a..7f4abc2995b 100644
--- a/engines/got/views/game.cpp
+++ b/engines/got/views/game.cpp
@@ -28,6 +28,7 @@
 #include "got/vars.h"
 #include "got/game/boss1.h"
 #include "got/game/boss2.h"
+#include "got/game/boss3.h"
 
 namespace Got {
 namespace Views {
@@ -54,11 +55,21 @@ bool Game::msgKeypress(const KeypressMessage &msg) {
 		return true;
 
 	case Common::KEYCODE_f:
-		// Hack used for testing end-game sequence
-		if (GAME1 && _G(current_level) == BOSS_LEVEL1)
-			closing_sequence1();
-		else if (GAME2 && _G(current_level) == BOSS_LEVEL2)
-			closing_sequence2();
+		if (gDebugLevel > 0) {
+			// Hack used for testing end-game sequence
+			if (GAME1 && _G(current_level) == BOSS_LEVEL1)
+				closing_sequence1();
+			else if (GAME2 && _G(current_level) == BOSS_LEVEL2)
+				closing_sequence2();
+			else if (GAME3 && _G(current_level) == BOSS_LEVEL3)
+				closing_sequence3();
+		}
+		break;
+
+	case Common::KEYCODE_e:
+		if (gDebugLevel > 0 && GAME3)
+			// Launch endgame screen
+			closing_sequence3_3();
 		break;
 
 	case Common::KEYCODE_s:
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 1fca0da632b..b33d746d474 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -23,6 +23,7 @@
 #include "got/game/back.h"
 #include "got/game/boss1.h"
 #include "got/game/boss2.h"
+#include "got/game/boss3.h"
 #include "got/game/move.h"
 #include "got/game/move_patterns.h"
 #include "got/game/object.h"
@@ -55,7 +56,8 @@ void GameContent::draw() {
 	drawActors(s);
 
 	if ((GAME1 && _G(current_level) == BOSS_LEVEL1) ||
-		(GAME2 && _G(current_level) == BOSS_LEVEL2))
+		(GAME2 && _G(current_level) == BOSS_LEVEL2) ||
+		(GAME3 && _G(current_level) == BOSS_LEVEL3))
 		drawBossHealth(s);
 
 	// If we're shaking the screen, render the content with the shake X/Y
@@ -147,6 +149,9 @@ bool GameContent::tick() {
 		updateActors();
 		checkForBossDead();
 		checkForCheats();
+
+		if (_G(endgame))
+			endgame_movement();
 		break;
 
 	case MODE_THOR_DIES:
@@ -173,7 +178,7 @@ bool GameContent::tick() {
 
 	case MODE_SCORE_INV:
 		if (--_pauseCtr <= 0) {
-			_pauseCtr = 5;
+			_pauseCtr = 2;
 
 			if (_G(thor)->health > 0) {
 				_G(thor)->health--;
@@ -207,6 +212,14 @@ bool GameContent::tick() {
 
 	checkForAreaChange();
 
+	// Check for end of game area
+	// TODO: Show high score table rather than going straight to main menu
+	if (_G(end_tile)) {
+		_G(end_tile) = false;
+		Gfx::fade_out();
+		g_events->send("TitleBackground", GameMessage("MAIN_MENU"));
+	}
+
 	return false;
 }
 
@@ -384,12 +397,23 @@ void GameContent::checkForBossDead() {
 		if (loop == 7) {
 			_G(boss_dead) = false;
 
-			//xerase_actors(actor, display_page);
-			//xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], display_page);
 			_G(exit_flag) = 0;
 
-			if (_G(boss_active) == 1) {
-				closing_sequence1();
+			if (_G(boss_active)) {
+				switch (_G(area)) {
+				case 1:
+					closing_sequence1();
+					break;
+				case 2:
+					closing_sequence2();
+					break;
+				case 3:
+					closing_sequence3();
+					break;
+				default:
+					break;
+				}
+
 				_G(boss_active) = 0;
 			}
 		}
@@ -682,6 +706,9 @@ void GameContent::closingSequence() {
 		case 2:
 			closing_sequence2_2();
 			break;
+		case 3:
+			closing_sequence3_2();
+			break;
 		default:
 			break;
 		}
@@ -695,6 +722,9 @@ void GameContent::closingSequence() {
 		case 2:
 			closing_sequence2_3();
 			break;
+		case 3:
+			closing_sequence3_3();
+			break;
 		default:
 			break;
 		}


Commit: dde8d6d37b95e563528990f185669be2433255e6
    https://github.com/scummvm/scummvm/commit/dde8d6d37b95e563528990f185669be2433255e6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix improper copying of actors causing later crash

Changed paths:
    engines/got/game/boss2.cpp
    engines/got/game/boss3.cpp


diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index 8382a517a20..40d498cac7d 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -33,7 +33,7 @@
 
 namespace Got {
 
-static const byte exp[] = {
+static const byte EXPLOSION[] = {
 	 61, 62, 65, 66, 69, 70, 73, 74, 77, 78,
 	 81, 82, 85, 86, 89, 90, 93, 94, 97, 98,
 	101,102,105,106,109,110,113,114,117,118,
@@ -273,8 +273,8 @@ static int boss2a_movement(ACTOR *actr) {
 		if (r > 59) r = 0;
 	}
 	expf[r] = 1;
-	x = (exp[r] % 20) * 16;
-	y = (exp[r] / 20) * 16;
+	x = (EXPLOSION[r] % 20) * 16;
+	y = (EXPLOSION[r] / 20) * 16;
 	_G(actor)[an].x = x;
 	_G(actor)[an].y = y;
 
diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index b0b16359716..d8e433de70a 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -38,13 +38,13 @@ namespace Got {
 static int  boss_mode;
 static int  num_pods, num_pods1;
 static byte pod_speed;
-static const byte exp[4][8] = {
+static const byte EXPLOSION[4][8] = {
 			{126,127,128,129,130,131,132,133},
 			{146,147,148,149,150,151,152,153},
 			{166,167,168,169,170,171,172,173},
 			{186,187,188,189,190,191,192,193} };
 
-static byte expf[4][8];
+static bool expf[4][8];
 static byte expcnt;
 
 static int boss_die();
@@ -177,7 +177,9 @@ static int boss_movement_one(ACTOR *actr) {
 				_G(actor)[_G(actor)[4].shot_actor].x = actr->x + 8;
 				_G(actor)[_G(actor)[4].shot_actor].y = actr->y + 16;
 				_G(actor)[_G(actor)[4].shot_actor].temp5 = 0;
-				for (i = 0; i < numPods; i++) memcpy(&_G(actor)[20 + i], &_G(actor)[19], 256);
+				for (i = 0; i < numPods; i++)
+					_G(actor)[20 + i] = _G(actor)[19];
+
 				num_pods1 = numPods;
 				actr->temp1 = 0;
 			}
@@ -535,7 +537,7 @@ void ending_screen() {
 	music_play(6, 1);
 	_G(timer_cnt) = 0;
 
-	memset(expf, 0, 32);
+	memset(expf, 0, 4 * 8);
 	_G(endgame) = 1;
 
 	_G(exprow) = 0;
@@ -568,8 +570,8 @@ int endgame_one() {
 		if (r > 31) r = 0;
 	}
 	expf[r / 8][r % 8] = 1;
-	x = (exp[r / 8][r % 8] % 20) * 16;
-	y = (exp[r / 8][r % 8] / 20) * 16;
+	x = (EXPLOSION[r / 8][r % 8] % 20) * 16;
+	y = (EXPLOSION[r / 8][r % 8] / 20) * 16;
 	_G(actor)[34].x = x;
 	_G(actor)[34].y = y;
 	_G(actor)[34].used = 1;
@@ -609,8 +611,8 @@ int endgame_movement() {
 		if (r > 7) r = 0;
 	}
 	expf[_G(exprow)][r] = 1;
-	x = (exp[_G(exprow)][r] % 20) * 16;
-	y = (exp[_G(exprow)][r] / 20) * 16;
+	x = (EXPLOSION[_G(exprow)][r] % 20) * 16;
+	y = (EXPLOSION[_G(exprow)][r] / 20) * 16;
 	_G(actor)[34].x = x;
 	_G(actor)[34].y = y;
 	_G(actor)[34].used = 1;


Commit: ea3845e87c29830df40a4ae180ad534d2470a5cd
    https://github.com/scummvm/scummvm/commit/ea3845e87c29830df40a4ae180ad534d2470a5cd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Adding HighScores class

Changed paths:
  A engines/got/data/high_scores.cpp
  A engines/got/data/high_scores.h
    engines/got/got.cpp
    engines/got/got.h
    engines/got/module.mk
    engines/got/vars.cpp
    engines/got/vars.h
    engines/got/views/game_content.cpp


diff --git a/engines/got/data/high_scores.cpp b/engines/got/data/high_scores.cpp
new file mode 100644
index 00000000000..52ea986124c
--- /dev/null
+++ b/engines/got/data/high_scores.cpp
@@ -0,0 +1,117 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/file.h"
+#include "common/savefile.h"
+#include "common/system.h"
+#include "got/data/high_scores.h"
+#include "got/got.h"
+
+namespace Got {
+
+static const HighScore DEFAULTS[HIGH_SCORES_PER_AREA] = {
+	{ 0, 10000, "Ron Davis" },
+	{ 0,  9000, "Gary Sirois" },
+	{ 0,  8000, "Adam Pedersen" },
+	{ 0,  7000, "Jason Blochowiak" },
+	{ 0,  6000, "Roy Davis" },
+	{ 0,  5000, "Wayne Timmerman" },
+	{ 0,  4000, "Dan Linton" }
+};
+
+void HighScore::sync(Common::Serializer &s) {
+	s.syncAsUint16LE(_unused);
+	s.syncAsUint32LE(_total);
+	s.syncBytes((byte *)_name, 32);
+}
+
+void HighScores::sync(Common::Serializer &s) {
+	for (int area = 0; area < 3; ++area)
+		for (int num = 0; num < HIGH_SCORES_PER_AREA; ++num)
+			_scores[area][num].sync(s);
+}
+
+void HighScores::load() {
+	Common::File f;
+	Common::InSaveFile *sf;
+	Common::String scoresName = g_engine->getHighScoresSaveName();
+
+	if ((sf = g_system->getSavefileManager()->openForLoading(scoresName)) != nullptr) {
+		// ScummVM high scores data present
+		Common::Serializer s(sf, nullptr);
+		sync(s);
+		delete sf;
+	} else if (f.open("config.got")) {
+		// Otherwise fall back on original generated config.got
+		f.seek(0x32);
+		Common::Serializer s(&f, nullptr);
+		sync(s);
+	} else {
+		// Generate new data
+		for (int area = 0; area < 3; ++area)
+			for (int num = 0; num < HIGH_SCORES_PER_AREA; ++num)
+				_scores[area][num] = DEFAULTS[num];
+	}
+}
+
+void HighScores::save() {
+	Common::OutSaveFile *sf = g_system->getSavefileManager()->openForSaving(
+		g_engine->getHighScoresSaveName());
+	if (!sf)
+		error("Error creating high scores save file");
+
+	Common::Serializer s(nullptr, sf);
+	sync(s);
+	sf->finalize();
+	delete sf;
+}
+
+static int sortScores(const HighScore &hs1, const HighScore &hs2) {
+	if (hs1._total < hs2._total)
+		return -1;
+	else if (hs1._total > hs2._total)
+		return 1;
+	else
+		return 0;
+}
+
+void HighScores::add(int area, const Common::String &name, int total) {
+	// Make a temporary copy of the area scores and add the new one
+	Common::Array<HighScore> temp;
+	for (int i = 0; i < HIGH_SCORES_PER_AREA; ++i)
+		temp.push_back(_scores[area - 1][i]);
+
+	temp.push_back(HighScore());
+	Common::strcpy_s(temp.back()._name, name.c_str());
+	temp.back()._total = total;
+
+	// Sort the scores by descending total
+	Common::sort(temp.begin(), temp.end(), sortScores);
+
+	// Copy all but the lowest resulting score back into table
+	for (int i = 0; i < HIGH_SCORES_PER_AREA; ++i)
+		_scores[area - 1][i] = temp[i];
+
+	// Save the resulting table
+	save();
+}
+
+} // namespace Got
diff --git a/engines/got/data/high_scores.h b/engines/got/data/high_scores.h
new file mode 100644
index 00000000000..8c3ab7d76db
--- /dev/null
+++ b/engines/got/data/high_scores.h
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef GOT_DATA_HIGH_SCORE_H
+#define GOT_DATA_HIGH_SCORE_H
+
+#include "common/serializer.h"
+
+namespace Got {
+
+#define HIGH_SCORES_PER_AREA 7
+
+struct HighScore {
+	uint16 _unused = 0;
+	uint32 _total = 0;
+	char _name[32] = {};
+
+	void sync(Common::Serializer &s);
+};
+
+struct HighScores {
+private:
+	void sync(Common::Serializer &s);
+
+public:
+	HighScore _scores[3][HIGH_SCORES_PER_AREA];
+
+	void load();
+	void save();
+	void add(int area, const Common::String &name, int total);
+};
+
+} // namespace Got
+
+#endif
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index af2f5caf3c3..80e96383a6c 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -239,4 +239,8 @@ void GotEngine::pauseEngineIntern(bool pause) {
 	Engine::pauseEngineIntern(pause);
 }
 
+Common::String GotEngine::getHighScoresSaveName() const {
+	return Common::String::format("%s-scores.dat", _targetName.c_str());
+}
+
 } // End of namespace Got
diff --git a/engines/got/got.h b/engines/got/got.h
index b2bad0defd8..ef35805bf85 100644
--- a/engines/got/got.h
+++ b/engines/got/got.h
@@ -103,6 +103,8 @@ public:
 
 	void syncSoundSettings() override;
 	void pauseEngineIntern(bool pause) override;
+
+	Common::String getHighScoresSaveName() const;
 };
 
 extern GotEngine *g_engine;
diff --git a/engines/got/module.mk b/engines/got/module.mk
index bad43cada34..d05f03eced5 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -9,6 +9,7 @@ MODULE_OBJS = \
 	sound.o \
 	vars.o \
 	data/actor.o \
+	data/high_scores.o \
 	data/level.o \
 	data/sd_data.o \
 	data/setup.o \
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 99912f05dc8..519ba1fd36b 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -48,6 +48,7 @@ void Vars::load() {
 	_sd_data.load();
 	_sound.load();
 	_status.load();
+	_highScores.load();
 
 	_music_flag = !ConfMan.getBool("music_mute");
 	_sound_flag = _pcsound_flag = !ConfMan.getBool("sfx_mute");
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 03a01d616ec..9830bff395b 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -26,6 +26,7 @@
 #include "common/queue.h"
 #include "graphics/screen.h"
 #include "got/data/defines.h"
+#include "got/data/high_scores.h"
 #include "got/data/sd_data.h"
 #include "got/game/script.h"
 #include "got/gfx/font.h"
@@ -90,6 +91,7 @@ public:
 	Gfx::Pics _objects;
 	Gfx::Pics _odin;
 	Gfx::Pics _status;
+	HighScores _highScores;
 	SdData _sd_data;
 	Sound _sound;
 	Scripts _scripts;
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index b33d746d474..62b14a75f1b 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -217,6 +217,7 @@ bool GameContent::tick() {
 	if (_G(end_tile)) {
 		_G(end_tile) = false;
 		Gfx::fade_out();
+		_G(highScores).add(_G(area), _G(playerName), _G(thor_info).score);
 		g_events->send("TitleBackground", GameMessage("MAIN_MENU"));
 	}
 


Commit: 23bbaebbda30e29c885fdf87ef3d600a0246b60e
    https://github.com/scummvm/scummvm/commit/23bbaebbda30e29c885fdf87ef3d600a0246b60e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fixes for high scores insertion

Changed paths:
    engines/got/data/high_scores.cpp
    engines/got/data/high_scores.h


diff --git a/engines/got/data/high_scores.cpp b/engines/got/data/high_scores.cpp
index 52ea986124c..f0d647b8f34 100644
--- a/engines/got/data/high_scores.cpp
+++ b/engines/got/data/high_scores.cpp
@@ -93,22 +93,25 @@ static int sortScores(const HighScore &hs1, const HighScore &hs2) {
 		return 0;
 }
 
-void HighScores::add(int area, const Common::String &name, int total) {
-	// Make a temporary copy of the area scores and add the new one
-	Common::Array<HighScore> temp;
-	for (int i = 0; i < HIGH_SCORES_PER_AREA; ++i)
-		temp.push_back(_scores[area - 1][i]);
-
-	temp.push_back(HighScore());
-	Common::strcpy_s(temp.back()._name, name.c_str());
-	temp.back()._total = total;
-
-	// Sort the scores by descending total
-	Common::sort(temp.begin(), temp.end(), sortScores);
-
-	// Copy all but the lowest resulting score back into table
-	for (int i = 0; i < HIGH_SCORES_PER_AREA; ++i)
-		_scores[area - 1][i] = temp[i];
+void HighScores::add(int area, const Common::String &name, uint total) {
+	// Find the index for the new score in the list
+	uint newIndex;
+	for (newIndex = 0; newIndex < HIGH_SCORES_PER_AREA &&
+		total < _scores[area - 1][newIndex]._total; ++newIndex) {
+	}
+	if (newIndex == HIGH_SCORES_PER_AREA)
+		// Lower than all current scores, so ignore it
+		return;
+
+	// Shift any lower scores to make space
+	for (int i = HIGH_SCORES_PER_AREA - 1; i > newIndex; --i)
+		_scores[area - 1][i] = _scores[area - 1][i - 1];
+
+	// Insert in new score
+	HighScore &hs = _scores[area - 1][newIndex];
+	Common::fill(hs._name, hs._name + 32, 0);
+	Common::strcpy_s(hs._name, name.c_str());
+	hs._total = total;
 
 	// Save the resulting table
 	save();
diff --git a/engines/got/data/high_scores.h b/engines/got/data/high_scores.h
index 8c3ab7d76db..4c748b3c443 100644
--- a/engines/got/data/high_scores.h
+++ b/engines/got/data/high_scores.h
@@ -45,7 +45,7 @@ public:
 
 	void load();
 	void save();
-	void add(int area, const Common::String &name, int total);
+	void add(int area, const Common::String &name, uint total);
 };
 
 } // namespace Got


Commit: 69d6df5988813f5f7fae53da416d115c731a1449
    https://github.com/scummvm/scummvm/commit/69d6df5988813f5f7fae53da416d115c731a1449
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Add Load Game option to main menu

Changed paths:
    engines/got/vars.cpp
    engines/got/views/dialogs/main_menu.cpp
    engines/got/views/dialogs/main_menu.h


diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 519ba1fd36b..87a1f93b84b 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -114,6 +114,8 @@ void Vars::clearKeyFlags() {
 }
 
 void Vars::resetEndgameFlags() {
+	_gameMode = MODE_NORMAL;
+	_demo = false;
 	_auto_load = false;
 	_end_tile = false;
 	_boss_dead = false;
diff --git a/engines/got/views/dialogs/main_menu.cpp b/engines/got/views/dialogs/main_menu.cpp
index a9cb73ebdf4..d7979e2678b 100644
--- a/engines/got/views/dialogs/main_menu.cpp
+++ b/engines/got/views/dialogs/main_menu.cpp
@@ -28,12 +28,17 @@ namespace Views {
 namespace Dialogs {
 
 static const char *OPTIONS[] = {
-	"Play Game", "High Scores", "Credits", "Demo", "Quit", nullptr
+	"Play Game", "Load Game", "High Scores", "Credits", "Demo", "Quit", nullptr
 };
 
 MainMenu::MainMenu() : SelectOption("MainMenu", "God of Thunder Menu", OPTIONS) {
 }
 
+bool MainMenu::msgFocus(const FocusMessage &msg) {
+	g_vars->resetEndgameFlags();
+	return SelectOption::msgFocus(msg);
+}
+
 void MainMenu::closed() {
 	_selectedItem = 4; // Quit game
 	selected();
@@ -46,13 +51,22 @@ void MainMenu::selected() {
 		addView("SelectGame");
 		break;
 
+	case 1:
+		if (!g_engine->loadGameDialog())
+			addView("SelectGame");
+		break;
+
 	case 3:
+		addView("Credits");
+		break;
+
+	case 4:
 		_G(demo) = true;
 		initialize_game();
 		replaceView("Game", true, true);
 		break;
 
-	case 4:
+	case 5:
 		addView("Quit");
 		break;
 
diff --git a/engines/got/views/dialogs/main_menu.h b/engines/got/views/dialogs/main_menu.h
index ff236533c7c..c0eafde7a25 100644
--- a/engines/got/views/dialogs/main_menu.h
+++ b/engines/got/views/dialogs/main_menu.h
@@ -34,6 +34,7 @@ public:
 	virtual ~MainMenu() {
 	}
 
+	bool msgFocus(const FocusMessage &msg) override;
 	void closed() override;
 	void selected() override;
 };


Commit: c16078f3bc3f408030e2446845d3d3a1981472f7
    https://github.com/scummvm/scummvm/commit/c16078f3bc3f408030e2446845d3d3a1981472f7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added high scores view, hooked it up

Changed paths:
    engines/got/module.mk
    engines/got/views/credits.cpp
    engines/got/views/dialogs/high_scores.cpp
    engines/got/views/dialogs/high_scores.h
    engines/got/views/dialogs/main_menu.cpp
    engines/got/views/game_content.cpp
    engines/got/views/views.h


diff --git a/engines/got/module.mk b/engines/got/module.mk
index d05f03eced5..dd88ab83378 100644
--- a/engines/got/module.mk
+++ b/engines/got/module.mk
@@ -50,6 +50,7 @@ MODULE_OBJS = \
 	views/dialogs/dialog.o \
 	views/dialogs/select_option.o \
 	views/dialogs/ask.o \
+	views/dialogs/high_scores.o \
 	views/dialogs/main_menu.o \
 	views/dialogs/options_menu.o \
 	views/dialogs/play_game.o \
diff --git a/engines/got/views/credits.cpp b/engines/got/views/credits.cpp
index a6ee731668b..c9c2fdfa3ef 100644
--- a/engines/got/views/credits.cpp
+++ b/engines/got/views/credits.cpp
@@ -111,10 +111,7 @@ bool Credits::tick() {
 		_delayCtr = 0;
 
 		if (_frameCtr == (CREDIT_TIME * CREDITS_COUNT) + 10) {
-			// TODO: The original switched to show the top high scores
-			// briefly, and then switches to the demo
-			fadeOut();
-			send("TitleBackground", GameMessage("MAIN_MENU"));
+			replaceView("HighScores", true, true);
 		} else {
 			++_frameCtr;
 			redraw();
diff --git a/engines/got/views/dialogs/high_scores.cpp b/engines/got/views/dialogs/high_scores.cpp
index 4033c1ad739..0e9861c0e38 100644
--- a/engines/got/views/dialogs/high_scores.cpp
+++ b/engines/got/views/dialogs/high_scores.cpp
@@ -19,36 +19,120 @@
  *
  */
 
-#include "got/views/dialogs/dialog.h"
+#include "got/views/dialogs/high_scores.h"
 #include "got/vars.h"
 
 namespace Got {
 namespace Views {
 namespace Dialogs {
 
-void Dialog::draw() {
+#define TIMEOUT 500
+
+HighScores::HighScores() : Dialog("HighScores") {
+	setBounds(Common::Rect(0, 0 + 24, 320, 192 + 24));
+}
+
+void HighScores::draw() {
+	// Draw background outside dialog
+	GfxSurface s = GfxSurface(*g_events->getScreen(),
+		Common::Rect(0, 0, 320, 240));
+
+	for (int col = 0, xp = 0; col < 10; ++col, xp += 32) {
+		for (int yp = 0; yp < 240; yp += 32)
+			s.blitFrom(_G(gfx)[26], Common::Point(xp, yp));
+	}
+
+	// Draw the dialog frame
+	Dialog::draw();
+
 	// Clear the inner content first
-	GfxSurface s = getSurface(true);
+	s = getSurface(true);
 	s.clear(215);
 
-	// Draw four corners
-	s = getSurface();
-	s.blitFrom(_G(bgPics)[192], Common::Point(0, 0));
-	s.blitFrom(_G(bgPics)[193], Common::Point(_bounds.width() - 16, 0));
-	s.blitFrom(_G(bgPics)[194], Common::Point(0, _bounds.height() - 16));
-	s.blitFrom(_G(bgPics)[195], Common::Point(_bounds.width() - 16, _bounds.height() - 16));
-
-	// Draw top/bottom horizontal lines
-	for (int x = 16; x < _bounds.width() - 16; x += 16) {
-		s.blitFrom(_G(bgPics)[196], Common::Point(x, 0));
-		s.blitFrom(_G(bgPics)[197], Common::Point(x, _bounds.height() - 16));
+	// Draw title
+	Common::String title = "High Scores - Part I";
+	for (int area = 2; area <= _currentArea; ++area)
+		title += 'I';
+
+	int titleStart = (s.w - title.size() * 8) / 2;
+	s.print(Common::Point(titleStart, 4), title, 54);
+
+	for (int i = 0; i < 7; ++i) {
+		const HighScore &hs = _G(highScores)._scores[_currentArea - 1][i];
+
+		// Draw frames for name and score
+		s.frameRect(Common::Rect(10, 20 + i * 18, 210, 20 + i * 18 + 16),
+			206);
+		s.frameRect(Common::Rect(220, 20 + i * 18, 280, 20 + i * 18 + 16),
+			206);
+
+		// Write out the name and scores
+		s.print(Common::Point(15, 24 + i * 18), hs._name, 14);
+		Common::String score = Common::String::format("%d", hs._total);
+		s.print(Common::Point(275 - (score.size() * 8), 24 + i * 18), score, 14);
 	}
+}
+
+bool HighScores::msgFocus(const FocusMessage &msg) {
+	_currentArea = 1;
+	_showAll = true;
+	_timeoutCtr = TIMEOUT;
+
+	Gfx::load_palette();
+	return true;
+}
+
+bool HighScores::msgGame(const GameMessage &msg) {
+	if (msg._name == "HIGH_SCORES") {
+		// Finished one of the parts of the game, so just
+		// set the view to show only scores for that area
+		replaceView("HighScores", true);
+		_currentArea = msg._value;
+		_showAll = false;
+
+		draw();
+		fadeIn();
+
+		return true;
+	}
+
+	return false;
+}
+
+bool HighScores::msgAction(const ActionMessage &msg) {
+	if (msg._action == KEYBIND_ESCAPE) {
+		goToMainMenu();
+	} else {
+		goToNextArea();
 
-	// Draw left/right vertical lines
-	for (int y = 16; y < _bounds.height() - 16; y += 16) {
-		s.blitFrom(_G(bgPics)[198], Common::Point(0, y));
-		s.blitFrom(_G(bgPics)[199], Common::Point(_bounds.width() - 16, y));
 	}
+	return true;
+}
+
+void HighScores::goToMainMenu() {
+	fadeOut();
+	send("TitleBackground", GameMessage("MAIN_MENU"));
+}
+
+void HighScores::goToNextArea() {
+	if (_showAll && _currentArea < 3) {
+		fadeOut();
+		++_currentArea;
+		draw();
+		fadeIn();
+		_timeoutCtr = TIMEOUT;
+
+	} else {
+		// Done all the areas, so
+		goToMainMenu();
+	}
+}
+
+bool HighScores::tick() {
+	if (--_timeoutCtr < 0)
+		goToNextArea();
+
+	return true;
 }
 
 } // namespace Dialogs
diff --git a/engines/got/views/dialogs/high_scores.h b/engines/got/views/dialogs/high_scores.h
index 13fa46c44ea..70551cb7247 100644
--- a/engines/got/views/dialogs/high_scores.h
+++ b/engines/got/views/dialogs/high_scores.h
@@ -19,24 +19,35 @@
  *
  */
 
-#ifndef GOT_VIEWS_DIALOGS_DIALOG_H
-#define GOT_VIEWS_DIALOGS_DIALOG_H
+#ifndef GOT_VIEWS_DIALOGS_HIGH_SCORES_H
+#define GOT_VIEWS_DIALOGS_HIGH_SCORES_H
 
 #include "graphics/managed_surface.h"
-#include "got/views/view.h"
+#include "got/views/dialogs/dialog.h"
 
 namespace Got {
 namespace Views {
 namespace Dialogs {
 
-class Dialog : public View {
+class HighScores : public Dialog {
+private:
+	int _currentArea = 0;
+	bool _showAll = false;
+	int _timeoutCtr = 0;
+
+	void goToMainMenu();
+	void goToNextArea();
+
 public:
-	Dialog(const Common::String &name) : View(name) {
-	}
-	virtual ~Dialog() {
+	HighScores();
+	virtual ~HighScores() {
 	}
 
 	void draw() override;
+	bool msgFocus(const FocusMessage &msg) override;
+	bool msgAction(const ActionMessage &msg) override;
+	bool msgGame(const GameMessage &msg) override;
+	bool tick() override;
 };
 
 } // namespace Dialogs
diff --git a/engines/got/views/dialogs/main_menu.cpp b/engines/got/views/dialogs/main_menu.cpp
index d7979e2678b..450c41981f8 100644
--- a/engines/got/views/dialogs/main_menu.cpp
+++ b/engines/got/views/dialogs/main_menu.cpp
@@ -56,6 +56,10 @@ void MainMenu::selected() {
 			addView("SelectGame");
 		break;
 
+	case 2:
+		replaceView("HighScores", true, true);
+		break;
+
 	case 3:
 		addView("Credits");
 		break;
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 62b14a75f1b..df34bdef3d5 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -213,12 +213,13 @@ bool GameContent::tick() {
 	checkForAreaChange();
 
 	// Check for end of game area
-	// TODO: Show high score table rather than going straight to main menu
 	if (_G(end_tile)) {
 		_G(end_tile) = false;
 		Gfx::fade_out();
+
+		// Add name to high scores list if necessary, and then show it
 		_G(highScores).add(_G(area), _G(playerName), _G(thor_info).score);
-		g_events->send("TitleBackground", GameMessage("MAIN_MENU"));
+		g_events->send("HighScores", GameMessage("HIGH_SCORES", _G(area)));
 	}
 
 	return false;
diff --git a/engines/got/views/views.h b/engines/got/views/views.h
index 953b9d2fce1..be860b67018 100644
--- a/engines/got/views/views.h
+++ b/engines/got/views/views.h
@@ -30,6 +30,7 @@
 #include "got/views/story.h"
 #include "got/views/title_background.h"
 #include "got/views/dialogs/ask.h"
+#include "got/views/dialogs/high_scores.h"
 #include "got/views/dialogs/main_menu.h"
 #include "got/views/dialogs/options_menu.h"
 #include "got/views/dialogs/quit.h"
@@ -56,6 +57,7 @@ struct Views {
 	TitleBackground _titleBackground;
 
 	Dialogs::Ask _ask;
+	Dialogs::HighScores _highScores;
 	Dialogs::MainMenu _mainMenu;
 	Dialogs::OptionsMenu _optionsMenu;
 	Dialogs::Quit _quit;


Commit: af6262443ed0ff9d4955d51ea90f9d7eb076e5b2
    https://github.com/scummvm/scummvm/commit/af6262443ed0ff9d4955d51ea90f9d7eb076e5b2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Updated credits.pl

Changed paths:
    engines/got/credits.pl


diff --git a/engines/got/credits.pl b/engines/got/credits.pl
index ca1868df67e..4608d989870 100644
--- a/engines/got/credits.pl
+++ b/engines/got/credits.pl
@@ -1,3 +1,3 @@
 begin_section("Got");
-	add_person("Name 1", "Handle 1", "");
+	add_person("Paul Gilbert", "dreammaster", "");
 end_section();


Commit: ec518d048850963b6feac1abcd8ea20d99113292
    https://github.com/scummvm/scummvm/commit/ec518d048850963b6feac1abcd8ea20d99113292
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Removed demo detection entry

For two reasons. First and foremost, the demo mode doesn't
really work yet. And it's available from the game's main
menu in any case. Secondly, demo detections should really
be just for distinct demos of the games. It will only
confuse users if the full game is detecting both as the
game as well as the demo at the same time.

Changed paths:
    engines/got/detection_tables.h


diff --git a/engines/got/detection_tables.h b/engines/got/detection_tables.h
index 57031cacba4..8e6c5f0b2f2 100644
--- a/engines/got/detection_tables.h
+++ b/engines/got/detection_tables.h
@@ -23,7 +23,6 @@ namespace Got {
 
 const PlainGameDescriptor gotGames[] = {
 	{ "got", "God of Thunder" },
-	{ "gotdemo", "God of Thunder" },
 	{ 0, 0 }
 };
 
@@ -38,16 +37,6 @@ const ADGameDescription gameDescriptions[] = {
 		GUIO1(GUIO_NOSPEECH)
 	},
 
-	{
-		"gotdemo",
-		"Demo",
-		AD_ENTRY1s("gotres.dat", "747ed508ffa3808156a4eb080e9859f8", 739710),
-		Common::EN_ANY,
-		Common::kPlatformDOS,
-		ADGF_UNSTABLE | ADGF_DEMO,
-		GUIO1(GUIO_NOSPEECH)
-	},
-
 	AD_TABLE_END_MARKER
 };
 


Commit: c722dcfa629876f6f54abe46ca1da7ba4350d19c
    https://github.com/scummvm/scummvm/commit/c722dcfa629876f6f54abe46ca1da7ba4350d19c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Add parser for music data that dumps it out

Hopefully it will help making a proper ScummVM implementation

Changed paths:
    engines/got/sound.cpp


diff --git a/engines/got/sound.cpp b/engines/got/sound.cpp
index 513df5ff7cc..5936fb9baa0 100644
--- a/engines/got/sound.cpp
+++ b/engines/got/sound.cpp
@@ -85,11 +85,11 @@ void Sound::music_play(const char *name, bool override) {
 		g_engine->_mixer->stopHandle(_musicHandle);
 		_currentMusic = name;
 
+		File file(name);
+
 #ifdef TODO
 		// FIXME: Completely wrong. Don't know music format yet
 		// Open it up for access
-		File file(name);
-
 		Common::SeekableReadStream *f = file.readStream(file.size());
 		Audio::AudioStream *audioStream = Audio::makeRawStream(
 			f, 11025, 0, DisposeAfterUse::YES);
@@ -97,6 +97,71 @@ void Sound::music_play(const char *name, bool override) {
 			&_musicHandle, audioStream);
 #else
 		warning("TODO: play_music %s", name);
+
+		// The following is a dump of the music data in the hopes
+		// it will help someone write a decoder for ScummVM based on it.
+		// After an unknown header that doesn't seem to be used, the
+		// music seems to be a set of pauses followed by what I think
+		// are single byte combinations of frequency and duration that
+		/*
+		Following is a dump of the "play note" method, in case it's useful:
+		MU_playNote     proc far
+		
+		freq            = byte ptr  6
+		duration        = byte ptr  8
+		
+		                push    bp
+		                mov     bp, sp
+		                pushf
+		                cli
+		                mov     al, [bp+freq]
+		                mov     ah, 0
+		                mov     dl, [bp+duration]
+		                mov     bx, ax
+		                mov     MU_lookupTable[bx], dl
+		                mov     dx, 388h
+		                mov     al, [bp+freq]
+		                out     dx, al
+		                in      al, dx
+		                in      al, dx
+		                in      al, dx
+		                in      al, dx
+		                in      al, dx
+		                in      al, dx
+		                inc     dx
+		                mov     al, [bp+duration]
+		                out     dx, al
+		                popf
+		                dec     dx
+		                mov     cx, 35
+		
+		loc_246C8:
+		                in      al, dx
+		                loop    loc_246C8
+		                pop     bp
+		                retf
+		MU_playNote     endp
+		*/
+
+		int hdrCount = file.readUint16LE();
+		file.skip((hdrCount - 1) * 2);
+
+		int pause, duration, freq;
+
+		while (!file.eos()) {
+			pause = file.readByte();
+			if (pause & 0x80)
+				pause = ((pause & 0x7f) << 8) | file.readByte();
+
+			freq = file.readByte();
+			duration = file.readByte();
+			if (freq == 0 && duration == 0) {
+				debug(1, "End of song");
+				break;
+			}
+
+			debug(1, "Pause %d, freq %d, duration %d", pause, freq, duration);
+		}
 #endif
 	}
 }


Commit: c91e38ddb3d02ee4430e35c9395fc537b0e45c90
    https://github.com/scummvm/scummvm/commit/c91e38ddb3d02ee4430e35c9395fc537b0e45c90
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Janitorial

Changed paths:
    engines/got/game/back.cpp
    engines/got/game/boss1.cpp
    engines/got/game/boss2.cpp
    engines/got/game/init.cpp
    engines/got/game/move.cpp
    engines/got/game/move_patterns.cpp
    engines/got/game/object.cpp
    engines/got/game/script.cpp
    engines/got/game/shot_pattern.cpp
    engines/got/game/special_tile.cpp
    engines/got/game/status.cpp
    engines/got/game/status.h
    engines/got/utils/file.cpp
    engines/got/utils/file.h


diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index 90d4b2c7143..8ebd2f7f19e 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -76,11 +76,10 @@ void show_level(int new_level) {
 	show_enemies();
 
 	if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154) _G(thor)->dir = 0;
-	//xdisplay_actors(&_G(actor)[MAX_ACTORS - 1], draw_page);
 	_G(thor)->dir = save_d;
 
 	if (_G(warp_flag))
-		_G(current_level) = new_level - 5;   //force phase
+		_G(current_level) = new_level - 5;   // Force phase
 	_G(warp_flag) = 0;
 
 	if (_G(warp_scroll)) {
@@ -96,7 +95,7 @@ void show_level(int new_level) {
 	}
 
 	if (!_G(setup).scroll_flag)
-		_G(current_level) = new_level; //force no scroll
+		_G(current_level) = new_level; // Force no scroll
 
 	if (_G(music_current) != _G(level_type))
 		_G(sound).music_pause();
@@ -297,36 +296,18 @@ void remove_objects(int y, int x) {
 	p = (y * 20) + x;
 
 	if (_G(object_map)[p] > 0) {
-#if 0
-		ix = x * 16;
-		iy = y * 16;
-		xfput(ix, iy, PAGE2, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
-		xfput(ix, iy, PAGE2, (char far *) (bg_pics + (_G(scrn).icon[y][x] * 262)));
-		xcopyd2d(ix, iy, ix + 16, iy + 16, ix, iy, PAGE2, draw_page, 320, 320);
-#endif
 		_G(object_map)[p] = 0;
 		_G(object_index)[p] = 0;
 	}
 }
 
 void place_tile(int x, int y, int tile) {
-#if 0
-	int ix, iy;
-
-	ix = x * 16;
-	iy = y * 16;
-
-	xfput(ix, iy, PAGE2, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
-	xfput(ix, iy, PAGE2, (char far *) (bg_pics + (tile * 262)));
-	xcopyd2d(ix, iy, ix + 16, iy + 16, ix, iy, PAGE2, draw_page, 320, 320);
-	xcopyd2d(ix, iy, ix + 16, iy + 16, ix, iy, PAGE2, display_page, 320, 320);
-#endif
 	_G(scrn).icon[y][x] = tile;
 	remove_objects(y, x);
 }
 
 int bgtile(int x, int y) {
-	if (x < 0 || x>319 || y < 0 || y>191) return 0;  //303 , 175
+	if (x < 0 || x>319 || y < 0 || y>191) return 0;
 
 	x = (x + 1) >> 4;
 	y = (y + 1) >> 4;
diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index 521f6dc65fd..ad6ad9585f4 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -83,7 +83,7 @@ int boss1_movement(ACTOR *actr) {
 		actr->num_moves = _G(setup).skill + 2;
 		goto done1;
 	}
-	if (actr->temp2) {          //retreating
+	if (actr->temp2) {          // Retreating
 		if (actr->x < 256) {
 			d = 3;
 			actr->x += 2;
diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index 40d498cac7d..440d6d449d7 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -78,10 +78,6 @@ int boss2_movement(ACTOR *actr) {
 	}
 	d = actr->last_dir;
 
-	//if(overlap(actr->x+2,actr->y+8,actr->x+30,actr->y+30,
-	//          _G(thor)->x,_G(thor)->y+4,_G(thor)->x+15,_G(thor)->y+15))
-	//  thor_damaged(actr);
-
 	x = actr->x;
 
 	f = 0;
@@ -117,7 +113,7 @@ int boss2_movement(ACTOR *actr) {
 		if (x == 48 || x == 112 || x == 176 || x == 240) {
 			drop_flag = true;
 			_G(actor)[3].temp6 = 40;
-			//    actr->next=3;
+
 			actor_always_shoots(actr, 1);
 			play_sound(FALL, 0);
 			_G(actor)[actr->shot_actor].x = actr->x + 12;
@@ -158,12 +154,9 @@ void check_boss2_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
 		_G(actor)[3].health -= 10;
 		if (_G(actor)[3].health == 50) {
 			play_sound(BOSS12, 1);
-#if 0
-			timer_cnt = 0;
-			while (timer_cnt < 120);
-#else
+
 			g_events->send("Game", GameMessage("PAUSE", 40));
-#endif
+
 			_G(actor)[3].i1 = 1;
 			_G(actor)[3].i2 = 0;
 			memset(expf, 0, 60);
@@ -278,11 +271,6 @@ static int boss2a_movement(ACTOR *actr) {
 	_G(actor)[an].x = x;
 	_G(actor)[an].y = y;
 
-#if 0
-	xfput(x, y, display_page, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
-	xfput(x, y, draw_page, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
-	xfput(x, y, PAGE2, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
-#endif
 	_G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
 
 	_G(actor)[3].i2++;
diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index 2ad6b8b1803..8982833c7c7 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -104,7 +104,6 @@ void initialize_game() {
 	show_level(_G(current_level));
 
 	if (!_G(auto_load)) {
-//		fade_in();
 		_G(sound).music_play(_G(level_type), 1);
 	}
 
diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index d01d755d940..92328dfd723 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -105,7 +105,7 @@ void actor_damaged(ACTOR *actr, int damage) {
 		if (damage >= actr->health) {
 			if (actr->type != 4) {
 				add_score(actr->init_health * 10);
-//				display_score();
+
 			} else {
 				kill_good_guy();
 			}
@@ -259,8 +259,6 @@ int _actor_shoots(ACTOR *actr, int dir) {
 }
 
 void actor_always_shoots(ACTOR *actr, int dir) {
-
-
 	_actor_shoots(actr, dir);
 }
 
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index d89f9e8f77e..3622e1287ba 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -64,35 +64,35 @@ int movement_eight(ACTOR *actr);
 int movement_nine(ACTOR *actr);
 int movement_ten(ACTOR *actr);
 int movement_eleven(ACTOR *actr);
-int movement_twelve(ACTOR *actr);         // horz straight until bump
-int movement_thirteen(ACTOR *actr);       // pause-seek (mushroom)
-int movement_fourteen(ACTOR *actr);       // move-bump-stop (boulder)
-int movement_fifteen(ACTOR *actr);        // no move, no frame cycle
-int movement_sixteen(ACTOR *actr);        // tornado 1
-int movement_seventeen(ACTOR *actr);      // tornado 2
-int movement_eighteen(ACTOR *actr);       // random-seek-bite-run
-int movement_nineteen(ACTOR *actr);       // tornado 2
-int movement_twenty(ACTOR *actr);         // tornado 2
-int movement_twentyone(ACTOR *actr);      // eyeball
-int movement_twentytwo(ACTOR *actr);      // spear
-int movement_twentythree(ACTOR *actr);    // spinball cw
-int movement_twentyfour(ACTOR *actr);     // spinball ccw
+int movement_twelve(ACTOR *actr);         // Horz straight until bump
+int movement_thirteen(ACTOR *actr);       // Pause-seek (mushroom)
+int movement_fourteen(ACTOR *actr);       // Move-bump-stop (boulder)
+int movement_fifteen(ACTOR *actr);        // No move, no frame cycle
+int movement_sixteen(ACTOR *actr);        // Tornado 1
+int movement_seventeen(ACTOR *actr);      // Tornado 2
+int movement_eighteen(ACTOR *actr);       // Random-seek-bite-run
+int movement_nineteen(ACTOR *actr);       // Tornado 2
+int movement_twenty(ACTOR *actr);         // Tornado 2
+int movement_twentyone(ACTOR *actr);      // Eyeball
+int movement_twentytwo(ACTOR *actr);      // Spear
+int movement_twentythree(ACTOR *actr);    // Spinball cw
+int movement_twentyfour(ACTOR *actr);     // Spinball ccw
 int movement_twentyfive(ACTOR *actr);     //
 int movement_twentysix(ACTOR *actr);      //
 int movement_twentyseven(ACTOR *actr);    //
-int movement_twentyeight(ACTOR *actr);    // tree boss
-int movement_twentynine(ACTOR *actr);     // horz or vert (pass_val)
-int movement_thirty(ACTOR *actr);         // vert straight
-int movement_thirtyone(ACTOR *actr);      // drop (stalagtite)
-int movement_thirtytwo(ACTOR *actr);      // bomb 1
-int movement_thirtythree(ACTOR *actr);    // bomb 2
-int movement_thirtyfour(ACTOR *actr);     // gun (4-dir)
-int movement_thirtyfive(ACTOR *actr);     // gun (4-dir)
-int movement_thirtysix(ACTOR *actr);      // acid drop
+int movement_twentyeight(ACTOR *actr);    // Tree boss
+int movement_twentynine(ACTOR *actr);     // Horz or vert (pass_val)
+int movement_thirty(ACTOR *actr);         // Vert straight
+int movement_thirtyone(ACTOR *actr);      // Drop (stalagtite)
+int movement_thirtytwo(ACTOR *actr);      // Bomb 1
+int movement_thirtythree(ACTOR *actr);    // Bomb 2
+int movement_thirtyfour(ACTOR *actr);     // Gun (4-dir)
+int movement_thirtyfive(ACTOR *actr);     // Gun (4-dir)
+int movement_thirtysix(ACTOR *actr);      // Acid drop
 int movement_thirtyseven(ACTOR *actr);    // 4-way rnd,rnd len
-int movement_thirtyeight(ACTOR *actr);    // timed darting
-int movement_thirtynine(ACTOR *actr);     // troll 1
-int movement_forty(ACTOR *actr);          // troll 2
+int movement_thirtyeight(ACTOR *actr);    // Timed darting
+int movement_thirtynine(ACTOR *actr);     // Troll 1
+int movement_forty(ACTOR *actr);          // Troll 2
 
 int (*const movement_func[]) (ACTOR *actr) = {
 	movement_zero,
@@ -295,7 +295,7 @@ int check_move0(int x, int y, ACTOR *actr) {
 	y2 = y + 15;
 
 	_G(thor_special_flag) = 0;
-	for (i = 3; i < MAX_ACTORS; i++) {   //max_actors
+	for (i = 3; i < MAX_ACTORS; i++) {
 		act = &_G(actor)[i];
 		if (act->solid & 128) continue;
 		if (!act->used) continue;
@@ -306,7 +306,7 @@ int check_move0(int x, int y, ACTOR *actr) {
 		x4 = act->x + act->size_x - 1;
 		y4 = act->y + act->size_y - 1;
 		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
-			if (act->func_num > 0) { //255=explosion
+			if (act->func_num > 0) { // 255=explosion
 				if (act->func_num == 255) return 0;
 				act->temp1 = x;
 				act->temp2 = y;
@@ -347,7 +347,7 @@ int check_move1(int x, int y, ACTOR *actr) {
 	x2 = (x + 10) >> 4;
 	y2 = (y + 10) >> 4;
 
-	//check for solid or fly over
+	// Check for solid or fly over
 	icn = TILE_FLY;
 	if (actr->flying) icn = TILE_SOLID;
 
@@ -371,10 +371,10 @@ int check_move1(int x, int y, ACTOR *actr) {
 	y2 = y + 10;
 
 	f = 0;
-	for (i = 3; i < MAX_ACTORS; i++) {       //max_actors
+	for (i = 3; i < MAX_ACTORS; i++) {
 		act = &_G(actor)[i];
 		if (!act->used) continue;
-		if (act->type == 3) continue;  //continue
+		if (act->type == 3) continue;
 		x3 = act->x;
 		if ((ABS(x3 - x1)) > 16) continue;
 		y3 = act->y;
@@ -428,7 +428,7 @@ int check_move2(int x, int y, ACTOR *actr) {
 	x2 = ((x + actr->size_x) - 1) >> 4;
 	y2 = ((y + actr->size_y) - 1) >> 4;
 
-	//check for solid or fly over
+	// Check for solid or fly over
 
 	icn = TILE_FLY;
 	if (actr->flying) icn = TILE_SOLID;
@@ -450,12 +450,12 @@ int check_move2(int x, int y, ACTOR *actr) {
 	x2 = (x + actr->size_x) - 1;
 	y2 = (y + actr->size_y) - 1;
 
-	for (i = 0; i < MAX_ACTORS; i++) {   //max_actors
+	for (i = 0; i < MAX_ACTORS; i++) {
 		act = &_G(actor)[i];
 		if (act->actor_num == actr->actor_num) continue;
 		if (act->actor_num == 1) continue;
 		if (!act->used) continue;
-		if (act->type == 3) continue;   //shot
+		if (act->type == 3) continue;   // Shot
 		if (i == 0) {
 			if (overlap(x1, y1, x2, y2, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
 				thor_damaged(actr);
@@ -500,7 +500,7 @@ int check_move3(int x, int y, ACTOR *actr) {
 	x2 = ((x + actr->size_x) - 1) >> 4;
 	y2 = ((y + actr->size_y) - 1) >> 4;
 
-	//check for solid or fly over
+	// Check for solid or fly over
 
 	icn = TILE_FLY;
 	if (actr->flying) icn = TILE_SOLID;
@@ -516,7 +516,7 @@ int check_move3(int x, int y, ACTOR *actr) {
 	if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
 	if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
 
-	//check for solid or fly over
+	// Check for solid or fly over
 	x1 = x + 1;
 	y1 = y + 1;
 	x2 = (x + actr->size_x) - 1;
@@ -526,12 +526,12 @@ int check_move3(int x, int y, ACTOR *actr) {
 		thor_damaged(actr);
 		return 0;
 	}
-	for (i = 3; i < MAX_ACTORS; i++) {   //max_actors
+	for (i = 3; i < MAX_ACTORS; i++) {
 		if (i == actr->actor_num) continue;
 		act = &_G(actor)[i];
 		if (!act->used) continue;
 		if (act->solid < 2) continue;
-		if (act->type == 3) continue;   //shot
+		if (act->type == 3) continue;   // Shot
 		if (act->actor_num == actr->creator) continue;
 		x3 = act->x;
 		if ((ABS(x3 - x1)) > 16) continue;
@@ -754,7 +754,7 @@ int check_special_move1(int x, int y, ACTOR *actr) {
 	x2 = (x + 15) >> 4;
 	y2 = (y + 15) >> 4;
 
-	//check for solid or fly over
+	// Check for solid or fly over
 
 	icn = TILE_FLY;
 	if (actr->flying) icn = TILE_SOLID;
@@ -775,7 +775,7 @@ int check_special_move1(int x, int y, ACTOR *actr) {
 	x2 = (x + 15);
 	y2 = (y + 15);
 
-	for (i = 3; i < MAX_ACTORS; i++) {   //max_actors
+	for (i = 3; i < MAX_ACTORS; i++) {
 		act = &_G(actor)[i];
 		if (act->actor_num == actr->actor_num) continue;
 		if (!act->used) continue;
@@ -788,11 +788,11 @@ int check_special_move1(int x, int y, ACTOR *actr) {
 		y4 = act->y + 15;
 		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) return 0;
 	}
-	for (i = 3; i < MAX_ACTORS; i++) {   //max_actors
+	for (i = 3; i < MAX_ACTORS; i++) {
 		act = &_G(actor)[i];
 		if (act->actor_num == actr->actor_num) continue;
 		if (!act->used) continue;
-		if (act->type == 3) continue;   //shot
+		if (act->type == 3) continue;   // Shot
 		x3 = act->x;
 		if ((ABS(x3 - x1)) > 16) continue;
 		y3 = act->y;
@@ -860,12 +860,12 @@ int special_movement_two(ACTOR *actr) {
 	int x3, y3, x4, y4;
 	ACTOR *act;
 
-	x1 = actr->temp1;       //calc thor pos
+	x1 = actr->temp1;       // Calc thor pos
 	y1 = actr->temp2;
 	x2 = x1 + 13;
 	y2 = y1 + 14;
 
-	for (i = 3; i < MAX_ACTORS; i++) {   //max_actors
+	for (i = 3; i < MAX_ACTORS; i++) {
 		act = &_G(actor)[i];
 		if (actr->actor_num == act->actor_num) continue;
 		if (!act->used) continue;
@@ -1913,7 +1913,6 @@ int movement_twentyfive(ACTOR *actr) {
 		return movement_one(actr);
 	}
 	if (!actr->temp1) {
-		//  actr->temp2=12;
 		actr->last_dir = g_events->getRandomNumber(3);
 		i = 4;
 		while (i--) {
@@ -1956,7 +1955,8 @@ void set_thor_vars() {
 	_G(thor_y2) = _G(thor)->y + 15;
 }
 
-int movement_twentyeight(ACTOR *actr) {         //fish
+// Fish
+int movement_twentyeight(ACTOR *actr) {
 	int d, x1, y1, ret;
 
 	d = actr->last_dir;
@@ -1987,7 +1987,6 @@ int movement_twentyeight(ACTOR *actr) {         //fish
 					actr->frame_speed = 4;
 					actr->i1 = g_events->getRandomNumber(60, 159);
 				}
-				//      else actr->solid=1;
 			}
 		}
 		goto done;
@@ -2036,12 +2035,14 @@ done:
 	return d;
 }
 
-int movement_twentynine(ACTOR *actr) {  //horz or vert (pass_val)
+// Horz or vert (pass_val)
+int movement_twentynine(ACTOR *actr) {
 	if (!actr->pass_value) return movement_thirty(actr);
 	else return movement_twelve(actr);
 }
 
-int movement_thirty(ACTOR *actr) {         //vert straight
+// Vert straight
+int movement_thirty(ACTOR *actr) {
 	int d, x1, y1;
 
 	d = actr->last_dir;
@@ -2064,7 +2065,8 @@ int movement_thirty(ACTOR *actr) {         //vert straight
 	return d;
 }
 
-int movement_thirtyone(ACTOR *actr) {         //drop (stalagtite)
+// Drop (stalagtite)
+int movement_thirtyone(ACTOR *actr) {
 	int d, x1, y1, cx, cy, ty, i;
 
 	d = actr->last_dir;
@@ -2094,32 +2096,32 @@ done:
 	return d;
 }
 
-int movement_thirtytwo(ACTOR *actr) {      //unused
-
+// Unused
+int movement_thirtytwo(ACTOR *actr) {
 	actr = actr;
 	return 0;
 }
 
-int movement_thirtythree(ACTOR *actr) {    //unused
-
+// Unused
+int movement_thirtythree(ACTOR *actr) {
 	actr = actr;
 	return 0;
 }
 
-int movement_thirtyfour(ACTOR *actr) {    //unused
-
+// Unused
+int movement_thirtyfour(ACTOR *actr) {
 	actr = actr;
 	return 0;
 }
 
-int movement_thirtyfive(ACTOR *actr) {    //gun (single)
-
+// Gun (single)
+int movement_thirtyfive(ACTOR *actr) {
 	actr->next = actr->last_dir;
 	return actr->dir;
 }
 
-int movement_thirtysix(ACTOR *actr) {    //acid drop
-
+// Acid drop
+int movement_thirtysix(ACTOR *actr) {
 	actr->speed = actr->pass_value;
 	next_frame(actr);
 	if (actr->next == 0 && actr->frame_count == actr->frame_speed) {
@@ -2129,7 +2131,7 @@ int movement_thirtysix(ACTOR *actr) {    //acid drop
 	return 0;
 }
 
-//4-way straight (random length) change
+// 4-way straight (random length) change
 int movement_thirtyseven(ACTOR *actr) {
 	int d, x1, y1, f;
 
@@ -2170,7 +2172,7 @@ int movement_thirtyseven(ACTOR *actr) {
 	return d;
 }
 
-//timed darting
+// Timed darting
 #define TIMER     actr->i1
 #define INIT_DIR  actr->temp1
 #define OTHER_DIR actr->temp2
@@ -2185,7 +2187,6 @@ int movement_thirtyeight(ACTOR *actr) {
 	x1 = actr->x;
 	y1 = actr->y;
 
-
 	if (!FLAG) {
 		FLAG = 1;
 		if (actr->pass_value) TIMER = actr->pass_value * 15;
@@ -2260,8 +2261,8 @@ done:
 	return d;
 }
 
-int movement_thirtynine(ACTOR *actr) {    //troll 1
-
+// Troll 1
+int movement_thirtynine(ACTOR *actr) {
 	if (_G(setup).skill == 0) {
 		actr->speed = 3; actr->num_moves = 1;
 	} else if (_G(setup).skill == 1) {
@@ -2270,7 +2271,6 @@ int movement_thirtynine(ACTOR *actr) {    //troll 1
 		actr->speed = 1; actr->num_moves = 1;
 	}
 
-
 	if (actr->pass_value < 5) return movement_forty(actr);
 	if (actr->pass_value == 10) {
 		if (overlap(actr->x + 1, actr->y + 1, actr->x + actr->size_x - 1,
@@ -2298,7 +2298,8 @@ int movement_thirtynine(ACTOR *actr) {    //troll 1
 	return actr->dir;
 }
 
-int movement_forty(ACTOR *actr) {    //troll 2
+// Troll 2
+int movement_forty(ACTOR *actr) {
 	int x1, x2, a, d, f;
 
 	if (overlap(actr->x + 1, actr->y + 1, actr->x + actr->size_x + 3,
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index d1616af07e7..93fcda7655f 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -53,35 +53,35 @@ void pick_up_object(int p) {
 	int r, x, y, s;
 
 	switch (_G(object_map)[p]) {
-	case 1:           //red jewel
+	case 1:           // Red jewel
 		if (_G(thor_info).jewels >= 999) {
 			cannot_carry_more();
 			return;
 		}
 		add_jewels(10);
 		break;
-	case 2:           //blue jewel
+	case 2:           // Blue jewel
 		if (_G(thor_info).jewels >= 999) {
 			cannot_carry_more();
 			return;
 		}
 		add_jewels(1);
 		break;
-	case 3:           //red potion
+	case 3:           // Red potion
 		if (_G(thor_info).magic >= 150) {
 			cannot_carry_more();
 			return;
 		}
 		add_magic(10);
 		break;
-	case 4:           //blue potion
+	case 4:           // Blue potion
 		if (_G(thor_info).magic >= 150) {
 			cannot_carry_more();
 			return;
 		}
 		add_magic(3);
 		break;
-	case 5:          //good apple
+	case 5:          // Good apple
 		if (_G(thor)->health >= 150) {
 			cannot_carry_more();
 			return;
@@ -90,26 +90,25 @@ void pick_up_object(int p) {
 		s = 1;
 		add_health(5);
 		break;
-	case 6:           //bad apple
+	case 6:           // Bad apple
 		play_sound(OW, 0);
 		s = 1;
 		add_health(-10);
 		break;
-	case 7:           //key (reset on exit)
-		//           if(_G(scrn).reset) r=0;
+	case 7:           // Key (reset on exit)
 		add_keys(1);
 		break;
-	case 8:          //treasure
+	case 8:           // Treasure
 		if (_G(thor_info).jewels >= 999) {
 			cannot_carry_more();
 			return;
 		}
 		add_jewels(50);
 		break;
-	case 9:          //trophy
+	case 9:          // Trophy
 		add_score(100);
 		break;
-	case 10:         //crown
+	case 10:         // Crown
 		add_score(1000);
 		break;
 	case 12:
@@ -171,10 +170,6 @@ void pick_up_object(int p) {
 	_G(oy) = y * 16;
 	_G(of) = 1;
 
-	//xfput(_G(ox), _G(oy), PAGE2, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
-	//xfput(_G(ox), _G(oy), PAGE2, (char far *) (bg_pics + (_G(scrn).icon[y][x] * 262)));
-	//xcopyd2d(_G(ox), _G(oy), _G(ox) + 16, _G(oy) + 16, _G(ox), _G(oy), PAGE2, draw_page, 320, 320);
-
 	r = 1;
 	s = 0;
 	if (!s)
@@ -182,7 +177,7 @@ void pick_up_object(int p) {
 	_G(object_map)[p] = 0;
 
 	if (r) {
-		// reset so it doesn't reappear on reentry to screen
+		// Reset so it doesn't reappear on reentry to screen
 		if (_G(object_index)[p] < 30)
 			_G(scrn).static_obj[_G(object_index)[p]] = 0;
 		_G(object_index)[p] = 0;
@@ -195,14 +190,22 @@ int drop_object(ACTOR *actr) {
 	rnd1 = g_events->getRandomNumber(99);
 	rnd2 = g_events->getRandomNumber(99);
 
-	if (rnd1 < 25) o = 5;      //apple
-	else if (rnd1 & 1) {    //jewels
-		if (rnd2 < 10) o = 1;      //red
-		else o = 2;           //blue
-	} else {                 //potion
-		if (rnd2 < 10) o = 3;    //red
-		else o = 4;           //blue
+	if (rnd1 < 25)
+		o = 5;      // Apple
+	else if (rnd1 & 1) {
+		// Jewels
+		if (rnd2 < 10)
+			o = 1;      // Red
+		else
+			o = 2;      // Blue
+	} else {
+		// Potion
+		if (rnd2 < 10)
+			o = 3;      // Red
+		else
+			o = 4;      // Blue
 	}
+
 	_drop_obj(actr, o);
 	return 1;
 }
@@ -214,13 +217,7 @@ int _drop_obj(ACTOR *actr, int o) {
 	if (!_G(object_map)[p] && _G(scrn).icon[p / 20][p % 20] >= 140) {  //nothing there and solid
 		_G(object_map)[p] = o;
 		_G(object_index)[p] = 27 + actr->actor_num;  //actor is 3-15
-#if 0
-		x = (p % 20) * 16;
-		y = (p / 20) * 16;
-		xfput(x, y, PAGE2, (char far *) objects[o - 1]);
-		xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, draw_page, 320, 320);
-		xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, display_page, 320, 320);
-#endif
+
 		return 1;
 	}
 
@@ -370,7 +367,6 @@ int use_shield(int flag) {
 }
 
 int use_lightning(int flag) {
-
 	if (flag) {
 		if (_G(thor_info).magic > 14) {
 			add_magic(-15);
@@ -384,7 +380,6 @@ int use_lightning(int flag) {
 }
 
 int use_tornado(int flag) {
-
 	if (flag) {
 		if (_G(thor_info).magic > 10) {
 			if (!_G(tornado_used) && !_G(actor)[2].dead && _G(magic_cnt) > 20) {
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 48cadbc38ce..05f9ac49957 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -552,7 +552,7 @@ int Scripts::read_script_file() {
 		for (i = 0; i < len; i++) {
 			ch = tmps[i];
 			if (ch == 34) quote_flag ^= 1;
-			else if (ch == 13 || ch == 10) {  //check for CR
+			else if (ch == 13 || ch == 10) {  // Check for CR
 				temp_buff[p] = 0;
 				break;
 			} else if ((ch == 39 || ch == 96) && !quote_flag) {
@@ -606,7 +606,7 @@ void Scripts::script_error(int err_num) {
 	}
 
 	if (err_num > ERROR_MAX)
-		err_num = 5;       // unknown=syntax
+		err_num = 5;       // Unknown=syntax
 
 	warning("%s in Line #%d", SCR_ERROR[err_num], line_num);
 }
@@ -1014,7 +1014,6 @@ void Scripts::scr_func3() {
 
 			_G(object_map)[p] = o;
 			_G(object_index)[p] = 31;  // actor is 3-15
-			//pause(30);
 		}
 	}
 }
@@ -1064,13 +1063,13 @@ int Scripts::exec_command(int num) {
 			_buffPtr = _newPtr;
 		}
 		break;
-	case 4:                         //return
+	case 4:                         // return
 		if (!_gosubPtr) {
 			ret = 9; break;
 		}
 		_buffPtr = _gosubStack[_gosubPtr--];
 		break;
-	case 5:                         //for
+	case 5:                         // for
 		_forPtr++;
 		if (_forPtr > 10) {
 			ret = 10; break;
@@ -1093,7 +1092,7 @@ int Scripts::exec_command(int num) {
 		_forVal[_forPtr] = _lValue;
 		_forStack[_forPtr] = _buffPtr;
 		break;
-	case 6:                         //next
+	case 6:                         // next
 		if (!_forPtr) {
 			ret = 11; break;
 		}
diff --git a/engines/got/game/shot_pattern.cpp b/engines/got/game/shot_pattern.cpp
index bfffb4cd112..73a5b428989 100644
--- a/engines/got/game/shot_pattern.cpp
+++ b/engines/got/game/shot_pattern.cpp
@@ -157,7 +157,7 @@ int shot_pattern_five(ACTOR *actr) {
 			actr->shots_allowed = 3 + _G(setup).skill;
 			actor_shoots(actr, 2);
 			play_sound(BOSS12, 0);
-			//     num=actr->creator;
+
 			num = actr->shot_actor;
 			actr->shot_cnt = 50;
 			_G(actor)[num].temp3 = 120;
diff --git a/engines/got/game/special_tile.cpp b/engines/got/game/special_tile.cpp
index e021678524c..a3565968fd6 100644
--- a/engines/got/game/special_tile.cpp
+++ b/engines/got/game/special_tile.cpp
@@ -152,7 +152,7 @@ int special_tile_thor(int x, int y, int icon) {
 	case 218:
 	case 219:
 		f = 1;
-	case 220:     //hole tiles
+	case 220:     // Hole tiles
 	case 221:
 	case 222:
 	case 223:
@@ -235,19 +235,13 @@ int special_tile(ACTOR *actr, int x, int y, int icon) {
 void erase_door(int x, int y) {
 	play_sound(DOOR, 0);
 	_G(scrn).icon[y][x] = _G(scrn).bg_color;
-
-	//x = x << 4;
-	//y = y << 4;
-	//xfput(x, y, PAGE2, (char far *) (bg_pics + (_G(scrn).bg_color * 262)));
-	//xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, draw_page, 320, 320);
-	//xcopyd2d(x, y, x + 16, y + 16, x, y, PAGE2, display_page, 320, 320);
 }
 
 int open_door1(int y, int x) {
 	if (_G(thor_info).keys > 0) {
 		erase_door(x, y);
 		_G(thor_info).keys--;
-		//display_keys();
+
 		return 1;
 	} else {
 		if (!_G(door_inform)) {
@@ -263,7 +257,7 @@ int cash_door1(int y, int x, int amount) {
 	if (_G(thor_info).jewels >= amount) {
 		erase_door(x, y);
 		_G(thor_info).jewels -= amount;
-		//display_jewels();
+
 		return 1;
 	} else {
 		if (amount == 10 && !_G(cash1_inform)) {
diff --git a/engines/got/game/status.cpp b/engines/got/game/status.cpp
index 64d49517f5d..4a491815343 100644
--- a/engines/got/game/status.cpp
+++ b/engines/got/game/status.cpp
@@ -64,32 +64,4 @@ void fill_score(int num, const char *endMessage) {
 	g_events->send("GameStatus", msg);
 }
 
-void score_for_inv() {
-#ifdef TODO
-	while (_G(thor)->health) {
-		_G(thor)->health--;
-		play_sound(WOOP, 1);
-		add_health(-1);
-		add_score(10);
-		pause(8);
-	}
-	while (_G(thor_info).magic) {
-		_G(thor_info).magic--;
-		play_sound(WOOP, 1);
-		add_magic(-1);
-		add_score(10);
-		pause(8);
-	}
-	while (_G(thor_info).jewels) {
-		_G(thor_info).jewels--;
-		play_sound(WOOP, 1);
-		add_jewels(-1);
-		add_score(10);
-		pause(8);
-	}
-#else
-	error("TODO: score_for_inv");
-#endif
-}
-
 } // namespace Got
diff --git a/engines/got/game/status.h b/engines/got/game/status.h
index a07ccd6de0a..299295eb774 100644
--- a/engines/got/game/status.h
+++ b/engines/got/game/status.h
@@ -34,7 +34,6 @@ extern void add_keys(int num);
 extern void fill_health();
 extern void fill_magic();
 extern void fill_score(int num, const char *endMessage = nullptr);
-extern void score_for_inv();
 
 } // namespace Got
 
diff --git a/engines/got/utils/file.cpp b/engines/got/utils/file.cpp
index 49899fdafbd..d445a6cf83c 100644
--- a/engines/got/utils/file.cpp
+++ b/engines/got/utils/file.cpp
@@ -123,104 +123,6 @@ bool load_speech(int index) {
 void setup_filenames(int level) {
 }
 
-void help(void) {
-#ifdef TODO
-	odin_speaks(2008, -1);
-#endif
-}
-
-void save_game() {
-#if TODO
-	int handle;
-	unsigned int total;
-	char buff[32];
-
-	if (game_over)
-		return;
-
-	setup.area = _G(area);
-	setup.game_over = game_over;
-
-	if (select_option(options_yesno, "Save Game?", 0) != 1) {
-		d_restore();
-		return;
-	}
-
-	d_restore();
-
-
-	if (_dos_open(save_filename, O_RDONLY, &handle) != 0) return;
-	_dos_read(handle, buff, 32, &total);
-	_dos_close(handle);
-
-	if (_dos_open(save_filename, O_WRONLY, &handle) != 0) return;
-	_dos_write(handle, buff, 32, &total);
-	_dos_write(handle, &setup, sizeof(SETUP), &total);
-	_dos_write(handle, &thor_info, sizeof(THOR_INFO), &total);
-	_dos_write(handle, _G(sd_data), 61440u, &total);
-	_dos_close(handle);
-	odin_speaks(2009, 0);
-#endif
-}
-
-bool load_game(int flag) {
-#ifdef TODO
-	int handle;
-	unsigned int total;
-	char buff[32];
-
-	if (flag) {
-		if (select_option(options_yesno, "Load Game?", 0) != 1) {
-			d_restore();
-			return 0;
-		}
-		d_restore();
-	}
-	if (_dos_open(save_filename, O_RDONLY, &handle) != 0) return 0;
-	_dos_read(handle, buff, 32, &total);
-	_dos_read(handle, &setup, sizeof(SETUP), &total);
-	_dos_read(handle, &thor_info, sizeof(THOR_INFO), &total);
-	_dos_read(handle, _G(sd_data), 61440u, &total);
-	_dos_close(handle);
-
-	current_area = thor_info.last_screen;
-	area = setup.area;
-	if (area == 0) area = 1;
-
-	thor->x = (thor_info.last_icon % 20) * 16;
-	thor->y = ((thor_info.last_icon / 20) * 16) - 1;
-	if (thor->x < 1) thor->x = 1;
-	if (thor->y < 0) thor->y = 0;
-	thor->dir = thor_info.last_dir;
-	thor->last_dir = thor_info.last_dir;
-	thor->health = thor_info.last_health;
-	thor->num_moves = 1;
-	thor->vunerable = 60;
-	thor->show = 60;
-	thor->speed_count = 6;
-	load_new_thor();
-	display_health();
-	display_magic();
-	display_jewels();
-	display_keys();
-	display_item();
-	if (!music_flag) setup.music = 0;
-	if (!sound_flag) setup.dig_sound = 0;
-	if (setup.music == 1) {
-		if (GAME1 == 1 && current_area == 59) {
-			if (flag) music_play(5, 1);
-		} else if (flag) music_play(level_type, 1);
-	} else {
-		setup.music = 1;
-		music_pause();
-		setup.music = 0;
-	}
-	game_over = setup.game_over;
-	slow_mode = setup.speed;
-#endif
-	return true;
-}
-
 long res_read(const Common::String &name, void *buff, bool failAllowed) {
 	Common::File f;
 	if (f.open(Common::Path(name))) {
diff --git a/engines/got/utils/file.h b/engines/got/utils/file.h
index fc57fecefb8..b0a28de279a 100644
--- a/engines/got/utils/file.h
+++ b/engines/got/utils/file.h
@@ -28,18 +28,11 @@
 namespace Got {
 
 extern long file_size(const char *path);
-extern unsigned int read_file(const char *filename, const char *buff,
-	long offset, unsigned int amount, int key);
 
 extern bool load_actor(int, int num);
-extern bool load_picture(int index, char *buff);
 extern void setup_filenames(int level);
 extern bool  load_speech(int index);
 extern long file_size(const char *path);
-extern void *get_file(const char *filename, int key);
-extern void save_game();
-extern bool load_game(int flag);
-extern void help();
 extern long res_read(const Common::String &name, void *buff,
 	bool failAllowed = false);
 extern void *res_falloc_read(const Common::String &name);


Commit: 6ea2c5647ffa5a189391be7e4b561a5896418c6c
    https://github.com/scummvm/scummvm/commit/6ea2c5647ffa5a189391be7e4b561a5896418c6c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Create engine-data file for executable graphics

The GfxChunks class can fall back on reading the graphics
directly from the executable. It now has a commented out
section that can take the resulting data and create the
stand-alone gfx file

Changed paths:
  A dists/engine-data/got.gfx
    engines/got/gfx/gfx_chunks.cpp


diff --git a/dists/engine-data/got.gfx b/dists/engine-data/got.gfx
new file mode 100644
index 00000000000..8c4a1503b36
Binary files /dev/null and b/dists/engine-data/got.gfx differ
diff --git a/engines/got/gfx/gfx_chunks.cpp b/engines/got/gfx/gfx_chunks.cpp
index f999f90f47c..17a122a0491 100644
--- a/engines/got/gfx/gfx_chunks.cpp
+++ b/engines/got/gfx/gfx_chunks.cpp
@@ -83,6 +83,15 @@ void GfxChunks::load() {
 	// Get stream to access images
 	Common::SeekableReadStream *f = getStream();
 
+#if 0
+	Common::DumpFile df;
+	if (df.open("got.gfx")) {
+		df.writeStream(f);
+		f->seek(0);
+	}
+	df.close();
+#endif
+
 	// Keep a copy in memory for decoding images as needed
 	_data = new byte[f->size()];
 	f->read(_data, f->size());
@@ -113,7 +122,7 @@ GraphicChunk &GfxChunks::operator[](uint idx) {
 Common::SeekableReadStream *GfxChunks::getStream() const {
 	// Check for stand-alone graphics file
 	Common::File *f = new Common::File;
-	if (f->open("graphics.got"))
+	if (f->open("got.gfx"))
 		return f;
 	delete f;
 


Commit: d443895448314db6e299252d239f35c7cccd5cfd
    https://github.com/scummvm/scummvm/commit/d443895448314db6e299252d239f35c7cccd5cfd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Added got.gfx to engine_data.mk

Changed paths:
    dists/engine-data/README
    dists/engine-data/engine_data.mk


diff --git a/dists/engine-data/README b/dists/engine-data/README
index c3f0b8d7529..8cda4ec29f2 100644
--- a/dists/engine-data/README
+++ b/dists/engine-data/README
@@ -45,6 +45,9 @@ This file contains set of free CJK fonts (or other big ones), used in our GUI an
 some engines. This file is intended to be big, thus, not suitable for ports with
 memory constraints.
 
+got.gfx:
+This is a set of graphics for the title screen and main menu that were embedded in the executable.
+
 grim-patch.lab:
 This file contains set of script patches for Grim Fandango game.
 
diff --git a/dists/engine-data/engine_data.mk b/dists/engine-data/engine_data.mk
index d770afdc1cd..3461515ad40 100644
--- a/dists/engine-data/engine_data.mk
+++ b/dists/engine-data/engine_data.mk
@@ -16,6 +16,9 @@ endif
 ifdef ENABLE_DRASCULA
 DIST_FILES_LIST += dists/engine-data/drascula.dat
 endif
+ifdef ENABLE_GOT
+DIST_FILES_LIST += dists/engine-data/got.gfx
+endif
 ifdef ENABLE_HADESCH
 DIST_FILES_LIST += dists/engine-data/hadesch_translations.dat
 endif


Commit: 1ad07f0b6af110de8e721c7d80134f468a99d97c
    https://github.com/scummvm/scummvm/commit/1ad07f0b6af110de8e721c7d80134f468a99d97c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Cleanup of HighScores class

Changed paths:
    engines/got/data/high_scores.cpp
    engines/got/data/high_scores.h


diff --git a/engines/got/data/high_scores.cpp b/engines/got/data/high_scores.cpp
index f0d647b8f34..9211fbb9357 100644
--- a/engines/got/data/high_scores.cpp
+++ b/engines/got/data/high_scores.cpp
@@ -84,18 +84,9 @@ void HighScores::save() {
 	delete sf;
 }
 
-static int sortScores(const HighScore &hs1, const HighScore &hs2) {
-	if (hs1._total < hs2._total)
-		return -1;
-	else if (hs1._total > hs2._total)
-		return 1;
-	else
-		return 0;
-}
-
 void HighScores::add(int area, const Common::String &name, uint total) {
 	// Find the index for the new score in the list
-	uint newIndex;
+	int newIndex;
 	for (newIndex = 0; newIndex < HIGH_SCORES_PER_AREA &&
 		total < _scores[area - 1][newIndex]._total; ++newIndex) {
 	}
diff --git a/engines/got/data/high_scores.h b/engines/got/data/high_scores.h
index 4c748b3c443..3db75102c9a 100644
--- a/engines/got/data/high_scores.h
+++ b/engines/got/data/high_scores.h
@@ -29,9 +29,9 @@ namespace Got {
 #define HIGH_SCORES_PER_AREA 7
 
 struct HighScore {
-	uint16 _unused = 0;
-	uint32 _total = 0;
-	char _name[32] = {};
+	uint16 _unused;
+	uint32 _total;
+	char _name[32];
 
 	void sync(Common::Serializer &s);
 };


Commit: 59abcd517606e9c668a0577fee95fee8eeeed0ee
    https://github.com/scummvm/scummvm/commit/59abcd517606e9c668a0577fee95fee8eeeed0ee
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Janitorial provided by eientei

Changed paths:
    engines/got/console.cpp
    engines/got/console.h
    engines/got/credits.pl
    engines/got/data/actor.cpp
    engines/got/data/actor.h
    engines/got/data/defines.h
    engines/got/data/high_scores.cpp
    engines/got/data/high_scores.h
    engines/got/data/level.cpp
    engines/got/data/level.h
    engines/got/data/sd_data.cpp
    engines/got/data/sd_data.h
    engines/got/data/setup.cpp
    engines/got/data/setup.h
    engines/got/data/thor_info.cpp
    engines/got/data/thor_info.h
    engines/got/detection.cpp
    engines/got/detection.h
    engines/got/detection_tables.h
    engines/got/events.cpp
    engines/got/events.h
    engines/got/game/back.cpp
    engines/got/game/boss1.cpp
    engines/got/game/boss2.cpp
    engines/got/game/boss3.cpp
    engines/got/game/init.cpp
    engines/got/game/main.cpp
    engines/got/game/move.cpp
    engines/got/game/move_patterns.cpp
    engines/got/game/object.cpp
    engines/got/game/script.cpp
    engines/got/game/script.h
    engines/got/game/shot_movement.cpp
    engines/got/game/shot_pattern.cpp
    engines/got/game/special_tile.cpp
    engines/got/game/status.cpp
    engines/got/gfx/font.cpp
    engines/got/gfx/font.h
    engines/got/gfx/gfx_chunks.cpp
    engines/got/gfx/gfx_chunks.h
    engines/got/gfx/gfx_pics.cpp
    engines/got/gfx/gfx_pics.h
    engines/got/gfx/gfx_surface.cpp
    engines/got/gfx/gfx_surface.h
    engines/got/gfx/image.cpp
    engines/got/gfx/palette.cpp
    engines/got/gfx/palette.h
    engines/got/got.cpp
    engines/got/got.h
    engines/got/messages.cpp
    engines/got/messages.h
    engines/got/metaengine.cpp
    engines/got/metaengine.h
    engines/got/module.mk
    engines/got/sound.cpp
    engines/got/sound.h
    engines/got/utils/compression.cpp
    engines/got/utils/file.cpp
    engines/got/utils/file.h
    engines/got/utils/res_archive.cpp
    engines/got/utils/res_archive.h
    engines/got/vars.cpp
    engines/got/vars.h
    engines/got/views/credits.cpp
    engines/got/views/credits.h
    engines/got/views/dialogs/ask.cpp
    engines/got/views/dialogs/ask.h
    engines/got/views/dialogs/dialog.cpp
    engines/got/views/dialogs/dialog.h
    engines/got/views/dialogs/high_scores.cpp
    engines/got/views/dialogs/high_scores.h
    engines/got/views/dialogs/main_menu.cpp
    engines/got/views/dialogs/main_menu.h
    engines/got/views/dialogs/options_menu.cpp
    engines/got/views/dialogs/options_menu.h
    engines/got/views/dialogs/play_game.cpp
    engines/got/views/dialogs/play_game.h
    engines/got/views/dialogs/quit.cpp
    engines/got/views/dialogs/quit.h
    engines/got/views/dialogs/quit_game.cpp
    engines/got/views/dialogs/quit_game.h
    engines/got/views/dialogs/save_game.cpp
    engines/got/views/dialogs/save_game.h
    engines/got/views/dialogs/say.cpp
    engines/got/views/dialogs/say.h
    engines/got/views/dialogs/select_game.cpp
    engines/got/views/dialogs/select_game.h
    engines/got/views/dialogs/select_item.cpp
    engines/got/views/dialogs/select_item.h
    engines/got/views/dialogs/select_option.cpp
    engines/got/views/dialogs/select_option.h
    engines/got/views/dialogs/select_scroll.cpp
    engines/got/views/dialogs/select_scroll.h
    engines/got/views/dialogs/select_slow.cpp
    engines/got/views/dialogs/select_slow.h
    engines/got/views/dialogs/set_music.cpp
    engines/got/views/dialogs/set_music.h
    engines/got/views/dialogs/set_sound.cpp
    engines/got/views/dialogs/set_sound.h
    engines/got/views/game.cpp
    engines/got/views/game.h
    engines/got/views/game_content.cpp
    engines/got/views/game_content.h
    engines/got/views/game_status.cpp
    engines/got/views/game_status.h
    engines/got/views/opening.cpp
    engines/got/views/opening.h
    engines/got/views/part_title.cpp
    engines/got/views/part_title.h
    engines/got/views/splash_screen.cpp
    engines/got/views/splash_screen.h
    engines/got/views/story.cpp
    engines/got/views/story.h
    engines/got/views/title_background.cpp
    engines/got/views/title_background.h
    engines/got/views/view.cpp
    engines/got/views/view.h
    engines/got/views/views.h


diff --git a/engines/got/console.cpp b/engines/got/console.cpp
index 0607a32d4d3..81f60f43220 100644
--- a/engines/got/console.cpp
+++ b/engines/got/console.cpp
@@ -29,126 +29,126 @@
 namespace Got {
 
 static const char *SAVE_FILENAMES[3] = {
-	"savegam1.got", "savegam1.gt2", "savegam1.gt3"
+    "savegam1.got", "savegam1.gt2", "savegam1.gt3"
 };
 
 Console::Console() : GUI::Debugger() {
-	registerCmd("view",   WRAP_METHOD(Console, cmdView));
-	registerCmd("sound", WRAP_METHOD(Console, cmdSound));
-	registerCmd("music", WRAP_METHOD(Console, cmdMusic));
-	registerCmd("load", WRAP_METHOD(Console, cmdLoad));
-	registerCmd("save", WRAP_METHOD(Console, cmdSave));
-	registerCmd("magic", WRAP_METHOD(Console, cmdMagic));
-	registerCmd("freeze", WRAP_METHOD(Console, cmdFreeze));
-	registerCmd("level", WRAP_METHOD(Console, cmdLevel));
-	registerCmd("flying", WRAP_METHOD(Console, cmdFlying));
+    registerCmd("view",   WRAP_METHOD(Console, cmdView));
+    registerCmd("sound", WRAP_METHOD(Console, cmdSound));
+    registerCmd("music", WRAP_METHOD(Console, cmdMusic));
+    registerCmd("load", WRAP_METHOD(Console, cmdLoad));
+    registerCmd("save", WRAP_METHOD(Console, cmdSave));
+    registerCmd("magic", WRAP_METHOD(Console, cmdMagic));
+    registerCmd("freeze", WRAP_METHOD(Console, cmdFreeze));
+    registerCmd("level", WRAP_METHOD(Console, cmdLevel));
+    registerCmd("flying", WRAP_METHOD(Console, cmdFlying));
 }
 
 Console::~Console() {
 }
 
 bool Console::cmdView(int argc, const char **argv) {
-	if (argc != 2) {
-		debugPrintf("view <view name>\n");
-		return true;
-	} else {
-		g_events->replaceView(argv[1], true);
-		return false;
-	}
+    if (argc != 2) {
+        debugPrintf("view <view name>\n");
+        return true;
+    } else {
+        g_events->replaceView(argv[1], true);
+        return false;
+    }
 }
 
 bool Console::cmdSound(int argc, const char **argv) {
-	if (argc == 2)
-		_G(sound).play_sound(atoi(argv[1]), true);
-	return false;
+    if (argc == 2)
+        _G(sound).play_sound(atoi(argv[1]), true);
+    return false;
 }
 
 bool Console::cmdMusic(int argc, const char **argv) {
-	if (argc == 2)
-		_G(sound).music_play(atoi(argv[1]), true);
-	return false;
+    if (argc == 2)
+        _G(sound).music_play(atoi(argv[1]), true);
+    return false;
 }
 
 bool Console::cmdLoad(int argc, const char **argv) {
-	Common::String filename = SAVE_FILENAMES[_G(area) - 1];
-	if (argc == 2)
-		filename = argv[1];
-
-	Common::InSaveFile *f;
-	if ((f = g_system->getSavefileManager()->openForLoading(filename)) == nullptr) {
-		debugPrintf("Could not open %s\n", filename.c_str());
-		return true;
-	} else {
-		Common::Serializer s(f, nullptr);
-		g_engine->syncGame(s);
-		delete f;
-		return false;
-	}
+    Common::String filename = SAVE_FILENAMES[_G(area) - 1];
+    if (argc == 2)
+        filename = argv[1];
+
+    Common::InSaveFile *f;
+    if ((f = g_system->getSavefileManager()->openForLoading(filename)) == nullptr) {
+        debugPrintf("Could not open %s\n", filename.c_str());
+        return true;
+    } else {
+        Common::Serializer s(f, nullptr);
+        g_engine->syncGame(s);
+        delete f;
+        return false;
+    }
 }
 
 bool Console::cmdSave(int argc, const char **argv) {
-	Common::String filename = SAVE_FILENAMES[_G(area) - 1];
-	if (argc == 2)
-		filename = argv[1];
+    Common::String filename = SAVE_FILENAMES[_G(area) - 1];
+    if (argc == 2)
+        filename = argv[1];
 
-	Common::OutSaveFile *f;
-	if ((f = g_system->getSavefileManager()->openForSaving(filename, false)) == nullptr) {
-		debugPrintf("Could not create %s\n", filename.c_str());
+    Common::OutSaveFile *f;
+    if ((f = g_system->getSavefileManager()->openForSaving(filename, false)) == nullptr) {
+        debugPrintf("Could not create %s\n", filename.c_str());
 
-	} else {
-		Common::Serializer s(nullptr, f);
-		g_engine->syncGame(s);
+    } else {
+        Common::Serializer s(nullptr, f);
+        g_engine->syncGame(s);
 
-		delete f;
+        delete f;
 
-		debugPrintf("Created %s\n", filename.c_str());
-	}
+        debugPrintf("Created %s\n", filename.c_str());
+    }
 
-	return true;
+    return true;
 }
 
 bool Console::cmdMagic(int argc, const char **argv) {
-	_G(thor_info).magic = (argc == 2) ? CLIP(atoi(argv[1]), 0, 150): 150;
-	
-	return false;
+    _G(thor_info).magic = (argc == 2) ? CLIP(atoi(argv[1]), 0, 150): 150;
+
+    return false;
 }
 
 bool Console::cmdFreeze(int argc, const char **argv) {
-	if (argc != 2) {
-		debugPrintf("freeze ['health', 'magic', 'gems']\n");
-	} else if (!strcmp(argv[1], "health")) {
-		_G(cheats).freezeHealth = !_G(cheats).freezeHealth;
-		debugPrintf("Health is %s\n", _G(cheats).freezeHealth ? "frozen" : "unfrozen");
-	} else if (!strcmp(argv[1], "magic")) {
-		_G(cheats).freezeMagic = !_G(cheats).freezeMagic;
-		debugPrintf("Magic is %s\n", _G(cheats).freezeMagic ? "frozen" : "unfrozen");
-	} else if (!strcmp(argv[1], "jewels")) {
-		_G(cheats).freezeJewels = !_G(cheats).freezeJewels;
-		debugPrintf("Jewels are %s\n", _G(cheats).freezeJewels ? "frozen" : "unfrozen");
-	} else if (!strcmp(argv[1], "all")) {
-		_G(cheats).freezeHealth = _G(cheats).freezeMagic =
-			_G(cheats).freezeJewels = !_G(cheats).freezeHealth;
-		debugPrintf("All are %s\n", _G(cheats).freezeHealth ? "frozen" : "unfrozen");
-	}
-
-	return true;
+    if (argc != 2) {
+        debugPrintf("freeze ['health', 'magic', 'gems']\n");
+    } else if (!strcmp(argv[1], "health")) {
+        _G(cheats).freezeHealth = !_G(cheats).freezeHealth;
+        debugPrintf("Health is %s\n", _G(cheats).freezeHealth ? "frozen" : "unfrozen");
+    } else if (!strcmp(argv[1], "magic")) {
+        _G(cheats).freezeMagic = !_G(cheats).freezeMagic;
+        debugPrintf("Magic is %s\n", _G(cheats).freezeMagic ? "frozen" : "unfrozen");
+    } else if (!strcmp(argv[1], "jewels")) {
+        _G(cheats).freezeJewels = !_G(cheats).freezeJewels;
+        debugPrintf("Jewels are %s\n", _G(cheats).freezeJewels ? "frozen" : "unfrozen");
+    } else if (!strcmp(argv[1], "all")) {
+        _G(cheats).freezeHealth = _G(cheats).freezeMagic =
+                                      _G(cheats).freezeJewels = !_G(cheats).freezeHealth;
+        debugPrintf("All are %s\n", _G(cheats).freezeHealth ? "frozen" : "unfrozen");
+    }
+
+    return true;
 }
 
 bool Console::cmdLevel(int argc, const char **argv) {
-	if (argc != 2) {
-		debugPrintf("Current level = %d\n", _G(current_level));
-		return true;
-	} else {
-		_G(new_level) = atoi(argv[1]);
-		_G(warp_flag) = true;
-		return false;
-	}
+    if (argc != 2) {
+        debugPrintf("Current level = %d\n", _G(current_level));
+        return true;
+    } else {
+        _G(new_level) = atoi(argv[1]);
+        _G(warp_flag) = true;
+        return false;
+    }
 }
 
 bool Console::cmdFlying(int argc, const char **argv) {
-	_G(thor)->flying = !_G(thor)->flying;
-	debugPrintf("Flying is %s\n", _G(thor)->flying ? "on" : "off");
-	return true;
+    _G(thor)->flying = !_G(thor)->flying;
+    debugPrintf("Flying is %s\n", _G(thor)->flying ? "on" : "off");
+    return true;
 }
 
 } // namespace Got
diff --git a/engines/got/console.h b/engines/got/console.h
index 1b61d8d76e6..b05391ca81c 100644
--- a/engines/got/console.h
+++ b/engines/got/console.h
@@ -29,19 +29,19 @@ namespace Got {
 
 class Console : public GUI::Debugger {
 private:
-	bool cmdView(int argc, const char **argv);
-	bool cmdSound(int argc, const char **argv);
-	bool cmdMusic(int argc, const char **argv);
-	bool cmdLoad(int argc, const char **argv);
-	bool cmdSave(int argc, const char **argv);
-	bool cmdMagic(int argc, const char **argv);
-	bool cmdFreeze(int argc, const char **argv);
-	bool cmdLevel(int argc, const char **argv);
-	bool cmdFlying(int argc, const char **argv);
+    bool cmdView(int argc, const char **argv);
+    bool cmdSound(int argc, const char **argv);
+    bool cmdMusic(int argc, const char **argv);
+    bool cmdLoad(int argc, const char **argv);
+    bool cmdSave(int argc, const char **argv);
+    bool cmdMagic(int argc, const char **argv);
+    bool cmdFreeze(int argc, const char **argv);
+    bool cmdLevel(int argc, const char **argv);
+    bool cmdFlying(int argc, const char **argv);
 
 public:
-	Console();
-	~Console() override;
+    Console();
+    ~Console() override;
 };
 
 } // End of namespace Got
diff --git a/engines/got/credits.pl b/engines/got/credits.pl
index 4608d989870..dfdb33dc671 100644
--- a/engines/got/credits.pl
+++ b/engines/got/credits.pl
@@ -1,3 +1,3 @@
 begin_section("Got");
-	add_person("Paul Gilbert", "dreammaster", "");
+add_person("Paul Gilbert", "dreammaster", "");
 end_section();
diff --git a/engines/got/data/actor.cpp b/engines/got/data/actor.cpp
index b46d7d27112..bf6b2149a2d 100644
--- a/engines/got/data/actor.cpp
+++ b/engines/got/data/actor.cpp
@@ -26,69 +26,69 @@
 namespace Got {
 
 void ACTOR::loadFixed(Common::SeekableReadStream *src) {
-	move = src->readByte();
-	width = src->readByte();
-	height = src->readByte();
-	directions = src->readByte();
-	frames = src->readByte();
-	frame_speed = src->readByte();
-	src->read(frame_sequence, 4);
-	speed = src->readByte();
-	size_x = src->readByte();
-	size_y = src->readByte();
-	strength = src->readByte();
-	health = src->readByte();
-	num_moves = src->readByte();
-	shot_type = src->readByte();
-	shot_pattern = src->readByte();
-	shots_allowed = src->readByte();
-	solid = src->readByte();
-	flying = src->readByte();
-	rating = src->readByte();
-	type = src->readByte();
-	src->read(name, 9);
-	func_num = src->readByte();
-	func_pass = src->readByte();
-	magic_hurts = src->readSint16LE();
-	src->read(future1, 4);
+    move = src->readByte();
+    width = src->readByte();
+    height = src->readByte();
+    directions = src->readByte();
+    frames = src->readByte();
+    frame_speed = src->readByte();
+    src->read(frame_sequence, 4);
+    speed = src->readByte();
+    size_x = src->readByte();
+    size_y = src->readByte();
+    strength = src->readByte();
+    health = src->readByte();
+    num_moves = src->readByte();
+    shot_type = src->readByte();
+    shot_pattern = src->readByte();
+    shots_allowed = src->readByte();
+    solid = src->readByte();
+    flying = src->readByte();
+    rating = src->readByte();
+    type = src->readByte();
+    src->read(name, 9);
+    func_num = src->readByte();
+    func_pass = src->readByte();
+    magic_hurts = src->readSint16LE();
+    src->read(future1, 4);
 }
 
 void ACTOR::loadFixed(const byte *src) {
-	Common::MemoryReadStream stream(src, 40);
-	loadFixed(&stream);
+    Common::MemoryReadStream stream(src, 40);
+    loadFixed(&stream);
 }
 
 void ACTOR::copyFixedAndPics(const ACTOR &src) {
-	move = src.move;
-	width = src.width;
-	height = src.height;
-	directions = src.directions;
-	frames = src.frames;
-	frame_speed = src.frame_speed;
-	Common::copy(src.frame_sequence, src.frame_sequence + 4, frame_sequence);
-	speed = src.speed;
-	size_x = src.size_x;
-	size_y = src.size_y;
-	strength = src.strength;
-	health = src.health;
-	num_moves = src.num_moves;
-	shot_type = src.shot_type;
-	shot_pattern = src.shot_pattern;
-	shots_allowed = src.shots_allowed;
-	solid = src.solid;
-	flying = src.flying;
-	rating = src.rating;
-	type = src.type;
-	Common::copy(src.name, src.name + 9, name);
-	func_num = src.func_num;
-	func_pass = src.func_pass;
-	magic_hurts = src.magic_hurts;
-	Common::copy(src.future1, src.future1 + 4, future1);
+    move = src.move;
+    width = src.width;
+    height = src.height;
+    directions = src.directions;
+    frames = src.frames;
+    frame_speed = src.frame_speed;
+    Common::copy(src.frame_sequence, src.frame_sequence + 4, frame_sequence);
+    speed = src.speed;
+    size_x = src.size_x;
+    size_y = src.size_y;
+    strength = src.strength;
+    health = src.health;
+    num_moves = src.num_moves;
+    shot_type = src.shot_type;
+    shot_pattern = src.shot_pattern;
+    shots_allowed = src.shots_allowed;
+    solid = src.solid;
+    flying = src.flying;
+    rating = src.rating;
+    type = src.type;
+    Common::copy(src.name, src.name + 9, name);
+    func_num = src.func_num;
+    func_pass = src.func_pass;
+    magic_hurts = src.magic_hurts;
+    Common::copy(src.future1, src.future1 + 4, future1);
 
-	// Copy all the surfaces for all the directions over
-	for (int d = 0; d < DIRECTION_COUNT; ++d)
-		for (int f = 0; f < FRAME_COUNT; ++f)
-			pic[d][f] = src.pic[d][f];
+    // Copy all the surfaces for all the directions over
+    for (int d = 0; d < DIRECTION_COUNT; ++d)
+        for (int f = 0; f < FRAME_COUNT; ++f)
+            pic[d][f] = src.pic[d][f];
 }
 
 } // namespace Got
diff --git a/engines/got/data/actor.h b/engines/got/data/actor.h
index 959adf11957..55be93a775e 100644
--- a/engines/got/data/actor.h
+++ b/engines/got/data/actor.h
@@ -31,92 +31,92 @@ namespace Got {
 #define FRAME_COUNT 4
 
 struct ACTOR {                      // Size=256
-	// First part loaded from disk  (size=40)
-	byte move = 0;                  // Movement pattern (0=none)
-	byte width = 0;                 // Physical width
-	byte height = 0;                // Physical height
-	byte directions = 0;            // 1,2 or 4 (1=uni-directional)
-	byte frames = 0;                // # frames per direction
-	byte frame_speed = 0;           // # cycles between frame changes
-	byte frame_sequence[4] = {};    // Sequence
-	byte speed = 0;                 // Move every Nth cycle
-	byte size_x = 0;                // Non-physical padding on X coor
-	byte size_y = 0;                // Non-phsyical padding on Y coor
-	byte strength = 0;              // Hit strength
-	byte health = 0;                // 
-	byte num_moves = 0;             // # of moves every <speed> cycles
-	byte shot_type = 0;             // Actor # of shot
-	byte shot_pattern = 0;          // Func number to decide to shoot
-	byte shots_allowed = 0;         // # shots allowed on screen
-	byte solid = 0;                 // 1=solid (not ghost,etc)
-	byte flying = 0;                // 
-	byte rating = 0;                // rnd(100) < rating = jewel
-	byte type = 0;                  // Actor (0=thor,1=hammer,2=enemy,3=shot)
-	char name[9] = {};              // Actors name
-	byte func_num = 0;              // Special function when thor touches
-	byte func_pass = 0;             // Value to pass to func
-	uint16  magic_hurts = 0;           // Bitwise magic hurts flags
-	byte future1[4] = {};
+    // First part loaded from disk  (size=40)
+    byte move = 0;                  // Movement pattern (0=none)
+    byte width = 0;                 // Physical width
+    byte height = 0;                // Physical height
+    byte directions = 0;            // 1,2 or 4 (1=uni-directional)
+    byte frames = 0;                // # frames per direction
+    byte frame_speed = 0;           // # cycles between frame changes
+    byte frame_sequence[4] = {};    // Sequence
+    byte speed = 0;                 // Move every Nth cycle
+    byte size_x = 0;                // Non-physical padding on X coor
+    byte size_y = 0;                // Non-phsyical padding on Y coor
+    byte strength = 0;              // Hit strength
+    byte health = 0;                //
+    byte num_moves = 0;             // # of moves every <speed> cycles
+    byte shot_type = 0;             // Actor # of shot
+    byte shot_pattern = 0;          // Func number to decide to shoot
+    byte shots_allowed = 0;         // # shots allowed on screen
+    byte solid = 0;                 // 1=solid (not ghost,etc)
+    byte flying = 0;                //
+    byte rating = 0;                // rnd(100) < rating = jewel
+    byte type = 0;                  // Actor (0=thor,1=hammer,2=enemy,3=shot)
+    char name[9] = {};              // Actors name
+    byte func_num = 0;              // Special function when thor touches
+    byte func_pass = 0;             // Value to pass to func
+    uint16  magic_hurts = 0;           // Bitwise magic hurts flags
+    byte future1[4] = {};
 
-	// The rest is dynamic    //size=216
-	// Direction/frame surfaces
-	Graphics::ManagedSurface pic[DIRECTION_COUNT][FRAME_COUNT];
+    // The rest is dynamic    //size=216
+    // Direction/frame surfaces
+    Graphics::ManagedSurface pic[DIRECTION_COUNT][FRAME_COUNT];
 
-	byte frame_count = 0;           // Count to switch frames
-	byte dir = 0;                   // Direction of travel
-	byte last_dir = 0;              // Last direction of travel
-	int  x = 0;                     // Actual X coor
-	int  y = 0;                     // Actual Y coor
-	int  center = 0;                // Center of object
-	int  last_x[2] = {};            // Last X coor on each page
-	int  last_y[2] = {};            // Last Y coor on each page
-	byte used = 0;                  // 1=active, 0=not active
-	byte next = 0;                  // Next frame to be shown
-	byte speed_count = 0;           // Count down to movement
-	byte vunerable = 0;             // Count down to vunerability
-	byte shot_cnt = 0;              // Count down to another shot
-	byte num_shots = 0;             // # of shots currently on screen
-	byte creator = 0;               // Which actor # created this actor
-	byte pause = 0;                 // Pause must be 0 to move
-	byte actor_num = 0;
-	byte move_count = 0;
-	byte dead = 0;
-	byte toggle = 0;
-	byte center_x = 0;
-	byte center_y = 0;
-	byte show = 0;                  // Display or not (for blinking)
-	byte temp1 = 0;
-	byte temp2 = 0;
-	byte counter = 0;
-	byte move_counter = 0;
-	byte edge_counter = 0;
-	byte temp3 = 0;
-	byte temp4 = 0;
-	byte temp5 = 0;
-	byte hit_thor = 0;
-	int  rand = 0;
-	byte init_dir = 0;
-	byte pass_value = 0;
-	byte shot_actor = 0;
-	byte magic_hit = 0;
-	byte temp6 = 0;
-	int  i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
-	byte init_health = 0;
-	byte talk_counter = 0;
-	byte etype = 0;
-	byte future2[25] = {};
+    byte frame_count = 0;           // Count to switch frames
+    byte dir = 0;                   // Direction of travel
+    byte last_dir = 0;              // Last direction of travel
+    int  x = 0;                     // Actual X coor
+    int  y = 0;                     // Actual Y coor
+    int  center = 0;                // Center of object
+    int  last_x[2] = {};            // Last X coor on each page
+    int  last_y[2] = {};            // Last Y coor on each page
+    byte used = 0;                  // 1=active, 0=not active
+    byte next = 0;                  // Next frame to be shown
+    byte speed_count = 0;           // Count down to movement
+    byte vunerable = 0;             // Count down to vunerability
+    byte shot_cnt = 0;              // Count down to another shot
+    byte num_shots = 0;             // # of shots currently on screen
+    byte creator = 0;               // Which actor # created this actor
+    byte pause = 0;                 // Pause must be 0 to move
+    byte actor_num = 0;
+    byte move_count = 0;
+    byte dead = 0;
+    byte toggle = 0;
+    byte center_x = 0;
+    byte center_y = 0;
+    byte show = 0;                  // Display or not (for blinking)
+    byte temp1 = 0;
+    byte temp2 = 0;
+    byte counter = 0;
+    byte move_counter = 0;
+    byte edge_counter = 0;
+    byte temp3 = 0;
+    byte temp4 = 0;
+    byte temp5 = 0;
+    byte hit_thor = 0;
+    int  rand = 0;
+    byte init_dir = 0;
+    byte pass_value = 0;
+    byte shot_actor = 0;
+    byte magic_hit = 0;
+    byte temp6 = 0;
+    int  i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0, i6 = 0;
+    byte init_health = 0;
+    byte talk_counter = 0;
+    byte etype = 0;
+    byte future2[25] = {};
 
-	void loadFixed(Common::SeekableReadStream *src);
-	void loadFixed(const byte *src);
+    void loadFixed(Common::SeekableReadStream *src);
+    void loadFixed(const byte *src);
 
-	/**
-	 * Copies the fixed portion and pics from a source actor.
-	 */
-	void copyFixedAndPics(const ACTOR &src);
+    /**
+     * Copies the fixed portion and pics from a source actor.
+     */
+    void copyFixedAndPics(const ACTOR &src);
 
-	int getPos() const {
-		return ((x + 7) / 16) + (((y + 8) / 16) * 20);
-	}
+    int getPos() const {
+        return ((x + 7) / 16) + (((y + 8) / 16) * 20);
+    }
 };
 
 } // namespace Got
diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index 0bbbf7e133e..3531c65aa06 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -36,13 +36,13 @@ namespace Got {
 #define IN_RANGE(v,l,h) (v>=l && v<=h)
 
 struct HEADER {
-	long offset = 0;
-	long length = 0;
+    long offset = 0;
+    long length = 0;
 
-	void load(Common::SeekableReadStream *src) {
-		offset = src->readUint32LE();
-		length = src->readUint32LE();
-	}
+    void load(Common::SeekableReadStream *src) {
+        offset = src->readUint32LE();
+        length = src->readUint32LE();
+    }
 };
 
 //==========================================================================
@@ -97,63 +97,63 @@ struct HEADER {
 
 #define sc_Index 0x3C4
 enum {
-	sc_Reset,
-	sc_Clock,
-	sc_MapMask,
-	sc_CharMap,
-	sc_MemMode
+    sc_Reset,
+    sc_Clock,
+    sc_MapMask,
+    sc_CharMap,
+    sc_MemMode
 };
 
 #define crtc_Index 0x3D4
 
 enum {
-	crtc_H_Total,
-	crtc_H_DispEnd,
-	crtc_H_Blank,
-	crtc_H_EndBlank,
-	crtc_H_Retrace,
-	crtc_H_EndRetrace,
-	crtc_V_Total,
-	crtc_OverFlow,
-	crtc_RowScan,
-	crtc_MaxScanLine,
-	crtc_CursorStart,
-	crtc_CursorEnd,
-	crtc_StartHigh,
-	crtc_StartLow,
-	crtc_CursorHigh,
-	crtc_CursorLow,
-	crtc_V_Retrace,
-	crtc_V_EndRetrace,
-	crtc_V_DispEnd,
-	crtc_Offset,
-	crtc_Underline,
-	crtc_V_Blank,
-	crtc_V_EndBlank,
-	crtc_Mode,
-	crtc_LineCompare
+    crtc_H_Total,
+    crtc_H_DispEnd,
+    crtc_H_Blank,
+    crtc_H_EndBlank,
+    crtc_H_Retrace,
+    crtc_H_EndRetrace,
+    crtc_V_Total,
+    crtc_OverFlow,
+    crtc_RowScan,
+    crtc_MaxScanLine,
+    crtc_CursorStart,
+    crtc_CursorEnd,
+    crtc_StartHigh,
+    crtc_StartLow,
+    crtc_CursorHigh,
+    crtc_CursorLow,
+    crtc_V_Retrace,
+    crtc_V_EndRetrace,
+    crtc_V_DispEnd,
+    crtc_Offset,
+    crtc_Underline,
+    crtc_V_Blank,
+    crtc_V_EndBlank,
+    crtc_Mode,
+    crtc_LineCompare
 };
 
 #define gc_Index 0x3CE
 enum {
-	gc_SetReset,
-	gc_EnableSetReset,
-	gc_ColorCompare,
-	gc_DataRotate,
-	gc_ReadMap,
-	gc_Mode,
-	gc_Misc,
-	gc_ColorDontCare,
-	gc_BitMask
+    gc_SetReset,
+    gc_EnableSetReset,
+    gc_ColorCompare,
+    gc_DataRotate,
+    gc_ReadMap,
+    gc_Mode,
+    gc_Misc,
+    gc_ColorDontCare,
+    gc_BitMask
 };
 
 #define atr_Index 0x3c0
 enum {
-	atr_Mode = 16,
-	atr_Overscan,
-	atr_ColorPlaneEnable,
-	atr_PelPan,
-	atr_ColorSelect
+    atr_Mode = 16,
+    atr_Overscan,
+    atr_ColorPlaneEnable,
+    atr_PelPan,
+    atr_ColorSelect
 };
 #define	status_Reg1 0x3da
 
diff --git a/engines/got/data/high_scores.cpp b/engines/got/data/high_scores.cpp
index 9211fbb9357..7e836644927 100644
--- a/engines/got/data/high_scores.cpp
+++ b/engines/got/data/high_scores.cpp
@@ -28,84 +28,84 @@
 namespace Got {
 
 static const HighScore DEFAULTS[HIGH_SCORES_PER_AREA] = {
-	{ 0, 10000, "Ron Davis" },
-	{ 0,  9000, "Gary Sirois" },
-	{ 0,  8000, "Adam Pedersen" },
-	{ 0,  7000, "Jason Blochowiak" },
-	{ 0,  6000, "Roy Davis" },
-	{ 0,  5000, "Wayne Timmerman" },
-	{ 0,  4000, "Dan Linton" }
+    { 0, 10000, "Ron Davis" },
+    { 0,  9000, "Gary Sirois" },
+    { 0,  8000, "Adam Pedersen" },
+    { 0,  7000, "Jason Blochowiak" },
+    { 0,  6000, "Roy Davis" },
+    { 0,  5000, "Wayne Timmerman" },
+    { 0,  4000, "Dan Linton" }
 };
 
 void HighScore::sync(Common::Serializer &s) {
-	s.syncAsUint16LE(_unused);
-	s.syncAsUint32LE(_total);
-	s.syncBytes((byte *)_name, 32);
+    s.syncAsUint16LE(_unused);
+    s.syncAsUint32LE(_total);
+    s.syncBytes((byte *)_name, 32);
 }
 
 void HighScores::sync(Common::Serializer &s) {
-	for (int area = 0; area < 3; ++area)
-		for (int num = 0; num < HIGH_SCORES_PER_AREA; ++num)
-			_scores[area][num].sync(s);
+    for (int area = 0; area < 3; ++area)
+        for (int num = 0; num < HIGH_SCORES_PER_AREA; ++num)
+            _scores[area][num].sync(s);
 }
 
 void HighScores::load() {
-	Common::File f;
-	Common::InSaveFile *sf;
-	Common::String scoresName = g_engine->getHighScoresSaveName();
+    Common::File f;
+    Common::InSaveFile *sf;
+    Common::String scoresName = g_engine->getHighScoresSaveName();
 
-	if ((sf = g_system->getSavefileManager()->openForLoading(scoresName)) != nullptr) {
-		// ScummVM high scores data present
-		Common::Serializer s(sf, nullptr);
-		sync(s);
-		delete sf;
-	} else if (f.open("config.got")) {
-		// Otherwise fall back on original generated config.got
-		f.seek(0x32);
-		Common::Serializer s(&f, nullptr);
-		sync(s);
-	} else {
-		// Generate new data
-		for (int area = 0; area < 3; ++area)
-			for (int num = 0; num < HIGH_SCORES_PER_AREA; ++num)
-				_scores[area][num] = DEFAULTS[num];
-	}
+    if ((sf = g_system->getSavefileManager()->openForLoading(scoresName)) != nullptr) {
+        // ScummVM high scores data present
+        Common::Serializer s(sf, nullptr);
+        sync(s);
+        delete sf;
+    } else if (f.open("config.got")) {
+        // Otherwise fall back on original generated config.got
+        f.seek(0x32);
+        Common::Serializer s(&f, nullptr);
+        sync(s);
+    } else {
+        // Generate new data
+        for (int area = 0; area < 3; ++area)
+            for (int num = 0; num < HIGH_SCORES_PER_AREA; ++num)
+                _scores[area][num] = DEFAULTS[num];
+    }
 }
 
 void HighScores::save() {
-	Common::OutSaveFile *sf = g_system->getSavefileManager()->openForSaving(
-		g_engine->getHighScoresSaveName());
-	if (!sf)
-		error("Error creating high scores save file");
+    Common::OutSaveFile *sf = g_system->getSavefileManager()->openForSaving(
+                                  g_engine->getHighScoresSaveName());
+    if (!sf)
+        error("Error creating high scores save file");
 
-	Common::Serializer s(nullptr, sf);
-	sync(s);
-	sf->finalize();
-	delete sf;
+    Common::Serializer s(nullptr, sf);
+    sync(s);
+    sf->finalize();
+    delete sf;
 }
 
 void HighScores::add(int area, const Common::String &name, uint total) {
-	// Find the index for the new score in the list
-	int newIndex;
-	for (newIndex = 0; newIndex < HIGH_SCORES_PER_AREA &&
-		total < _scores[area - 1][newIndex]._total; ++newIndex) {
-	}
-	if (newIndex == HIGH_SCORES_PER_AREA)
-		// Lower than all current scores, so ignore it
-		return;
+    // Find the index for the new score in the list
+    int newIndex;
+    for (newIndex = 0; newIndex < HIGH_SCORES_PER_AREA &&
+            total < _scores[area - 1][newIndex]._total; ++newIndex) {
+    }
+    if (newIndex == HIGH_SCORES_PER_AREA)
+        // Lower than all current scores, so ignore it
+        return;
 
-	// Shift any lower scores to make space
-	for (int i = HIGH_SCORES_PER_AREA - 1; i > newIndex; --i)
-		_scores[area - 1][i] = _scores[area - 1][i - 1];
+    // Shift any lower scores to make space
+    for (int i = HIGH_SCORES_PER_AREA - 1; i > newIndex; --i)
+        _scores[area - 1][i] = _scores[area - 1][i - 1];
 
-	// Insert in new score
-	HighScore &hs = _scores[area - 1][newIndex];
-	Common::fill(hs._name, hs._name + 32, 0);
-	Common::strcpy_s(hs._name, name.c_str());
-	hs._total = total;
+    // Insert in new score
+    HighScore &hs = _scores[area - 1][newIndex];
+    Common::fill(hs._name, hs._name + 32, 0);
+    Common::strcpy_s(hs._name, name.c_str());
+    hs._total = total;
 
-	// Save the resulting table
-	save();
+    // Save the resulting table
+    save();
 }
 
 } // namespace Got
diff --git a/engines/got/data/high_scores.h b/engines/got/data/high_scores.h
index 3db75102c9a..2ea739a8e4f 100644
--- a/engines/got/data/high_scores.h
+++ b/engines/got/data/high_scores.h
@@ -29,23 +29,23 @@ namespace Got {
 #define HIGH_SCORES_PER_AREA 7
 
 struct HighScore {
-	uint16 _unused;
-	uint32 _total;
-	char _name[32];
+    uint16 _unused;
+    uint32 _total;
+    char _name[32];
 
-	void sync(Common::Serializer &s);
+    void sync(Common::Serializer &s);
 };
 
 struct HighScores {
 private:
-	void sync(Common::Serializer &s);
+    void sync(Common::Serializer &s);
 
 public:
-	HighScore _scores[3][HIGH_SCORES_PER_AREA];
+    HighScore _scores[3][HIGH_SCORES_PER_AREA];
 
-	void load();
-	void save();
-	void add(int area, const Common::String &name, uint total);
+    void load();
+    void save();
+    void add(int area, const Common::String &name, uint total);
 };
 
 } // namespace Got
diff --git a/engines/got/data/level.cpp b/engines/got/data/level.cpp
index 239358f7871..cc91dd8241b 100644
--- a/engines/got/data/level.cpp
+++ b/engines/got/data/level.cpp
@@ -27,43 +27,43 @@
 namespace Got {
 
 void LEVEL::sync(Common::Serializer &s) {
-	for (int i = 0; i < 12; ++i)
-		s.syncBytes(icon[i], 20);
+    for (int i = 0; i < 12; ++i)
+        s.syncBytes(icon[i], 20);
 
-	s.syncAsByte(bg_color);
-	s.syncAsByte(type);
+    s.syncAsByte(bg_color);
+    s.syncAsByte(type);
 
-	s.syncBytes(actor_type, 16);
-	s.syncBytes(actor_loc, 16);
-	s.syncBytes(actor_value, 16);
-	s.syncBytes(pal_colors, 3);
-	s.syncBytes(actor_invis, 16);
-	s.syncBytes(extra, 13);
-	s.syncBytes(static_obj, 30);
+    s.syncBytes(actor_type, 16);
+    s.syncBytes(actor_loc, 16);
+    s.syncBytes(actor_value, 16);
+    s.syncBytes(pal_colors, 3);
+    s.syncBytes(actor_invis, 16);
+    s.syncBytes(extra, 13);
+    s.syncBytes(static_obj, 30);
 
-	for (int i = 0; i < 30; ++i)
-		s.syncAsSint16LE(static_x[i]);
-	for (int i = 0; i < 30; ++i)
-		s.syncAsSint16LE(static_y[i]);
+    for (int i = 0; i < 30; ++i)
+        s.syncAsSint16LE(static_x[i]);
+    for (int i = 0; i < 30; ++i)
+        s.syncAsSint16LE(static_y[i]);
 
-	s.syncBytes(new_level, 10);
-	s.syncBytes(new_level_loc, 10);
+    s.syncBytes(new_level, 10);
+    s.syncBytes(new_level_loc, 10);
 
-	s.syncAsByte(area);
-	s.syncBytes(actor_dir, 16);
-	s.syncBytes(future, 3);
+    s.syncAsByte(area);
+    s.syncBytes(actor_dir, 16);
+    s.syncBytes(future, 3);
 }
 
 void LEVEL::load(int level) {
-	Common::MemoryReadStream src(_G(sd_data)[level], 512);
-	Common::Serializer s(&src, nullptr);
-	sync(s);
+    Common::MemoryReadStream src(_G(sd_data)[level], 512);
+    Common::Serializer s(&src, nullptr);
+    sync(s);
 }
 
 void LEVEL::save(int level) {
-	Common::MemoryWriteStream dest(_G(sd_data)[level], 512);
-	Common::Serializer s(nullptr, &dest);
-	sync(s);
+    Common::MemoryWriteStream dest(_G(sd_data)[level], 512);
+    Common::Serializer s(nullptr, &dest);
+    sync(s);
 }
 
 } // namespace Got
diff --git a/engines/got/data/level.h b/engines/got/data/level.h
index fdb83fc54bc..76a5e255214 100644
--- a/engines/got/data/level.h
+++ b/engines/got/data/level.h
@@ -30,36 +30,36 @@ namespace Got {
 
 struct LEVEL {                    // size=512
 private:
-	void sync(Common::Serializer &s);
+    void sync(Common::Serializer &s);
 public:
-	byte icon[12][20] = {};       // 0   grid of icons
-	byte bg_color = 0;            // 240 background color
-	byte type = 0;                // 241 music
-	byte actor_type[16] = {};     // 242 type of enemies (12 max)
-	byte actor_loc[16] = {};      // 254 location of enemies
-	byte actor_value[16] = {};    // pass value
-	byte pal_colors[3] = {};      // change 251,253,254 to these three
-	byte actor_invis[16] = {};
-	byte extra[13] = {};
+    byte icon[12][20] = {};       // 0   grid of icons
+    byte bg_color = 0;            // 240 background color
+    byte type = 0;                // 241 music
+    byte actor_type[16] = {};     // 242 type of enemies (12 max)
+    byte actor_loc[16] = {};      // 254 location of enemies
+    byte actor_value[16] = {};    // pass value
+    byte pal_colors[3] = {};      // change 251,253,254 to these three
+    byte actor_invis[16] = {};
+    byte extra[13] = {};
 
-	byte static_obj[OBJECTS_COUNT] = {};     // 302 static objects (treasure, keys,etc)
-	int  static_x[OBJECTS_COUNT] = {};       // 332 X coor of static objects
-	int  static_y[OBJECTS_COUNT] = {};       // 392 Y coor of static objects
-	byte new_level[10] = {};      // 452 level jump for icon 200-204
-	byte new_level_loc[10] = {};  // 462 grid location to jump in to
-	byte area = 0;                // 472 game area (1=forest,etc)
-	byte actor_dir[16] = {};      // initial dir
-	byte future[3] = {};          // 473
+    byte static_obj[OBJECTS_COUNT] = {};     // 302 static objects (treasure, keys,etc)
+    int  static_x[OBJECTS_COUNT] = {};       // 332 X coor of static objects
+    int  static_y[OBJECTS_COUNT] = {};       // 392 Y coor of static objects
+    byte new_level[10] = {};      // 452 level jump for icon 200-204
+    byte new_level_loc[10] = {};  // 462 grid location to jump in to
+    byte area = 0;                // 472 game area (1=forest,etc)
+    byte actor_dir[16] = {};      // initial dir
+    byte future[3] = {};          // 473
 
-	/**
-	 * Loads level data from the global sd_data for the given level
-	 */
-	void load(int level);
+    /**
+     * Loads level data from the global sd_data for the given level
+     */
+    void load(int level);
 
-	/**
-	 * Saves the level data to the global sd_data 
-	 */
-	void save(int level);
+    /**
+     * Saves the level data to the global sd_data
+     */
+    void save(int level);
 };
 
 } // namespace Got
diff --git a/engines/got/data/sd_data.cpp b/engines/got/data/sd_data.cpp
index 2d47751d9cb..664888b7f4c 100644
--- a/engines/got/data/sd_data.cpp
+++ b/engines/got/data/sd_data.cpp
@@ -28,27 +28,27 @@ namespace Got {
 #define SD_DATA_SIZE 61440
 
 SdData::SdData() {
-	_data = new byte[SD_DATA_SIZE];
+    _data = new byte[SD_DATA_SIZE];
 }
 
 SdData::~SdData() {
-	delete[] _data;
+    delete[] _data;
 }
 
 void SdData::load() {
-	Common::String fname = Common::String::format("SDAT%d", _area);
-	res_read(fname, _data);
+    Common::String fname = Common::String::format("SDAT%d", _area);
+    res_read(fname, _data);
 }
 
 void SdData::setArea(int area) {
-	if (area != _area) {
-		_area = area;
-		load();
-	}
+    if (area != _area) {
+        _area = area;
+        load();
+    }
 }
 
 void SdData::sync(Common::Serializer &s) {
-	s.syncBytes(_data, SD_DATA_SIZE);
+    s.syncBytes(_data, SD_DATA_SIZE);
 }
 
 } // namespace Got
diff --git a/engines/got/data/sd_data.h b/engines/got/data/sd_data.h
index 934c482ccec..8dba23a8eac 100644
--- a/engines/got/data/sd_data.h
+++ b/engines/got/data/sd_data.h
@@ -29,24 +29,24 @@ namespace Got {
 
 class SdData {
 private:
-	byte *_data;
-	int _area = 1;
+    byte *_data;
+    int _area = 1;
 
 public:
-	SdData();
-	~SdData();
-	void load();
+    SdData();
+    ~SdData();
+    void load();
 
-	bool getArea() const {
-		return _area;
-	}
-	void setArea(int area);
+    bool getArea() const {
+        return _area;
+    }
+    void setArea(int area);
 
-	void sync(Common::Serializer &s);
+    void sync(Common::Serializer &s);
 
-	byte *operator[](int level) const {
-		return _data + level * 512;
-	}
+    byte *operator[](int level) const {
+        return _data + level * 512;
+    }
 };
 
 } // namespace Got
diff --git a/engines/got/data/setup.cpp b/engines/got/data/setup.cpp
index b81bd9d3d16..4145ab7a84a 100644
--- a/engines/got/data/setup.cpp
+++ b/engines/got/data/setup.cpp
@@ -24,23 +24,23 @@
 namespace Got {
 
 void SETUP::sync(Common::Serializer &s) {
-	// Sync the flags bit-fields
-	assert(((byte *)&value - (byte *)this) == 8);
-	s.syncBytes((byte *)this, 8);
+    // Sync the flags bit-fields
+    assert(((byte *)&value - (byte *)this) == 8);
+    s.syncBytes((byte *)this, 8);
 
-	s.syncBytes(value, 16);
-	s.syncAsByte(junk);
-	s.syncAsByte(game);
-	s.syncAsByte(area);
-	s.syncAsByte(pc_sound);
-	s.syncAsByte(dig_sound);
-	s.syncAsByte(music);
-	s.syncAsByte(speed);
-	s.syncAsByte(scroll_flag);
-	s.syncBytes(boss_dead, 3);
-	s.syncAsByte(skill);
-	s.syncAsByte(game_over);
-	s.syncBytes(future, 19);
+    s.syncBytes(value, 16);
+    s.syncAsByte(junk);
+    s.syncAsByte(game);
+    s.syncAsByte(area);
+    s.syncAsByte(pc_sound);
+    s.syncAsByte(dig_sound);
+    s.syncAsByte(music);
+    s.syncAsByte(speed);
+    s.syncAsByte(scroll_flag);
+    s.syncBytes(boss_dead, 3);
+    s.syncAsByte(skill);
+    s.syncAsByte(game_over);
+    s.syncBytes(future, 19);
 }
 
 } // namespace Got
diff --git a/engines/got/data/setup.h b/engines/got/data/setup.h
index 129e56695b1..0eb8de82231 100644
--- a/engines/got/data/setup.h
+++ b/engines/got/data/setup.h
@@ -27,103 +27,103 @@
 namespace Got {
 
 struct SETUP {
-	SETUP() :
-		f00(0), f01(0), f02(0), f03(0), f04(0), f05(0), f06(0), f07(0), f08(0), f09(0),
-		f10(0), f11(0), f12(0), f13(0), f14(0), f15(0), f16(0), f17(0), f18(0), f19(0),
-		f20(0), f21(0), f22(0), f23(0), f24(0), f25(0), f26(0), f27(0), f28(0), f29(0),
-		f30(0), f31(0), f32(0), f33(0), f34(0), f35(0), f36(0), f37(0), f38(0), f39(0),
-		f40(0), f41(0), f42(0), f43(0), f44(0), f45(0), f46(0), f47(0), f48(0), f49(0),
-		f50(0), f51(0), f52(0), f53(0), f54(0), f55(0), f56(0), f57(0), f58(0), f59(0),
-		f60(0), f61(0), f62(0), f63(0) {
-	}
-
-	unsigned int  f00 : 1;
-	unsigned int  f01 : 1;
-	unsigned int  f02 : 1;
-	unsigned int  f03 : 1;
-	unsigned int  f04 : 1;
-	unsigned int  f05 : 1;
-	unsigned int  f06 : 1;
-	unsigned int  f07 : 1;
-
-	unsigned int  f08 : 1;
-	unsigned int  f09 : 1;
-	unsigned int  f10 : 1;
-	unsigned int  f11 : 1;
-	unsigned int  f12 : 1;
-	unsigned int  f13 : 1;
-	unsigned int  f14 : 1;
-	unsigned int  f15 : 1;
-
-	unsigned int  f16 : 1;
-	unsigned int  f17 : 1;
-	unsigned int  f18 : 1;
-	unsigned int  f19 : 1;
-	unsigned int  f20 : 1;
-	unsigned int  f21 : 1;
-	unsigned int  f22 : 1;
-	unsigned int  f23 : 1;
-
-	unsigned int  f24 : 1;
-	unsigned int  f25 : 1;
-	unsigned int  f26 : 1;
-	unsigned int  f27 : 1;
-	unsigned int  f28 : 1;
-	unsigned int  f29 : 1;
-	unsigned int  f30 : 1;
-	unsigned int  f31 : 1;
-
-	unsigned int  f32 : 1;
-	unsigned int  f33 : 1;
-	unsigned int  f34 : 1;
-	unsigned int  f35 : 1;
-	unsigned int  f36 : 1;
-	unsigned int  f37 : 1;
-	unsigned int  f38 : 1;
-	unsigned int  f39 : 1;
-
-	unsigned int  f40 : 1;
-	unsigned int  f41 : 1;
-	unsigned int  f42 : 1;
-	unsigned int  f43 : 1;
-	unsigned int  f44 : 1;
-	unsigned int  f45 : 1;
-	unsigned int  f46 : 1;
-	unsigned int  f47 : 1;
-
-	unsigned int  f48 : 1;
-	unsigned int  f49 : 1;
-	unsigned int  f50 : 1;
-	unsigned int  f51 : 1;
-	unsigned int  f52 : 1;
-	unsigned int  f53 : 1;
-	unsigned int  f54 : 1;
-	unsigned int  f55 : 1;
-
-	unsigned int  f56 : 1;
-	unsigned int  f57 : 1;
-	unsigned int  f58 : 1;
-	unsigned int  f59 : 1;
-	unsigned int  f60 : 1;
-	unsigned int  f61 : 1;
-	unsigned int  f62 : 1;
-	unsigned int  f63 : 1;
-
-	byte value[16] = {};
-	byte junk = 0;
-	byte game = 0;
-	byte area = 0;          //1,2,3
-	byte pc_sound = 0;      //1=enabled
-	byte dig_sound = 0;     //1 & !pc_sound = enabled
-	byte music = 0;         //1=enabled
-	byte speed = 0;         //1=slow mode (for slower 286's)
-	byte scroll_flag = 0;   //unused
-	byte boss_dead[3] = {};
-	byte skill = 0;         //0=easy, 1=normal, 2=hard
-	byte game_over = 0;
-	byte future[19] = {};   //probably not needed
-
-	void sync(Common::Serializer &s);
+    SETUP() :
+        f00(0), f01(0), f02(0), f03(0), f04(0), f05(0), f06(0), f07(0), f08(0), f09(0),
+        f10(0), f11(0), f12(0), f13(0), f14(0), f15(0), f16(0), f17(0), f18(0), f19(0),
+        f20(0), f21(0), f22(0), f23(0), f24(0), f25(0), f26(0), f27(0), f28(0), f29(0),
+        f30(0), f31(0), f32(0), f33(0), f34(0), f35(0), f36(0), f37(0), f38(0), f39(0),
+        f40(0), f41(0), f42(0), f43(0), f44(0), f45(0), f46(0), f47(0), f48(0), f49(0),
+        f50(0), f51(0), f52(0), f53(0), f54(0), f55(0), f56(0), f57(0), f58(0), f59(0),
+        f60(0), f61(0), f62(0), f63(0) {
+    }
+
+    unsigned int  f00 : 1;
+    unsigned int  f01 : 1;
+    unsigned int  f02 : 1;
+    unsigned int  f03 : 1;
+    unsigned int  f04 : 1;
+    unsigned int  f05 : 1;
+    unsigned int  f06 : 1;
+    unsigned int  f07 : 1;
+
+    unsigned int  f08 : 1;
+    unsigned int  f09 : 1;
+    unsigned int  f10 : 1;
+    unsigned int  f11 : 1;
+    unsigned int  f12 : 1;
+    unsigned int  f13 : 1;
+    unsigned int  f14 : 1;
+    unsigned int  f15 : 1;
+
+    unsigned int  f16 : 1;
+    unsigned int  f17 : 1;
+    unsigned int  f18 : 1;
+    unsigned int  f19 : 1;
+    unsigned int  f20 : 1;
+    unsigned int  f21 : 1;
+    unsigned int  f22 : 1;
+    unsigned int  f23 : 1;
+
+    unsigned int  f24 : 1;
+    unsigned int  f25 : 1;
+    unsigned int  f26 : 1;
+    unsigned int  f27 : 1;
+    unsigned int  f28 : 1;
+    unsigned int  f29 : 1;
+    unsigned int  f30 : 1;
+    unsigned int  f31 : 1;
+
+    unsigned int  f32 : 1;
+    unsigned int  f33 : 1;
+    unsigned int  f34 : 1;
+    unsigned int  f35 : 1;
+    unsigned int  f36 : 1;
+    unsigned int  f37 : 1;
+    unsigned int  f38 : 1;
+    unsigned int  f39 : 1;
+
+    unsigned int  f40 : 1;
+    unsigned int  f41 : 1;
+    unsigned int  f42 : 1;
+    unsigned int  f43 : 1;
+    unsigned int  f44 : 1;
+    unsigned int  f45 : 1;
+    unsigned int  f46 : 1;
+    unsigned int  f47 : 1;
+
+    unsigned int  f48 : 1;
+    unsigned int  f49 : 1;
+    unsigned int  f50 : 1;
+    unsigned int  f51 : 1;
+    unsigned int  f52 : 1;
+    unsigned int  f53 : 1;
+    unsigned int  f54 : 1;
+    unsigned int  f55 : 1;
+
+    unsigned int  f56 : 1;
+    unsigned int  f57 : 1;
+    unsigned int  f58 : 1;
+    unsigned int  f59 : 1;
+    unsigned int  f60 : 1;
+    unsigned int  f61 : 1;
+    unsigned int  f62 : 1;
+    unsigned int  f63 : 1;
+
+    byte value[16] = {};
+    byte junk = 0;
+    byte game = 0;
+    byte area = 0;          //1,2,3
+    byte pc_sound = 0;      //1=enabled
+    byte dig_sound = 0;     //1 & !pc_sound = enabled
+    byte music = 0;         //1=enabled
+    byte speed = 0;         //1=slow mode (for slower 286's)
+    byte scroll_flag = 0;   //unused
+    byte boss_dead[3] = {};
+    byte skill = 0;         //0=easy, 1=normal, 2=hard
+    byte game_over = 0;
+    byte future[19] = {};   //probably not needed
+
+    void sync(Common::Serializer &s);
 };
 
 } // namespace Got
diff --git a/engines/got/data/thor_info.cpp b/engines/got/data/thor_info.cpp
index de41bdeeb2c..f9dda0f048a 100644
--- a/engines/got/data/thor_info.cpp
+++ b/engines/got/data/thor_info.cpp
@@ -25,39 +25,39 @@
 namespace Got {
 
 void THOR_INFO::sync(Common::Serializer &s) {
-	uint32 ptr = 0;
-
-	s.syncAsByte(magic);
-	s.syncAsByte(keys);
-	s.syncAsSint16LE(jewels);
-	s.syncAsByte(last_area);
-	s.syncAsByte(last_screen);
-	s.syncAsByte(last_icon);
-	s.syncAsByte(last_dir);
-	s.syncAsSint16LE(inventory);
-	s.syncAsByte(item);
-	s.syncAsByte(last_health);
-	s.syncAsByte(last_magic);
-	s.syncAsSint16LE(last_jewels);
-	s.syncAsByte(last_keys);
-	s.syncAsByte(last_item);
-	s.syncAsSint16LE(last_inventory);
-	s.syncAsByte(level);
-	s.syncAsUint32LE(score);
-	s.syncAsUint32LE(last_score);
-
-	s.syncAsByte(object);
-	s.syncAsUint16LE(ptr);
-	s.syncAsByte(last_object);
-	s.syncAsUint16LE(ptr);
-
-	s.syncAsByte(armor);
-	s.syncBytes(future, 65);
-
-	if (s.isLoading()) {
-		object_name = (object == 0) ? nullptr : OBJECT_NAMES[object - 1];
-		last_object_name = (last_object == 0) ? nullptr : OBJECT_NAMES[last_object - 1];
-	}
+    uint32 ptr = 0;
+
+    s.syncAsByte(magic);
+    s.syncAsByte(keys);
+    s.syncAsSint16LE(jewels);
+    s.syncAsByte(last_area);
+    s.syncAsByte(last_screen);
+    s.syncAsByte(last_icon);
+    s.syncAsByte(last_dir);
+    s.syncAsSint16LE(inventory);
+    s.syncAsByte(item);
+    s.syncAsByte(last_health);
+    s.syncAsByte(last_magic);
+    s.syncAsSint16LE(last_jewels);
+    s.syncAsByte(last_keys);
+    s.syncAsByte(last_item);
+    s.syncAsSint16LE(last_inventory);
+    s.syncAsByte(level);
+    s.syncAsUint32LE(score);
+    s.syncAsUint32LE(last_score);
+
+    s.syncAsByte(object);
+    s.syncAsUint16LE(ptr);
+    s.syncAsByte(last_object);
+    s.syncAsUint16LE(ptr);
+
+    s.syncAsByte(armor);
+    s.syncBytes(future, 65);
+
+    if (s.isLoading()) {
+        object_name = (object == 0) ? nullptr : OBJECT_NAMES[object - 1];
+        last_object_name = (last_object == 0) ? nullptr : OBJECT_NAMES[last_object - 1];
+    }
 }
 
 } // namespace Got
diff --git a/engines/got/data/thor_info.h b/engines/got/data/thor_info.h
index 8d4bec373e1..0115fc033a9 100644
--- a/engines/got/data/thor_info.h
+++ b/engines/got/data/thor_info.h
@@ -27,32 +27,32 @@
 namespace Got {
 
 struct THOR_INFO {
-	byte magic = 0;
-	byte keys = 0;
-	int  jewels = 0;
-	byte last_area = 0;
-	byte last_screen = 0;
-	byte last_icon = 0;
-	byte last_dir = 0;
-	int  inventory = 0;
-	byte item = 0;         //currently selected item
-	byte last_health = 0;
-	byte last_magic = 0;
-	int  last_jewels = 0;
-	byte last_keys = 0;
-	byte last_item = 0;
-	int  last_inventory = 0;
-	byte level = 0;         //current level (1,2,3)
-	long score = 0;
-	long last_score = 0;
-	byte object = 0;
-	const char *object_name = nullptr;
-	byte last_object = 0;
-	const char *last_object_name = nullptr;
-	byte armor = 0;
-	byte future[65] = {};
+    byte magic = 0;
+    byte keys = 0;
+    int  jewels = 0;
+    byte last_area = 0;
+    byte last_screen = 0;
+    byte last_icon = 0;
+    byte last_dir = 0;
+    int  inventory = 0;
+    byte item = 0;         //currently selected item
+    byte last_health = 0;
+    byte last_magic = 0;
+    int  last_jewels = 0;
+    byte last_keys = 0;
+    byte last_item = 0;
+    int  last_inventory = 0;
+    byte level = 0;         //current level (1,2,3)
+    long score = 0;
+    long last_score = 0;
+    byte object = 0;
+    const char *object_name = nullptr;
+    byte last_object = 0;
+    const char *last_object_name = nullptr;
+    byte armor = 0;
+    byte future[65] = {};
 
-	void sync(Common::Serializer &s);
+    void sync(Common::Serializer &s);
 };
 
 } // namespace Got
diff --git a/engines/got/detection.cpp b/engines/got/detection.cpp
index 20d69f6e50f..273133c950a 100644
--- a/engines/got/detection.cpp
+++ b/engines/got/detection.cpp
@@ -30,16 +30,16 @@
 #include "got/detection_tables.h"
 
 const DebugChannelDef GotMetaEngineDetection::debugFlagList[] = {
-	{ Got::kDebugGraphics, "Graphics", "Graphics debug level" },
-	{ Got::kDebugPath, "Path", "Pathfinding debug level" },
-	{ Got::kDebugFilePath, "FilePath", "File path debug level" },
-	{ Got::kDebugScan, "Scan", "Scan for unrecognised games" },
-	{ Got::kDebugScript, "Script", "Enable debug script dump" },
-	DEBUG_CHANNEL_END
+    { Got::kDebugGraphics, "Graphics", "Graphics debug level" },
+    { Got::kDebugPath, "Path", "Pathfinding debug level" },
+    { Got::kDebugFilePath, "FilePath", "File path debug level" },
+    { Got::kDebugScan, "Scan", "Scan for unrecognised games" },
+    { Got::kDebugScript, "Script", "Enable debug script dump" },
+    DEBUG_CHANNEL_END
 };
 
 GotMetaEngineDetection::GotMetaEngineDetection() : AdvancedMetaEngineDetection(
-	Got::gameDescriptions, Got::gotGames) {
+        Got::gameDescriptions, Got::gotGames) {
 }
 
 REGISTER_PLUGIN_STATIC(GOT_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, GotMetaEngineDetection);
diff --git a/engines/got/detection.h b/engines/got/detection.h
index b9238d19804..5d6b5a47773 100644
--- a/engines/got/detection.h
+++ b/engines/got/detection.h
@@ -27,11 +27,11 @@
 namespace Got {
 
 enum GotDebugChannels {
-	kDebugGraphics = 1,
-	kDebugPath,
-	kDebugScan,
-	kDebugFilePath,
-	kDebugScript,
+    kDebugGraphics = 1,
+    kDebugPath,
+    kDebugScan,
+    kDebugFilePath,
+    kDebugScript,
 };
 
 extern const PlainGameDescriptor gotGames[];
@@ -43,27 +43,27 @@ extern const ADGameDescription gameDescriptions[];
 } // End of namespace Got
 
 class GotMetaEngineDetection : public AdvancedMetaEngineDetection<ADGameDescription> {
-	static const DebugChannelDef debugFlagList[];
+    static const DebugChannelDef debugFlagList[];
 
 public:
-	GotMetaEngineDetection();
-	~GotMetaEngineDetection() override {}
+    GotMetaEngineDetection();
+    ~GotMetaEngineDetection() override {}
 
-	const char *getName() const override {
-		return "got";
-	}
+    const char *getName() const override {
+        return "got";
+    }
 
-	const char *getEngineName() const override {
-		return "Got";
-	}
+    const char *getEngineName() const override {
+        return "Got";
+    }
 
-	const char *getOriginalCopyright() const override {
-		return "Got (C)";
-	}
+    const char *getOriginalCopyright() const override {
+        return "Got (C)";
+    }
 
-	const DebugChannelDef *getDebugChannels() const override {
-		return debugFlagList;
-	}
+    const DebugChannelDef *getDebugChannels() const override {
+        return debugFlagList;
+    }
 };
 
 #endif // GOT_DETECTION_H
diff --git a/engines/got/detection_tables.h b/engines/got/detection_tables.h
index 8e6c5f0b2f2..179772c198d 100644
--- a/engines/got/detection_tables.h
+++ b/engines/got/detection_tables.h
@@ -22,22 +22,22 @@
 namespace Got {
 
 const PlainGameDescriptor gotGames[] = {
-	{ "got", "God of Thunder" },
-	{ 0, 0 }
+    { "got", "God of Thunder" },
+    { 0, 0 }
 };
 
 const ADGameDescription gameDescriptions[] = {
-	{
-		"got",
-		nullptr,
-		AD_ENTRY1s("gotres.dat", "747ed508ffa3808156a4eb080e9859f8", 739710),
-		Common::EN_ANY,
-		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
-		GUIO1(GUIO_NOSPEECH)
-	},
+    {
+        "got",
+        nullptr,
+        AD_ENTRY1s("gotres.dat", "747ed508ffa3808156a4eb080e9859f8", 739710),
+        Common::EN_ANY,
+        Common::kPlatformDOS,
+        ADGF_UNSTABLE,
+        GUIO1(GUIO_NOSPEECH)
+    },
 
-	AD_TABLE_END_MARKER
+    AD_TABLE_END_MARKER
 };
 
 } // End of namespace Got
diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 3f809eee260..e871e20e91e 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -34,482 +34,482 @@ Events *g_events;
 // Index and RGB63 values used for palette animation
 // like water effects and gems sparkling
 static const uint16 PAL_CLR1[] = {
-	0xf300, 0x003b, 0xf000, 0x003b, 0xf100, 0x003b, 0xf200, 0x003b
+    0xf300, 0x003b, 0xf000, 0x003b, 0xf100, 0x003b, 0xf200, 0x003b
 };
 static const uint16 PAL_SET1[] = {
-	0xf027, 0x273f, 0xf127, 0x273f, 0xf227, 0x273f, 0xf327, 0x273f
+    0xf027, 0x273f, 0xf127, 0x273f, 0xf227, 0x273f, 0xf327, 0x273f
 };
 static const uint16 PAL_CLR2[] = {
-	0xf73b, 0x0000, 0xf43b, 0x0000, 0xf53b, 0x0000, 0xf63b, 0x0000
+    0xf73b, 0x0000, 0xf43b, 0x0000, 0xf53b, 0x0000, 0xf63b, 0x0000
 };
 static const uint16 PAL_SET2[] = {
-	0xf43f, 0x2727, 0xf53f, 0x2727, 0xf63f, 0x2727, 0xf73f, 0x2727
+    0xf43f, 0x2727, 0xf53f, 0x2727, 0xf63f, 0x2727, 0xf73f, 0x2727
 };
 
 Events::Events() : UIElement("Root", nullptr) {
-	g_events = this;
+    g_events = this;
 }
 
 Events::~Events() {
-	g_events = nullptr;
+    g_events = nullptr;
 }
 
 void Events::runGame() {
-	uint currTime, nextFrameTime = 0;
-	int palCycleCtr = 0;
-	_screen = new Graphics::Screen();
-	Views::Views views;	// Loads all views in the structure
-
-	// Set up the initial game view
-	int saveSlot = ConfMan.getInt("save_slot");
-	if (saveSlot != -1) {
-		if (g_engine->loadGameState(saveSlot).getCode() != Common::kNoError)
-			saveSlot = -1;
-	}
-	if (saveSlot == -1)
-		addView(isDemo() ? "Game" : "SplashScreen");
-
-	// Main game loop
-	Common::Event e;
-	while (!_views.empty() && !shouldQuit()) {
-		while (g_system->getEventManager()->pollEvent(e)) {
-			if (e.type == Common::EVENT_QUIT ||
-					e.type == Common::EVENT_RETURN_TO_LAUNCHER) {
-				_views.clear();
-				break;
-			} else if (!_G(demo)) {
-				processEvent(e);
-			}
-		}
-
-		if (_views.empty())
-			break;
-
-		g_system->delayMillis(10);
-
-		// Rotate the palette
-		if (++palCycleCtr == 2) {
-			palCycleCtr = 0;
-
-			bool gameVisible = false;
-			for (uint i = 0; i < _views.size() && !gameVisible; ++i)
-				gameVisible = _views[i]->_name == "Game";
-
-			if (gameVisible)
-				rotatePalette();
-		}
-
-		if ((currTime = g_system->getMillis()) >= nextFrameTime) {
-			nextFrameTime = currTime + FRAME_DELAY;
-			nextFrame();
-		}
-	}
-
-	delete _screen;
+    uint currTime, nextFrameTime = 0;
+    int palCycleCtr = 0;
+    _screen = new Graphics::Screen();
+    Views::Views views;	// Loads all views in the structure
+
+    // Set up the initial game view
+    int saveSlot = ConfMan.getInt("save_slot");
+    if (saveSlot != -1) {
+        if (g_engine->loadGameState(saveSlot).getCode() != Common::kNoError)
+            saveSlot = -1;
+    }
+    if (saveSlot == -1)
+        addView(isDemo() ? "Game" : "SplashScreen");
+
+    // Main game loop
+    Common::Event e;
+    while (!_views.empty() && !shouldQuit()) {
+        while (g_system->getEventManager()->pollEvent(e)) {
+            if (e.type == Common::EVENT_QUIT ||
+                    e.type == Common::EVENT_RETURN_TO_LAUNCHER) {
+                _views.clear();
+                break;
+            } else if (!_G(demo)) {
+                processEvent(e);
+            }
+        }
+
+        if (_views.empty())
+            break;
+
+        g_system->delayMillis(10);
+
+        // Rotate the palette
+        if (++palCycleCtr == 2) {
+            palCycleCtr = 0;
+
+            bool gameVisible = false;
+            for (uint i = 0; i < _views.size() && !gameVisible; ++i)
+                gameVisible = _views[i]->_name == "Game";
+
+            if (gameVisible)
+                rotatePalette();
+        }
+
+        if ((currTime = g_system->getMillis()) >= nextFrameTime) {
+            nextFrameTime = currTime + FRAME_DELAY;
+            nextFrame();
+        }
+    }
+
+    delete _screen;
 }
 
 void Events::nextFrame() {
-	// Update state variables
-	_G(rand1) = getRandomNumber(99);
-	_G(rand2) = getRandomNumber(99);
-	_G(pge) = _G(pge) ^ 1;
-	_G(shot_ok) = true;
-	_G(magic_cnt)++;
-
-	// In demo mode, handle the next key
-	if (_G(demo) && _G(gameMode) == MODE_NORMAL) {
-		if (_G(demoKeys).empty()) {
-			_views.clear();
-			return;
-		} else {
-			processDemoEvent(_G(demoKeys).pop());
-		}
-	}
-
-	// Check if any script needs resuming
-	_G(scripts).runIfResuming();
-
-	// Do tick action to the views to handle gameplay logic
-	tick();
-
-	// Draw the current view's elements as needed, and update screen
-	drawElements();
-	_screen->update();
+    // Update state variables
+    _G(rand1) = getRandomNumber(99);
+    _G(rand2) = getRandomNumber(99);
+    _G(pge) = _G(pge) ^ 1;
+    _G(shot_ok) = true;
+    _G(magic_cnt)++;
+
+    // In demo mode, handle the next key
+    if (_G(demo) && _G(gameMode) == MODE_NORMAL) {
+        if (_G(demoKeys).empty()) {
+            _views.clear();
+            return;
+        } else {
+            processDemoEvent(_G(demoKeys).pop());
+        }
+    }
+
+    // Check if any script needs resuming
+    _G(scripts).runIfResuming();
+
+    // Do tick action to the views to handle gameplay logic
+    tick();
+
+    // Draw the current view's elements as needed, and update screen
+    drawElements();
+    _screen->update();
 }
 
 #define LOOP_THRESHOLD 5
 
 void Events::rotatePalette() {
-	const uint16 *entry;
-	++_palLoop;
-
-	if (_palLoop > LOOP_THRESHOLD) {
-		_palLoop = 0;
-	} else {
-		switch (_palLoop) {
-		case LOOP_THRESHOLD - 4:
-			entry = &PAL_CLR2[_palCnt2];
-			break;
-		case LOOP_THRESHOLD - 3:
-			entry = &PAL_SET2[_palCnt2];
-
-			_palCnt2 += 2;
-			if (_palCnt2 >= 8)
-				_palCnt2 = 0;
-			break;
-		case LOOP_THRESHOLD - 2:
-			entry = &PAL_CLR1[_palCnt1];
-			break;
-		case LOOP_THRESHOLD - 1:
-			entry = &PAL_SET1[_palCnt1];
-
-			_palCnt1 += 2;
-			if (_palCnt1 >= 8)
-				_palCnt1 = 0;
-			break;
-		default:
-			return;
-		}
-
-		Gfx::xsetpal(entry[0] >> 8, (entry[0] & 0xff) << 2,
-			(entry[1] >> 8) << 2, (entry[1] & 0xff) << 2);
-	}
+    const uint16 *entry;
+    ++_palLoop;
+
+    if (_palLoop > LOOP_THRESHOLD) {
+        _palLoop = 0;
+    } else {
+        switch (_palLoop) {
+        case LOOP_THRESHOLD - 4:
+            entry = &PAL_CLR2[_palCnt2];
+            break;
+        case LOOP_THRESHOLD - 3:
+            entry = &PAL_SET2[_palCnt2];
+
+            _palCnt2 += 2;
+            if (_palCnt2 >= 8)
+                _palCnt2 = 0;
+            break;
+        case LOOP_THRESHOLD - 2:
+            entry = &PAL_CLR1[_palCnt1];
+            break;
+        case LOOP_THRESHOLD - 1:
+            entry = &PAL_SET1[_palCnt1];
+
+            _palCnt1 += 2;
+            if (_palCnt1 >= 8)
+                _palCnt1 = 0;
+            break;
+        default:
+            return;
+        }
+
+        Gfx::xsetpal(entry[0] >> 8, (entry[0] & 0xff) << 2,
+                     (entry[1] >> 8) << 2, (entry[1] & 0xff) << 2);
+    }
 }
 
 void Events::processEvent(Common::Event &ev) {
-	switch (ev.type) {
-	case Common::EVENT_KEYDOWN:
-		if (ev.kbd.keycode < 100)
-			_G(key_flag)[ev.kbd.keycode] = true;
-
-		if (ev.kbd.keycode < Common::KEYCODE_NUMLOCK)
-			msgKeypress(KeypressMessage(ev.kbd));
-		break;
-	case Common::EVENT_KEYUP:
-		if (ev.kbd.keycode < 100)
-			_G(key_flag)[ev.kbd.keycode] = false;
-		break;
-	case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
-		_G(key_flag)[actionToKeyFlag(ev.customType)] = true;
-		msgAction(ActionMessage(ev.customType));
-		break;
-	case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
-		_G(key_flag)[actionToKeyFlag(ev.customType)] = false;
-		break;
-	case Common::EVENT_LBUTTONDOWN:
-	case Common::EVENT_RBUTTONDOWN:
-	case Common::EVENT_MBUTTONDOWN:
-		msgMouseDown(MouseDownMessage(ev.type, ev.mouse));
-		break;
-	case Common::EVENT_LBUTTONUP:
-	case Common::EVENT_RBUTTONUP:
-	case Common::EVENT_MBUTTONUP:
-		msgMouseUp(MouseUpMessage(ev.type, ev.mouse));
-		break;
-	case Common::EVENT_MOUSEMOVE:
-		msgMouseMove(MouseMoveMessage(ev.type, ev.mouse));
-		break;
-	default:
-		break;
-	}
+    switch (ev.type) {
+    case Common::EVENT_KEYDOWN:
+        if (ev.kbd.keycode < 100)
+            _G(key_flag)[ev.kbd.keycode] = true;
+
+        if (ev.kbd.keycode < Common::KEYCODE_NUMLOCK)
+            msgKeypress(KeypressMessage(ev.kbd));
+        break;
+    case Common::EVENT_KEYUP:
+        if (ev.kbd.keycode < 100)
+            _G(key_flag)[ev.kbd.keycode] = false;
+        break;
+    case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+        _G(key_flag)[actionToKeyFlag(ev.customType)] = true;
+        msgAction(ActionMessage(ev.customType));
+        break;
+    case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
+        _G(key_flag)[actionToKeyFlag(ev.customType)] = false;
+        break;
+    case Common::EVENT_LBUTTONDOWN:
+    case Common::EVENT_RBUTTONDOWN:
+    case Common::EVENT_MBUTTONDOWN:
+        msgMouseDown(MouseDownMessage(ev.type, ev.mouse));
+        break;
+    case Common::EVENT_LBUTTONUP:
+    case Common::EVENT_RBUTTONUP:
+    case Common::EVENT_MBUTTONUP:
+        msgMouseUp(MouseUpMessage(ev.type, ev.mouse));
+        break;
+    case Common::EVENT_MOUSEMOVE:
+        msgMouseMove(MouseMoveMessage(ev.type, ev.mouse));
+        break;
+    default:
+        break;
+    }
 }
 
 void Events::processDemoEvent(byte ev) {
-	bool flag = ev & 0x80;
-	ev &= 0x7f;
-
-	int action = -1;
-	switch (ev) {
-	case 0:
-		return;
-	case 72:
-		ev = key_up;
-		action = KEYBIND_UP;
-		break;
-	case 80:
-		ev = key_down;
-		break;
-	case 75:
-		ev = key_left;
-		break;
-	case 77:
-		ev = key_right;
-		break;
-	case 56:
-		ev = key_fire;
-		action = KEYBIND_FIRE;
-		break;
-	case 29:
-		ev = key_magic;
-		action = KEYBIND_MAGIC;
-		break;
-	default:
-		break;
-	}
-
-	_G(key_flag)[ev] = flag;
-
-	if (flag && action != -1)
-		msgAction(ActionMessage(action));
+    bool flag = ev & 0x80;
+    ev &= 0x7f;
+
+    int action = -1;
+    switch (ev) {
+    case 0:
+        return;
+    case 72:
+        ev = key_up;
+        action = KEYBIND_UP;
+        break;
+    case 80:
+        ev = key_down;
+        break;
+    case 75:
+        ev = key_left;
+        break;
+    case 77:
+        ev = key_right;
+        break;
+    case 56:
+        ev = key_fire;
+        action = KEYBIND_FIRE;
+        break;
+    case 29:
+        ev = key_magic;
+        action = KEYBIND_MAGIC;
+        break;
+    default:
+        break;
+    }
+
+    _G(key_flag)[ev] = flag;
+
+    if (flag && action != -1)
+        msgAction(ActionMessage(action));
 }
 
 int Events::actionToKeyFlag(int action) const {
-	return (action == KEYBIND_ESCAPE) ? Common::KEYCODE_ESCAPE :
-		(int)action;
+    return (action == KEYBIND_ESCAPE) ? Common::KEYCODE_ESCAPE :
+           (int)action;
 }
 
 void Events::replaceView(UIElement *ui, bool replaceAllViews, bool fadeOutIn) {
-	assert(ui);
-	UIElement *priorView = focusedView();
+    assert(ui);
+    UIElement *priorView = focusedView();
 
-	if (fadeOutIn)
-		Gfx::fade_out();
+    if (fadeOutIn)
+        Gfx::fade_out();
 
-	if (replaceAllViews) {
-		clearViews();
+    if (replaceAllViews) {
+        clearViews();
 
-	} else if (!_views.empty()) {
-		priorView->msgUnfocus(UnfocusMessage());
-		_views.pop();
-	}
+    } else if (!_views.empty()) {
+        priorView->msgUnfocus(UnfocusMessage());
+        _views.pop();
+    }
 
-	// Redraw any prior views to erase the removed view
-	for (uint i = 0; i < _views.size(); ++i) {
-		_views[i]->redraw();
-		_views[i]->draw();
-	}
+    // Redraw any prior views to erase the removed view
+    for (uint i = 0; i < _views.size(); ++i) {
+        _views[i]->redraw();
+        _views[i]->draw();
+    }
 
-	// Add the new view
-	_views.push(ui);
+    // Add the new view
+    _views.push(ui);
 
-	ui->redraw();
-	ui->msgFocus(FocusMessage(priorView));
-	ui->draw();
+    ui->redraw();
+    ui->msgFocus(FocusMessage(priorView));
+    ui->draw();
 
-	if (fadeOutIn)
-		Gfx::fade_in();
+    if (fadeOutIn)
+        Gfx::fade_in();
 }
 
 void Events::replaceView(const Common::String &name, bool replaceAllViews, bool fadeOutIn) {
-	replaceView(findView(name), replaceAllViews, fadeOutIn);
+    replaceView(findView(name), replaceAllViews, fadeOutIn);
 }
 
 void Events::addView(UIElement *ui) {
-	assert(ui);
-	UIElement *priorView = focusedView();
+    assert(ui);
+    UIElement *priorView = focusedView();
 
-	if (!_views.empty())
-		priorView->msgUnfocus(UnfocusMessage());
+    if (!_views.empty())
+        priorView->msgUnfocus(UnfocusMessage());
 
-	_views.push(ui);
-	ui->redraw();
-	ui->msgFocus(FocusMessage(priorView));
+    _views.push(ui);
+    ui->redraw();
+    ui->msgFocus(FocusMessage(priorView));
 }
 
 void Events::addView(const Common::String &name) {
-	addView(findView(name));
+    addView(findView(name));
 }
 
 void Events::popView() {
-	UIElement *priorView = focusedView();
-	priorView->msgUnfocus(UnfocusMessage());
-	_views.pop();
+    UIElement *priorView = focusedView();
+    priorView->msgUnfocus(UnfocusMessage());
+    _views.pop();
 
-	for (uint i = 0; i < _views.size(); ++i) {
-		_views[i]->redraw();
-		_views[i]->draw();
-	}
+    for (uint i = 0; i < _views.size(); ++i) {
+        _views[i]->redraw();
+        _views[i]->draw();
+    }
 
-	if (!_views.empty()) {
-		UIElement *view = focusedView();
-		view->msgFocus(FocusMessage(priorView));
-		view->redraw();
-		view->draw();
-	}
+    if (!_views.empty()) {
+        UIElement *view = focusedView();
+        view->msgFocus(FocusMessage(priorView));
+        view->redraw();
+        view->draw();
+    }
 }
 
 void Events::redrawViews() {
-	for (uint i = 0; i < _views.size(); ++i) {
-		_views[i]->redraw();
-		_views[i]->draw();
-	}
+    for (uint i = 0; i < _views.size(); ++i) {
+        _views[i]->redraw();
+        _views[i]->draw();
+    }
 }
 
 bool Events::isPresent(const Common::String &name) const {
-	for (uint i = 0; i < _views.size(); ++i) {
-		if (_views[i]->_name == name)
-			return true;
-	}
+    for (uint i = 0; i < _views.size(); ++i) {
+        if (_views[i]->_name == name)
+            return true;
+    }
 
-	return false;
+    return false;
 }
 
 void Events::clearViews() {
-	if (!_views.empty())
-		focusedView()->msgUnfocus(UnfocusMessage());
+    if (!_views.empty())
+        focusedView()->msgUnfocus(UnfocusMessage());
 
-	_views.clear();
+    _views.clear();
 }
 
 void Events::addKeypress(const Common::KeyCode kc) {
-	Common::KeyState ks;
-	ks.keycode = kc;
-	if (kc >= Common::KEYCODE_SPACE && kc <= Common::KEYCODE_TILDE)
-		ks.ascii = kc;
+    Common::KeyState ks;
+    ks.keycode = kc;
+    if (kc >= Common::KEYCODE_SPACE && kc <= Common::KEYCODE_TILDE)
+        ks.ascii = kc;
 
-	focusedView()->msgKeypress(KeypressMessage(ks));
+    focusedView()->msgKeypress(KeypressMessage(ks));
 }
 
 /*------------------------------------------------------------------------*/
 
 Bounds::Bounds(Common::Rect &innerBounds) :
-		_bounds(0, 0, 320, 240),
-		_innerBounds(innerBounds),
-		left(_bounds.left), top(_bounds.top),
-		right(_bounds.right), bottom(_bounds.bottom) {
+    _bounds(0, 0, 320, 240),
+    _innerBounds(innerBounds),
+    left(_bounds.left), top(_bounds.top),
+    right(_bounds.right), bottom(_bounds.bottom) {
 }
 
 Bounds &Bounds::operator=(const Common::Rect &r) {
-	_bounds = r;
-	_innerBounds = r;
-	_innerBounds.grow(-_borderSize);
-	return *this;
+    _bounds = r;
+    _innerBounds = r;
+    _innerBounds.grow(-_borderSize);
+    return *this;
 }
 
 void Bounds::setBorderSize(size_t borderSize) {
-	_borderSize = borderSize;
-	_innerBounds = *this;
-	_innerBounds.grow(-_borderSize);
+    _borderSize = borderSize;
+    _innerBounds = *this;
+    _innerBounds.grow(-_borderSize);
 }
 
 /*------------------------------------------------------------------------*/
 
 UIElement::UIElement(const Common::String &name) :
-		_name(name), _parent(g_engine), _bounds(_innerBounds) {
-	g_engine->_children.push_back(this);
+    _name(name), _parent(g_engine), _bounds(_innerBounds) {
+    g_engine->_children.push_back(this);
 }
 
 UIElement::UIElement(const Common::String &name, UIElement *uiParent) :
-		_name(name), _parent(uiParent),
-		_bounds(_innerBounds) {
-	if (_parent)
-		_parent->_children.push_back(this);
+    _name(name), _parent(uiParent),
+    _bounds(_innerBounds) {
+    if (_parent)
+        _parent->_children.push_back(this);
 }
 
 void UIElement::redraw() {
-	_needsRedraw = true;
+    _needsRedraw = true;
 
-	for (size_t i = 0; i < _children.size(); ++i)
-		_children[i]->redraw();
+    for (size_t i = 0; i < _children.size(); ++i)
+        _children[i]->redraw();
 }
 
 void UIElement::drawElements() {
-	if (_needsRedraw) {
-		draw();
-		_needsRedraw = false;
-	}
+    if (_needsRedraw) {
+        draw();
+        _needsRedraw = false;
+    }
 
-	for (size_t i = 0; i < _children.size(); ++i)
-		_children[i]->drawElements();
+    for (size_t i = 0; i < _children.size(); ++i)
+        _children[i]->drawElements();
 }
 
 UIElement *UIElement::findViewGlobally(const Common::String &name) {
-	return g_events->findView(name);
+    return g_events->findView(name);
 }
 
 void UIElement::focus() {
-	g_events->replaceView(this);
+    g_events->replaceView(this);
 }
 
 void UIElement::close() {
-	assert(g_events->focusedView() == this);
-	g_events->popView();
+    assert(g_events->focusedView() == this);
+    g_events->popView();
 }
 
 bool UIElement::isFocused() const {
-	return g_events->focusedView() == this;
+    return g_events->focusedView() == this;
 }
 
 void UIElement::clearSurface() {
-	GfxSurface s = getSurface();
-	s.fillRect(Common::Rect(s.w, s.h), 0);
+    GfxSurface s = getSurface();
+    s.fillRect(Common::Rect(s.w, s.h), 0);
 }
 
 void UIElement::draw() {
-	for (size_t i = 0; i < _children.size(); ++i) {
-		_children[i]->draw();
-	}
+    for (size_t i = 0; i < _children.size(); ++i) {
+        _children[i]->draw();
+    }
 }
 
 bool UIElement::tick() {
-	if (_timeoutCtr && --_timeoutCtr == 0) {
-		timeout();
-	}
+    if (_timeoutCtr && --_timeoutCtr == 0) {
+        timeout();
+    }
 
-	for (size_t i = 0; i < _children.size(); ++i) {
-		if (_children[i]->tick())
-			return true;
-	}
+    for (size_t i = 0; i < _children.size(); ++i) {
+        if (_children[i]->tick())
+            return true;
+    }
 
-	return false;
+    return false;
 }
 
 UIElement *UIElement::findView(const Common::String &name) {
-	if (_name.equalsIgnoreCase(name))
-		return this;
+    if (_name.equalsIgnoreCase(name))
+        return this;
 
-	UIElement *result;
-	for (size_t i = 0; i < _children.size(); ++i) {
-		if ((result = _children[i]->findView(name)) != nullptr)
-			return result;
-	}
+    UIElement *result;
+    for (size_t i = 0; i < _children.size(); ++i) {
+        if ((result = _children[i]->findView(name)) != nullptr)
+            return result;
+    }
 
-	return nullptr;
+    return nullptr;
 }
 
 void UIElement::replaceView(UIElement *ui, bool replaceAllViews, bool fadeOutIn) {
-	g_events->replaceView(ui, replaceAllViews, fadeOutIn);
+    g_events->replaceView(ui, replaceAllViews, fadeOutIn);
 }
 
 void UIElement::replaceView(const Common::String &name, bool replaceAllViews, bool fadeOutIn) {
-	g_events->replaceView(name, replaceAllViews, fadeOutIn);
+    g_events->replaceView(name, replaceAllViews, fadeOutIn);
 }
 
 void UIElement::addView(UIElement *ui) {
-	g_events->addView(ui);
+    g_events->addView(ui);
 }
 
 void UIElement::addView(const Common::String &name) {
-	g_events->addView(name);
+    g_events->addView(name);
 }
 
 void UIElement::addView() {
-	g_events->addView(this);
+    g_events->addView(this);
 }
 
 GfxSurface UIElement::getSurface(bool innerBounds) const {
-	return GfxSurface(*g_events->getScreen(),
-		innerBounds ? _innerBounds : _bounds);
+    return GfxSurface(*g_events->getScreen(),
+                      innerBounds ? _innerBounds : _bounds);
 }
 
 int UIElement::getRandomNumber(int minNumber, int maxNumber) {
-	return g_engine->getRandomNumber(maxNumber - minNumber + 1) + minNumber;
+    return g_engine->getRandomNumber(maxNumber - minNumber + 1) + minNumber;
 }
 
 int UIElement::getRandomNumber(int maxNumber) {
-	return g_engine->getRandomNumber(maxNumber);
+    return g_engine->getRandomNumber(maxNumber);
 }
 
 void UIElement::delaySeconds(uint seconds) {
-	_timeoutCtr = seconds * FRAME_RATE;
+    _timeoutCtr = seconds * FRAME_RATE;
 }
 
 void UIElement::delayFrames(uint frames) {
-	_timeoutCtr = frames;
+    _timeoutCtr = frames;
 }
 
 void UIElement::timeout() {
-	redraw();
+    redraw();
 }
 
 } // namespace Got
diff --git a/engines/got/events.h b/engines/got/events.h
index 67aad22f3db..a5c164acb09 100644
--- a/engines/got/events.h
+++ b/engines/got/events.h
@@ -43,186 +43,202 @@ class Events;
  */
 struct Bounds {
 private:
-	Common::Rect _bounds;
-	Common::Rect &_innerBounds;
-	int _borderSize = 0;
+    Common::Rect _bounds;
+    Common::Rect &_innerBounds;
+    int _borderSize = 0;
 public:
-	const int16 &left;
-	const int16 ⊤
-	const int16 &right;
-	const int16 ⊥
+    const int16 &left;
+    const int16 ⊤
+    const int16 &right;
+    const int16 ⊥
 public:
-	Bounds(Common::Rect &innerBounds);
-	operator const Common::Rect &() const { return _bounds; }
-	Bounds &operator=(const Common::Rect &r);
-	void setBorderSize(size_t borderSize);
-	size_t borderSize() const { return _borderSize; }
-	int16 width() const { return _bounds.width(); }
-	int16 height() const { return _bounds.height(); }
+    Bounds(Common::Rect &innerBounds);
+    operator const Common::Rect &() const {
+        return _bounds;
+    }
+    Bounds &operator=(const Common::Rect &r);
+    void setBorderSize(size_t borderSize);
+    size_t borderSize() const {
+        return _borderSize;
+    }
+    int16 width() const {
+        return _bounds.width();
+    }
+    int16 height() const {
+        return _bounds.height();
+    }
 };
 
 /**
  * User interface element
  */
 class UIElement {
-	friend class Events;
+    friend class Events;
 private:
-	int _timeoutCtr = 0;
+    int _timeoutCtr = 0;
 protected:
-	UIElement *_parent;
-	Common::Array<UIElement *> _children;
-	Common::Rect _innerBounds;
-	Bounds _bounds;
-	bool _needsRedraw = true;
-	Common::String _name;
+    UIElement *_parent;
+    Common::Array<UIElement *> _children;
+    Common::Rect _innerBounds;
+    Bounds _bounds;
+    bool _needsRedraw = true;
+    Common::String _name;
 protected:
-	/**
-	 * Set a delay countdown in seconds, after which timeout() is called
-	 */
-	void delaySeconds(uint seconds);
-
-	/**
-	 * Set a delay countdown in frames, after which timeout() is called
-	 */
-	void delayFrames(uint frames);
-
-	/**
-	 * Returns true if a delay is active
-	 */
-	bool isDelayActive() const {
-		return _timeoutCtr != 0;
-	}
-
-	/**
-	 * Cancels any active delay
-	 */
-	void cancelDelay() {
-		_timeoutCtr = 0;
-	}
-
-	/**
-	 * Called when an active timeout countdown expired
-	 */
-	virtual void timeout();
+    /**
+     * Set a delay countdown in seconds, after which timeout() is called
+     */
+    void delaySeconds(uint seconds);
+
+    /**
+     * Set a delay countdown in frames, after which timeout() is called
+     */
+    void delayFrames(uint frames);
+
+    /**
+     * Returns true if a delay is active
+     */
+    bool isDelayActive() const {
+        return _timeoutCtr != 0;
+    }
+
+    /**
+     * Cancels any active delay
+     */
+    void cancelDelay() {
+        _timeoutCtr = 0;
+    }
+
+    /**
+     * Called when an active timeout countdown expired
+     */
+    virtual void timeout();
 
 private:
-	/**
-	 * Outer method for doing drawing
-	 *
-	 */
-	void drawElements();
-
-	/**
-	 * Finds a view globally
-	 */
-	static UIElement *findViewGlobally(const Common::String &name);
+    /**
+     * Outer method for doing drawing
+     *
+     */
+    void drawElements();
+
+    /**
+     * Finds a view globally
+     */
+    static UIElement *findViewGlobally(const Common::String &name);
 public:
-	UIElement(const Common::String &name, UIElement *uiParent);
-	UIElement(const Common::String &name);
-	virtual ~UIElement() {}
-
-	/**
-	 * Returns true if the elements needs to be redrawn
-	 */
-	bool needsRedraw() const { return _needsRedraw; }
-
-	/**
-	 * Sets that the element needs to be redrawn
-	 */
-	void redraw();
-
-	/**
-	 * Focuses the element as the current view
-	 */
-	void focus();
-
-	/**
-	 * Closes the current view. The view must have been added
-	 * via addView, so there's a remaining view afterwards
-	 */
-	virtual void close();
-
-	/*
-	 * Returns true if the view is focused
-	 */
-	bool isFocused() const;
-
-	/**
-	 * Sets the focus to a new view
-	 */
-	void replaceView(UIElement *ui, bool replaceAllViews = false, bool fadeOutIn = false);
-	void replaceView(const Common::String &name, bool replaceAllViews = false, bool fadeOutIn = false);
-
-	/**
-	 * Adds a focused view to the view stack without replacing current one
-	 */
-	void addView(UIElement *ui);
-	void addView(const Common::String &name);
-	void addView();
-	void open() { addView(); }
-
-	/**
-	 * Returns a random number
-	 */
-	int getRandomNumber(int minNumber, int maxNumber);
-	int getRandomNumber(int maxNumber);
-
-	/**
-	 * Sets the element's bounds
-	 */
-	virtual void setBounds(const Common::Rect &r) {
-		_bounds = r;
-	}
-
-	/**
-	 * Gets the element's bounds
-	 */
-	Common::Rect getBounds() const {
-		return _bounds;
-	}
-
-	/**
-	 * Gets a view's name
-	 */
-	const Common::String &getName() const {
-		return _name;
-	}
-
-	/**
-	 * Returns a surface for drawing the element
-	 */
-	Gfx::GfxSurface getSurface(bool innerBounds = false) const;
-
-	/**
-	 * Clear the surface
-	 */
-	virtual void clearSurface();
-
-	/**
-	 * Draws the element
-	 */
-	virtual void draw();
-
-	/**
-	 * Called for game frame ticks
-	 */
-	virtual bool tick();
-
-	/**
-	 * Find a view by name
-	 */
-	virtual UIElement *findView(const Common::String &name);
-
-	/**
-	 * Handles events
-	 */
-	// Mouse move only has a minimal implementation for performance reasons
+    UIElement(const Common::String &name, UIElement *uiParent);
+    UIElement(const Common::String &name);
+    virtual ~UIElement() {}
+
+    /**
+     * Returns true if the elements needs to be redrawn
+     */
+    bool needsRedraw() const {
+        return _needsRedraw;
+    }
+
+    /**
+     * Sets that the element needs to be redrawn
+     */
+    void redraw();
+
+    /**
+     * Focuses the element as the current view
+     */
+    void focus();
+
+    /**
+     * Closes the current view. The view must have been added
+     * via addView, so there's a remaining view afterwards
+     */
+    virtual void close();
+
+    /*
+     * Returns true if the view is focused
+     */
+    bool isFocused() const;
+
+    /**
+     * Sets the focus to a new view
+     */
+    void replaceView(UIElement *ui, bool replaceAllViews = false, bool fadeOutIn = false);
+    void replaceView(const Common::String &name, bool replaceAllViews = false, bool fadeOutIn = false);
+
+    /**
+     * Adds a focused view to the view stack without replacing current one
+     */
+    void addView(UIElement *ui);
+    void addView(const Common::String &name);
+    void addView();
+    void open() {
+        addView();
+    }
+
+    /**
+     * Returns a random number
+     */
+    int getRandomNumber(int minNumber, int maxNumber);
+    int getRandomNumber(int maxNumber);
+
+    /**
+     * Sets the element's bounds
+     */
+    virtual void setBounds(const Common::Rect &r) {
+        _bounds = r;
+    }
+
+    /**
+     * Gets the element's bounds
+     */
+    Common::Rect getBounds() const {
+        return _bounds;
+    }
+
+    /**
+     * Gets a view's name
+     */
+    const Common::String &getName() const {
+        return _name;
+    }
+
+    /**
+     * Returns a surface for drawing the element
+     */
+    Gfx::GfxSurface getSurface(bool innerBounds = false) const;
+
+    /**
+     * Clear the surface
+     */
+    virtual void clearSurface();
+
+    /**
+     * Draws the element
+     */
+    virtual void draw();
+
+    /**
+     * Called for game frame ticks
+     */
+    virtual bool tick();
+
+    /**
+     * Find a view by name
+     */
+    virtual UIElement *findView(const Common::String &name);
+
+    /**
+     * Handles events
+     */
+    // Mouse move only has a minimal implementation for performance reasons
 protected:
-	virtual bool msgMouseMove(const MouseMoveMessage &msg) { return false; }
+    virtual bool msgMouseMove(const MouseMoveMessage &msg) {
+        return false;
+    }
 public:
-	bool send(const MouseMoveMessage &msg) { return msgMouseMove(msg); }
+    bool send(const MouseMoveMessage &msg) {
+        return msgMouseMove(msg);
+    }
 
-	#define MESSAGE(NAME) \
+#define MESSAGE(NAME) \
 	protected: \
 		virtual bool msg##NAME(const NAME##Message &e) { \
 			for (Common::Array<UIElement *>::iterator it = _children.begin(); \
@@ -241,17 +257,17 @@ public:
 			return msg##NAME(msg); \
 		} \
 
-	MESSAGE(Focus);
-	MESSAGE(Unfocus);
-	MESSAGE(MouseEnter);
-	MESSAGE(MouseLeave);
-	MESSAGE(Keypress);
-	MESSAGE(MouseDown);
-	MESSAGE(MouseUp);
-	MESSAGE(Action);
-	MESSAGE(Game);
-	MESSAGE(Value);
-	#undef MESSAGE
+    MESSAGE(Focus);
+    MESSAGE(Unfocus);
+    MESSAGE(MouseEnter);
+    MESSAGE(MouseLeave);
+    MESSAGE(Keypress);
+    MESSAGE(MouseDown);
+    MESSAGE(MouseUp);
+    MESSAGE(Action);
+    MESSAGE(Game);
+    MESSAGE(Value);
+#undef MESSAGE
 };
 
 /**
@@ -263,162 +279,162 @@ public:
  */
 class Events : public UIElement {
 private:
-	Graphics::Screen *_screen = nullptr;
-	Common::Stack<UIElement *> _views;
-	int _palLoop = 0;
-	int _palCnt1 = 0;
-	int _palCnt2 = 0;
-
-	void nextFrame();
-	int actionToKeyFlag(int action) const;
-	void rotatePalette();
-
-	/**
-	 * Process an event
-	 */
-	void processEvent(Common::Event &ev);
-
-	/**
-	 * Process a demo event
-	 */
-	void processDemoEvent(byte ev);
+    Graphics::Screen *_screen = nullptr;
+    Common::Stack<UIElement *> _views;
+    int _palLoop = 0;
+    int _palCnt1 = 0;
+    int _palCnt2 = 0;
+
+    void nextFrame();
+    int actionToKeyFlag(int action) const;
+    void rotatePalette();
+
+    /**
+     * Process an event
+     */
+    void processEvent(Common::Event &ev);
+
+    /**
+     * Process a demo event
+     */
+    void processDemoEvent(byte ev);
 
 protected:
-	/**
-	 * Returns true if the game should quit
-	 */
-	virtual bool shouldQuit() const = 0;
-
-	/**
-	 * Overrides events we want to only go to the focused view
-	 */
-	#define MESSAGE(NAME) \
+    /**
+     * Returns true if the game should quit
+     */
+    virtual bool shouldQuit() const = 0;
+
+    /**
+     * Overrides events we want to only go to the focused view
+     */
+#define MESSAGE(NAME) \
 		bool msg##NAME(const NAME##Message &e) override { \
 			return !_views.empty() ? focusedView()->msg##NAME(e) : false; \
 		}
-	MESSAGE(Action);
-	MESSAGE(Focus);
-	MESSAGE(Unfocus);
-	MESSAGE(MouseEnter);
-	MESSAGE(MouseLeave);
-	MESSAGE(Keypress);
-	MESSAGE(MouseDown);
-	MESSAGE(MouseUp);
-	MESSAGE(MouseMove);
-	#undef MESSAGE
+    MESSAGE(Action);
+    MESSAGE(Focus);
+    MESSAGE(Unfocus);
+    MESSAGE(MouseEnter);
+    MESSAGE(MouseLeave);
+    MESSAGE(Keypress);
+    MESSAGE(MouseDown);
+    MESSAGE(MouseUp);
+    MESSAGE(MouseMove);
+#undef MESSAGE
 public:
-	Events();
-	virtual ~Events();
-
-	virtual bool isDemo() const = 0;
-
-	/**
-	 * Main game loop
-	 */
-	void runGame();
-
-	/**
-	 * Sets the focus to a new view
-	 */
-	void replaceView(UIElement *ui, bool replaceAllViews = false, bool fadeOutIn = false);
-	void replaceView(const Common::String &name, bool replaceAllViews = false, bool fadeOutIn = false);
-
-	/**
-	 * Adds a focused view to the view stack without replacing current one
-	 */
-	void addView(UIElement *ui);
-	void addView(const Common::String &name);
-
-	/**
-	 * Clears the view list
-	 */
-	void clearViews();
-
-	/**
-	 * Pops a view from the view stack
-	 */
-	void popView();
-
-	/**
-	 * Redraws the views in order. This is used in rare cases
-	 * where a view draws outside it's defined area, and needs
-	 * to restore whether the background was before
-	 */
-	void redrawViews();
-
-	/**
-	 * Returns the currently focused view, if any
-	 */
-	UIElement *focusedView() const {
-		return _views.empty() ? nullptr : _views.top();
-	}
-
-	/**
-	 * Returns the view prior to the current view, if any
-	 */
-	UIElement *priorView() const {
-		return _views.size() < 2 ? nullptr :
-			_views[_views.size() - 2];
-	}
-
-	/**
-	 * Returns the first view in the stack
-	 */
-	UIElement *firstView() const {
-		return _views.empty() ? nullptr : _views[0];
-	}
-
-	/**
-	 * Returns true if a view of a given name is present
-	 * at all in the visible view stack
-	 */
-	bool isPresent(const Common::String &name) const;
-
-	/**
-	 * Returns true if combat is active
-	 */
-	bool isInCombat() const {
-		return isPresent("Combat");
-	}
-
-	/**
-	 * Returns the underlying screen
-	 */
-	Graphics::Screen *getScreen() const {
-		return _screen;
-	}
-
-	/**
-	 * Draws the focused view
-	 */
-	void drawElements() {
-		if (!_views.empty())
-			focusedView()->drawElements();
-	}
-
-	/**
-	 * Add a keypress to the event queue
-	 */
-	void addKeypress(const Common::KeyCode kc);
-
-	/**
-	 * Events manager doesn't have any intrinsic drawing
-	 */
-	void draw() override {}
-
-	/**
-	 * Called once every game frame
-	 */
-	bool tick() override {
-		return !_views.empty() ? focusedView()->tick() : false;
-	}
-
-	/**
-	 * Calling the close method for g_events closes the active view
-	 */
-	void close() override {
-		focusedView()->close();
-	}
+    Events();
+    virtual ~Events();
+
+    virtual bool isDemo() const = 0;
+
+    /**
+     * Main game loop
+     */
+    void runGame();
+
+    /**
+     * Sets the focus to a new view
+     */
+    void replaceView(UIElement *ui, bool replaceAllViews = false, bool fadeOutIn = false);
+    void replaceView(const Common::String &name, bool replaceAllViews = false, bool fadeOutIn = false);
+
+    /**
+     * Adds a focused view to the view stack without replacing current one
+     */
+    void addView(UIElement *ui);
+    void addView(const Common::String &name);
+
+    /**
+     * Clears the view list
+     */
+    void clearViews();
+
+    /**
+     * Pops a view from the view stack
+     */
+    void popView();
+
+    /**
+     * Redraws the views in order. This is used in rare cases
+     * where a view draws outside it's defined area, and needs
+     * to restore whether the background was before
+     */
+    void redrawViews();
+
+    /**
+     * Returns the currently focused view, if any
+     */
+    UIElement *focusedView() const {
+        return _views.empty() ? nullptr : _views.top();
+    }
+
+    /**
+     * Returns the view prior to the current view, if any
+     */
+    UIElement *priorView() const {
+        return _views.size() < 2 ? nullptr :
+               _views[_views.size() - 2];
+    }
+
+    /**
+     * Returns the first view in the stack
+     */
+    UIElement *firstView() const {
+        return _views.empty() ? nullptr : _views[0];
+    }
+
+    /**
+     * Returns true if a view of a given name is present
+     * at all in the visible view stack
+     */
+    bool isPresent(const Common::String &name) const;
+
+    /**
+     * Returns true if combat is active
+     */
+    bool isInCombat() const {
+        return isPresent("Combat");
+    }
+
+    /**
+     * Returns the underlying screen
+     */
+    Graphics::Screen *getScreen() const {
+        return _screen;
+    }
+
+    /**
+     * Draws the focused view
+     */
+    void drawElements() {
+        if (!_views.empty())
+            focusedView()->drawElements();
+    }
+
+    /**
+     * Add a keypress to the event queue
+     */
+    void addKeypress(const Common::KeyCode kc);
+
+    /**
+     * Events manager doesn't have any intrinsic drawing
+     */
+    void draw() override {}
+
+    /**
+     * Called once every game frame
+     */
+    bool tick() override {
+        return !_views.empty() ? focusedView()->tick() : false;
+    }
+
+    /**
+     * Calling the close method for g_events closes the active view
+     */
+    void close() override {
+        focusedView()->close();
+    }
 };
 
 extern Events *g_events;
diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index 8ebd2f7f19e..4e195b1a798 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -35,326 +35,326 @@
 namespace Got {
 
 const char *OBJECT_NAMES[] = {
-	"Shrub","Child's Doll","UNUSED","FUTURE",
-	"FUTURE","FUTURE","FUTURE","FUTURE","FUTURE",
-	"FUTURE","FUTURE","FUTURE","FUTURE","FUTURE",
-	"FUTURE"
+    "Shrub","Child's Doll","UNUSED","FUTURE",
+    "FUTURE","FUTURE","FUTURE","FUTURE","FUTURE",
+    "FUTURE","FUTURE","FUTURE","FUTURE","FUTURE",
+    "FUTURE"
 };
 const char *ITEM_NAMES[] = {
-	"Enchanted Apple","Lightning Power",
-	"Winged Boots","Wind Power",
-	"Amulet of Protection","Thunder Power"
+    "Enchanted Apple","Lightning Power",
+    "Winged Boots","Wind Power",
+    "Amulet of Protection","Thunder Power"
 };
 
 static const char *odinEndMessage;
 
 void show_level(int new_level) {
-	int save_d;
-
-	_G(boss_active) = 0;
-	if (!_G(shield_on))
-		_G(actor)[2].used = 0;
-	_G(bomb_flag) = 0;
-	_G(slipping) = false;
-
-	save_d = _G(thor)->dir;
-	if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154)
-		_G(thor)->dir = 0;
-
-	// The original copied 130 bytes from _G(scrn).static_object onwards into sd_data.
-	// This doesn't make sense, because that would put the ending in the middle of static_y.
-	// Plus, it follows with an entire copy of scrn into sd_data anyway, so the first
-	// move seems entirely redundant.
-	_G(scrn).save(_G(current_level));
-	_G(scrn).load(_G(new_level));
-
-	_G(level_type) = _G(scrn).type;
-
-	_G(thor)->next = 0;
-
-	show_objects();
-	show_enemies();
-
-	if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154) _G(thor)->dir = 0;
-	_G(thor)->dir = save_d;
-
-	if (_G(warp_flag))
-		_G(current_level) = new_level - 5;   // Force phase
-	_G(warp_flag) = 0;
-
-	if (_G(warp_scroll)) {
-		_G(warp_scroll) = 0;
-		if (_G(thor)->dir == 0)
-			_G(current_level) = new_level + 10;
-		else if (_G(thor)->dir == 1)
-			_G(current_level) = new_level - 10;
-		else if (_G(thor)->dir == 2)
-			_G(current_level) = new_level + 1;
-		else if (_G(thor)->dir == 3)
-			_G(current_level) = new_level - 1;
-	}
-
-	if (!_G(setup).scroll_flag)
-		_G(current_level) = new_level; // Force no scroll
-
-	if (_G(music_current) != _G(level_type))
-		_G(sound).music_pause();
-
-	switch (_G(new_level) - _G(current_level)) {
-	case 0:
-		// Nothing to do
-		show_level_done();
-		break;
-	case -1:
-		_G(gameMode) = MODE_AREA_CHANGE;
-		_G(transitionDir) = DIR_LEFT;
-		break;
-	case 1:
-		_G(gameMode) = MODE_AREA_CHANGE;
-		_G(transitionDir) = DIR_RIGHT;
-		break;
-	case -10:
-		_G(gameMode) = MODE_AREA_CHANGE;
-		_G(transitionDir) = DIR_UP;
-		break;
-	case 10:
-		_G(gameMode) = MODE_AREA_CHANGE;
-		_G(transitionDir) = DIR_DOWN;
-		break;
-	default:
-		_G(gameMode) = MODE_AREA_CHANGE;
-		_G(transitionDir) = DIR_PHASED;
-		break;
-	}
+    int save_d;
+
+    _G(boss_active) = 0;
+    if (!_G(shield_on))
+        _G(actor)[2].used = 0;
+    _G(bomb_flag) = 0;
+    _G(slipping) = false;
+
+    save_d = _G(thor)->dir;
+    if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154)
+        _G(thor)->dir = 0;
+
+    // The original copied 130 bytes from _G(scrn).static_object onwards into sd_data.
+    // This doesn't make sense, because that would put the ending in the middle of static_y.
+    // Plus, it follows with an entire copy of scrn into sd_data anyway, so the first
+    // move seems entirely redundant.
+    _G(scrn).save(_G(current_level));
+    _G(scrn).load(_G(new_level));
+
+    _G(level_type) = _G(scrn).type;
+
+    _G(thor)->next = 0;
+
+    show_objects();
+    show_enemies();
+
+    if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154) _G(thor)->dir = 0;
+    _G(thor)->dir = save_d;
+
+    if (_G(warp_flag))
+        _G(current_level) = new_level - 5;   // Force phase
+    _G(warp_flag) = 0;
+
+    if (_G(warp_scroll)) {
+        _G(warp_scroll) = 0;
+        if (_G(thor)->dir == 0)
+            _G(current_level) = new_level + 10;
+        else if (_G(thor)->dir == 1)
+            _G(current_level) = new_level - 10;
+        else if (_G(thor)->dir == 2)
+            _G(current_level) = new_level + 1;
+        else if (_G(thor)->dir == 3)
+            _G(current_level) = new_level - 1;
+    }
+
+    if (!_G(setup).scroll_flag)
+        _G(current_level) = new_level; // Force no scroll
+
+    if (_G(music_current) != _G(level_type))
+        _G(sound).music_pause();
+
+    switch (_G(new_level) - _G(current_level)) {
+    case 0:
+        // Nothing to do
+        show_level_done();
+        break;
+    case -1:
+        _G(gameMode) = MODE_AREA_CHANGE;
+        _G(transitionDir) = DIR_LEFT;
+        break;
+    case 1:
+        _G(gameMode) = MODE_AREA_CHANGE;
+        _G(transitionDir) = DIR_RIGHT;
+        break;
+    case -10:
+        _G(gameMode) = MODE_AREA_CHANGE;
+        _G(transitionDir) = DIR_UP;
+        break;
+    case 10:
+        _G(gameMode) = MODE_AREA_CHANGE;
+        _G(transitionDir) = DIR_DOWN;
+        break;
+    default:
+        _G(gameMode) = MODE_AREA_CHANGE;
+        _G(transitionDir) = DIR_PHASED;
+        break;
+    }
 }
 
 
 void show_level_done() {
-	_G(current_level) = _G(new_level);
-
-	_G(thor_info).last_health = _G(thor)->health;
-	_G(thor_info).last_magic = _G(thor_info).magic;
-	_G(thor_info).last_jewels = _G(thor_info).jewels;
-	_G(thor_info).last_keys = _G(thor_info).keys;
-	_G(thor_info).last_score = _G(thor_info).score;
-	_G(thor_info).last_item = _G(thor_info).item;
-	_G(thor_info).last_screen = _G(current_level);
-	_G(thor_info).last_icon = ((_G(thor)->x + 8) / 16) + (((_G(thor)->y + 14) / 16) * 20);
-	_G(thor_info).last_dir = _G(thor)->dir;
-	_G(thor_info).last_inventory = _G(thor_info).inventory;
-	_G(thor_info).last_object = _G(thor_info).object;
-	_G(thor_info).last_object_name = _G(thor_info).object_name;
-
-	_G(last_setup) = _G(setup);
-
-	bool f = true;
-	if (GAME1 && _G(new_level) == BOSS_LEVEL1) {
-		if (!_G(setup).boss_dead[0]) {
-			if (!_G(auto_load))
-				boss_level1();
-			f = false;
-		}
-	}
-	if (GAME2 && _G(new_level) == BOSS_LEVEL2) {
-		if (!_G(setup).boss_dead[1]) {
-			if (!_G(auto_load))
-				boss_level2();
-			f = false;
-		}
-	}
-	if (GAME3) {
-		if (_G(new_level) == BOSS_LEVEL3) {
-			if (!_G(setup).boss_dead[2]) {
-				if (!_G(auto_load))
-					boss_level3();
-				f = 0;
-			}
-		}
-		if (_G(current_level) == ENDING_SCREEN) {
-			ending_screen();
-			f = 0;
-		}
-	}
-
-	if (_G(startup))
-		f = false;
-	if (f)
-		music_play(_G(level_type), 0);
+    _G(current_level) = _G(new_level);
+
+    _G(thor_info).last_health = _G(thor)->health;
+    _G(thor_info).last_magic = _G(thor_info).magic;
+    _G(thor_info).last_jewels = _G(thor_info).jewels;
+    _G(thor_info).last_keys = _G(thor_info).keys;
+    _G(thor_info).last_score = _G(thor_info).score;
+    _G(thor_info).last_item = _G(thor_info).item;
+    _G(thor_info).last_screen = _G(current_level);
+    _G(thor_info).last_icon = ((_G(thor)->x + 8) / 16) + (((_G(thor)->y + 14) / 16) * 20);
+    _G(thor_info).last_dir = _G(thor)->dir;
+    _G(thor_info).last_inventory = _G(thor_info).inventory;
+    _G(thor_info).last_object = _G(thor_info).object;
+    _G(thor_info).last_object_name = _G(thor_info).object_name;
+
+    _G(last_setup) = _G(setup);
+
+    bool f = true;
+    if (GAME1 && _G(new_level) == BOSS_LEVEL1) {
+        if (!_G(setup).boss_dead[0]) {
+            if (!_G(auto_load))
+                boss_level1();
+            f = false;
+        }
+    }
+    if (GAME2 && _G(new_level) == BOSS_LEVEL2) {
+        if (!_G(setup).boss_dead[1]) {
+            if (!_G(auto_load))
+                boss_level2();
+            f = false;
+        }
+    }
+    if (GAME3) {
+        if (_G(new_level) == BOSS_LEVEL3) {
+            if (!_G(setup).boss_dead[2]) {
+                if (!_G(auto_load))
+                    boss_level3();
+                f = 0;
+            }
+        }
+        if (_G(current_level) == ENDING_SCREEN) {
+            ending_screen();
+            f = 0;
+        }
+    }
+
+    if (_G(startup))
+        f = false;
+    if (f)
+        music_play(_G(level_type), 0);
 }
 
 static void odin_speaks_end() {
-	// In case Thor is now dead, flag as such
-	if (!_G(thor)->health) {
-		_G(thor)->show = 0;
-		_G(exit_flag) = 2;
-	}
-
-	// If there's an end message, pass it on to the view hierarchy.
-	// This is used in cases like the game end where multiple
-	// odin_speaks are done in sequence
-	if (odinEndMessage)
-		g_events->send(GameMessage(odinEndMessage));
+    // In case Thor is now dead, flag as such
+    if (!_G(thor)->health) {
+        _G(thor)->show = 0;
+        _G(exit_flag) = 2;
+    }
+
+    // If there's an end message, pass it on to the view hierarchy.
+    // This is used in cases like the game end where multiple
+    // odin_speaks are done in sequence
+    if (odinEndMessage)
+        g_events->send(GameMessage(odinEndMessage));
 }
 
 void odin_speaks(int index, int item, const char *endMessage) {
-	odinEndMessage = endMessage;
+    odinEndMessage = endMessage;
 
-	execute_script((long)index, _G(odin), odin_speaks_end);
+    execute_script((long)index, _G(odin), odin_speaks_end);
 }
 
 
 int switch_icons() {
-	int x, y, ix, iy;
-
-	play_sound(WOOP, 0);
-
-	for (y = 0; y < 12; y++) {
-		for (x = 0; x < 20; x++) {
-			ix = x * 16;
-			iy = y * 16;
-			if (_G(scrn).icon[y][x] == 93) {
-				place_tile(x, y, 144);
-			} else if (_G(scrn).icon[y][x] == 144) {
-				place_tile(x, y, 93);
-				kill_enemies(iy, ix);
-			}
-			if (_G(scrn).icon[y][x] == 94) {
-				place_tile(x, y, 146);
-			} else if (_G(scrn).icon[y][x] == 146) {
-				place_tile(x, y, 94);
-				kill_enemies(iy, ix);
-			}
-		}
-	}
-
-	return 0;
+    int x, y, ix, iy;
+
+    play_sound(WOOP, 0);
+
+    for (y = 0; y < 12; y++) {
+        for (x = 0; x < 20; x++) {
+            ix = x * 16;
+            iy = y * 16;
+            if (_G(scrn).icon[y][x] == 93) {
+                place_tile(x, y, 144);
+            } else if (_G(scrn).icon[y][x] == 144) {
+                place_tile(x, y, 93);
+                kill_enemies(iy, ix);
+            }
+            if (_G(scrn).icon[y][x] == 94) {
+                place_tile(x, y, 146);
+            } else if (_G(scrn).icon[y][x] == 146) {
+                place_tile(x, y, 94);
+                kill_enemies(iy, ix);
+            }
+        }
+    }
+
+    return 0;
 }
 
 int rotate_arrows() {
-	int x, y;
-
-	play_sound(WOOP, 0);
-
-	for (y = 0; y < 12; y++) {
-		for (x = 0; x < 20; x++) {
-			if (_G(scrn).icon[y][x] == 205)
-				place_tile(x, y, 208);
-			else if (_G(scrn).icon[y][x] == 206)
-				place_tile(x, y, 207);
-			else if (_G(scrn).icon[y][x] == 207)
-				place_tile(x, y, 205);
-			else if (_G(scrn).icon[y][x] == 208)
-				place_tile(x, y, 206);
-		}
-	}
-
-	return 0;
+    int x, y;
+
+    play_sound(WOOP, 0);
+
+    for (y = 0; y < 12; y++) {
+        for (x = 0; x < 20; x++) {
+            if (_G(scrn).icon[y][x] == 205)
+                place_tile(x, y, 208);
+            else if (_G(scrn).icon[y][x] == 206)
+                place_tile(x, y, 207);
+            else if (_G(scrn).icon[y][x] == 207)
+                place_tile(x, y, 205);
+            else if (_G(scrn).icon[y][x] == 208)
+                place_tile(x, y, 206);
+        }
+    }
+
+    return 0;
 }
 
 void kill_enemies(int iy, int ix) {
-	int i, x1, y1, x2, y2;
-
-	for (i = 3; i < MAX_ACTORS; i++) {
-		if (_G(actor)[i].used) {
-			x1 = _G(actor)[i].x;
-			y1 = _G(actor)[i].y + _G(actor)[i].size_y - 2;
-			x2 = (_G(actor)[i].x + _G(actor)[i].size_x);
-			y2 = _G(actor)[i].y + _G(actor)[i].size_y - 1;
-
-			if (point_within(x1, y1, ix, iy, ix + 15, iy + 15))
-				actor_destroyed(&_G(actor)[i]);
-			else if (point_within(x2, y1, ix, iy, ix + 15, iy + 15))
-				actor_destroyed(&_G(actor)[i]);
-			else if (point_within(x1, y2, ix, iy, ix + 15, iy + 15))
-				actor_destroyed(&_G(actor)[i]);
-			else if (point_within(x2, y2, ix, iy, ix + 15, iy + 15))
-				actor_destroyed(&_G(actor)[i]);
-		}
-	}
-
-	x1 = _G(thor)->x;
-	y1 = _G(thor)->y + 11;
-	x2 = x1 + 13;
-	y2 = y1 + 5;
-
-	if (point_within(x1, y1, ix, iy, ix + 15, iy + 15)) goto dead;
-	if (point_within(x2, y1, ix, iy, ix + 15, iy + 15)) goto dead;
-	if (point_within(x1, y2, ix, iy, ix + 15, iy + 15)) goto dead;
-	if (point_within(x2, y2, ix, iy, ix + 15, iy + 15)) goto dead;
-	return;
+    int i, x1, y1, x2, y2;
+
+    for (i = 3; i < MAX_ACTORS; i++) {
+        if (_G(actor)[i].used) {
+            x1 = _G(actor)[i].x;
+            y1 = _G(actor)[i].y + _G(actor)[i].size_y - 2;
+            x2 = (_G(actor)[i].x + _G(actor)[i].size_x);
+            y2 = _G(actor)[i].y + _G(actor)[i].size_y - 1;
+
+            if (point_within(x1, y1, ix, iy, ix + 15, iy + 15))
+                actor_destroyed(&_G(actor)[i]);
+            else if (point_within(x2, y1, ix, iy, ix + 15, iy + 15))
+                actor_destroyed(&_G(actor)[i]);
+            else if (point_within(x1, y2, ix, iy, ix + 15, iy + 15))
+                actor_destroyed(&_G(actor)[i]);
+            else if (point_within(x2, y2, ix, iy, ix + 15, iy + 15))
+                actor_destroyed(&_G(actor)[i]);
+        }
+    }
+
+    x1 = _G(thor)->x;
+    y1 = _G(thor)->y + 11;
+    x2 = x1 + 13;
+    y2 = y1 + 5;
+
+    if (point_within(x1, y1, ix, iy, ix + 15, iy + 15)) goto dead;
+    if (point_within(x2, y1, ix, iy, ix + 15, iy + 15)) goto dead;
+    if (point_within(x1, y2, ix, iy, ix + 15, iy + 15)) goto dead;
+    if (point_within(x2, y2, ix, iy, ix + 15, iy + 15)) goto dead;
+    return;
 
 dead:
-	if (!_G(cheats).freezeHealth) {
-		_G(thor)->health = 0;
-		g_events->send(GameMessage("THOR_DIES"));
-	}
+    if (!_G(cheats).freezeHealth) {
+        _G(thor)->health = 0;
+        g_events->send(GameMessage("THOR_DIES"));
+    }
 }
 
 void remove_objects(int y, int x) {
-	int p;
+    int p;
 
-	p = (y * 20) + x;
+    p = (y * 20) + x;
 
-	if (_G(object_map)[p] > 0) {
-		_G(object_map)[p] = 0;
-		_G(object_index)[p] = 0;
-	}
+    if (_G(object_map)[p] > 0) {
+        _G(object_map)[p] = 0;
+        _G(object_index)[p] = 0;
+    }
 }
 
 void place_tile(int x, int y, int tile) {
-	_G(scrn).icon[y][x] = tile;
-	remove_objects(y, x);
+    _G(scrn).icon[y][x] = tile;
+    remove_objects(y, x);
 }
 
 int bgtile(int x, int y) {
-	if (x < 0 || x>319 || y < 0 || y>191) return 0;
+    if (x < 0 || x>319 || y < 0 || y>191) return 0;
 
-	x = (x + 1) >> 4;
-	y = (y + 1) >> 4;
+    x = (x + 1) >> 4;
+    y = (y + 1) >> 4;
 
-	return _G(scrn).icon[y][x];
+    return _G(scrn).icon[y][x];
 }
 
 void select_item() {
-	// Only allow opening the dialog if something isn't currently going on
-	if (g_engine->canSaveAutosaveCurrently()) {
-		g_events->addView("SelectItem");
-	}
+    // Only allow opening the dialog if something isn't currently going on
+    if (g_engine->canSaveAutosaveCurrently()) {
+        g_events->addView("SelectItem");
+    }
 }
 
 int actor_speaks(ACTOR *actr, int index, int item) {
-	Common::String str;
-	int v;
-	long lind;
-
-	if (actr->type != 4)
-		return 0;
-	v = atoi(actr->name);
-	if (v < 1 || v>20)
-		return 0;
-
-	lind = (long)_G(current_level);
-	lind = lind * 1000;
-	lind += (long)actr->actor_num;
-
-	str = Common::String::format("FACE%d", v);
-	if (Common::File::exists(Common::Path(str))) {
-		Gfx::Pics pics(str, 262);
-		execute_script(lind, pics);
-	} else {
-		execute_script(lind, _G(odin));
-	}
-
-	if (!_G(thor)->health) {
-		_G(thor)->show = 0;
-		_G(exit_flag) = 2;
-	}
-
-	d_restore();
-	index = index;
-	item = item;
-
-	return 1;
+    Common::String str;
+    int v;
+    long lind;
+
+    if (actr->type != 4)
+        return 0;
+    v = atoi(actr->name);
+    if (v < 1 || v>20)
+        return 0;
+
+    lind = (long)_G(current_level);
+    lind = lind * 1000;
+    lind += (long)actr->actor_num;
+
+    str = Common::String::format("FACE%d", v);
+    if (Common::File::exists(Common::Path(str))) {
+        Gfx::Pics pics(str, 262);
+        execute_script(lind, pics);
+    } else {
+        execute_script(lind, _G(odin));
+    }
+
+    if (!_G(thor)->health) {
+        _G(thor)->show = 0;
+        _G(exit_flag) = 2;
+    }
+
+    d_restore();
+    index = index;
+    item = item;
+
+    return 1;
 }
 
 } // namespace Got
diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index ad6ad9585f4..518cba60b6a 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -36,267 +36,267 @@ namespace Got {
 static int boss1_dead();
 
 int boss1_movement(ACTOR *actr) {
-	int d, x1, y1, f;
-
-	if (_G(boss_dead))
-		return boss1_dead();
-
-	d = actr->last_dir;
-	if (actr->edge_counter) {
-		actr->edge_counter--;
-		goto done;
-	}
-	x1 = actr->x;
-	y1 = actr->y;
-
-	if (overlap(actr->x + 2, actr->y + 8, actr->x + 30, actr->y + 30,
-		_G(thor)->x, _G(thor)->y + 8, _G(thor)->x + 15, _G(thor)->y + 15)) {
-		thor_damaged(actr);
-	}
-	if (actr->temp3) {  //start striking
-		actr->temp3--;
-		if (!actr->temp3) play_sound(BOSS11, 0);
-		if (_G(hourglass_flag))
-			actr->num_moves = 3;
-		else
-			actr->num_moves = 6;
-
-		goto done0;
-	}
-
-	// Strike
-	if (actr->temp1) {  
-		actr->temp1--;
-		if (actr->x < (_G(thor_x1) + 12))
-			actr->temp1 = 0;
-		actr->temp2 = 1;
-		d = 2;
-		actr->x -= 2;
-
-		if (overlap(actr->x + 2, actr->y + 8, actr->x + 32, actr->y + 30,
-			_G(thor)->x, _G(thor)->y + 8, _G(thor)->x + 15, _G(thor)->y + 15)) {
-			actr->temp1 = 0;
-			goto done1;
-		}
-
-		actr->next = 3;
-		actr->num_moves = _G(setup).skill + 2;
-		goto done1;
-	}
-	if (actr->temp2) {          // Retreating
-		if (actr->x < 256) {
-			d = 3;
-			actr->x += 2;
-			if (overlap(actr->x + 2, actr->y + 8, actr->x + 32, actr->y + 30,
-				_G(thor)->x, _G(thor)->y + 8, _G(thor)->x + 15, _G(thor)->y + 15)) {
-				goto done1;
-			}
-			actr->num_moves = _G(setup).skill + 1;
-			goto done0;
-		} else actr->temp2 = 0;
-	}
-	if (ABS((_G(thor_y1))-(actr->y + 20)) < 8) {
-		if (!actr->temp1) {
-			if (actr->x > _G(thor_x1)) {
-				actr->temp3 = 75;
-				actr->temp1 = 130;
-				actr->temp2 = 0;
-			}
-		}
-	}
-	f = 0;
-	if (actr->counter) {
-		actr->counter--;
-		switch (d) {
-		case 1:
-			x1 = _G(actor)[5].x;
-			y1 = _G(actor)[5].y;
-			y1 += 2;
-
-			if (!check_move2(x1, y1, &_G(actor)[5]))
-				f = 1;
-			else {
-				actr->x = _G(actor)[5].x;
-				actr->y = _G(actor)[5].y - 16;
-			}
-			break;
-		case 0:
-			y1 -= 2;
-			if (!check_move2(x1, y1, actr)) f = 1;
-			break;
-		case 3:
-			x1 = _G(actor)[5].x;
-			y1 = _G(actor)[5].y;
-			y1 += 2;
-			if (!check_move2(x1, y1, &_G(actor)[5])) f = 1;
-			else {
-				actr->x = _G(actor)[5].x;
-				actr->y = _G(actor)[5].y - 16;
-			}
-			break;
-		case 2:
-			y1 -= 2;
-			if (!check_move2(x1, y1, actr)) f = 1;
-			break;
-		}
-	} else f = 1;
-
-	if (f == 1) {
-		actr->counter = g_events->getRandomNumber(10, 99);
-		d = g_events->getRandomNumber(1);
-		actr->edge_counter = 20;
-	}
+    int d, x1, y1, f;
+
+    if (_G(boss_dead))
+        return boss1_dead();
+
+    d = actr->last_dir;
+    if (actr->edge_counter) {
+        actr->edge_counter--;
+        goto done;
+    }
+    x1 = actr->x;
+    y1 = actr->y;
+
+    if (overlap(actr->x + 2, actr->y + 8, actr->x + 30, actr->y + 30,
+                _G(thor)->x, _G(thor)->y + 8, _G(thor)->x + 15, _G(thor)->y + 15)) {
+        thor_damaged(actr);
+    }
+    if (actr->temp3) {  //start striking
+        actr->temp3--;
+        if (!actr->temp3) play_sound(BOSS11, 0);
+        if (_G(hourglass_flag))
+            actr->num_moves = 3;
+        else
+            actr->num_moves = 6;
+
+        goto done0;
+    }
+
+    // Strike
+    if (actr->temp1) {
+        actr->temp1--;
+        if (actr->x < (_G(thor_x1) + 12))
+            actr->temp1 = 0;
+        actr->temp2 = 1;
+        d = 2;
+        actr->x -= 2;
+
+        if (overlap(actr->x + 2, actr->y + 8, actr->x + 32, actr->y + 30,
+                    _G(thor)->x, _G(thor)->y + 8, _G(thor)->x + 15, _G(thor)->y + 15)) {
+            actr->temp1 = 0;
+            goto done1;
+        }
+
+        actr->next = 3;
+        actr->num_moves = _G(setup).skill + 2;
+        goto done1;
+    }
+    if (actr->temp2) {          // Retreating
+        if (actr->x < 256) {
+            d = 3;
+            actr->x += 2;
+            if (overlap(actr->x + 2, actr->y + 8, actr->x + 32, actr->y + 30,
+                        _G(thor)->x, _G(thor)->y + 8, _G(thor)->x + 15, _G(thor)->y + 15)) {
+                goto done1;
+            }
+            actr->num_moves = _G(setup).skill + 1;
+            goto done0;
+        } else actr->temp2 = 0;
+    }
+    if (ABS((_G(thor_y1))-(actr->y + 20)) < 8) {
+        if (!actr->temp1) {
+            if (actr->x > _G(thor_x1)) {
+                actr->temp3 = 75;
+                actr->temp1 = 130;
+                actr->temp2 = 0;
+            }
+        }
+    }
+    f = 0;
+    if (actr->counter) {
+        actr->counter--;
+        switch (d) {
+        case 1:
+            x1 = _G(actor)[5].x;
+            y1 = _G(actor)[5].y;
+            y1 += 2;
+
+            if (!check_move2(x1, y1, &_G(actor)[5]))
+                f = 1;
+            else {
+                actr->x = _G(actor)[5].x;
+                actr->y = _G(actor)[5].y - 16;
+            }
+            break;
+        case 0:
+            y1 -= 2;
+            if (!check_move2(x1, y1, actr)) f = 1;
+            break;
+        case 3:
+            x1 = _G(actor)[5].x;
+            y1 = _G(actor)[5].y;
+            y1 += 2;
+            if (!check_move2(x1, y1, &_G(actor)[5])) f = 1;
+            else {
+                actr->x = _G(actor)[5].x;
+                actr->y = _G(actor)[5].y - 16;
+            }
+            break;
+        case 2:
+            y1 -= 2;
+            if (!check_move2(x1, y1, actr)) f = 1;
+            break;
+        }
+    } else f = 1;
+
+    if (f == 1) {
+        actr->counter = g_events->getRandomNumber(10, 99);
+        d = g_events->getRandomNumber(1);
+        actr->edge_counter = 20;
+    }
 
 done:
-	if (d > 1) d -= 2;
+    if (d > 1) d -= 2;
 
 done0:
-	next_frame(actr);
-	if (actr->next == 3) actr->next = 0;
+    next_frame(actr);
+    if (actr->next == 3) actr->next = 0;
 
 done1:
-	actr->last_dir = d;
-
-	_G(actor)[4].next = actr->next;
-	_G(actor)[5].next = actr->next;
-	_G(actor)[6].next = actr->next;
-
-	_G(actor)[4].last_dir = d;
-	_G(actor)[5].last_dir = d;
-	_G(actor)[6].last_dir = d;
-
-	_G(actor)[4].x = actr->x + 16;
-	_G(actor)[4].y = actr->y;
-	_G(actor)[5].x = actr->x;
-	_G(actor)[5].y = actr->y + 16;
-	_G(actor)[6].x = actr->x + 16;
-	_G(actor)[6].y = actr->y + 16;
-	_G(actor)[4].num_moves = actr->num_moves;
-	_G(actor)[5].num_moves = actr->num_moves;
-	_G(actor)[6].num_moves = actr->num_moves;
-
-	if (actr->directions == 1) return 0;
-	return d;
+    actr->last_dir = d;
+
+    _G(actor)[4].next = actr->next;
+    _G(actor)[5].next = actr->next;
+    _G(actor)[6].next = actr->next;
+
+    _G(actor)[4].last_dir = d;
+    _G(actor)[5].last_dir = d;
+    _G(actor)[6].last_dir = d;
+
+    _G(actor)[4].x = actr->x + 16;
+    _G(actor)[4].y = actr->y;
+    _G(actor)[5].x = actr->x;
+    _G(actor)[5].y = actr->y + 16;
+    _G(actor)[6].x = actr->x + 16;
+    _G(actor)[6].y = actr->y + 16;
+    _G(actor)[4].num_moves = actr->num_moves;
+    _G(actor)[5].num_moves = actr->num_moves;
+    _G(actor)[6].num_moves = actr->num_moves;
+
+    if (actr->directions == 1) return 0;
+    return d;
 }
 
 void check_boss1_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
-	int rep;
-
-	if (actr->move == 15 && act_num == 4) {
-		if ((!_G(actor)[3].vunerable) && (_G(actor)[3].next != 3) &&
-			overlap(x1, y1, x2, y2, actr->x + 6, actr->y + 4, actr->x + 14, actr->y + 20)) {
-			actor_damaged(&_G(actor)[3], _G(hammer)->strength);
-			if (_G(cheat) && _G(key_flag)[_Z])
-				_G(actor)[3].health = 0;
-			else
-				_G(actor)[3].health -= 10;
-
-			_G(actor)[3].speed_count = 50;
-			boss_status(_G(actor)[3].health);
-			_G(actor)[3].vunerable = 100;
-			play_sound(BOSS13, 1);
-			_G(actor)[3].next = 1;
-
-			for (rep = 4; rep < 7; rep++) {
-				_G(actor)[rep].next = 1;
-				_G(actor)[rep].speed_count = 50;
-			}
-
-			if (_G(actor)[3].health == 0)
-				_G(boss_dead) = 1;
-		}
-	}
+    int rep;
+
+    if (actr->move == 15 && act_num == 4) {
+        if ((!_G(actor)[3].vunerable) && (_G(actor)[3].next != 3) &&
+                overlap(x1, y1, x2, y2, actr->x + 6, actr->y + 4, actr->x + 14, actr->y + 20)) {
+            actor_damaged(&_G(actor)[3], _G(hammer)->strength);
+            if (_G(cheat) && _G(key_flag)[_Z])
+                _G(actor)[3].health = 0;
+            else
+                _G(actor)[3].health -= 10;
+
+            _G(actor)[3].speed_count = 50;
+            boss_status(_G(actor)[3].health);
+            _G(actor)[3].vunerable = 100;
+            play_sound(BOSS13, 1);
+            _G(actor)[3].next = 1;
+
+            for (rep = 4; rep < 7; rep++) {
+                _G(actor)[rep].next = 1;
+                _G(actor)[rep].speed_count = 50;
+            }
+
+            if (_G(actor)[3].health == 0)
+                _G(boss_dead) = 1;
+        }
+    }
 }
 
 void boss_level1() {
-	setup_boss(1);
-	_G(boss_active) = 1;
-	music_pause();
-	play_sound(BOSS11, 1);
-	g_events->send("Game", GameMessage("PAUSE", 40));
-	music_play(5, 1);
+    setup_boss(1);
+    _G(boss_active) = 1;
+    music_pause();
+    play_sound(BOSS11, 1);
+    g_events->send("Game", GameMessage("PAUSE", 40));
+    music_play(5, 1);
 }
 
 static int boss1_dead() {
-	int rep, n, x, y, r, x1, y1;
-
-	_G(hourglass_flag) = 0;
-	if (_G(boss_dead) == 1) {
-		REPEAT(4) {
-			x1 = _G(actor)[3 + rep].last_x[_G(pge)];
-			y1 = _G(actor)[3 + rep].last_y[_G(pge)];
-			x = _G(actor)[3 + rep].x;
-			y = _G(actor)[3 + rep].y;
-			n = _G(actor)[3 + rep].actor_num;
-			r = _G(actor)[3 + rep].rating;
-
-			_G(actor)[3 + rep] = _G(explosion);
-			_G(actor)[3 + rep].actor_num = n;
-			_G(actor)[3 + rep].rating = r;
-			_G(actor)[3 + rep].x = x;
-			_G(actor)[3 + rep].y = y;
-			_G(actor)[3 + rep].last_x[_G(pge)] = x1;
-			_G(actor)[3 + rep].last_x[_G(pge) ^ 1] = x;
-			_G(actor)[3 + rep].last_y[_G(pge)] = y1;
-			_G(actor)[3 + rep].last_y[_G(pge) ^ 1] = y;
-			_G(actor)[3 + rep].used = 1;
-			_G(actor)[3 + rep].vunerable = 255;
-			_G(actor)[3 + rep].move = 6;
-			_G(actor)[3 + rep].next = rep;
-			_G(actor)[3 + rep].speed = g_events->getRandomNumber(6, 8);
-			_G(actor)[3 + rep].num_shots = (10 - _G(actor)[3 + rep].speed) * 10;
-			_G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
-		}
-		play_sound(EXPLODE, 1);
-		_G(boss_dead)++;
-		for (rep = 7; rep < MAX_ACTORS; rep++)
-			if (_G(actor)[rep].used)
-				actor_destroyed(&_G(actor)[rep]);
-	}
-
-	return _G(actor)[3].last_dir;
+    int rep, n, x, y, r, x1, y1;
+
+    _G(hourglass_flag) = 0;
+    if (_G(boss_dead) == 1) {
+        REPEAT(4) {
+            x1 = _G(actor)[3 + rep].last_x[_G(pge)];
+            y1 = _G(actor)[3 + rep].last_y[_G(pge)];
+            x = _G(actor)[3 + rep].x;
+            y = _G(actor)[3 + rep].y;
+            n = _G(actor)[3 + rep].actor_num;
+            r = _G(actor)[3 + rep].rating;
+
+            _G(actor)[3 + rep] = _G(explosion);
+            _G(actor)[3 + rep].actor_num = n;
+            _G(actor)[3 + rep].rating = r;
+            _G(actor)[3 + rep].x = x;
+            _G(actor)[3 + rep].y = y;
+            _G(actor)[3 + rep].last_x[_G(pge)] = x1;
+            _G(actor)[3 + rep].last_x[_G(pge) ^ 1] = x;
+            _G(actor)[3 + rep].last_y[_G(pge)] = y1;
+            _G(actor)[3 + rep].last_y[_G(pge) ^ 1] = y;
+            _G(actor)[3 + rep].used = 1;
+            _G(actor)[3 + rep].vunerable = 255;
+            _G(actor)[3 + rep].move = 6;
+            _G(actor)[3 + rep].next = rep;
+            _G(actor)[3 + rep].speed = g_events->getRandomNumber(6, 8);
+            _G(actor)[3 + rep].num_shots = (10 - _G(actor)[3 + rep].speed) * 10;
+            _G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
+        }
+        play_sound(EXPLODE, 1);
+        _G(boss_dead)++;
+        for (rep = 7; rep < MAX_ACTORS; rep++)
+            if (_G(actor)[rep].used)
+                actor_destroyed(&_G(actor)[rep]);
+    }
+
+    return _G(actor)[3].last_dir;
 }
 
 void closing_sequence1() {
-	_G(game_over) = 1;
-	music_play(4, 1);
-	odin_speaks(1001, 13, "CLOSING");
+    _G(game_over) = 1;
+    music_play(4, 1);
+    odin_speaks(1001, 13, "CLOSING");
 }
 
 void closing_sequence1_2() {
-	_G(thor_info).armor = 1;
-	load_new_thor();
-	_G(thor)->dir = 1;
-	_G(thor)->next = 0;
-	fill_score(20, "CLOSING");
+    _G(thor_info).armor = 1;
+    load_new_thor();
+    _G(thor)->dir = 1;
+    _G(thor)->next = 0;
+    fill_score(20, "CLOSING");
 }
 
 void closing_sequence1_3() {
-	fill_health();
-	fill_magic();
-	odin_speaks(1002, 0, "CLOSING");
+    fill_health();
+    fill_magic();
+    odin_speaks(1002, 0, "CLOSING");
 }
 
 void closing_sequence1_4() {
-	int rep;
-	REPEAT(16) _G(scrn).actor_type[rep] = 0;
-	_G(boss_dead) = 0;
-	_G(setup).boss_dead[0] = 1;
-	_G(boss_active) = 0;
-	_G(scrn).type = 4;
-	show_level(BOSS_LEVEL1);
-
-	play_sound(ANGEL, 1);
-	place_tile(18, 6, 148);
-	place_tile(19, 6, 202);
-	actor_visible(1);
-	actor_visible(2);
-
-	LEVEL lvl;
-	lvl.load(59);
-	lvl.icon[6][18] = 148;
-	lvl.icon[6][19] = 202;
-	lvl.save(59);
+    int rep;
+    REPEAT(16) _G(scrn).actor_type[rep] = 0;
+    _G(boss_dead) = 0;
+    _G(setup).boss_dead[0] = 1;
+    _G(boss_active) = 0;
+    _G(scrn).type = 4;
+    show_level(BOSS_LEVEL1);
+
+    play_sound(ANGEL, 1);
+    place_tile(18, 6, 148);
+    place_tile(19, 6, 202);
+    actor_visible(1);
+    actor_visible(2);
+
+    LEVEL lvl;
+    lvl.load(59);
+    lvl.icon[6][18] = 148;
+    lvl.icon[6][19] = 202;
+    lvl.save(59);
 }
 
 } // namespace Got
diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index 440d6d449d7..e8bb993df1f 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -34,12 +34,12 @@
 namespace Got {
 
 static const byte EXPLOSION[] = {
-	 61, 62, 65, 66, 69, 70, 73, 74, 77, 78,
-	 81, 82, 85, 86, 89, 90, 93, 94, 97, 98,
-	101,102,105,106,109,110,113,114,117,118,
-	121,122,125,126,129,130,133,134,137,138,
-	141,142,145,146,149,150,153,154,157,158,
-	161,162,165,166,169,170,173,174,177,178
+    61, 62, 65, 66, 69, 70, 73, 74, 77, 78,
+    81, 82, 85, 86, 89, 90, 93, 94, 97, 98,
+    101,102,105,106,109,110,113,114,117,118,
+    121,122,125,126,129,130,133,134,137,138,
+    141,142,145,146,149,150,153,154,157,158,
+    161,162,165,166,169,170,173,174,177,178
 };
 static byte expf[60];
 static byte num_skulls;  // Hehe
@@ -53,359 +53,359 @@ static int boss2_die();
 static void boss_set(int d, int x, int y);
 
 int boss2_movement(ACTOR *actr) {
-	int d, f, x;
-
-	switch (_G(setup).skill) {
-	case 0:
-		num_skulls = 3;
-		num_spikes = 5;
-		break;
-	case 1:
-		num_skulls = 6;
-		num_spikes = 8;
-		break;
-	case 2:
-		num_skulls = 9;
-		num_spikes = 11;
-		break;
-	}
-	if (_G(boss_dead))
-		return boss2_die();
-
-	if (actr->i1) {
-		if (actr->i1 == 1) return boss2a_movement(actr);
-		else return boss2b_movement(actr);
-	}
-	d = actr->last_dir;
-
-	x = actr->x;
-
-	f = 0;
-	if (actr->temp6) actr->temp6--;
-	if (!actr->temp6) {
-		drop_flag = false;
-		if (actr->temp5) actr->temp5--;
-		if (!actr->temp5) f = 1;
-		else {
-			if (d == 2) {
-				if (x > 18) actr->x -= 2;
-				else f = 1;
-			} else if (d == 3) {
-				if (x < 272) actr->x += 2;
-				else f = 1;
-			}
-		}
-		if (f) {
-			actr->temp5 = _G(rand1) + 60;
-			if (d == 2) d = 3;
-			else d = 2;
-		}
-	}
-
-	actr->frame_count--;
-	if (actr->frame_count <= 0) {
-		actr->next++;
-		if (actr->next > 2) actr->next = 0;
-		actr->frame_count = actr->frame_speed;
-	}
-	x = actr->x;
-	if (actr->num_shots < num_skulls && !drop_flag) {
-		if (x == 48 || x == 112 || x == 176 || x == 240) {
-			drop_flag = true;
-			_G(actor)[3].temp6 = 40;
-
-			actor_always_shoots(actr, 1);
-			play_sound(FALL, 0);
-			_G(actor)[actr->shot_actor].x = actr->x + 12;
-			_G(actor)[actr->shot_actor].y = actr->y + 32;
-			_G(actor)[actr->shot_actor].temp2 = 0;
-			_G(actor)[actr->shot_actor].temp3 = 4;
-			_G(actor)[actr->shot_actor].temp4 = 4;
-		}
-	}
-
-	boss_set(d, x, actr->y);
-
-	if (actr->directions == 1) return 0;
-	return d;
+    int d, f, x;
+
+    switch (_G(setup).skill) {
+    case 0:
+        num_skulls = 3;
+        num_spikes = 5;
+        break;
+    case 1:
+        num_skulls = 6;
+        num_spikes = 8;
+        break;
+    case 2:
+        num_skulls = 9;
+        num_spikes = 11;
+        break;
+    }
+    if (_G(boss_dead))
+        return boss2_die();
+
+    if (actr->i1) {
+        if (actr->i1 == 1) return boss2a_movement(actr);
+        else return boss2b_movement(actr);
+    }
+    d = actr->last_dir;
+
+    x = actr->x;
+
+    f = 0;
+    if (actr->temp6) actr->temp6--;
+    if (!actr->temp6) {
+        drop_flag = false;
+        if (actr->temp5) actr->temp5--;
+        if (!actr->temp5) f = 1;
+        else {
+            if (d == 2) {
+                if (x > 18) actr->x -= 2;
+                else f = 1;
+            } else if (d == 3) {
+                if (x < 272) actr->x += 2;
+                else f = 1;
+            }
+        }
+        if (f) {
+            actr->temp5 = _G(rand1) + 60;
+            if (d == 2) d = 3;
+            else d = 2;
+        }
+    }
+
+    actr->frame_count--;
+    if (actr->frame_count <= 0) {
+        actr->next++;
+        if (actr->next > 2) actr->next = 0;
+        actr->frame_count = actr->frame_speed;
+    }
+    x = actr->x;
+    if (actr->num_shots < num_skulls && !drop_flag) {
+        if (x == 48 || x == 112 || x == 176 || x == 240) {
+            drop_flag = true;
+            _G(actor)[3].temp6 = 40;
+
+            actor_always_shoots(actr, 1);
+            play_sound(FALL, 0);
+            _G(actor)[actr->shot_actor].x = actr->x + 12;
+            _G(actor)[actr->shot_actor].y = actr->y + 32;
+            _G(actor)[actr->shot_actor].temp2 = 0;
+            _G(actor)[actr->shot_actor].temp3 = 4;
+            _G(actor)[actr->shot_actor].temp4 = 4;
+        }
+    }
+
+    boss_set(d, x, actr->y);
+
+    if (actr->directions == 1) return 0;
+    return d;
 }
 
 static void boss_set(int d, int x, int y) {
-	_G(actor)[4].next = _G(actor)[3].next;
-	_G(actor)[5].next = _G(actor)[3].next;
-	_G(actor)[6].next = _G(actor)[3].next;
-	_G(actor)[3].last_dir = d;
-	_G(actor)[4].last_dir = d;
-	_G(actor)[5].last_dir = d;
-	_G(actor)[6].last_dir = d;
-	_G(actor)[4].x = x + 16;
-	_G(actor)[4].y = y;
-	_G(actor)[5].x = x;
-	_G(actor)[5].y = y + 16;
-	_G(actor)[6].x = x + 16;
-	_G(actor)[6].y = y + 16;
+    _G(actor)[4].next = _G(actor)[3].next;
+    _G(actor)[5].next = _G(actor)[3].next;
+    _G(actor)[6].next = _G(actor)[3].next;
+    _G(actor)[3].last_dir = d;
+    _G(actor)[4].last_dir = d;
+    _G(actor)[5].last_dir = d;
+    _G(actor)[6].last_dir = d;
+    _G(actor)[4].x = x + 16;
+    _G(actor)[4].y = y;
+    _G(actor)[5].x = x;
+    _G(actor)[5].y = y + 16;
+    _G(actor)[6].x = x + 16;
+    _G(actor)[6].y = y + 16;
 }
 
 void check_boss2_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
-	int rep;
-
-	if ((!_G(actor)[3].vunerable)) {
-		actor_damaged(&_G(actor)[3], _G(hammer)->strength);
-		_G(actor)[3].health -= 10;
-		if (_G(actor)[3].health == 50) {
-			play_sound(BOSS12, 1);
-
-			g_events->send("Game", GameMessage("PAUSE", 40));
-
-			_G(actor)[3].i1 = 1;
-			_G(actor)[3].i2 = 0;
-			memset(expf, 0, 60);
-			for (rep = 7; rep < MAX_ACTORS; rep++)
-				if (_G(actor)[rep].used)
-					actor_destroyed(&_G(actor)[rep]);
-			_G(actor)[3].num_shots = 0;
-		} else play_sound(BOSS13, 1);
-		_G(actor)[3].speed_count = 75;
-		boss_status(_G(actor)[3].health);
-		_G(actor)[3].vunerable = 75;
-		_G(actor)[3].next = 1;
-		for (rep = 4; rep < 7; rep++) {
-			_G(actor)[rep].next = 1;
-			_G(actor)[rep].speed_count = 50;
-		}
-		if (_G(actor)[3].health == 0) {
-			_G(boss_dead) = 1;
-			for (rep = 7; rep < MAX_ACTORS; rep++)
-				if (_G(actor)[rep].used)
-					actor_destroyed(&_G(actor)[rep]);
-		}
-	}
-	x1 = x1;
-	y1 = y1;
-	x2 = x2;
-	y2 = y2;
-	actr = actr;
-	act_num = act_num;
+    int rep;
+
+    if ((!_G(actor)[3].vunerable)) {
+        actor_damaged(&_G(actor)[3], _G(hammer)->strength);
+        _G(actor)[3].health -= 10;
+        if (_G(actor)[3].health == 50) {
+            play_sound(BOSS12, 1);
+
+            g_events->send("Game", GameMessage("PAUSE", 40));
+
+            _G(actor)[3].i1 = 1;
+            _G(actor)[3].i2 = 0;
+            memset(expf, 0, 60);
+            for (rep = 7; rep < MAX_ACTORS; rep++)
+                if (_G(actor)[rep].used)
+                    actor_destroyed(&_G(actor)[rep]);
+            _G(actor)[3].num_shots = 0;
+        } else play_sound(BOSS13, 1);
+        _G(actor)[3].speed_count = 75;
+        boss_status(_G(actor)[3].health);
+        _G(actor)[3].vunerable = 75;
+        _G(actor)[3].next = 1;
+        for (rep = 4; rep < 7; rep++) {
+            _G(actor)[rep].next = 1;
+            _G(actor)[rep].speed_count = 50;
+        }
+        if (_G(actor)[3].health == 0) {
+            _G(boss_dead) = 1;
+            for (rep = 7; rep < MAX_ACTORS; rep++)
+                if (_G(actor)[rep].used)
+                    actor_destroyed(&_G(actor)[rep]);
+        }
+    }
+    x1 = x1;
+    y1 = y1;
+    x2 = x2;
+    y2 = y2;
+    actr = actr;
+    act_num = act_num;
 }
 
 void boss_level2() {
-	setup_boss(2);
-	_G(boss_active) = 1;
-	boss_status(-1);
-	music_pause();
-	play_sound(BOSS11, 1);
-	_G(timer_cnt) = 0;
-
-	drop_flag = false;
-	Common::fill(su, su + 18, 0);
-
-	g_events->send("Game", GameMessage("PAUSE", 40));
-	music_play(7, 1);
+    setup_boss(2);
+    _G(boss_active) = 1;
+    boss_status(-1);
+    music_pause();
+    play_sound(BOSS11, 1);
+    _G(timer_cnt) = 0;
+
+    drop_flag = false;
+    Common::fill(su, su + 18, 0);
+
+    g_events->send("Game", GameMessage("PAUSE", 40));
+    music_play(7, 1);
 }
 
 static int boss2_die() {
-	int rep, n, x, y, r, x1, y1;
-
-	_G(hourglass_flag) = 0;
-	_G(thunder_flag) = 0;
-	if (_G(boss_dead) == 1) {
-		REPEAT(4) {
-			x1 = _G(actor)[3 + rep].last_x[_G(pge)];
-			y1 = _G(actor)[3 + rep].last_y[_G(pge)];
-			x = _G(actor)[3 + rep].x;
-			y = _G(actor)[3 + rep].y;
-			n = _G(actor)[3 + rep].actor_num;
-			r = _G(actor)[3 + rep].rating;
-
-			_G(actor)[3 + rep] = _G(explosion);
-
-			_G(actor)[3 + rep].actor_num = n;
-			_G(actor)[3 + rep].rating = r;
-			_G(actor)[3 + rep].x = x;
-			_G(actor)[3 + rep].y = y;
-			_G(actor)[3 + rep].last_x[_G(pge)] = x1;
-			_G(actor)[3 + rep].last_x[_G(pge) ^ 1] = x;
-			_G(actor)[3 + rep].last_y[_G(pge)] = y1;
-			_G(actor)[3 + rep].last_y[_G(pge) ^ 1] = y;
-			_G(actor)[3 + rep].used = 1;
-			_G(actor)[3 + rep].vunerable = 255;
-			_G(actor)[3 + rep].move = 6;
-			_G(actor)[3 + rep].next = rep;
-			_G(actor)[3 + rep].speed = g_events->getRandomNumber(6, 8);
-			_G(actor)[3 + rep].num_shots = (10 - _G(actor)[3 + rep].speed) * 10;
-			_G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
-		}
-
-		play_sound(EXPLODE, 1);
-		_G(boss_dead)++;
-	}
-
-	return _G(actor)[3].last_dir;
+    int rep, n, x, y, r, x1, y1;
+
+    _G(hourglass_flag) = 0;
+    _G(thunder_flag) = 0;
+    if (_G(boss_dead) == 1) {
+        REPEAT(4) {
+            x1 = _G(actor)[3 + rep].last_x[_G(pge)];
+            y1 = _G(actor)[3 + rep].last_y[_G(pge)];
+            x = _G(actor)[3 + rep].x;
+            y = _G(actor)[3 + rep].y;
+            n = _G(actor)[3 + rep].actor_num;
+            r = _G(actor)[3 + rep].rating;
+
+            _G(actor)[3 + rep] = _G(explosion);
+
+            _G(actor)[3 + rep].actor_num = n;
+            _G(actor)[3 + rep].rating = r;
+            _G(actor)[3 + rep].x = x;
+            _G(actor)[3 + rep].y = y;
+            _G(actor)[3 + rep].last_x[_G(pge)] = x1;
+            _G(actor)[3 + rep].last_x[_G(pge) ^ 1] = x;
+            _G(actor)[3 + rep].last_y[_G(pge)] = y1;
+            _G(actor)[3 + rep].last_y[_G(pge) ^ 1] = y;
+            _G(actor)[3 + rep].used = 1;
+            _G(actor)[3 + rep].vunerable = 255;
+            _G(actor)[3 + rep].move = 6;
+            _G(actor)[3 + rep].next = rep;
+            _G(actor)[3 + rep].speed = g_events->getRandomNumber(6, 8);
+            _G(actor)[3 + rep].num_shots = (10 - _G(actor)[3 + rep].speed) * 10;
+            _G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
+        }
+
+        play_sound(EXPLODE, 1);
+        _G(boss_dead)++;
+    }
+
+    return _G(actor)[3].last_dir;
 }
 
 // Boss - skull (explode)
 static int boss2a_movement(ACTOR *actr) {
-	int an, x, y, r;
-
-	next_frame(actr);
-	_G(actor)[4].next = actr->next;
-	_G(actor)[5].next = actr->next;
-	_G(actor)[6].next = actr->next;
-	actr->vunerable = 20;
-	if (actr->num_shots) return 0;
-	if (_G(actor)[5].num_shots) return 0;
-
-	play_sound(EXPLODE, 1);
-	actor_always_shoots(&_G(actor)[5], 0);
-	an = _G(actor)[5].shot_actor;
-	_G(actor)[an].move = 9;
-
-	r = _G(rand1) % 60;
-	while (expf[r]) {
-		r++;
-		if (r > 59) r = 0;
-	}
-	expf[r] = 1;
-	x = (EXPLOSION[r] % 20) * 16;
-	y = (EXPLOSION[r] / 20) * 16;
-	_G(actor)[an].x = x;
-	_G(actor)[an].y = y;
-
-	_G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
-
-	_G(actor)[3].i2++;
-	if (_G(actor)[3].i2 > 59) {
-		_G(actor)[3].i1 = 2;
-		_G(actor)[3].i2 = 0;
-		_G(actor)[3].num_moves = 3;
-	}
-
-	return 0;
+    int an, x, y, r;
+
+    next_frame(actr);
+    _G(actor)[4].next = actr->next;
+    _G(actor)[5].next = actr->next;
+    _G(actor)[6].next = actr->next;
+    actr->vunerable = 20;
+    if (actr->num_shots) return 0;
+    if (_G(actor)[5].num_shots) return 0;
+
+    play_sound(EXPLODE, 1);
+    actor_always_shoots(&_G(actor)[5], 0);
+    an = _G(actor)[5].shot_actor;
+    _G(actor)[an].move = 9;
+
+    r = _G(rand1) % 60;
+    while (expf[r]) {
+        r++;
+        if (r > 59) r = 0;
+    }
+    expf[r] = 1;
+    x = (EXPLOSION[r] % 20) * 16;
+    y = (EXPLOSION[r] / 20) * 16;
+    _G(actor)[an].x = x;
+    _G(actor)[an].y = y;
+
+    _G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
+
+    _G(actor)[3].i2++;
+    if (_G(actor)[3].i2 > 59) {
+        _G(actor)[3].i1 = 2;
+        _G(actor)[3].i2 = 0;
+        _G(actor)[3].num_moves = 3;
+    }
+
+    return 0;
 }
 
 // Boss - skull - shake
 static int boss2b_movement(ACTOR *actr) {
-	int rep, an, hx, hy, d;
-
-	if (_G(hammer)->used && _G(hammer)->move != 5) {
-		hx = _G(hammer)->x;
-		hy = _G(hammer)->y;
-		for (rep = 7; rep < 15; rep++) {
-			if (!_G(actor)[rep].used) continue;
-			if (overlap(hx + 1, hy + 1, hx + 10, hy + 10, _G(actor)[rep].x, _G(actor)[rep].y,
-				_G(actor)[rep].x + _G(actor)[rep].size_x - 1, _G(actor)[rep].y + _G(actor)[rep].size_y - 1)) {
-				_G(hammer)->move = 5;
-				d = reverse_direction(_G(hammer));
-				_G(hammer)->dir = d;
-				break;
-			}
-		}
-	}
-	if (actr->i4) {
-		actr->i4--;
-		if (!actr->i4) _G(thunder_flag) = 0;
-	}
-	if (!actr->i2) {
-		if (actr->x < 144) actr->x += 2;
-		else if (actr->x > 144) actr->x -= 2;
-		else {
-			actr->i2 = 1;
-			actr->i3 = 0;
-		}
-		goto done;
-	}
-	if (_G(actor)[4].num_shots) goto done;
-
-	if (!actr->i3) {
-		actr->i3 = g_events->getRandomNumber(2, 3);
-	}
-
-	if (actr->i3 == 2) actr->x -= 2;
-	else actr->x += 2;
-
-	if (actr->x < 20 || actr->x>270) {
-		_G(thunder_flag) = 100;
-		actr->i4 = 50;
-		play_sound(EXPLODE, 1);
-		actr->i2 = 0;
-		hx = _G(thor)->x;
-
-		Common::fill(su, su + 18, 0);
-		actor_always_shoots(&_G(actor)[4], 1);
-		an = _G(actor)[4].shot_actor;
-		hx = (_G(thor)->x / 16);
-		_G(actor)[an].x = _G(thor)->x;  //hx*16;
-		_G(actor)[an].y = g_events->getRandomNumber(15);
-
-		su[hx] = 1;
-		_G(actor)[an].next = g_events->getRandomNumber(3);
-		REPEAT(num_spikes) {
-			while (1) {
-				hx = g_events->getRandomNumber(17);
-				if (!su[hx]) break;
-			}
-			su[hx] = 1;
-			actor_always_shoots(&_G(actor)[4], 1);
-			an = _G(actor)[4].shot_actor;
-			_G(actor)[an].next = g_events->getRandomNumber(3);
-			_G(actor)[an].x = 16 + hx * 16;
-			_G(actor)[an].y = g_events->getRandomNumber(15);
-		}
-	}
+    int rep, an, hx, hy, d;
+
+    if (_G(hammer)->used && _G(hammer)->move != 5) {
+        hx = _G(hammer)->x;
+        hy = _G(hammer)->y;
+        for (rep = 7; rep < 15; rep++) {
+            if (!_G(actor)[rep].used) continue;
+            if (overlap(hx + 1, hy + 1, hx + 10, hy + 10, _G(actor)[rep].x, _G(actor)[rep].y,
+                        _G(actor)[rep].x + _G(actor)[rep].size_x - 1, _G(actor)[rep].y + _G(actor)[rep].size_y - 1)) {
+                _G(hammer)->move = 5;
+                d = reverse_direction(_G(hammer));
+                _G(hammer)->dir = d;
+                break;
+            }
+        }
+    }
+    if (actr->i4) {
+        actr->i4--;
+        if (!actr->i4) _G(thunder_flag) = 0;
+    }
+    if (!actr->i2) {
+        if (actr->x < 144) actr->x += 2;
+        else if (actr->x > 144) actr->x -= 2;
+        else {
+            actr->i2 = 1;
+            actr->i3 = 0;
+        }
+        goto done;
+    }
+    if (_G(actor)[4].num_shots) goto done;
+
+    if (!actr->i3) {
+        actr->i3 = g_events->getRandomNumber(2, 3);
+    }
+
+    if (actr->i3 == 2) actr->x -= 2;
+    else actr->x += 2;
+
+    if (actr->x < 20 || actr->x>270) {
+        _G(thunder_flag) = 100;
+        actr->i4 = 50;
+        play_sound(EXPLODE, 1);
+        actr->i2 = 0;
+        hx = _G(thor)->x;
+
+        Common::fill(su, su + 18, 0);
+        actor_always_shoots(&_G(actor)[4], 1);
+        an = _G(actor)[4].shot_actor;
+        hx = (_G(thor)->x / 16);
+        _G(actor)[an].x = _G(thor)->x;  //hx*16;
+        _G(actor)[an].y = g_events->getRandomNumber(15);
+
+        su[hx] = 1;
+        _G(actor)[an].next = g_events->getRandomNumber(3);
+        REPEAT(num_spikes) {
+            while (1) {
+                hx = g_events->getRandomNumber(17);
+                if (!su[hx]) break;
+            }
+            su[hx] = 1;
+            actor_always_shoots(&_G(actor)[4], 1);
+            an = _G(actor)[4].shot_actor;
+            _G(actor)[an].next = g_events->getRandomNumber(3);
+            _G(actor)[an].x = 16 + hx * 16;
+            _G(actor)[an].y = g_events->getRandomNumber(15);
+        }
+    }
 
 done:
-	next_frame(actr);
-	boss_set(actr->dir, actr->x, actr->y);
-	return 0;
+    next_frame(actr);
+    boss_set(actr->dir, actr->x, actr->y);
+    return 0;
 }
 
 void closing_sequence2() {
-	music_play(6, 1);
-	odin_speaks(1001, 0, "CLOSING");
+    music_play(6, 1);
+    odin_speaks(1001, 0, "CLOSING");
 }
 
 void closing_sequence2_2() {
-	_G(thor_info).armor = 10;
-	load_new_thor();
-	_G(thor)->dir = 1;
-	_G(thor)->next = 0;
+    _G(thor_info).armor = 10;
+    load_new_thor();
+    _G(thor)->dir = 1;
+    _G(thor)->next = 0;
 
-	fill_score(20, "CLOSING");
+    fill_score(20, "CLOSING");
 }
 
 void closing_sequence2_3() {
-	fill_health();
-	fill_magic();
-	odin_speaks(1002, 0, "CLOSING");
+    fill_health();
+    fill_magic();
+    odin_speaks(1002, 0, "CLOSING");
 }
 
 void closing_sequence2_4() {
-	LEVEL lvl;
-	int rep;
-
-	REPEAT(16) _G(scrn).actor_type[rep] = 0;
-	_G(boss_dead) = 0;
-	_G(setup).boss_dead[1] = 1;
-	_G(game_over) = 1;
-	_G(boss_active) = 0;
-	_G(scrn).type = 6;
-	//	_G(game_is_over) = 1;
-	show_level(BOSS_LEVEL2);
-
-	play_sound(ANGEL, 1);
-	place_tile(18, 10, 152);
-	place_tile(19, 10, 202);
-	actor_visible(1);
-	actor_visible(2);
-	_G(actor)[7].x = 288;
-	_G(actor)[7].y = 160;
-	_G(actor)[8].x = 304;
-	_G(actor)[8].y = 160;
-
-	lvl.load(BOSS_LEVEL2);
-	lvl.icon[6][18] = 152;
-	lvl.icon[6][19] = 202;
-	lvl.save(BOSS_LEVEL2);
+    LEVEL lvl;
+    int rep;
+
+    REPEAT(16) _G(scrn).actor_type[rep] = 0;
+    _G(boss_dead) = 0;
+    _G(setup).boss_dead[1] = 1;
+    _G(game_over) = 1;
+    _G(boss_active) = 0;
+    _G(scrn).type = 6;
+    //	_G(game_is_over) = 1;
+    show_level(BOSS_LEVEL2);
+
+    play_sound(ANGEL, 1);
+    place_tile(18, 10, 152);
+    place_tile(19, 10, 202);
+    actor_visible(1);
+    actor_visible(2);
+    _G(actor)[7].x = 288;
+    _G(actor)[7].y = 160;
+    _G(actor)[8].x = 304;
+    _G(actor)[8].y = 160;
+
+    lvl.load(BOSS_LEVEL2);
+    lvl.icon[6][18] = 152;
+    lvl.icon[6][19] = 202;
+    lvl.save(BOSS_LEVEL2);
 }
 
 } // namespace Got
diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index d8e433de70a..09dae26b6f1 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -39,10 +39,11 @@ static int  boss_mode;
 static int  num_pods, num_pods1;
 static byte pod_speed;
 static const byte EXPLOSION[4][8] = {
-			{126,127,128,129,130,131,132,133},
-			{146,147,148,149,150,151,152,153},
-			{166,167,168,169,170,171,172,173},
-			{186,187,188,189,190,191,192,193} };
+    {126,127,128,129,130,131,132,133},
+    {146,147,148,149,150,151,152,153},
+    {166,167,168,169,170,171,172,173},
+    {186,187,188,189,190,191,192,193}
+};
 
 static bool expf[4][8];
 static byte expcnt;
@@ -52,587 +53,587 @@ static void check_boss_hit();
 static void boss_change_mode();
 
 static void set_boss(ACTOR *actr) {
-	_G(actor)[4].next = actr->next;
-	_G(actor)[5].next = actr->next;
-	_G(actor)[6].next = actr->next;
-
-	_G(actor)[4].last_dir = actr->dir;
-	_G(actor)[5].last_dir = actr->dir;
-	_G(actor)[6].last_dir = actr->dir;
-	_G(actor)[4].dir = actr->dir;
-	_G(actor)[5].dir = actr->dir;
-	_G(actor)[6].dir = actr->dir;
-
-	_G(actor)[4].x = actr->x + 16;
-	_G(actor)[4].y = actr->y;
-	_G(actor)[5].x = actr->x;
-	_G(actor)[5].y = actr->y + 16;
-	_G(actor)[6].x = actr->x + 16;
-	_G(actor)[6].y = actr->y + 16;
+    _G(actor)[4].next = actr->next;
+    _G(actor)[5].next = actr->next;
+    _G(actor)[6].next = actr->next;
+
+    _G(actor)[4].last_dir = actr->dir;
+    _G(actor)[5].last_dir = actr->dir;
+    _G(actor)[6].last_dir = actr->dir;
+    _G(actor)[4].dir = actr->dir;
+    _G(actor)[5].dir = actr->dir;
+    _G(actor)[6].dir = actr->dir;
+
+    _G(actor)[4].x = actr->x + 16;
+    _G(actor)[4].y = actr->y;
+    _G(actor)[5].x = actr->x;
+    _G(actor)[5].y = actr->y + 16;
+    _G(actor)[6].x = actr->x + 16;
+    _G(actor)[6].y = actr->y + 16;
 }
 
 // Boss - Loki-2
 static int boss_movement_one(ACTOR *actr) {
-	int rx, ry, i, numPods = 0;
-
-	actr->num_moves = 2;
-	pod_speed = 2;
-
-	switch (_G(setup).skill) {
-	case 0:
-		numPods = 3;
-		break;
-	case 1:
-		numPods = 5;
-		break;
-	case 2:
-		numPods = 8;
-		break;
-	}
-
-	if (!actr->temp1) {
-		// Disappear
-		actr->dir = 1;
-		actr->frame_count = LFC;
-		actr->next = 0;
-		actr->temp1 = 1;
-		actr->i6 = 1;
-		actr->solid |= 128;
-		_G(actor)[4].solid |= 128;
-		_G(actor)[5].solid |= 128;
-		_G(actor)[6].solid |= 128;
-		play_sound(EXPLODE, 1);
-		goto done;
-	}
-	if (actr->i6) {
-		// Fade out
-		actr->frame_count--;
-		if (actr->frame_count <= 0) {
-			actr->next++;
-			if (actr->next > 2) {
-				actr->i6 = 0;
-				actr->temp3 = 160;
-			}
-			actr->frame_count = 3;
-		}
-		goto done1;
-	}
-	if (actr->temp3 > 1) {
-		actr->temp3--;
-		goto done1;
-	} else if (actr->temp3) {
-		for (i = 0; i < num_pods1; i++)
-			if (_G(actor)[19 + i].used)
-				goto done1;
-
-		while (1) {
-			rx = g_events->getRandomNumber(255) + 16;
-			ry = g_events->getRandomNumber(143);
-			if (!overlap(rx, ry, rx + 32, ry + 32, _G(thor_x1), _G(thor_y1),
-					_G(thor_x2), _G(thor_y2)))
-				break;
-		}
-
-		actr->x = rx;
-		actr->y = ry;
-		actr->frame_count = LFC;
-		actr->temp4 = 40;
-		actr->temp3 = 0;
-		play_sound(EXPLODE, 1);
-		goto done1;
-	}
-
-	if (actr->temp4) {
-		// Fade in
-		actr->frame_count--;
-		if (actr->frame_count <= 0) {
-			actr->next--;
-			if (actr->next > 254) {
-				actr->next = 0;
-				actr->dir = 0;
-				actr->temp4 = 0;
-				actr->temp5 = 80;
-				actr->solid &= 0x7f;
-				_G(actor)[4].solid &= 0x7f;
-				_G(actor)[5].solid &= 0x7f;
-				_G(actor)[6].solid &= 0x7f;
-			}
-
-			actr->frame_count = 3;
-		}
-		goto done1;
-	}
-
-	if (actr->temp5) {
-		// Shoot
-		actr->temp5--;
-		if (actr->temp5 == 20) {
-			actr->next = 3;
-			goto done1;
-		}
-		if (!actr->temp5) {
-			if (_G(actor)[4].num_shots < _G(actor)[4].shots_allowed) {
-				actor_always_shoots(&_G(actor)[4], 0);
-				_G(actor)[_G(actor)[4].shot_actor].num_moves = pod_speed;
-				_G(actor)[_G(actor)[4].shot_actor].x = actr->x + 8;
-				_G(actor)[_G(actor)[4].shot_actor].y = actr->y + 16;
-				_G(actor)[_G(actor)[4].shot_actor].temp5 = 0;
-				for (i = 0; i < numPods; i++)
-					_G(actor)[20 + i] = _G(actor)[19];
-
-				num_pods1 = numPods;
-				actr->temp1 = 0;
-			}
-		}
-
-		if (actr->temp5 < 31)
-			goto done1;
-	}
+    int rx, ry, i, numPods = 0;
+
+    actr->num_moves = 2;
+    pod_speed = 2;
+
+    switch (_G(setup).skill) {
+    case 0:
+        numPods = 3;
+        break;
+    case 1:
+        numPods = 5;
+        break;
+    case 2:
+        numPods = 8;
+        break;
+    }
+
+    if (!actr->temp1) {
+        // Disappear
+        actr->dir = 1;
+        actr->frame_count = LFC;
+        actr->next = 0;
+        actr->temp1 = 1;
+        actr->i6 = 1;
+        actr->solid |= 128;
+        _G(actor)[4].solid |= 128;
+        _G(actor)[5].solid |= 128;
+        _G(actor)[6].solid |= 128;
+        play_sound(EXPLODE, 1);
+        goto done;
+    }
+    if (actr->i6) {
+        // Fade out
+        actr->frame_count--;
+        if (actr->frame_count <= 0) {
+            actr->next++;
+            if (actr->next > 2) {
+                actr->i6 = 0;
+                actr->temp3 = 160;
+            }
+            actr->frame_count = 3;
+        }
+        goto done1;
+    }
+    if (actr->temp3 > 1) {
+        actr->temp3--;
+        goto done1;
+    } else if (actr->temp3) {
+        for (i = 0; i < num_pods1; i++)
+            if (_G(actor)[19 + i].used)
+                goto done1;
+
+        while (1) {
+            rx = g_events->getRandomNumber(255) + 16;
+            ry = g_events->getRandomNumber(143);
+            if (!overlap(rx, ry, rx + 32, ry + 32, _G(thor_x1), _G(thor_y1),
+                         _G(thor_x2), _G(thor_y2)))
+                break;
+        }
+
+        actr->x = rx;
+        actr->y = ry;
+        actr->frame_count = LFC;
+        actr->temp4 = 40;
+        actr->temp3 = 0;
+        play_sound(EXPLODE, 1);
+        goto done1;
+    }
+
+    if (actr->temp4) {
+        // Fade in
+        actr->frame_count--;
+        if (actr->frame_count <= 0) {
+            actr->next--;
+            if (actr->next > 254) {
+                actr->next = 0;
+                actr->dir = 0;
+                actr->temp4 = 0;
+                actr->temp5 = 80;
+                actr->solid &= 0x7f;
+                _G(actor)[4].solid &= 0x7f;
+                _G(actor)[5].solid &= 0x7f;
+                _G(actor)[6].solid &= 0x7f;
+            }
+
+            actr->frame_count = 3;
+        }
+        goto done1;
+    }
+
+    if (actr->temp5) {
+        // Shoot
+        actr->temp5--;
+        if (actr->temp5 == 20) {
+            actr->next = 3;
+            goto done1;
+        }
+        if (!actr->temp5) {
+            if (_G(actor)[4].num_shots < _G(actor)[4].shots_allowed) {
+                actor_always_shoots(&_G(actor)[4], 0);
+                _G(actor)[_G(actor)[4].shot_actor].num_moves = pod_speed;
+                _G(actor)[_G(actor)[4].shot_actor].x = actr->x + 8;
+                _G(actor)[_G(actor)[4].shot_actor].y = actr->y + 16;
+                _G(actor)[_G(actor)[4].shot_actor].temp5 = 0;
+                for (i = 0; i < numPods; i++)
+                    _G(actor)[20 + i] = _G(actor)[19];
+
+                num_pods1 = numPods;
+                actr->temp1 = 0;
+            }
+        }
+
+        if (actr->temp5 < 31)
+            goto done1;
+    }
 
 done:
-	actr->frame_count--;
-	if (actr->frame_count <= 0) {
-		actr->next++;
-		if (actr->next > 2)
-			actr->next = 0;
-		actr->frame_count = LFC;
-	}
+    actr->frame_count--;
+    if (actr->frame_count <= 0) {
+        actr->next++;
+        if (actr->next > 2)
+            actr->next = 0;
+        actr->frame_count = LFC;
+    }
 done1:
-	set_boss(actr);
-	return actr->dir;
+    set_boss(actr);
+    return actr->dir;
 }
 
 // Boss - Loki-1
 int boss3_movement(ACTOR *actr) {
-	int d, x1, y1, f, ox, oy;
-
-	if (actr->temp2)
-		actr->temp2--;
-	if (_G(boss_dead))
-		return boss_die();
-	check_boss_hit();
-
-	if (!boss_mode) return boss_movement_one(actr);
-	num_pods1 = 10;
-	switch (_G(setup).skill) {
-	case 0:
-		actr->num_moves = 3;
-		actr->speed = 2;
-		break;
-	case 1:
-		actr->num_moves = 2;
-		actr->speed = 1;
-		break;
-	case 2:
-		actr->num_moves = 5;
-		actr->speed = 2;
-		break;
-	}
-
-	d = actr->last_dir;
-	actr->temp3++;
-
-	f = 0;
-	if (actr->temp4) {
-		actr->temp4--;
-		if (!actr->temp4) {
-			actr->temp3 = 0;
-			_G(actor)[3].frame_speed = 4;
-			_G(actor)[3].dir = 0;
-			_G(actor)[3].last_dir = 0;
-			_G(actor)[3].next = 3;
-			_G(actor)[4].dir = 0;
-			_G(actor)[4].last_dir = 0;
-			_G(actor)[4].next = 3;
-		}
-		goto skip_move;
-	}
-
-	if (actr->edge_counter) actr->edge_counter--;
-	else goto new_dir;
-
-	if (overlap(actr->x + 2, actr->y + 8, actr->x + 30, actr->y + 30,
-		_G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15))
-		thor_damaged(actr);
-
-	ox = actr->x;
-	oy = actr->y;
-	switch (actr->temp5) {
-	case 0:
-		x1 = _G(actor)[3].x;
-		y1 = _G(actor)[3].y - 2;
-		if (!check_move2(x1, y1, &_G(actor)[3])) {
-			f = 1;
-			break;
-		}
-		if (!check_move2(x1 + 16, y1, &_G(actor)[4])) f = 1;
-		actr->y = oy - 2;
-		break;
-	case 1:
-		x1 = _G(actor)[5].x;
-		y1 = _G(actor)[5].y + 2;
-		if (!check_move2(x1, y1, &_G(actor)[5])) {
-			f = 1;
-			break;
-		}
-		if (!check_move2(x1 + 16, y1, &_G(actor)[6])) f = 1;
-		actr->y = oy + 2;
-		break;
-	case 2:
-		x1 = _G(actor)[3].x - 2;
-		y1 = _G(actor)[3].y;
-		if (!check_move2(x1, y1, &_G(actor)[3])) {
-			f = 1;
-			break;
-		}
-		if (!check_move2(x1, y1 + 16, &_G(actor)[5])) f = 1;
-		actr->x = ox - 2;
-		break;
-	case 3:
-		x1 = _G(actor)[4].x + 2;
-		y1 = _G(actor)[4].y;
-		if (!check_move2(x1, y1, &_G(actor)[4])) {
-			f = 1;
-			break;
-		}
-		if (!check_move2(x1, y1 + 16, &_G(actor)[6])) f = 1;
-		actr->x = ox + 2;
-		break;
-	case 4:               //ul
-		x1 = _G(actor)[3].x - 2;
-		y1 = _G(actor)[3].y - 2;
-		if (!check_move2(x1, y1, &_G(actor)[3])) {
-			f = 1;
-			break;
-		}
-		actr->x = ox - 2;
-		actr->y = oy - 2;
-		break;
-	case 5:
-		x1 = _G(actor)[4].x + 2;
-		y1 = _G(actor)[4].y - 2;
-		if (!check_move2(x1, y1, &_G(actor)[4])) {
-			f = 1;
-			break;
-		}
-		actr->x = ox + 2;
-		actr->y = oy - 2;
-		break;
-	case 6:
-		x1 = _G(actor)[6].x + 2;
-		y1 = _G(actor)[6].y + 2;
-		if (!check_move2(x1, y1, &_G(actor)[6])) {
-			f = 1;
-			break;
-		}
-		actr->x = ox + 2;
-		actr->y = oy + 2;
-		break;
-	case 7:
-		x1 = _G(actor)[5].x - 2;
-		y1 = _G(actor)[5].y + 2;
-		if (!check_move2(x1, y1, &_G(actor)[5])) {
-			f = 1;
-			break;
-		}
-		actr->x = ox - 2;
-		actr->y = oy + 2;
-		break;
-	}
-	actr->frame_count--;
-	if (actr->frame_count <= 0) {
-		actr->next++;
-		if (actr->next > 2) actr->next = 0;
-		actr->frame_count = 30;
-	}
+    int d, x1, y1, f, ox, oy;
+
+    if (actr->temp2)
+        actr->temp2--;
+    if (_G(boss_dead))
+        return boss_die();
+    check_boss_hit();
+
+    if (!boss_mode) return boss_movement_one(actr);
+    num_pods1 = 10;
+    switch (_G(setup).skill) {
+    case 0:
+        actr->num_moves = 3;
+        actr->speed = 2;
+        break;
+    case 1:
+        actr->num_moves = 2;
+        actr->speed = 1;
+        break;
+    case 2:
+        actr->num_moves = 5;
+        actr->speed = 2;
+        break;
+    }
+
+    d = actr->last_dir;
+    actr->temp3++;
+
+    f = 0;
+    if (actr->temp4) {
+        actr->temp4--;
+        if (!actr->temp4) {
+            actr->temp3 = 0;
+            _G(actor)[3].frame_speed = 4;
+            _G(actor)[3].dir = 0;
+            _G(actor)[3].last_dir = 0;
+            _G(actor)[3].next = 3;
+            _G(actor)[4].dir = 0;
+            _G(actor)[4].last_dir = 0;
+            _G(actor)[4].next = 3;
+        }
+        goto skip_move;
+    }
+
+    if (actr->edge_counter) actr->edge_counter--;
+    else goto new_dir;
+
+    if (overlap(actr->x + 2, actr->y + 8, actr->x + 30, actr->y + 30,
+                _G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15))
+        thor_damaged(actr);
+
+    ox = actr->x;
+    oy = actr->y;
+    switch (actr->temp5) {
+    case 0:
+        x1 = _G(actor)[3].x;
+        y1 = _G(actor)[3].y - 2;
+        if (!check_move2(x1, y1, &_G(actor)[3])) {
+            f = 1;
+            break;
+        }
+        if (!check_move2(x1 + 16, y1, &_G(actor)[4])) f = 1;
+        actr->y = oy - 2;
+        break;
+    case 1:
+        x1 = _G(actor)[5].x;
+        y1 = _G(actor)[5].y + 2;
+        if (!check_move2(x1, y1, &_G(actor)[5])) {
+            f = 1;
+            break;
+        }
+        if (!check_move2(x1 + 16, y1, &_G(actor)[6])) f = 1;
+        actr->y = oy + 2;
+        break;
+    case 2:
+        x1 = _G(actor)[3].x - 2;
+        y1 = _G(actor)[3].y;
+        if (!check_move2(x1, y1, &_G(actor)[3])) {
+            f = 1;
+            break;
+        }
+        if (!check_move2(x1, y1 + 16, &_G(actor)[5])) f = 1;
+        actr->x = ox - 2;
+        break;
+    case 3:
+        x1 = _G(actor)[4].x + 2;
+        y1 = _G(actor)[4].y;
+        if (!check_move2(x1, y1, &_G(actor)[4])) {
+            f = 1;
+            break;
+        }
+        if (!check_move2(x1, y1 + 16, &_G(actor)[6])) f = 1;
+        actr->x = ox + 2;
+        break;
+    case 4:               //ul
+        x1 = _G(actor)[3].x - 2;
+        y1 = _G(actor)[3].y - 2;
+        if (!check_move2(x1, y1, &_G(actor)[3])) {
+            f = 1;
+            break;
+        }
+        actr->x = ox - 2;
+        actr->y = oy - 2;
+        break;
+    case 5:
+        x1 = _G(actor)[4].x + 2;
+        y1 = _G(actor)[4].y - 2;
+        if (!check_move2(x1, y1, &_G(actor)[4])) {
+            f = 1;
+            break;
+        }
+        actr->x = ox + 2;
+        actr->y = oy - 2;
+        break;
+    case 6:
+        x1 = _G(actor)[6].x + 2;
+        y1 = _G(actor)[6].y + 2;
+        if (!check_move2(x1, y1, &_G(actor)[6])) {
+            f = 1;
+            break;
+        }
+        actr->x = ox + 2;
+        actr->y = oy + 2;
+        break;
+    case 7:
+        x1 = _G(actor)[5].x - 2;
+        y1 = _G(actor)[5].y + 2;
+        if (!check_move2(x1, y1, &_G(actor)[5])) {
+            f = 1;
+            break;
+        }
+        actr->x = ox - 2;
+        actr->y = oy + 2;
+        break;
+    }
+    actr->frame_count--;
+    if (actr->frame_count <= 0) {
+        actr->next++;
+        if (actr->next > 2) actr->next = 0;
+        actr->frame_count = 30;
+    }
 
 skip_move:
 
-	set_boss(actr);
-	if (!f) goto done;
+    set_boss(actr);
+    if (!f) goto done;
 
 new_dir:
-	if (actr->temp3 < 120) goto new_dir1;
-	_G(actor)[3].frame_speed = 8;
-	_G(actor)[3].next = 3;
-	_G(actor)[4].next = 3;
-	actr->temp4 = 120;
-	actor_always_shoots(actr, 0);
-	_G(actor)[actr->shot_actor].x = actr->x + 8;
-	_G(actor)[actr->shot_actor].y = actr->y - 8;
-	_G(actor)[actr->shot_actor].temp1 = g_events->getRandomNumber(90, 189);
-	_G(actor)[actr->shot_actor].temp5 = 30;
-	_G(actor)[actr->shot_actor].speed = 2;
-	play_sound(BOSS12, 1);
+    if (actr->temp3 < 120) goto new_dir1;
+    _G(actor)[3].frame_speed = 8;
+    _G(actor)[3].next = 3;
+    _G(actor)[4].next = 3;
+    actr->temp4 = 120;
+    actor_always_shoots(actr, 0);
+    _G(actor)[actr->shot_actor].x = actr->x + 8;
+    _G(actor)[actr->shot_actor].y = actr->y - 8;
+    _G(actor)[actr->shot_actor].temp1 = g_events->getRandomNumber(90, 189);
+    _G(actor)[actr->shot_actor].temp5 = 30;
+    _G(actor)[actr->shot_actor].speed = 2;
+    play_sound(BOSS12, 1);
 
 new_dir1:
-	actr->temp5 = _G(rand1) % 8;
-	actr->edge_counter = _G(rand2) + 60;
+    actr->temp5 = _G(rand1) % 8;
+    actr->edge_counter = _G(rand2) + 60;
 
 done:
-	if (actr->directions == 1) return 0;
-	return d;
+    if (actr->directions == 1) return 0;
+    return d;
 }
 
 static void check_boss_hit() {
-	int rep;
-
-	if (_G(actor)[3].solid & 128) {
-		for (rep = 3; rep < 7; rep++) _G(actor)[rep].magic_hit = 0;
-		return;
-	}
-	if (_G(actor)[3].magic_hit || _G(actor)[4].magic_hit ||
-		_G(actor)[5].magic_hit || _G(actor)[6].magic_hit) {
-		if (!_G(actor)[3].temp2) {
-			actor_damaged(&_G(actor)[3], 10);
-
-			if (_G(cheat) && _G(key_flag)[_Z])
-				_G(actor)[3].health -= 50;
-			else
-				_G(actor)[3].health -= 10;
-			_G(actor)[3].speed_count = 50;
-
-			boss_status(_G(actor)[3].health);
-			_G(actor)[3].vunerable = 50;
-			play_sound(BOSS13, 1);
-
-			for (rep = 4; rep < 7; rep++) {
-				_G(actor)[rep].magic_hit = 0;
-				_G(actor)[rep].next = 1;
-				_G(actor)[rep].speed_count = 50;
-			}
-
-			if (_G(actor)[3].health == 0) {
-				_G(boss_dead) = 1;
-				for (rep = 7; rep < MAX_ACTORS; rep++)
-					if (_G(actor)[rep].used)
-						actor_destroyed(&_G(actor)[rep]);
-			}
-
-			if (_G(actor)[3].health == 50) {
-				boss_change_mode();
-				_G(actor)[3].temp1 = 0;
-				_G(actor)[3].temp2 = 0;
-				_G(actor)[3].temp3 = 0;
-				_G(actor)[3].temp4 = 0;
-				_G(actor)[3].temp5 = 0;
-				_G(actor)[3].i6 = 0;
-				_G(actor)[3].speed_count = 2;
-			} else {
-				_G(actor)[3].temp2 = 40;
-			}
-		}
-		for (rep = 3; rep < 7; rep++)
-			_G(actor)[rep].magic_hit = 0;
-	}
+    int rep;
+
+    if (_G(actor)[3].solid & 128) {
+        for (rep = 3; rep < 7; rep++) _G(actor)[rep].magic_hit = 0;
+        return;
+    }
+    if (_G(actor)[3].magic_hit || _G(actor)[4].magic_hit ||
+            _G(actor)[5].magic_hit || _G(actor)[6].magic_hit) {
+        if (!_G(actor)[3].temp2) {
+            actor_damaged(&_G(actor)[3], 10);
+
+            if (_G(cheat) && _G(key_flag)[_Z])
+                _G(actor)[3].health -= 50;
+            else
+                _G(actor)[3].health -= 10;
+            _G(actor)[3].speed_count = 50;
+
+            boss_status(_G(actor)[3].health);
+            _G(actor)[3].vunerable = 50;
+            play_sound(BOSS13, 1);
+
+            for (rep = 4; rep < 7; rep++) {
+                _G(actor)[rep].magic_hit = 0;
+                _G(actor)[rep].next = 1;
+                _G(actor)[rep].speed_count = 50;
+            }
+
+            if (_G(actor)[3].health == 0) {
+                _G(boss_dead) = 1;
+                for (rep = 7; rep < MAX_ACTORS; rep++)
+                    if (_G(actor)[rep].used)
+                        actor_destroyed(&_G(actor)[rep]);
+            }
+
+            if (_G(actor)[3].health == 50) {
+                boss_change_mode();
+                _G(actor)[3].temp1 = 0;
+                _G(actor)[3].temp2 = 0;
+                _G(actor)[3].temp3 = 0;
+                _G(actor)[3].temp4 = 0;
+                _G(actor)[3].temp5 = 0;
+                _G(actor)[3].i6 = 0;
+                _G(actor)[3].speed_count = 2;
+            } else {
+                _G(actor)[3].temp2 = 40;
+            }
+        }
+        for (rep = 3; rep < 7; rep++)
+            _G(actor)[rep].magic_hit = 0;
+    }
 }
 
 static void boss_change_mode() {
-	if (!_G(boss_intro2)) {
-		Gfx::Pics loki("FACE18", 262);
-		execute_script(1003, loki);
-		d_restore();
-		_G(boss_intro2) = true;
-	}
-	boss_mode = 0;
+    if (!_G(boss_intro2)) {
+        Gfx::Pics loki("FACE18", 262);
+        execute_script(1003, loki);
+        d_restore();
+        _G(boss_intro2) = true;
+    }
+    boss_mode = 0;
 }
 
 void boss_level3() {
-	setup_boss(3);
-	_G(boss_active) = 1;
-	boss_status(-1);
-	music_pause();
-	play_sound(BOSS11, 1);
-	_G(timer_cnt) = 0;
-
-	g_events->send("Game", GameMessage("PAUSE", 40));
-
-	if (!_G(boss_intro1)) {
-		Gfx::Pics loki("FACE18", 262);
-		execute_script(1002, loki);
-		d_restore();
-		_G(boss_intro1) = true;
-	}
-
-	music_play(7, 1);
-	_G(apple_drop) = 0;
-	boss_mode = 1;
+    setup_boss(3);
+    _G(boss_active) = 1;
+    boss_status(-1);
+    music_pause();
+    play_sound(BOSS11, 1);
+    _G(timer_cnt) = 0;
+
+    g_events->send("Game", GameMessage("PAUSE", 40));
+
+    if (!_G(boss_intro1)) {
+        Gfx::Pics loki("FACE18", 262);
+        execute_script(1002, loki);
+        d_restore();
+        _G(boss_intro1) = true;
+    }
+
+    music_play(7, 1);
+    _G(apple_drop) = 0;
+    boss_mode = 1;
 }
 
 static int boss_die() {
-	int rep, n, x, y, r, x1, y1;
-
-	if (_G(boss_dead) == 1) {
-		REPEAT(4) {
-			x1 = _G(actor)[3 + rep].last_x[_G(pge)];
-			y1 = _G(actor)[3 + rep].last_y[_G(pge)];
-			x = _G(actor)[3 + rep].x;
-			y = _G(actor)[3 + rep].y;
-			n = _G(actor)[3 + rep].actor_num;
-			r = _G(actor)[3 + rep].rating;
-
-			_G(actor)[3 + rep] = _G(explosion);
-
-			_G(actor)[3 + rep].actor_num = n;
-			_G(actor)[3 + rep].rating = r;
-			_G(actor)[3 + rep].x = x;
-			_G(actor)[3 + rep].y = y;
-			_G(actor)[3 + rep].last_x[_G(pge)] = x1;
-			_G(actor)[3 + rep].last_x[_G(pge) ^ 1] = x;
-			_G(actor)[3 + rep].last_y[_G(pge)] = y1;
-			_G(actor)[3 + rep].last_y[_G(pge) ^ 1] = y;
-			_G(actor)[3 + rep].used = 1;
-			_G(actor)[3 + rep].vunerable = 255;
-			_G(actor)[3 + rep].move = 6;
-			_G(actor)[3 + rep].next = rep;
-			_G(actor)[3 + rep].speed = g_events->getRandomNumber(6, 8);
-			_G(actor)[3 + rep].num_shots = (10 - _G(actor)[3 + rep].speed) * 10;
-			_G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
-		}
-
-		play_sound(EXPLODE, 1);
-		_G(boss_dead)++;
-	}
-
-	return _G(actor)[3].last_dir;
+    int rep, n, x, y, r, x1, y1;
+
+    if (_G(boss_dead) == 1) {
+        REPEAT(4) {
+            x1 = _G(actor)[3 + rep].last_x[_G(pge)];
+            y1 = _G(actor)[3 + rep].last_y[_G(pge)];
+            x = _G(actor)[3 + rep].x;
+            y = _G(actor)[3 + rep].y;
+            n = _G(actor)[3 + rep].actor_num;
+            r = _G(actor)[3 + rep].rating;
+
+            _G(actor)[3 + rep] = _G(explosion);
+
+            _G(actor)[3 + rep].actor_num = n;
+            _G(actor)[3 + rep].rating = r;
+            _G(actor)[3 + rep].x = x;
+            _G(actor)[3 + rep].y = y;
+            _G(actor)[3 + rep].last_x[_G(pge)] = x1;
+            _G(actor)[3 + rep].last_x[_G(pge) ^ 1] = x;
+            _G(actor)[3 + rep].last_y[_G(pge)] = y1;
+            _G(actor)[3 + rep].last_y[_G(pge) ^ 1] = y;
+            _G(actor)[3 + rep].used = 1;
+            _G(actor)[3 + rep].vunerable = 255;
+            _G(actor)[3 + rep].move = 6;
+            _G(actor)[3 + rep].next = rep;
+            _G(actor)[3 + rep].speed = g_events->getRandomNumber(6, 8);
+            _G(actor)[3 + rep].num_shots = (10 - _G(actor)[3 + rep].speed) * 10;
+            _G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
+        }
+
+        play_sound(EXPLODE, 1);
+        _G(boss_dead)++;
+    }
+
+    return _G(actor)[3].last_dir;
 }
 
 void closing_sequence3() {
-	music_play(6, 1);
-	odin_speaks(1001, 0, "CLOSING");
+    music_play(6, 1);
+    odin_speaks(1001, 0, "CLOSING");
 }
 
 void closing_sequence3_2() {
-	fill_score(20, "CLOSING");
+    fill_score(20, "CLOSING");
 }
 
 void closing_sequence3_3() {
-	int rep;
-
-	fill_health();
-	fill_magic();
-
-	REPEAT(16) _G(scrn).actor_type[rep] = 0;
-	_G(boss_dead) = 0;
-	_G(setup).boss_dead[2] = 1;
-	_G(game_over) = 1;
-	_G(boss_active) = 0;
-	_G(scrn).type = 6;
-	show_level(BOSS_LEVEL3);
-
-	_G(exit_flag) = 0;
-	music_pause();
-
-	_G(new_level) = ENDING_SCREEN;
-	_G(thor)->x = 152;
-	_G(thor)->y = 160;
-	_G(thor)->dir = 1;
+    int rep;
+
+    fill_health();
+    fill_magic();
+
+    REPEAT(16) _G(scrn).actor_type[rep] = 0;
+    _G(boss_dead) = 0;
+    _G(setup).boss_dead[2] = 1;
+    _G(game_over) = 1;
+    _G(boss_active) = 0;
+    _G(scrn).type = 6;
+    show_level(BOSS_LEVEL3);
+
+    _G(exit_flag) = 0;
+    music_pause();
+
+    _G(new_level) = ENDING_SCREEN;
+    _G(thor)->x = 152;
+    _G(thor)->y = 160;
+    _G(thor)->dir = 1;
 }
 
 void ending_screen() {
-	int i;
-
-	for (i = 3; i < MAX_ACTORS; i++)
-		_G(actor)[i].move = 1;
-	music_play(6, 1);
-	_G(timer_cnt) = 0;
-
-	memset(expf, 0, 4 * 8);
-	_G(endgame) = 1;
-
-	_G(exprow) = 0;
-	expcnt = 0;
-
-	_G(actor)[34] = _G(explosion);
-	_G(actor)[34].used = 0;
-	_G(actor)[34].speed = 2;
-	_G(actor)[34].speed_count = _G(actor)[34].speed;
-	_G(actor)[34].num_shots = 3;  // Used to reverse explosion
-	_G(actor)[34].vunerable = 255;
-	_G(actor)[34].i2 = 6;
+    int i;
+
+    for (i = 3; i < MAX_ACTORS; i++)
+        _G(actor)[i].move = 1;
+    music_play(6, 1);
+    _G(timer_cnt) = 0;
+
+    memset(expf, 0, 4 * 8);
+    _G(endgame) = 1;
+
+    _G(exprow) = 0;
+    expcnt = 0;
+
+    _G(actor)[34] = _G(explosion);
+    _G(actor)[34].used = 0;
+    _G(actor)[34].speed = 2;
+    _G(actor)[34].speed_count = _G(actor)[34].speed;
+    _G(actor)[34].num_shots = 3;  // Used to reverse explosion
+    _G(actor)[34].vunerable = 255;
+    _G(actor)[34].i2 = 6;
 }
 
 // Explode
 int endgame_one() {
-	int x, y, r;
-
-	if (_G(actor)[34].i2) {
-		_G(actor)[34].i2--;
-		return 0;
-	}
-
-	_G(actor)[34].i2 = 6;
-	play_sound(EXPLODE, 1);
-
-	r = _G(rand1) % 32;
-	while (expf[r / 8][r % 8]) {
-		r++;
-		if (r > 31) r = 0;
-	}
-	expf[r / 8][r % 8] = 1;
-	x = (EXPLOSION[r / 8][r % 8] % 20) * 16;
-	y = (EXPLOSION[r / 8][r % 8] / 20) * 16;
-	_G(actor)[34].x = x;
-	_G(actor)[34].y = y;
-	_G(actor)[34].used = 1;
-	_G(actor)[34].next = 0;
-	_G(actor)[34].num_shots = 3;
-
-	_G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
-
-	_G(endgame)++;
-	if (_G(endgame) > 32) {
-		_G(actor)[34].used = 0;
-		_G(endgame) = 0;
-	}
-	return 1;
+    int x, y, r;
+
+    if (_G(actor)[34].i2) {
+        _G(actor)[34].i2--;
+        return 0;
+    }
+
+    _G(actor)[34].i2 = 6;
+    play_sound(EXPLODE, 1);
+
+    r = _G(rand1) % 32;
+    while (expf[r / 8][r % 8]) {
+        r++;
+        if (r > 31) r = 0;
+    }
+    expf[r / 8][r % 8] = 1;
+    x = (EXPLOSION[r / 8][r % 8] % 20) * 16;
+    y = (EXPLOSION[r / 8][r % 8] / 20) * 16;
+    _G(actor)[34].x = x;
+    _G(actor)[34].y = y;
+    _G(actor)[34].used = 1;
+    _G(actor)[34].next = 0;
+    _G(actor)[34].num_shots = 3;
+
+    _G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
+
+    _G(endgame)++;
+    if (_G(endgame) > 32) {
+        _G(actor)[34].used = 0;
+        _G(endgame) = 0;
+    }
+    return 1;
 }
 
 // Explode
 int endgame_movement() {
-	int x, y, r;
-
-	if (!_G(endgame))
-		return 0;
-	if (expcnt > 3) {
-		endgame_one();
-		return 0;
-	}
-	if (_G(actor)[34].i2) {
-		_G(actor)[34].i2--;
-		return 0;
-	}
-	_G(actor)[34].i2 = 6;
-	play_sound(EXPLODE, 1);
-
-	r = _G(rand1) % 8;
-	while (expf[_G(exprow)][r]) {
-		r++;
-		if (r > 7) r = 0;
-	}
-	expf[_G(exprow)][r] = 1;
-	x = (EXPLOSION[_G(exprow)][r] % 20) * 16;
-	y = (EXPLOSION[_G(exprow)][r] / 20) * 16;
-	_G(actor)[34].x = x;
-	_G(actor)[34].y = y;
-	_G(actor)[34].used = 1;
-	_G(actor)[34].next = 0;
-	_G(actor)[34].num_shots = 3;
-
-	_G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
-	_G(scrn).icon[(y / 16) - 4][x / 16] = _G(scrn).bg_color;
-
-	_G(endgame)++;
-	if (_G(endgame) > 8) {
-		_G(endgame) = 1;
-		_G(exprow)++;
-		expcnt++;
-		if (expcnt > 3) {
-			memset(expf, 0, 32);
-		}
-	}
-
-	return 1;
+    int x, y, r;
+
+    if (!_G(endgame))
+        return 0;
+    if (expcnt > 3) {
+        endgame_one();
+        return 0;
+    }
+    if (_G(actor)[34].i2) {
+        _G(actor)[34].i2--;
+        return 0;
+    }
+    _G(actor)[34].i2 = 6;
+    play_sound(EXPLODE, 1);
+
+    r = _G(rand1) % 8;
+    while (expf[_G(exprow)][r]) {
+        r++;
+        if (r > 7) r = 0;
+    }
+    expf[_G(exprow)][r] = 1;
+    x = (EXPLOSION[_G(exprow)][r] % 20) * 16;
+    y = (EXPLOSION[_G(exprow)][r] / 20) * 16;
+    _G(actor)[34].x = x;
+    _G(actor)[34].y = y;
+    _G(actor)[34].used = 1;
+    _G(actor)[34].next = 0;
+    _G(actor)[34].num_shots = 3;
+
+    _G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
+    _G(scrn).icon[(y / 16) - 4][x / 16] = _G(scrn).bg_color;
+
+    _G(endgame)++;
+    if (_G(endgame) > 8) {
+        _G(endgame) = 1;
+        _G(exprow)++;
+        expcnt++;
+        if (expcnt > 3) {
+            memset(expf, 0, 32);
+        }
+    }
+
+    return 1;
 }
 
 } // namespace Got
diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index 8982833c7c7..3184c10b143 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -33,160 +33,160 @@
 namespace Got {
 
 void setup_player() {
-	memset(&_G(thor_info), 0, sizeof(_G(thor_info)));
-	_G(thor_info).inventory = 0;
-	if (_G(area) > 1)
-		_G(thor_info).inventory |= APPLE_MAGIC + LIGHTNING_MAGIC;
-	if (_G(area) > 2)
-		_G(thor_info).inventory |= BOOTS_MAGIC + WIND_MAGIC;
-
-	_G(thor)->health = 150;
-	_G(thor_info).magic = _G(area) > 1 ? 150 : 0;
-	_G(thor_info).jewels = 0;
-	_G(thor_info).score = 0;
-	_G(thor_info).keys = 0;
-	_G(thor_info).last_item = 0;
-	_G(thor_info).object = 0;
-	_G(thor_info).object_name = nullptr;
-	_G(thor)->last_x[0] = _G(thor)->x;
-	_G(thor)->last_x[1] = _G(thor)->x;
-	_G(thor)->last_y[0] = _G(thor)->y;
-	_G(thor)->last_y[1] = _G(thor)->y;
-	_G(thor_info).last_icon = (6 * 20) + 8;
-	_G(thor_info).last_screen = 23;
-	_G(thor)->dir = 1;
-
-	switch (_G(area)) {
-	case 1:
-		_G(thor)->x = 152;
-		_G(thor)->y = 96;
-		break;
-	case 2:
-		_G(thor)->x = 32;
-		_G(thor)->y = 32;
-		break;
-	case 3:
-		_G(thor)->x = 272;
-		_G(thor)->y = 80;
-		break;
-	default:
-		break;
-	}
+    memset(&_G(thor_info), 0, sizeof(_G(thor_info)));
+    _G(thor_info).inventory = 0;
+    if (_G(area) > 1)
+        _G(thor_info).inventory |= APPLE_MAGIC + LIGHTNING_MAGIC;
+    if (_G(area) > 2)
+        _G(thor_info).inventory |= BOOTS_MAGIC + WIND_MAGIC;
+
+    _G(thor)->health = 150;
+    _G(thor_info).magic = _G(area) > 1 ? 150 : 0;
+    _G(thor_info).jewels = 0;
+    _G(thor_info).score = 0;
+    _G(thor_info).keys = 0;
+    _G(thor_info).last_item = 0;
+    _G(thor_info).object = 0;
+    _G(thor_info).object_name = nullptr;
+    _G(thor)->last_x[0] = _G(thor)->x;
+    _G(thor)->last_x[1] = _G(thor)->x;
+    _G(thor)->last_y[0] = _G(thor)->y;
+    _G(thor)->last_y[1] = _G(thor)->y;
+    _G(thor_info).last_icon = (6 * 20) + 8;
+    _G(thor_info).last_screen = 23;
+    _G(thor)->dir = 1;
+
+    switch (_G(area)) {
+    case 1:
+        _G(thor)->x = 152;
+        _G(thor)->y = 96;
+        break;
+    case 2:
+        _G(thor)->x = 32;
+        _G(thor)->y = 32;
+        break;
+    case 3:
+        _G(thor)->x = 272;
+        _G(thor)->y = 80;
+        break;
+    default:
+        break;
+    }
 }
 
 void initialize_game() {
-	load_standard_actors();
-	setup_player();
-
-	if (_G(demo)) {
-		g_vars->setArea(1);
-		_G(thor)->health = 100;
-		_G(thor_info).magic = 100;
-		_G(thor_info).jewels = 463;
-		_G(thor_info).score = 12455;
-		_G(setup).skill = 0;
-		_G(thor_info).inventory = 1 + 2;
-		_G(current_level) = 54;
-		_G(thor_info).item = 2;
-
-		File f("DEMO");
-		_G(demoKeys).clear();
-		for (int i = 0; i < DEMO_LEN; ++i)
-			_G(demoKeys).push(f.readByte());
-
-	}
-
-	_G(thor)->speed_count = 6;
-
-	// Load level data
-	_G(new_level) = _G(current_level);
-	_G(scrn).load(_G(current_level));
-	show_level(_G(current_level));
-
-	if (!_G(auto_load)) {
-		_G(sound).music_play(_G(level_type), 1);
-	}
-
-	g_vars->resetEndgameFlags();
-	_G(startup) = false;
+    load_standard_actors();
+    setup_player();
+
+    if (_G(demo)) {
+        g_vars->setArea(1);
+        _G(thor)->health = 100;
+        _G(thor_info).magic = 100;
+        _G(thor_info).jewels = 463;
+        _G(thor_info).score = 12455;
+        _G(setup).skill = 0;
+        _G(thor_info).inventory = 1 + 2;
+        _G(current_level) = 54;
+        _G(thor_info).item = 2;
+
+        File f("DEMO");
+        _G(demoKeys).clear();
+        for (int i = 0; i < DEMO_LEN; ++i)
+            _G(demoKeys).push(f.readByte());
+
+    }
+
+    _G(thor)->speed_count = 6;
+
+    // Load level data
+    _G(new_level) = _G(current_level);
+    _G(scrn).load(_G(current_level));
+    show_level(_G(current_level));
+
+    if (!_G(auto_load)) {
+        _G(sound).music_play(_G(level_type), 1);
+    }
+
+    g_vars->resetEndgameFlags();
+    _G(startup) = false;
 }
 
 void deinitialize_game() {
 }
 
 int setup_boss(int num) {
-	int rep;
-	Common::String ress, prefix;
-	Common::File f;
-
-	if (_G(boss_loaded) == num)
-		return 1;
-
-	if (_G(boss_loaded)) {
-		REPEAT(3) {
-			if (_G(boss_sound)[rep])
-				free(_G(boss_sound)[rep]);
-			if (_G(boss_pcsound)[rep])
-				free(_G(boss_pcsound)[rep]);
-		}
-	}
-
-	ress = Common::String::format("BOSSV%d1", num);
-	_G(boss_sound)[0] = (byte *)res_falloc_read(ress);
-	if (!_G(boss_sound)[0]) return 0;
-	_G(dig_sound)[NUM_SOUNDS - 3] = _G(boss_sound)[0];
-
-	ress = Common::String::format("BOSSV%d2", num);
-	_G(boss_sound)[1] = (byte *)res_falloc_read(ress);
-	if (!_G(boss_sound)[1]) return 0;
-	_G(dig_sound)[NUM_SOUNDS - 2] = _G(boss_sound)[1];
-
-	ress = Common::String::format("BOSSV%d3", num);
-	_G(boss_sound)[2] = (byte *)res_falloc_read(ress);
-	if (!_G(boss_sound)[2]) return 0;
-	_G(dig_sound)[NUM_SOUNDS - 1] = _G(boss_sound)[2];
-
-	prefix = (num == 2) ? "BOSSP1" : Common::String::format("BOSSP%d", num);
-	ress = prefix + "1";
-	_G(boss_pcsound)[0] = (byte *)res_falloc_read(ress);
-	if (!_G(boss_pcsound)[0]) return 0;
-
-	_G(pc_sound)[NUM_SOUNDS - 3] = _G(boss_pcsound)[0];
-	_G(pc_sound)[NUM_SOUNDS - 3][0] = 0;
-	_G(pc_sound)[NUM_SOUNDS - 3][1] = 0;
-
-	if (!f.open(Common::Path(ress)))
-		return 0;
-	_G(pcsound_length)[NUM_SOUNDS - 3] = f.size();
-	f.close();
-
-	ress = prefix + "2";
-	_G(boss_pcsound)[1] = (byte *)res_falloc_read(ress);
-	if (!_G(boss_pcsound)[1]) return 0;
-
-	_G(pc_sound)[NUM_SOUNDS - 2] = _G(boss_pcsound)[1];
-	_G(pc_sound)[NUM_SOUNDS - 2][0] = 0;
-	_G(pc_sound)[NUM_SOUNDS - 2][1] = 0;
-
-	if (!f.open(Common::Path(ress)))
-		return 0;
-	_G(pcsound_length)[NUM_SOUNDS - 2] = f.size();
-	f.close();
-
-	ress = prefix + "3";
-	_G(boss_pcsound)[2] = (byte *)res_falloc_read(ress);
-	if (!_G(boss_pcsound)[2]) return 0;
-	_G(pc_sound)[NUM_SOUNDS - 1] = _G(boss_pcsound)[2];
-	_G(pc_sound)[NUM_SOUNDS - 1][0] = 0;
-	_G(pc_sound)[NUM_SOUNDS - 1][1] = 0;
-
-	if (!f.open(Common::Path(ress)))
-		return 0;
-	_G(pcsound_length)[NUM_SOUNDS - 1] = f.size();
-	f.close();
-
-	_G(boss_loaded) = num;
-	return 1;
+    int rep;
+    Common::String ress, prefix;
+    Common::File f;
+
+    if (_G(boss_loaded) == num)
+        return 1;
+
+    if (_G(boss_loaded)) {
+        REPEAT(3) {
+            if (_G(boss_sound)[rep])
+                free(_G(boss_sound)[rep]);
+            if (_G(boss_pcsound)[rep])
+                free(_G(boss_pcsound)[rep]);
+        }
+    }
+
+    ress = Common::String::format("BOSSV%d1", num);
+    _G(boss_sound)[0] = (byte *)res_falloc_read(ress);
+    if (!_G(boss_sound)[0]) return 0;
+    _G(dig_sound)[NUM_SOUNDS - 3] = _G(boss_sound)[0];
+
+    ress = Common::String::format("BOSSV%d2", num);
+    _G(boss_sound)[1] = (byte *)res_falloc_read(ress);
+    if (!_G(boss_sound)[1]) return 0;
+    _G(dig_sound)[NUM_SOUNDS - 2] = _G(boss_sound)[1];
+
+    ress = Common::String::format("BOSSV%d3", num);
+    _G(boss_sound)[2] = (byte *)res_falloc_read(ress);
+    if (!_G(boss_sound)[2]) return 0;
+    _G(dig_sound)[NUM_SOUNDS - 1] = _G(boss_sound)[2];
+
+    prefix = (num == 2) ? "BOSSP1" : Common::String::format("BOSSP%d", num);
+    ress = prefix + "1";
+    _G(boss_pcsound)[0] = (byte *)res_falloc_read(ress);
+    if (!_G(boss_pcsound)[0]) return 0;
+
+    _G(pc_sound)[NUM_SOUNDS - 3] = _G(boss_pcsound)[0];
+    _G(pc_sound)[NUM_SOUNDS - 3][0] = 0;
+    _G(pc_sound)[NUM_SOUNDS - 3][1] = 0;
+
+    if (!f.open(Common::Path(ress)))
+        return 0;
+    _G(pcsound_length)[NUM_SOUNDS - 3] = f.size();
+    f.close();
+
+    ress = prefix + "2";
+    _G(boss_pcsound)[1] = (byte *)res_falloc_read(ress);
+    if (!_G(boss_pcsound)[1]) return 0;
+
+    _G(pc_sound)[NUM_SOUNDS - 2] = _G(boss_pcsound)[1];
+    _G(pc_sound)[NUM_SOUNDS - 2][0] = 0;
+    _G(pc_sound)[NUM_SOUNDS - 2][1] = 0;
+
+    if (!f.open(Common::Path(ress)))
+        return 0;
+    _G(pcsound_length)[NUM_SOUNDS - 2] = f.size();
+    f.close();
+
+    ress = prefix + "3";
+    _G(boss_pcsound)[2] = (byte *)res_falloc_read(ress);
+    if (!_G(boss_pcsound)[2]) return 0;
+    _G(pc_sound)[NUM_SOUNDS - 1] = _G(boss_pcsound)[2];
+    _G(pc_sound)[NUM_SOUNDS - 1][0] = 0;
+    _G(pc_sound)[NUM_SOUNDS - 1][1] = 0;
+
+    if (!f.open(Common::Path(ress)))
+        return 0;
+    _G(pcsound_length)[NUM_SOUNDS - 1] = f.size();
+    f.close();
+
+    _G(boss_loaded) = num;
+    return 1;
 }
 
 } // namespace Got
diff --git a/engines/got/game/main.cpp b/engines/got/game/main.cpp
index a86cb4a6ec3..cc249358eed 100644
--- a/engines/got/game/main.cpp
+++ b/engines/got/game/main.cpp
@@ -26,49 +26,49 @@
 namespace Got {
 
 void setup_load() {
-	_G(thor)->used = 1;
-	_G(new_level) = _G(thor_info).last_screen;
-	_G(thor)->x = (_G(thor_info).last_icon % 20) * 16;
-	_G(thor)->y = ((_G(thor_info).last_icon / 20) * 16) - 1;
-	if (_G(thor)->x < 1) _G(thor)->x = 1;
-	if (_G(thor)->y < 0) _G(thor)->y = 0;
-	_G(thor)->last_x[0] = _G(thor)->x;
-	_G(thor)->last_x[1] = _G(thor)->x;
-	_G(thor)->last_y[0] = _G(thor)->y;
-	_G(thor)->last_y[1] = _G(thor)->y;
-	_G(thor)->dir = _G(thor_info).last_dir;
-	_G(thor)->last_dir = _G(thor_info).last_dir;
-	_G(thor)->health = _G(thor_info).last_health;
-	_G(thor_info).magic = _G(thor_info).last_magic;
-	_G(thor_info).jewels = _G(thor_info).last_jewels;
-	_G(thor_info).keys = _G(thor_info).last_keys;
-	_G(thor_info).score = _G(thor_info).last_score;
-	_G(thor_info).item = _G(thor_info).last_item;
-	_G(thor_info).inventory = _G(thor_info).last_inventory;
-	_G(thor_info).object = _G(thor_info).last_object;
-	_G(thor_info).object_name = _G(thor_info).last_object_name;
-	_G(thor)->num_moves = 1;
-	_G(thor)->vunerable = 60;
-	_G(thor)->show = 60;
-	_G(hourglass_flag) = 0;
-	_G(apple_flag) = 0;
-	_G(bomb_flag) = 0;
-	_G(thunder_flag) = 0;
-	_G(lightning_used) = 0;
-	_G(tornado_used) = 0;
-	_G(shield_on) = 0;
-	_G(actor)[1].used = 0;
-	_G(actor)[2].used = 0;
-	_G(thor)->speed_count = 6;
+    _G(thor)->used = 1;
+    _G(new_level) = _G(thor_info).last_screen;
+    _G(thor)->x = (_G(thor_info).last_icon % 20) * 16;
+    _G(thor)->y = ((_G(thor_info).last_icon / 20) * 16) - 1;
+    if (_G(thor)->x < 1) _G(thor)->x = 1;
+    if (_G(thor)->y < 0) _G(thor)->y = 0;
+    _G(thor)->last_x[0] = _G(thor)->x;
+    _G(thor)->last_x[1] = _G(thor)->x;
+    _G(thor)->last_y[0] = _G(thor)->y;
+    _G(thor)->last_y[1] = _G(thor)->y;
+    _G(thor)->dir = _G(thor_info).last_dir;
+    _G(thor)->last_dir = _G(thor_info).last_dir;
+    _G(thor)->health = _G(thor_info).last_health;
+    _G(thor_info).magic = _G(thor_info).last_magic;
+    _G(thor_info).jewels = _G(thor_info).last_jewels;
+    _G(thor_info).keys = _G(thor_info).last_keys;
+    _G(thor_info).score = _G(thor_info).last_score;
+    _G(thor_info).item = _G(thor_info).last_item;
+    _G(thor_info).inventory = _G(thor_info).last_inventory;
+    _G(thor_info).object = _G(thor_info).last_object;
+    _G(thor_info).object_name = _G(thor_info).last_object_name;
+    _G(thor)->num_moves = 1;
+    _G(thor)->vunerable = 60;
+    _G(thor)->show = 60;
+    _G(hourglass_flag) = 0;
+    _G(apple_flag) = 0;
+    _G(bomb_flag) = 0;
+    _G(thunder_flag) = 0;
+    _G(lightning_used) = 0;
+    _G(tornado_used) = 0;
+    _G(shield_on) = 0;
+    _G(actor)[1].used = 0;
+    _G(actor)[2].used = 0;
+    _G(thor)->speed_count = 6;
 
-	_G(scrn).load(_G(new_level));
+    _G(scrn).load(_G(new_level));
 
-	_G(current_level) = _G(new_level);
-	show_level(_G(new_level));
+    _G(current_level) = _G(new_level);
+    show_level(_G(new_level));
 }
 
 void pause(int delay) {
-	g_system->delayMillis(delay);
+    g_system->delayMillis(delay);
 }
 
 } // namespace Got
diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index 92328dfd723..089ec56abd4 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -31,307 +31,307 @@
 namespace Got {
 
 void next_frame(ACTOR *actr) {
-	actr->frame_count--;
+    actr->frame_count--;
 
-	if (actr->frame_count <= 0) {
-		actr->next++;
+    if (actr->frame_count <= 0) {
+        actr->next++;
 
-		if (actr->next > 3)
-			actr->next = 0;
+        if (actr->next > 3)
+            actr->next = 0;
 
-		actr->frame_count = actr->frame_speed;
-	}
+        actr->frame_count = actr->frame_speed;
+    }
 }
 
 bool point_within(int x, int y, int x1, int y1, int x2, int y2) {
-	return ((x >= x1) && (x <= x2) && (y >= y1) && (y <= y2));
+    return ((x >= x1) && (x <= x2) && (y >= y1) && (y <= y2));
 }
 
 bool overlap(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
-	if ((x1 >= x3) && (x1 <= x4) && (y1 >= y3) && (y1 <= y4)) return true;
-	if ((x2 >= x3) && (x2 <= x4) && (y2 >= y3) && (y2 <= y4)) return true;
-	if ((x1 >= x3) && (x1 <= x4) && (y2 >= y3) && (y2 <= y4)) return true;
-	if ((x2 >= x3) && (x2 <= x4) && (y1 >= y3) && (y1 <= y4)) return true;
-	if ((x3 >= x1) && (x3 <= x2) && (y3 >= y1) && (y3 <= y2)) return true;
-	if ((x4 >= x1) && (x4 <= x2) && (y4 >= y1) && (y4 <= y2)) return true;
-	if ((x3 >= x1) && (x3 <= x2) && (y4 >= y1) && (y4 <= y2)) return true;
-	if ((x4 >= x1) && (x4 <= x2) && (y3 >= y1) && (y3 <= y2)) return true;
-	return false;
+    if ((x1 >= x3) && (x1 <= x4) && (y1 >= y3) && (y1 <= y4)) return true;
+    if ((x2 >= x3) && (x2 <= x4) && (y2 >= y3) && (y2 <= y4)) return true;
+    if ((x1 >= x3) && (x1 <= x4) && (y2 >= y3) && (y2 <= y4)) return true;
+    if ((x2 >= x3) && (x2 <= x4) && (y1 >= y3) && (y1 <= y4)) return true;
+    if ((x3 >= x1) && (x3 <= x2) && (y3 >= y1) && (y3 <= y2)) return true;
+    if ((x4 >= x1) && (x4 <= x2) && (y4 >= y1) && (y4 <= y2)) return true;
+    if ((x3 >= x1) && (x3 <= x2) && (y4 >= y1) && (y4 <= y2)) return true;
+    if ((x4 >= x1) && (x4 <= x2) && (y3 >= y1) && (y3 <= y2)) return true;
+    return false;
 }
 
 int reverse_direction(ACTOR *actr) {
-	if (actr->dir == 1) return 0;
-	if (actr->dir == 2) return 3;
-	if (actr->dir == 3) return 2;
-	return 1;
+    if (actr->dir == 1) return 0;
+    if (actr->dir == 2) return 3;
+    if (actr->dir == 3) return 2;
+    return 1;
 }
 
 void thor_shoots() {
-	if ((_G(hammer)->used != 1) && (!_G(hammer)->dead) && (!_G(thor)->shot_cnt)) {
-		play_sound(SWISH, 0);
-		_G(thor)->shot_cnt = 20;
-		_G(hammer)->used = 1;
-		_G(hammer)->dir = _G(thor)->dir;
-		_G(hammer)->last_dir = _G(thor)->dir;
-		_G(hammer)->x = _G(thor)->x;
-		_G(hammer)->y = _G(thor)->y + 2;
-		_G(hammer)->move = 2;
-		_G(hammer)->next = 0;
-		_G(hammer)->last_x[0] = _G(hammer)->x;
-		_G(hammer)->last_x[1] = _G(hammer)->x;
-		_G(hammer)->last_y[0] = _G(hammer)->y;
-		_G(hammer)->last_y[1] = _G(hammer)->y;
-	}
+    if ((_G(hammer)->used != 1) && (!_G(hammer)->dead) && (!_G(thor)->shot_cnt)) {
+        play_sound(SWISH, 0);
+        _G(thor)->shot_cnt = 20;
+        _G(hammer)->used = 1;
+        _G(hammer)->dir = _G(thor)->dir;
+        _G(hammer)->last_dir = _G(thor)->dir;
+        _G(hammer)->x = _G(thor)->x;
+        _G(hammer)->y = _G(thor)->y + 2;
+        _G(hammer)->move = 2;
+        _G(hammer)->next = 0;
+        _G(hammer)->last_x[0] = _G(hammer)->x;
+        _G(hammer)->last_x[1] = _G(hammer)->x;
+        _G(hammer)->last_y[0] = _G(hammer)->y;
+        _G(hammer)->last_y[1] = _G(hammer)->y;
+    }
 }
 
 int kill_good_guy(void) {
-	if (!_G(killgg_inform) && !_G(thunder_flag)) {
-		odin_speaks(2010, 0);
-		_G(killgg_inform) = 1;
-	}
+    if (!_G(killgg_inform) && !_G(thunder_flag)) {
+        odin_speaks(2010, 0);
+        _G(killgg_inform) = 1;
+    }
 
-	add_score(-1000);
-	return 0;
+    add_score(-1000);
+    return 0;
 }
 
 void actor_damaged(ACTOR *actr, int damage) {
-	if (!_G(setup).skill)
-		damage *= 2;
-	else if (_G(setup).skill == 2)
-		damage /= 2;
-
-	if (!actr->vunerable && actr->type != 3 && (actr->solid & 0x7f) != 2) {
-		actr->vunerable = STAMINA;
-		if (damage >= actr->health) {
-			if (actr->type != 4) {
-				add_score(actr->init_health * 10);
-
-			} else {
-				kill_good_guy();
-			}
-
-			actor_destroyed(actr);
-		} else {
-			actr->show = 10;
-			actr->health -= damage;
-			actr->speed_count += 8;
-		}
-	} else if (!actr->vunerable) {
-		actr->vunerable = STAMINA;
-
-		if (actr->func_num == 4) {
-			switch_icons();
-		}
-		if (actr->func_num == 7) {
-			rotate_arrows();
-		}
-	}
+    if (!_G(setup).skill)
+        damage *= 2;
+    else if (_G(setup).skill == 2)
+        damage /= 2;
+
+    if (!actr->vunerable && actr->type != 3 && (actr->solid & 0x7f) != 2) {
+        actr->vunerable = STAMINA;
+        if (damage >= actr->health) {
+            if (actr->type != 4) {
+                add_score(actr->init_health * 10);
+
+            } else {
+                kill_good_guy();
+            }
+
+            actor_destroyed(actr);
+        } else {
+            actr->show = 10;
+            actr->health -= damage;
+            actr->speed_count += 8;
+        }
+    } else if (!actr->vunerable) {
+        actr->vunerable = STAMINA;
+
+        if (actr->func_num == 4) {
+            switch_icons();
+        }
+        if (actr->func_num == 7) {
+            rotate_arrows();
+        }
+    }
 
 }
 
 void thor_damaged(ACTOR *actr) {
-	int damage;
-
-	actr->hit_thor = 1;
-
-	// If we're invincible, ignore any damage
-	if (_G(cheats).freezeHealth)
-		return;
-
-	if (GAME3 && actr->func_num == 11) {
-		if (actr->talk_counter) {
-			actr->talk_counter--;
-			return;
-		}
-
-		int t = actr->type;
-		actr->type = 4;
-		actor_speaks(actr, 0, 0);
-		actr->type = t;
-		actr->talk_counter = 30;
-		return;
-	}
-
-	damage = actr->strength;
-	if (damage != 255) {
-		if (!_G(setup).skill) damage /= 2;
-		else if (_G(setup).skill == 2) damage *= 2;
-	}
-	if ((!_G(thor)->vunerable && !_G(shield_on)) || damage == 255) {
-		if (damage >= _G(thor)->health) {
-			_G(thor)->vunerable = 40;
-			_G(thor)->show = 0;
-			_G(thor)->health = 0;
-			_G(exit_flag) = 2;
-			g_events->send(GameMessage("THOR_DIES"));
-		} else if (damage) {
-			_G(thor)->vunerable = 40;
-			_G(sound).play_sound(OW, 0);
-			_G(thor)->show = 10;
-			_G(thor)->health -= damage;
-		}
-	}
+    int damage;
+
+    actr->hit_thor = 1;
+
+    // If we're invincible, ignore any damage
+    if (_G(cheats).freezeHealth)
+        return;
+
+    if (GAME3 && actr->func_num == 11) {
+        if (actr->talk_counter) {
+            actr->talk_counter--;
+            return;
+        }
+
+        int t = actr->type;
+        actr->type = 4;
+        actor_speaks(actr, 0, 0);
+        actr->type = t;
+        actr->talk_counter = 30;
+        return;
+    }
+
+    damage = actr->strength;
+    if (damage != 255) {
+        if (!_G(setup).skill) damage /= 2;
+        else if (_G(setup).skill == 2) damage *= 2;
+    }
+    if ((!_G(thor)->vunerable && !_G(shield_on)) || damage == 255) {
+        if (damage >= _G(thor)->health) {
+            _G(thor)->vunerable = 40;
+            _G(thor)->show = 0;
+            _G(thor)->health = 0;
+            _G(exit_flag) = 2;
+            g_events->send(GameMessage("THOR_DIES"));
+        } else if (damage) {
+            _G(thor)->vunerable = 40;
+            _G(sound).play_sound(OW, 0);
+            _G(thor)->show = 10;
+            _G(thor)->health -= damage;
+        }
+    }
 }
 
 void actor_destroyed(ACTOR *actr) {
-	int x, y, x1, y1, r, n, t;
-	int pge = _G(pge);
-
-	if (actr->actor_num > 2) {
-		x = actr->last_x[pge ^ 1];
-		y = actr->last_y[pge ^ 1];
-		x1 = actr->last_x[pge];
-		y1 = actr->last_y[pge];
-		r = actr->rating;
-		n = actr->actor_num;
-		t = actr->type;
-
-		if (actr->func_num == 255)
-			actr->copyFixedAndPics(_G(explosion));
-		else
-			actr->copyFixedAndPics(_G(sparkle));
-
-		actr->type = t;
-		actr->actor_num = n;
-		actr->rating = r;
-		actr->x = x;
-		actr->y = y;
-		actr->last_x[pge] = x1;
-		actr->last_x[pge ^ 1] = x;
-		actr->last_y[pge] = y1;
-		actr->last_y[pge ^ 1] = y;
-		actr->speed_count = actr->speed;
-		actr->used = 1;
-		actr->num_shots = 3;  // used to reverse explosion
-		actr->vunerable = 255;
-	} else {
-		actr->dead = 2;
-		actr->used = 0;
-	}
+    int x, y, x1, y1, r, n, t;
+    int pge = _G(pge);
+
+    if (actr->actor_num > 2) {
+        x = actr->last_x[pge ^ 1];
+        y = actr->last_y[pge ^ 1];
+        x1 = actr->last_x[pge];
+        y1 = actr->last_y[pge];
+        r = actr->rating;
+        n = actr->actor_num;
+        t = actr->type;
+
+        if (actr->func_num == 255)
+            actr->copyFixedAndPics(_G(explosion));
+        else
+            actr->copyFixedAndPics(_G(sparkle));
+
+        actr->type = t;
+        actr->actor_num = n;
+        actr->rating = r;
+        actr->x = x;
+        actr->y = y;
+        actr->last_x[pge] = x1;
+        actr->last_x[pge ^ 1] = x;
+        actr->last_y[pge] = y1;
+        actr->last_y[pge ^ 1] = y;
+        actr->speed_count = actr->speed;
+        actr->used = 1;
+        actr->num_shots = 3;  // used to reverse explosion
+        actr->vunerable = 255;
+    } else {
+        actr->dead = 2;
+        actr->used = 0;
+    }
 }
 
 int _actor_shoots(ACTOR *actr, int dir) {
-	int t, i, cx, cy;
-	ACTOR *act;
-
-	t = actr->shot_type - 1;
-	for (i = MAX_ENEMIES + 3; i < MAX_ACTORS; i++) {
-		if ((!_G(actor)[i].used) && (!_G(actor)[i].dead)) {
-			act = &_G(actor)[i];
-			*act = _G(shot)[t];
-
-			if (actr->size_y < act->size_y) cy = actr->y - ((act->size_y - actr->size_y) / 2);
-			else cy = actr->y + ((actr->size_y - act->size_y) / 2);
-			if (actr->size_x < act->size_x) cx = actr->x - ((act->size_x - actr->size_x) / 2);
-			else cx = actr->x + ((actr->size_x - act->size_x) / 2);
-			if (cy > 174) cy = 174;
-			if (cx > 304) cx = 304;
-			act->x = cx;
-			act->y = cy;
-			act->last_dir = dir;
-			act->next = 0;
-			act->dir = dir;
-			if (act->directions == 1) act->dir = 0;
-			else if (act->directions == 4 && act->frames == 1) {
-				act->next = dir;
-				act->dir = 0;
-			}
-			act->frame_count = act->frame_speed;
-			act->speed_count = act->speed;
-			act->last_x[0] = cx;
-			act->last_x[1] = cx;
-			act->last_x[0] = actr->x;
-			act->last_x[1] = actr->x;
-			act->last_y[0] = cy;
-			act->last_y[1] = cy;
-			act->used = 1;
-			act->creator = actr->actor_num;
-			act->move_count = act->num_moves;
-			act->dead = 0;
-			actr->shot_actor = i;
-			actr->num_shots++;
-			actr->shot_cnt = 20;
-			_G(shot_ok) = 0;
-			return 1;
-		}
-	}
-	return 0;
+    int t, i, cx, cy;
+    ACTOR *act;
+
+    t = actr->shot_type - 1;
+    for (i = MAX_ENEMIES + 3; i < MAX_ACTORS; i++) {
+        if ((!_G(actor)[i].used) && (!_G(actor)[i].dead)) {
+            act = &_G(actor)[i];
+            *act = _G(shot)[t];
+
+            if (actr->size_y < act->size_y) cy = actr->y - ((act->size_y - actr->size_y) / 2);
+            else cy = actr->y + ((actr->size_y - act->size_y) / 2);
+            if (actr->size_x < act->size_x) cx = actr->x - ((act->size_x - actr->size_x) / 2);
+            else cx = actr->x + ((actr->size_x - act->size_x) / 2);
+            if (cy > 174) cy = 174;
+            if (cx > 304) cx = 304;
+            act->x = cx;
+            act->y = cy;
+            act->last_dir = dir;
+            act->next = 0;
+            act->dir = dir;
+            if (act->directions == 1) act->dir = 0;
+            else if (act->directions == 4 && act->frames == 1) {
+                act->next = dir;
+                act->dir = 0;
+            }
+            act->frame_count = act->frame_speed;
+            act->speed_count = act->speed;
+            act->last_x[0] = cx;
+            act->last_x[1] = cx;
+            act->last_x[0] = actr->x;
+            act->last_x[1] = actr->x;
+            act->last_y[0] = cy;
+            act->last_y[1] = cy;
+            act->used = 1;
+            act->creator = actr->actor_num;
+            act->move_count = act->num_moves;
+            act->dead = 0;
+            actr->shot_actor = i;
+            actr->num_shots++;
+            actr->shot_cnt = 20;
+            _G(shot_ok) = 0;
+            return 1;
+        }
+    }
+    return 0;
 }
 
 void actor_always_shoots(ACTOR *actr, int dir) {
-	_actor_shoots(actr, dir);
+    _actor_shoots(actr, dir);
 }
 
 int actor_shoots(ACTOR *actr, int dir) {
-	int i, cx, cy, tx, ty;
-	int icn;
-
-	cx = (actr->x + (actr->size_x / 2)) >> 4;
-	cy = ((actr->y + actr->size_y) - 2) >> 4;
-
-	tx = _G(thor)->center_x;
-	ty = _G(thor)->center_y;
-
-	icn = 140;
-	if (_G(shot)[actr->shot_type - 1].flying == 1) icn = 80;
-
-	switch (dir) {
-	case 0:
-		for (i = ty + 1; i <= cy; i++)
-			if (_G(scrn).icon[i][cx] < icn) return 0;
-		break;
-	case 1:
-		for (i = cy; i <= ty; i++)
-			if (_G(scrn).icon[i][cx] < icn) return 0;
-		break;
-	case 2:
-		for (i = tx; i < cx; i++)
-			if (_G(scrn).icon[cy][i] < icn) return 0;
-		break;
-	case 3:
-		for (i = cx; i < tx; i++)
-			if (_G(scrn).icon[cy][i] < icn) return 0;
-		break;
-	}
-	return _actor_shoots(actr, dir);
+    int i, cx, cy, tx, ty;
+    int icn;
+
+    cx = (actr->x + (actr->size_x / 2)) >> 4;
+    cy = ((actr->y + actr->size_y) - 2) >> 4;
+
+    tx = _G(thor)->center_x;
+    ty = _G(thor)->center_y;
+
+    icn = 140;
+    if (_G(shot)[actr->shot_type - 1].flying == 1) icn = 80;
+
+    switch (dir) {
+    case 0:
+        for (i = ty + 1; i <= cy; i++)
+            if (_G(scrn).icon[i][cx] < icn) return 0;
+        break;
+    case 1:
+        for (i = cy; i <= ty; i++)
+            if (_G(scrn).icon[i][cx] < icn) return 0;
+        break;
+    case 2:
+        for (i = tx; i < cx; i++)
+            if (_G(scrn).icon[cy][i] < icn) return 0;
+        break;
+    case 3:
+        for (i = cx; i < tx; i++)
+            if (_G(scrn).icon[cy][i] < icn) return 0;
+        break;
+    }
+    return _actor_shoots(actr, dir);
 }
 
 void move_actor(ACTOR *actr) {
-	int i;
-
-	if (actr->vunerable != 0) actr->vunerable--;
-	if (actr->shot_cnt != 0) actr->shot_cnt--;
-	if (actr->show != 0) actr->show--;
-
-	if (!actr->shot_cnt && _G(shot_ok)) {
-		if (actr->shots_allowed) {
-			if (actr->num_shots < actr->shots_allowed) {
-				shot_pattern_func[actr->shot_pattern](actr);
-			}
-		}
-	}
-
-	actr->speed_count--;
-	if (actr->speed_count <= 0) {
-		if (!actr->move_counter) actr->speed_count = actr->speed;
-		else actr->speed_count = (actr->speed << 1);
-		if (actr->type == 3) i = shot_movement_func[actr->move](actr);
-		else i = movement_func[actr->move](actr);
-		if (actr->directions == 2) i &= 1;
-		if (i != actr->dir) actr->dir = i;
-
-		if (actr->move == 0 && _G(current_level) != _G(new_level) && _G(shield_on)) {
-			_G(actor)[2].x = actr->x - 2;
-			if (_G(actor)[2].x < 0) _G(actor)[2].x = 0;
-			_G(actor)[2].y = actr->y;
-			_G(actor)[2].last_x[0] = _G(actor)[2].x;
-			_G(actor)[2].last_x[1] = _G(actor)[2].x;
-			_G(actor)[2].last_y[0] = _G(actor)[2].y;
-			_G(actor)[2].last_y[1] = _G(actor)[2].y;
-		}
-	} else i = actr->dir;
-
-	actr->x &= 0xfffe;
+    int i;
+
+    if (actr->vunerable != 0) actr->vunerable--;
+    if (actr->shot_cnt != 0) actr->shot_cnt--;
+    if (actr->show != 0) actr->show--;
+
+    if (!actr->shot_cnt && _G(shot_ok)) {
+        if (actr->shots_allowed) {
+            if (actr->num_shots < actr->shots_allowed) {
+                shot_pattern_func[actr->shot_pattern](actr);
+            }
+        }
+    }
+
+    actr->speed_count--;
+    if (actr->speed_count <= 0) {
+        if (!actr->move_counter) actr->speed_count = actr->speed;
+        else actr->speed_count = (actr->speed << 1);
+        if (actr->type == 3) i = shot_movement_func[actr->move](actr);
+        else i = movement_func[actr->move](actr);
+        if (actr->directions == 2) i &= 1;
+        if (i != actr->dir) actr->dir = i;
+
+        if (actr->move == 0 && _G(current_level) != _G(new_level) && _G(shield_on)) {
+            _G(actor)[2].x = actr->x - 2;
+            if (_G(actor)[2].x < 0) _G(actor)[2].x = 0;
+            _G(actor)[2].y = actr->y;
+            _G(actor)[2].last_x[0] = _G(actor)[2].x;
+            _G(actor)[2].last_x[1] = _G(actor)[2].x;
+            _G(actor)[2].last_y[0] = _G(actor)[2].y;
+            _G(actor)[2].last_y[1] = _G(actor)[2].y;
+        }
+    } else i = actr->dir;
+
+    actr->x &= 0xfffe;
 }
 
 } // namespace Got
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 3622e1287ba..bf7a30cd138 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -95,47 +95,47 @@ int movement_thirtynine(ACTOR *actr);     // Troll 1
 int movement_forty(ACTOR *actr);          // Troll 2
 
 int (*const movement_func[]) (ACTOR *actr) = {
-	movement_zero,
-	movement_one,
-	movement_two,
-	movement_three,
-	movement_four,
-	movement_five,
-	movement_six,
-	movement_seven,
-	movement_eight,
-	movement_nine,
-	movement_ten,
-	movement_eleven,
-	movement_twelve,
-	movement_thirteen,
-	movement_fourteen,
-	movement_fifteen,
-	movement_sixteen,
-	movement_seventeen,
-	movement_eighteen,
-	movement_nineteen,
-	movement_twenty,
-	movement_twentyone,
-	movement_twentytwo,
-	movement_twentythree,
-	movement_twentyfour,
-	movement_twentyfive,
-	movement_twentysix,
-	movement_twentyseven,
-	movement_twentyeight,
-	movement_twentynine,
-	movement_thirty,
-	movement_thirtyone,
-	movement_thirtytwo,
-	movement_thirtythree,
-	movement_thirtyfour,
-	movement_thirtyfive,
-	movement_thirtysix,
-	movement_thirtyseven,
-	movement_thirtyeight,
-	movement_thirtynine,
-	movement_forty
+    movement_zero,
+    movement_one,
+    movement_two,
+    movement_three,
+    movement_four,
+    movement_five,
+    movement_six,
+    movement_seven,
+    movement_eight,
+    movement_nine,
+    movement_ten,
+    movement_eleven,
+    movement_twelve,
+    movement_thirteen,
+    movement_fourteen,
+    movement_fifteen,
+    movement_sixteen,
+    movement_seventeen,
+    movement_eighteen,
+    movement_nineteen,
+    movement_twenty,
+    movement_twentyone,
+    movement_twentytwo,
+    movement_twentythree,
+    movement_twentyfour,
+    movement_twentyfive,
+    movement_twentysix,
+    movement_twentyseven,
+    movement_twentyeight,
+    movement_twentynine,
+    movement_thirty,
+    movement_thirtyone,
+    movement_thirtytwo,
+    movement_thirtythree,
+    movement_thirtyfour,
+    movement_thirtyfive,
+    movement_thirtysix,
+    movement_thirtyseven,
+    movement_thirtyeight,
+    movement_thirtynine,
+    movement_forty
 };
 
 int special_movement_one(ACTOR *actr);
@@ -151,2025 +151,2033 @@ int special_movement_ten(ACTOR *actr);
 int special_movement_eleven(ACTOR *actr);
 
 int (*special_movement_func[])(ACTOR *actr) = {
-	NULL,
-	special_movement_one,
-	special_movement_two,
-	special_movement_three,
-	special_movement_four,
-	special_movement_five,
-	special_movement_six,
-	special_movement_seven,
-	special_movement_eight,
-	special_movement_nine,
-	special_movement_ten,
-	special_movement_eleven
+    NULL,
+    special_movement_one,
+    special_movement_two,
+    special_movement_three,
+    special_movement_four,
+    special_movement_five,
+    special_movement_six,
+    special_movement_seven,
+    special_movement_eight,
+    special_movement_nine,
+    special_movement_ten,
+    special_movement_eleven
 };
 
 
 // Check Thor move
 int check_move0(int x, int y, ACTOR *actr) {
-	int x1, x2, y1, y2;
-	int x3, x4, y3, y4;
-	int i, ti;
-	ACTOR *act;
-	byte icn1, icn2, icn3, icn4;
-
-	_G(thor_icon1) = 0;
-	_G(thor_icon2) = 0;
-	_G(thor_icon3) = 0;
-	_G(thor_icon4) = 0;
-
-	if (x < 0) {
-		if (_G(current_level) > 0) {
-			_G(new_level) = _G(current_level) - 1;
-			actr->x = 304;
-			actr->last_x[0] = 304;
-			actr->last_x[1] = 304;
-			actr->show = 0;
-			actr->move_count = 0;
-			set_thor_vars();
-			return 1;
-		} else return 0;
-	}
-	if (x > 306) {
-		if (_G(current_level) < 119) {
-			_G(new_level) = _G(current_level) + 1;
-			actr->x = 0;
-			actr->last_x[0] = 0;
-			actr->last_x[1] = 0;
-			actr->show = 0;
-			actr->move_count = 0;
-			set_thor_vars();
-			return 1;
-		} else return 0;
-	}
-	if (y < 0) {
-		if (_G(current_level) > 9) {
-			_G(new_level) = _G(current_level) - 10;
-			actr->y = 175;
-			actr->last_y[0] = 175;
-			actr->show = 0;
-			actr->last_y[1] = 175;
-			actr->move_count = 0;
-			set_thor_vars();
-			return 1;
-		} else return 0;
-	}
-	if (y > 175) {
-		if (_G(current_level) < 110) {
-			_G(new_level) = _G(current_level) + 10;
-			actr->y = 0;
-			actr->last_y[0] = 0;
-			actr->last_y[1] = 0;
-			actr->show = 0;
-			actr->move_count = 0;
-			set_thor_vars();
-			return 1;
-		} else return 0;
-	}
-	x1 = (x + 1) >> 4;
-	y1 = (y + 8) >> 4;
-	if (_G(thor)->dir > 1) x2 = (x + 12) >> 4;
-	else x2 = (x + 10) >> 4;
-	y2 = (y + 15) >> 4;
-
-	_G(slip_flag) = 0;
-
-	// Check for cheat flying mode
-	if (!actr->flying) {
-		icn1 = _G(scrn).icon[y1][x1];
-		icn2 = _G(scrn).icon[y2][x1];
-		icn3 = _G(scrn).icon[y1][x2];
-		icn4 = _G(scrn).icon[y2][x2];
-		ti = 0;
-
-		if (icn1 < TILE_FLY) {
-			_G(thor_icon1) = 1; ti = 1;
-		}
-		if (icn2 < TILE_FLY) {
-			_G(thor_icon2) = 1; ti = 1;
-		}
-		if (icn3 < TILE_FLY) {
-			_G(thor_icon3) = 1; ti = 1;
-		}
-		if (icn4 < TILE_FLY) {
-			_G(thor_icon4) = 1; ti = 1;
-		}
-		if (ti) return 0;
-
-		if (icn1 > TILE_SPECIAL) {
-			if (!special_tile_thor(y1, x1, icn1)) return 0;
-			icn2 = _G(scrn).icon[y2][x1];
-			icn3 = _G(scrn).icon[y1][x2];
-			icn4 = _G(scrn).icon[y2][x2];
-		}
-		if (icn2 > TILE_SPECIAL) {
-			if (!special_tile_thor(y2, x1, icn2)) return 0;
-			icn3 = _G(scrn).icon[y1][x2];
-			icn4 = _G(scrn).icon[y2][x2];
-		}
-		if (icn3 > TILE_SPECIAL) {
-			if (!special_tile_thor(y1, x2, icn3)) return 0;
-			icn4 = _G(scrn).icon[y2][x2];
-		}
-		if (icn4 > TILE_SPECIAL) {
-			if (!special_tile_thor(y2, x2, icn4)) return 0;
-		}
-	}
-
-	if (!_G(slip_flag)) {
-		_G(slipping) = 0;
-		_G(slip_cnt) = 0;
-	}
-	if (_G(slip_flag) && !_G(slipping))
-		_G(slip_cnt)++;
-	if (_G(slip_cnt) > 8)
-		_G(slipping) = 1;
-	_G(slip_flag) = 0;
-
-
-	x1 = x + 1;
-	y1 = y + 8;
-	if (_G(thor)->dir > 1) x2 = x + 12;
-	else x2 = x + 12;
-	y2 = y + 15;
-
-	_G(thor_special_flag) = 0;
-	for (i = 3; i < MAX_ACTORS; i++) {
-		act = &_G(actor)[i];
-		if (act->solid & 128) continue;
-		if (!act->used) continue;
-		x3 = act->x + 1;
-		if ((ABS(x3 - x1)) > 16) continue;
-		y3 = act->y + 1;
-		if ((ABS(y3 - y1)) > 16) continue;
-		x4 = act->x + act->size_x - 1;
-		y4 = act->y + act->size_y - 1;
-		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
-			if (act->func_num > 0) { // 255=explosion
-				if (act->func_num == 255) return 0;
-				act->temp1 = x;
-				act->temp2 = y;
-				_G(thor_special_flag) = 1;
-				return special_movement_func[act->func_num](act);
-			} else {
-				_G(thor_special_flag) = 0;
-				thor_damaged(act);
-				if (act->solid < 2) {
-					if (!act->vunerable && (!(act->type & 1))) play_sound(PUNCH1, 0);
-					if (!_G(hammer)->used && _G(key_flag)[key_fire])
-						actor_damaged(act, _G(hammer)->strength);
-					else
-						actor_damaged(act, _G(thor)->strength);
-				}
-			}
-			return 1;
-		}
-	}
-	actr->x = x;
-	actr->y = y;
-	return 1;
+    int x1, x2, y1, y2;
+    int x3, x4, y3, y4;
+    int i, ti;
+    ACTOR *act;
+    byte icn1, icn2, icn3, icn4;
+
+    _G(thor_icon1) = 0;
+    _G(thor_icon2) = 0;
+    _G(thor_icon3) = 0;
+    _G(thor_icon4) = 0;
+
+    if (x < 0) {
+        if (_G(current_level) > 0) {
+            _G(new_level) = _G(current_level) - 1;
+            actr->x = 304;
+            actr->last_x[0] = 304;
+            actr->last_x[1] = 304;
+            actr->show = 0;
+            actr->move_count = 0;
+            set_thor_vars();
+            return 1;
+        } else return 0;
+    }
+    if (x > 306) {
+        if (_G(current_level) < 119) {
+            _G(new_level) = _G(current_level) + 1;
+            actr->x = 0;
+            actr->last_x[0] = 0;
+            actr->last_x[1] = 0;
+            actr->show = 0;
+            actr->move_count = 0;
+            set_thor_vars();
+            return 1;
+        } else return 0;
+    }
+    if (y < 0) {
+        if (_G(current_level) > 9) {
+            _G(new_level) = _G(current_level) - 10;
+            actr->y = 175;
+            actr->last_y[0] = 175;
+            actr->show = 0;
+            actr->last_y[1] = 175;
+            actr->move_count = 0;
+            set_thor_vars();
+            return 1;
+        } else return 0;
+    }
+    if (y > 175) {
+        if (_G(current_level) < 110) {
+            _G(new_level) = _G(current_level) + 10;
+            actr->y = 0;
+            actr->last_y[0] = 0;
+            actr->last_y[1] = 0;
+            actr->show = 0;
+            actr->move_count = 0;
+            set_thor_vars();
+            return 1;
+        } else return 0;
+    }
+    x1 = (x + 1) >> 4;
+    y1 = (y + 8) >> 4;
+    if (_G(thor)->dir > 1) x2 = (x + 12) >> 4;
+    else x2 = (x + 10) >> 4;
+    y2 = (y + 15) >> 4;
+
+    _G(slip_flag) = 0;
+
+    // Check for cheat flying mode
+    if (!actr->flying) {
+        icn1 = _G(scrn).icon[y1][x1];
+        icn2 = _G(scrn).icon[y2][x1];
+        icn3 = _G(scrn).icon[y1][x2];
+        icn4 = _G(scrn).icon[y2][x2];
+        ti = 0;
+
+        if (icn1 < TILE_FLY) {
+            _G(thor_icon1) = 1;
+            ti = 1;
+        }
+        if (icn2 < TILE_FLY) {
+            _G(thor_icon2) = 1;
+            ti = 1;
+        }
+        if (icn3 < TILE_FLY) {
+            _G(thor_icon3) = 1;
+            ti = 1;
+        }
+        if (icn4 < TILE_FLY) {
+            _G(thor_icon4) = 1;
+            ti = 1;
+        }
+        if (ti) return 0;
+
+        if (icn1 > TILE_SPECIAL) {
+            if (!special_tile_thor(y1, x1, icn1)) return 0;
+            icn2 = _G(scrn).icon[y2][x1];
+            icn3 = _G(scrn).icon[y1][x2];
+            icn4 = _G(scrn).icon[y2][x2];
+        }
+        if (icn2 > TILE_SPECIAL) {
+            if (!special_tile_thor(y2, x1, icn2)) return 0;
+            icn3 = _G(scrn).icon[y1][x2];
+            icn4 = _G(scrn).icon[y2][x2];
+        }
+        if (icn3 > TILE_SPECIAL) {
+            if (!special_tile_thor(y1, x2, icn3)) return 0;
+            icn4 = _G(scrn).icon[y2][x2];
+        }
+        if (icn4 > TILE_SPECIAL) {
+            if (!special_tile_thor(y2, x2, icn4)) return 0;
+        }
+    }
+
+    if (!_G(slip_flag)) {
+        _G(slipping) = 0;
+        _G(slip_cnt) = 0;
+    }
+    if (_G(slip_flag) && !_G(slipping))
+        _G(slip_cnt)++;
+    if (_G(slip_cnt) > 8)
+        _G(slipping) = 1;
+    _G(slip_flag) = 0;
+
+
+    x1 = x + 1;
+    y1 = y + 8;
+    if (_G(thor)->dir > 1) x2 = x + 12;
+    else x2 = x + 12;
+    y2 = y + 15;
+
+    _G(thor_special_flag) = 0;
+    for (i = 3; i < MAX_ACTORS; i++) {
+        act = &_G(actor)[i];
+        if (act->solid & 128) continue;
+        if (!act->used) continue;
+        x3 = act->x + 1;
+        if ((ABS(x3 - x1)) > 16) continue;
+        y3 = act->y + 1;
+        if ((ABS(y3 - y1)) > 16) continue;
+        x4 = act->x + act->size_x - 1;
+        y4 = act->y + act->size_y - 1;
+        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
+            if (act->func_num > 0) { // 255=explosion
+                if (act->func_num == 255) return 0;
+                act->temp1 = x;
+                act->temp2 = y;
+                _G(thor_special_flag) = 1;
+                return special_movement_func[act->func_num](act);
+            } else {
+                _G(thor_special_flag) = 0;
+                thor_damaged(act);
+                if (act->solid < 2) {
+                    if (!act->vunerable && (!(act->type & 1))) play_sound(PUNCH1, 0);
+                    if (!_G(hammer)->used && _G(key_flag)[key_fire])
+                        actor_damaged(act, _G(hammer)->strength);
+                    else
+                        actor_damaged(act, _G(thor)->strength);
+                }
+            }
+            return 1;
+        }
+    }
+    actr->x = x;
+    actr->y = y;
+    return 1;
 }
 
 // Check hammer move
-int check_move1(int x, int y, ACTOR *actr) {   
-	int  x1, x2, y1, y2, i;
-	int  x3, y3, x4, y4;
-	int  icn, f;
-	byte icn1, icn2, icn3, icn4;
-
-	ACTOR *act;
-
-	if (x < 0 || x>306 || y < 0 || y>177) return 0;
-
-	x1 = (x + 1) >> 4;
-	y1 = (y + 6) >> 4;
-	x2 = (x + 10) >> 4;
-	y2 = (y + 10) >> 4;
-
-	// Check for solid or fly over
-	icn = TILE_FLY;
-	if (actr->flying) icn = TILE_SOLID;
-
-	icn1 = _G(scrn).icon[y1][x1];
-	icn2 = _G(scrn).icon[y2][x1];
-	icn3 = _G(scrn).icon[y1][x2];
-	icn4 = _G(scrn).icon[y2][x2];
-	if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) {
-		if (actr->actor_num == 1 && actr->move == 2) play_sound(CLANG, 0);
-		return 0;
-	}
-
-	if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
-	if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
-	if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
-	if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
-
-	x1 = x + 1;
-	y1 = y + 1;
-	x2 = x + 10;
-	y2 = y + 10;
-
-	f = 0;
-	for (i = 3; i < MAX_ACTORS; i++) {
-		act = &_G(actor)[i];
-		if (!act->used) continue;
-		if (act->type == 3) continue;
-		x3 = act->x;
-		if ((ABS(x3 - x1)) > 16) continue;
-		y3 = act->y;
-		if ((ABS(y3 - y1)) > 16) continue;
-		x4 = act->x + act->size_x - 1;
-		y4 = act->y + act->size_y - 1;
-
-		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
-			if (_G(boss_active) && !GAME3) {
-				switch (_G(area)) {
-				case 1:
-					check_boss1_hit(act, x1, y1, x2, y2, i);
-					break;
-				case 2:
-					check_boss2_hit(act, x1, y1, x2, y2, i);
-					break;
-				default:
-					// Area 3 boss Loki isn't checked here
-					break;
-				}
-			} else {
-				if (act->solid == 2 && (actr->move == 16 || actr->move == 17))
-					return 0;
-				actor_damaged(act, actr->strength);
-			}
-			f++;
-		}
-	}
-	if (f && actr->move == 2) return 0;
-	actr->x = x;
-	actr->y = y;
-	return 1;
+int check_move1(int x, int y, ACTOR *actr) {
+    int  x1, x2, y1, y2, i;
+    int  x3, y3, x4, y4;
+    int  icn, f;
+    byte icn1, icn2, icn3, icn4;
+
+    ACTOR *act;
+
+    if (x < 0 || x>306 || y < 0 || y>177) return 0;
+
+    x1 = (x + 1) >> 4;
+    y1 = (y + 6) >> 4;
+    x2 = (x + 10) >> 4;
+    y2 = (y + 10) >> 4;
+
+    // Check for solid or fly over
+    icn = TILE_FLY;
+    if (actr->flying) icn = TILE_SOLID;
+
+    icn1 = _G(scrn).icon[y1][x1];
+    icn2 = _G(scrn).icon[y2][x1];
+    icn3 = _G(scrn).icon[y1][x2];
+    icn4 = _G(scrn).icon[y2][x2];
+    if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) {
+        if (actr->actor_num == 1 && actr->move == 2) play_sound(CLANG, 0);
+        return 0;
+    }
+
+    if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
+    if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
+    if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
+    if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
+
+    x1 = x + 1;
+    y1 = y + 1;
+    x2 = x + 10;
+    y2 = y + 10;
+
+    f = 0;
+    for (i = 3; i < MAX_ACTORS; i++) {
+        act = &_G(actor)[i];
+        if (!act->used) continue;
+        if (act->type == 3) continue;
+        x3 = act->x;
+        if ((ABS(x3 - x1)) > 16) continue;
+        y3 = act->y;
+        if ((ABS(y3 - y1)) > 16) continue;
+        x4 = act->x + act->size_x - 1;
+        y4 = act->y + act->size_y - 1;
+
+        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
+            if (_G(boss_active) && !GAME3) {
+                switch (_G(area)) {
+                case 1:
+                    check_boss1_hit(act, x1, y1, x2, y2, i);
+                    break;
+                case 2:
+                    check_boss2_hit(act, x1, y1, x2, y2, i);
+                    break;
+                default:
+                    // Area 3 boss Loki isn't checked here
+                    break;
+                }
+            } else {
+                if (act->solid == 2 && (actr->move == 16 || actr->move == 17))
+                    return 0;
+                actor_damaged(act, actr->strength);
+            }
+            f++;
+        }
+    }
+    if (f && actr->move == 2) return 0;
+    actr->x = x;
+    actr->y = y;
+    return 1;
 }
 
 // Check enemy move
 int check_move2(int x, int y, ACTOR *actr) {
-	int x1, x2, y1, y2, i;
-	int x3, y3, x4, y4;
-	int icn;
-	byte icn1, icn2, icn3, icn4;
-
-	ACTOR *act;
-
-	if (actr->actor_num < 3) return check_move1(x, y, actr);
-
-	if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175) return 0;
-
-	x1 = (x + 1) >> 4;
-	if (!actr->func_num) y1 = (y + (actr->size_y / 2)) >> 4;
-	else y1 = (y + 1) >> 4;
-	x2 = ((x + actr->size_x) - 1) >> 4;
-	y2 = ((y + actr->size_y) - 1) >> 4;
-
-	// Check for solid or fly over
-
-	icn = TILE_FLY;
-	if (actr->flying) icn = TILE_SOLID;
-
-
-	icn1 = _G(scrn).icon[y1][x1];
-	icn2 = _G(scrn).icon[y2][x1];
-	icn3 = _G(scrn).icon[y1][x2];
-	icn4 = _G(scrn).icon[y2][x2];
-	if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) return 0;
-
-	if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
-	if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
-	if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
-	if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
-
-	x1 = x + 1;
-	y1 = y + 1;
-	x2 = (x + actr->size_x) - 1;
-	y2 = (y + actr->size_y) - 1;
-
-	for (i = 0; i < MAX_ACTORS; i++) {
-		act = &_G(actor)[i];
-		if (act->actor_num == actr->actor_num) continue;
-		if (act->actor_num == 1) continue;
-		if (!act->used) continue;
-		if (act->type == 3) continue;   // Shot
-		if (i == 0) {
-			if (overlap(x1, y1, x2, y2, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
-				thor_damaged(actr);
-				return 0;
-			}
-		} else {
-			x3 = act->x;
-			if ((ABS(x3 - x1)) > 16) continue;
-			y3 = act->y;
-			if ((ABS(y3 - y1)) > 16) continue;
-			x4 = act->x + act->size_x;
-			y4 = act->y + act->size_y;
-			if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
-				if (actr->move == 38) {
-					if (act->func_num == 4)
-						_G(switch_flag) = 1;
-					else if (act->func_num == 7)
-						_G(switch_flag) = 2;
-				}
-				return 0;
-			}
-		}
-	}
-	actr->x = x;
-	actr->y = y;
-	return 1;
+    int x1, x2, y1, y2, i;
+    int x3, y3, x4, y4;
+    int icn;
+    byte icn1, icn2, icn3, icn4;
+
+    ACTOR *act;
+
+    if (actr->actor_num < 3) return check_move1(x, y, actr);
+
+    if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175) return 0;
+
+    x1 = (x + 1) >> 4;
+    if (!actr->func_num) y1 = (y + (actr->size_y / 2)) >> 4;
+    else y1 = (y + 1) >> 4;
+    x2 = ((x + actr->size_x) - 1) >> 4;
+    y2 = ((y + actr->size_y) - 1) >> 4;
+
+    // Check for solid or fly over
+
+    icn = TILE_FLY;
+    if (actr->flying) icn = TILE_SOLID;
+
+
+    icn1 = _G(scrn).icon[y1][x1];
+    icn2 = _G(scrn).icon[y2][x1];
+    icn3 = _G(scrn).icon[y1][x2];
+    icn4 = _G(scrn).icon[y2][x2];
+    if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) return 0;
+
+    if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
+    if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
+    if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
+    if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
+
+    x1 = x + 1;
+    y1 = y + 1;
+    x2 = (x + actr->size_x) - 1;
+    y2 = (y + actr->size_y) - 1;
+
+    for (i = 0; i < MAX_ACTORS; i++) {
+        act = &_G(actor)[i];
+        if (act->actor_num == actr->actor_num) continue;
+        if (act->actor_num == 1) continue;
+        if (!act->used) continue;
+        if (act->type == 3) continue;   // Shot
+        if (i == 0) {
+            if (overlap(x1, y1, x2, y2, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
+                thor_damaged(actr);
+                return 0;
+            }
+        } else {
+            x3 = act->x;
+            if ((ABS(x3 - x1)) > 16) continue;
+            y3 = act->y;
+            if ((ABS(y3 - y1)) > 16) continue;
+            x4 = act->x + act->size_x;
+            y4 = act->y + act->size_y;
+            if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
+                if (actr->move == 38) {
+                    if (act->func_num == 4)
+                        _G(switch_flag) = 1;
+                    else if (act->func_num == 7)
+                        _G(switch_flag) = 2;
+                }
+                return 0;
+            }
+        }
+    }
+    actr->x = x;
+    actr->y = y;
+    return 1;
 }
 
 // Check enemy shot move
 int check_move3(int x, int y, ACTOR *actr) {
-	int x1, x2, y1, y2;
-	int x3, x4, y3, y4, i;
-	byte icn1, icn2, icn3, icn4;
-	ACTOR *act;
-
-	int icn;
-
-	if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175) return 0;
-
-	x1 = (x + 1) >> 4;
-	y1 = (y + (actr->size_y / 2)) >> 4;
-	x2 = ((x + actr->size_x) - 1) >> 4;
-	y2 = ((y + actr->size_y) - 1) >> 4;
-
-	// Check for solid or fly over
-
-	icn = TILE_FLY;
-	if (actr->flying) icn = TILE_SOLID;
-
-	icn1 = _G(scrn).icon[y1][x1];
-	icn2 = _G(scrn).icon[y2][x1];
-	icn3 = _G(scrn).icon[y1][x2];
-	icn4 = _G(scrn).icon[y2][x2];
-	if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) return 0;
-
-	if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
-	if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
-	if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
-	if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
-
-	// Check for solid or fly over
-	x1 = x + 1;
-	y1 = y + 1;
-	x2 = (x + actr->size_x) - 1;
-	y2 = (y + actr->size_y) - 1;
-
-	if (overlap(x1, y1, x2, y2, _G(thor_x1), _G(thor_real_y1), _G(thor_x2), _G(thor_y2))) {
-		thor_damaged(actr);
-		return 0;
-	}
-	for (i = 3; i < MAX_ACTORS; i++) {
-		if (i == actr->actor_num) continue;
-		act = &_G(actor)[i];
-		if (!act->used) continue;
-		if (act->solid < 2) continue;
-		if (act->type == 3) continue;   // Shot
-		if (act->actor_num == actr->creator) continue;
-		x3 = act->x;
-		if ((ABS(x3 - x1)) > 16) continue;
-		y3 = act->y;
-		if ((ABS(y3 - y1)) > 16) continue;
-		x4 = x3 + 15;
-		y4 = y3 + 15;
-		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) return 0;
-	}
-	actr->x = x;
-	actr->y = y;
-	return 1;
+    int x1, x2, y1, y2;
+    int x3, x4, y3, y4, i;
+    byte icn1, icn2, icn3, icn4;
+    ACTOR *act;
+
+    int icn;
+
+    if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175) return 0;
+
+    x1 = (x + 1) >> 4;
+    y1 = (y + (actr->size_y / 2)) >> 4;
+    x2 = ((x + actr->size_x) - 1) >> 4;
+    y2 = ((y + actr->size_y) - 1) >> 4;
+
+    // Check for solid or fly over
+
+    icn = TILE_FLY;
+    if (actr->flying) icn = TILE_SOLID;
+
+    icn1 = _G(scrn).icon[y1][x1];
+    icn2 = _G(scrn).icon[y2][x1];
+    icn3 = _G(scrn).icon[y1][x2];
+    icn4 = _G(scrn).icon[y2][x2];
+    if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) return 0;
+
+    if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
+    if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
+    if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
+    if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
+
+    // Check for solid or fly over
+    x1 = x + 1;
+    y1 = y + 1;
+    x2 = (x + actr->size_x) - 1;
+    y2 = (y + actr->size_y) - 1;
+
+    if (overlap(x1, y1, x2, y2, _G(thor_x1), _G(thor_real_y1), _G(thor_x2), _G(thor_y2))) {
+        thor_damaged(actr);
+        return 0;
+    }
+    for (i = 3; i < MAX_ACTORS; i++) {
+        if (i == actr->actor_num) continue;
+        act = &_G(actor)[i];
+        if (!act->used) continue;
+        if (act->solid < 2) continue;
+        if (act->type == 3) continue;   // Shot
+        if (act->actor_num == actr->creator) continue;
+        x3 = act->x;
+        if ((ABS(x3 - x1)) > 16) continue;
+        y3 = act->y;
+        if ((ABS(y3 - y1)) > 16) continue;
+        x4 = x3 + 15;
+        y4 = y3 + 15;
+        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) return 0;
+    }
+    actr->x = x;
+    actr->y = y;
+    return 1;
 }
 
 // Flying enemies
 int check_move4(int x, int y, ACTOR *actr) {
-	if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175) return 0;
-	if (overlap(x, y, x + actr->size_x - 1, y + actr->size_y - 1,
-		_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
-		if (actr->type == 3) thor_damaged(actr);
-		return 0;
-	}
-	actr->x = x;
-	actr->y = y;
-	return 1;
+    if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175) return 0;
+    if (overlap(x, y, x + actr->size_x - 1, y + actr->size_y - 1,
+                _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
+        if (actr->type == 3) thor_damaged(actr);
+        return 0;
+    }
+    actr->x = x;
+    actr->y = y;
+    return 1;
 }
 
 #define THOR_PAD1 2
 #define THOR_PAD2 4
 
 int  check_thor_move(int x, int y, ACTOR *actr) {
-	if (check_move0(x, y, actr))
-		return 1;
-	if (_G(diag_flag) || _G(thor_special_flag))
-		return 0;
-	if ((_G(thor_icon1) + _G(thor_icon2) + _G(thor_icon3) + _G(thor_icon4)) > 1)
-		return 0;
-
-	switch (actr->dir) {
-	case 0:
-		if (_G(thor_icon1)) {
-			actr->dir = 3;
-			if (check_move0(x + THOR_PAD1, y + 2, actr)) {
-				actr->dir = 0;
-				return 1;
-			}
-		} else if (_G(thor_icon3)) {
-			actr->dir = 2;
-			if (check_move0(x - THOR_PAD1, y + 2, actr)) {
-				actr->dir = 0;
-				return 1;
-			}
-		}
-		actr->dir = 0;
-		break;
-	case 1:
-		if (_G(thor_icon2)) {
-			actr->dir = 3;
-			if (check_move0(x + THOR_PAD1, y - 2, actr)) {
-				actr->dir = 1;
-				return 1;
-			}
-		} else if (_G(thor_icon4)) {
-			actr->dir = 2;
-			if (check_move0(x - THOR_PAD1, y - 2, actr)) {
-				actr->dir = 1;
-				return 1;
-			}
-		}
-		actr->dir = 1;
-		break;
-	case 2:
-		if (_G(thor_icon1)) {
-			if (check_move0(x + 2, y + THOR_PAD1, actr)) return 1;
-		} else if (_G(thor_icon2)) {
-			if (check_move0(x + 2, y - THOR_PAD1, actr)) return 1;
-		}
-		break;
-	case 3:
-		if (_G(thor_icon3)) {
-			if (check_move0(x - 2, y + THOR_PAD1, actr)) return 1;
-		} else if (_G(thor_icon4)) {
-			if (check_move0(x - 2, y - THOR_PAD1, actr)) return 1;
-		}
-		break;
-	}
-
-	return 0;
+    if (check_move0(x, y, actr))
+        return 1;
+    if (_G(diag_flag) || _G(thor_special_flag))
+        return 0;
+    if ((_G(thor_icon1) + _G(thor_icon2) + _G(thor_icon3) + _G(thor_icon4)) > 1)
+        return 0;
+
+    switch (actr->dir) {
+    case 0:
+        if (_G(thor_icon1)) {
+            actr->dir = 3;
+            if (check_move0(x + THOR_PAD1, y + 2, actr)) {
+                actr->dir = 0;
+                return 1;
+            }
+        } else if (_G(thor_icon3)) {
+            actr->dir = 2;
+            if (check_move0(x - THOR_PAD1, y + 2, actr)) {
+                actr->dir = 0;
+                return 1;
+            }
+        }
+        actr->dir = 0;
+        break;
+    case 1:
+        if (_G(thor_icon2)) {
+            actr->dir = 3;
+            if (check_move0(x + THOR_PAD1, y - 2, actr)) {
+                actr->dir = 1;
+                return 1;
+            }
+        } else if (_G(thor_icon4)) {
+            actr->dir = 2;
+            if (check_move0(x - THOR_PAD1, y - 2, actr)) {
+                actr->dir = 1;
+                return 1;
+            }
+        }
+        actr->dir = 1;
+        break;
+    case 2:
+        if (_G(thor_icon1)) {
+            if (check_move0(x + 2, y + THOR_PAD1, actr)) return 1;
+        } else if (_G(thor_icon2)) {
+            if (check_move0(x + 2, y - THOR_PAD1, actr)) return 1;
+        }
+        break;
+    case 3:
+        if (_G(thor_icon3)) {
+            if (check_move0(x - 2, y + THOR_PAD1, actr)) return 1;
+        } else if (_G(thor_icon4)) {
+            if (check_move0(x - 2, y - THOR_PAD1, actr)) return 1;
+        }
+        break;
+    }
+
+    return 0;
 }
 
 // Player control
 int movement_zero(ACTOR *actr) {
-	int d, x, y, od;
-	d = actr->dir;
-	od = d;
-
-	set_thor_vars();
-
-	if ((_G(hammer)->used) && (_G(hammer)->move == 5)) {
-		if (overlap(_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2),
-			_G(hammer)->x, _G(hammer)->y, _G(hammer)->x + 13, _G(hammer)->y + 13)) {
-			actor_destroyed(_G(hammer));
-		}
-	}
-	x = actr->x;
-	y = actr->y;
-	_G(diag_flag) = 0;
-	if (actr->move_counter) actr->move_counter--;
-
-	if (_G(slipping)) {
-		if (_G(slip_cnt) == 8) play_sound(FALL, 1);
-		y += 2;
-		_G(slip_cnt)--;
-		if (!_G(slip_cnt))
-			_G(slipping) = false;
-
-		check_thor_move(x, y, actr);
-		_G(thor)->speed_count = 4;
-		return d;
-	}
-
-	if (_G(key_flag)[key_up] && _G(key_flag)[key_left]) {
-		d = 2;
-		actr->dir = d;
-		_G(diag) = 1;
-		_G(diag_flag) = 1;
-		if (check_thor_move(x - 2, y - 2, actr)) {
-			next_frame(actr);
-			return d;
-		}
-	} else if (_G(key_flag)[key_up] && _G(key_flag)[key_right]) {
-		d = 3;
-		actr->dir = d;
-		_G(diag) = 2;
-		_G(diag_flag) = 1;
-		if (check_thor_move(x + 2, y - 2, actr)) {
-			next_frame(actr);
-			return d;
-		}
-	} else if (_G(key_flag)[key_down] && _G(key_flag)[key_left]) {
-		d = 2;
-		actr->dir = d;
-		_G(diag) = 4;
-		_G(diag_flag) = 1;
-		if (check_thor_move(x - 2, y + 2, actr)) {
-			next_frame(actr);
-			return d;
-		}
-	} else if (_G(key_flag)[key_down] && _G(key_flag)[key_right]) {
-		d = 3;
-		actr->dir = d;
-		_G(diag) = 3;
-		_G(diag_flag) = 1;
-		if (check_thor_move(x + 2, y + 2, actr)) {
-			next_frame(actr);
-			return d;
-		}
-	}
-	_G(diag) = 0;
-	if (_G(key_flag)[key_right]) {
-		if (!_G(key_flag)[key_left]) {
-			d = 3;
-			actr->dir = d;
-			if (check_thor_move(x + 2, y, actr)) {
-				next_frame(actr);
-				return d;
-			}
-		}
-	}
-	if (_G(key_flag)[key_left]) {
-		if (!_G(key_flag)[key_right]) {
-			d = 2;
-			actr->dir = d;
-			if (check_thor_move(x - 2, y, actr)) {
-				next_frame(actr);
-				return d;
-			}
-		}
-	}
-	if (_G(key_flag)[key_down]) {
-		if (!_G(key_flag)[key_up]) {
-			d = 1;
-			actr->dir = d;
-			if (check_thor_move(x, y + 2, actr)) {
-				next_frame(actr);
-				return d;
-			}
-		}
-	}
-	if (_G(key_flag)[key_up]) {
-		if (!_G(key_flag)[key_down]) {
-			d = 0;
-			actr->dir = d;
-			if (check_thor_move(x, y - 2, actr)) {
-				next_frame(actr);
-				return d;
-			}
-		}
-	}
-	actr->move_counter = 5;
-	actr->next = 0;
-	actr->dir = od;
-	return d;
+    int d, x, y, od;
+    d = actr->dir;
+    od = d;
+
+    set_thor_vars();
+
+    if ((_G(hammer)->used) && (_G(hammer)->move == 5)) {
+        if (overlap(_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2),
+                    _G(hammer)->x, _G(hammer)->y, _G(hammer)->x + 13, _G(hammer)->y + 13)) {
+            actor_destroyed(_G(hammer));
+        }
+    }
+    x = actr->x;
+    y = actr->y;
+    _G(diag_flag) = 0;
+    if (actr->move_counter) actr->move_counter--;
+
+    if (_G(slipping)) {
+        if (_G(slip_cnt) == 8) play_sound(FALL, 1);
+        y += 2;
+        _G(slip_cnt)--;
+        if (!_G(slip_cnt))
+            _G(slipping) = false;
+
+        check_thor_move(x, y, actr);
+        _G(thor)->speed_count = 4;
+        return d;
+    }
+
+    if (_G(key_flag)[key_up] && _G(key_flag)[key_left]) {
+        d = 2;
+        actr->dir = d;
+        _G(diag) = 1;
+        _G(diag_flag) = 1;
+        if (check_thor_move(x - 2, y - 2, actr)) {
+            next_frame(actr);
+            return d;
+        }
+    } else if (_G(key_flag)[key_up] && _G(key_flag)[key_right]) {
+        d = 3;
+        actr->dir = d;
+        _G(diag) = 2;
+        _G(diag_flag) = 1;
+        if (check_thor_move(x + 2, y - 2, actr)) {
+            next_frame(actr);
+            return d;
+        }
+    } else if (_G(key_flag)[key_down] && _G(key_flag)[key_left]) {
+        d = 2;
+        actr->dir = d;
+        _G(diag) = 4;
+        _G(diag_flag) = 1;
+        if (check_thor_move(x - 2, y + 2, actr)) {
+            next_frame(actr);
+            return d;
+        }
+    } else if (_G(key_flag)[key_down] && _G(key_flag)[key_right]) {
+        d = 3;
+        actr->dir = d;
+        _G(diag) = 3;
+        _G(diag_flag) = 1;
+        if (check_thor_move(x + 2, y + 2, actr)) {
+            next_frame(actr);
+            return d;
+        }
+    }
+    _G(diag) = 0;
+    if (_G(key_flag)[key_right]) {
+        if (!_G(key_flag)[key_left]) {
+            d = 3;
+            actr->dir = d;
+            if (check_thor_move(x + 2, y, actr)) {
+                next_frame(actr);
+                return d;
+            }
+        }
+    }
+    if (_G(key_flag)[key_left]) {
+        if (!_G(key_flag)[key_right]) {
+            d = 2;
+            actr->dir = d;
+            if (check_thor_move(x - 2, y, actr)) {
+                next_frame(actr);
+                return d;
+            }
+        }
+    }
+    if (_G(key_flag)[key_down]) {
+        if (!_G(key_flag)[key_up]) {
+            d = 1;
+            actr->dir = d;
+            if (check_thor_move(x, y + 2, actr)) {
+                next_frame(actr);
+                return d;
+            }
+        }
+    }
+    if (_G(key_flag)[key_up]) {
+        if (!_G(key_flag)[key_down]) {
+            d = 0;
+            actr->dir = d;
+            if (check_thor_move(x, y - 2, actr)) {
+                next_frame(actr);
+                return d;
+            }
+        }
+    }
+    actr->move_counter = 5;
+    actr->next = 0;
+    actr->dir = od;
+    return d;
 }
 
 int check_special_move1(int x, int y, ACTOR *actr) {
-	int x1, x2, y1, y2, i;
-	int x3, y3, x4, y4;
-	int icn;
-	byte icn1, icn2, icn3, icn4;
-
-	ACTOR *act;
-
-	if (actr->actor_num < 3) return check_move1(x, y, actr);
-
-	if (x < 0 || x>304 || y < 0 || y>176) return 0;
-
-	x1 = x >> 4;
-	y1 = y >> 4;
-	x2 = (x + 15) >> 4;
-	y2 = (y + 15) >> 4;
-
-	// Check for solid or fly over
-
-	icn = TILE_FLY;
-	if (actr->flying) icn = TILE_SOLID;
-
-	icn1 = _G(scrn).icon[y1][x1];
-	icn2 = _G(scrn).icon[y2][x1];
-	icn3 = _G(scrn).icon[y1][x2];
-	icn4 = _G(scrn).icon[y2][x2];
-	if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) return 0;
-
-	if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
-	if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
-	if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
-	if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
-
-	x1 = x;
-	y1 = y;
-	x2 = (x + 15);
-	y2 = (y + 15);
-
-	for (i = 3; i < MAX_ACTORS; i++) {
-		act = &_G(actor)[i];
-		if (act->actor_num == actr->actor_num) continue;
-		if (!act->used) continue;
-		if (act->type == 3) continue;   //shot
-		x3 = act->x;
-		if ((ABS(x3 - x1)) > 16) continue;
-		y3 = act->y;
-		if ((ABS(y3 - y1)) > 16) continue;
-		x4 = act->x + act->size_x;
-		y4 = act->y + 15;
-		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) return 0;
-	}
-	for (i = 3; i < MAX_ACTORS; i++) {
-		act = &_G(actor)[i];
-		if (act->actor_num == actr->actor_num) continue;
-		if (!act->used) continue;
-		if (act->type == 3) continue;   // Shot
-		x3 = act->x;
-		if ((ABS(x3 - x1)) > 16) continue;
-		y3 = act->y;
-		if ((ABS(y3 - y1)) > 16) continue;
-		x4 = act->x + act->size_x;
-		y4 = act->y + act->size_y;
-		if (overlap(_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2), x3, y3, x4, y4)) return 0;
-	}
-	actr->x = x;
-	actr->y = y;
-	return 1;
+    int x1, x2, y1, y2, i;
+    int x3, y3, x4, y4;
+    int icn;
+    byte icn1, icn2, icn3, icn4;
+
+    ACTOR *act;
+
+    if (actr->actor_num < 3) return check_move1(x, y, actr);
+
+    if (x < 0 || x>304 || y < 0 || y>176) return 0;
+
+    x1 = x >> 4;
+    y1 = y >> 4;
+    x2 = (x + 15) >> 4;
+    y2 = (y + 15) >> 4;
+
+    // Check for solid or fly over
+
+    icn = TILE_FLY;
+    if (actr->flying) icn = TILE_SOLID;
+
+    icn1 = _G(scrn).icon[y1][x1];
+    icn2 = _G(scrn).icon[y2][x1];
+    icn3 = _G(scrn).icon[y1][x2];
+    icn4 = _G(scrn).icon[y2][x2];
+    if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) return 0;
+
+    if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
+    if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
+    if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
+    if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
+
+    x1 = x;
+    y1 = y;
+    x2 = (x + 15);
+    y2 = (y + 15);
+
+    for (i = 3; i < MAX_ACTORS; i++) {
+        act = &_G(actor)[i];
+        if (act->actor_num == actr->actor_num) continue;
+        if (!act->used) continue;
+        if (act->type == 3) continue;   //shot
+        x3 = act->x;
+        if ((ABS(x3 - x1)) > 16) continue;
+        y3 = act->y;
+        if ((ABS(y3 - y1)) > 16) continue;
+        x4 = act->x + act->size_x;
+        y4 = act->y + 15;
+        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) return 0;
+    }
+    for (i = 3; i < MAX_ACTORS; i++) {
+        act = &_G(actor)[i];
+        if (act->actor_num == actr->actor_num) continue;
+        if (!act->used) continue;
+        if (act->type == 3) continue;   // Shot
+        x3 = act->x;
+        if ((ABS(x3 - x1)) > 16) continue;
+        y3 = act->y;
+        if ((ABS(y3 - y1)) > 16) continue;
+        x4 = act->x + act->size_x;
+        y4 = act->y + act->size_y;
+        if (overlap(_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2), x3, y3, x4, y4)) return 0;
+    }
+    actr->x = x;
+    actr->y = y;
+    return 1;
 }
 
 //*==========================================================================
 
 // Block
 int special_movement_one(ACTOR *actr) {
-	int d, x1, y1, sd;
-
-	if (_G(diag_flag)) return 0;
-	d = _G(thor)->dir;
-	x1 = actr->x;
-	y1 = actr->y;
-	sd = actr->last_dir;
-	actr->last_dir = d;
-
-	switch (d) {
-	case 0:
-		y1 -= 2;
-		if (!check_special_move1(x1, y1, actr)) {
-			actr->last_dir = sd;
-			return 0;
-		}
-		break;
-	case 1:
-		y1 += 2;
-		if (!check_special_move1(x1, y1, actr)) {
-			actr->last_dir = sd;
-			return 0;
-		}
-		break;
-	case 2:
-		x1 -= 2;
-		if (!check_special_move1(x1, y1, actr)) {
-			actr->last_dir = sd;
-			return 0;
-		}
-		break;
-	case 3:
-		x1 += 2;
-		if (!check_special_move1(x1, y1, actr)) {
-			actr->last_dir = sd;
-			return 0;
-		}
-		break;
-	}
-	next_frame(actr);
-	actr->last_dir = d;
-	return 1;
+    int d, x1, y1, sd;
+
+    if (_G(diag_flag)) return 0;
+    d = _G(thor)->dir;
+    x1 = actr->x;
+    y1 = actr->y;
+    sd = actr->last_dir;
+    actr->last_dir = d;
+
+    switch (d) {
+    case 0:
+        y1 -= 2;
+        if (!check_special_move1(x1, y1, actr)) {
+            actr->last_dir = sd;
+            return 0;
+        }
+        break;
+    case 1:
+        y1 += 2;
+        if (!check_special_move1(x1, y1, actr)) {
+            actr->last_dir = sd;
+            return 0;
+        }
+        break;
+    case 2:
+        x1 -= 2;
+        if (!check_special_move1(x1, y1, actr)) {
+            actr->last_dir = sd;
+            return 0;
+        }
+        break;
+    case 3:
+        x1 += 2;
+        if (!check_special_move1(x1, y1, actr)) {
+            actr->last_dir = sd;
+            return 0;
+        }
+        break;
+    }
+    next_frame(actr);
+    actr->last_dir = d;
+    return 1;
 }
 
 // Angle
 int special_movement_two(ACTOR *actr) {
-	int x1, y1, x2, y2, i;
-	int x3, y3, x4, y4;
-	ACTOR *act;
-
-	x1 = actr->temp1;       // Calc thor pos
-	y1 = actr->temp2;
-	x2 = x1 + 13;
-	y2 = y1 + 14;
-
-	for (i = 3; i < MAX_ACTORS; i++) {
-		act = &_G(actor)[i];
-		if (actr->actor_num == act->actor_num) continue;
-		if (!act->used) continue;
-		x3 = act->x;
-		if ((ABS(x3 - x1)) > 16) continue;
-		y3 = act->y;
-		if ((ABS(y3 - y1)) > 16) continue;
-		x4 = act->x + act->size_x;
-		y4 = act->y + act->size_y;
-		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) return 0;
-	}
-	if (!actr->func_pass) {
-		if (_G(thor)->health < 150) {
-			if (!sound_playing()) play_sound(ANGEL, 0);
-			_G(thor)->health += 1;
-			display_health();
-		}
-	} else {
-		if (_G(thor_info).magic < 150) {
-			if (!sound_playing()) play_sound(ANGEL, 0);
-			_G(thor_info).magic += 1;
-			display_magic();
-		}
-	}
-	return 1;
+    int x1, y1, x2, y2, i;
+    int x3, y3, x4, y4;
+    ACTOR *act;
+
+    x1 = actr->temp1;       // Calc thor pos
+    y1 = actr->temp2;
+    x2 = x1 + 13;
+    y2 = y1 + 14;
+
+    for (i = 3; i < MAX_ACTORS; i++) {
+        act = &_G(actor)[i];
+        if (actr->actor_num == act->actor_num) continue;
+        if (!act->used) continue;
+        x3 = act->x;
+        if ((ABS(x3 - x1)) > 16) continue;
+        y3 = act->y;
+        if ((ABS(y3 - y1)) > 16) continue;
+        x4 = act->x + act->size_x;
+        y4 = act->y + act->size_y;
+        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) return 0;
+    }
+    if (!actr->func_pass) {
+        if (_G(thor)->health < 150) {
+            if (!sound_playing()) play_sound(ANGEL, 0);
+            _G(thor)->health += 1;
+            display_health();
+        }
+    } else {
+        if (_G(thor_info).magic < 150) {
+            if (!sound_playing()) play_sound(ANGEL, 0);
+            _G(thor_info).magic += 1;
+            display_magic();
+        }
+    }
+    return 1;
 }
 
 // Yellow globe
 int special_movement_three(ACTOR *actr) {
-	long lind;
+    long lind;
 
-	if (_G(thunder_flag))
-		return 0;
+    if (_G(thunder_flag))
+        return 0;
 
-	lind = (long)_G(current_level);
-	lind = lind * 1000;
-	lind += (long)actr->actor_num;
-	execute_script(lind, _G(odin));
+    lind = (long)_G(current_level);
+    lind = lind * 1000;
+    lind += (long)actr->actor_num;
+    execute_script(lind, _G(odin));
 
-	return 0;
+    return 0;
 }
 
 // Peg switch
 int special_movement_four(ACTOR *actr) {
-	if (actr->shot_cnt != 0) return 0;
-	actr->shot_cnt = 30;
-	actr = actr;
-	_G(switch_flag) = 1;
-	return 0;
+    if (actr->shot_cnt != 0) return 0;
+    actr->shot_cnt = 30;
+    actr = actr;
+    _G(switch_flag) = 1;
+    return 0;
 }
 
 // Boulder roll
 int special_movement_five(ACTOR *actr) {
-	int d;
-
-	d = _G(thor)->dir;
-
-	if (_G(diag_flag)) {
-		switch (_G(diag)) {
-		case 1:
-			if (_G(thor_x1) < (actr->x + 15)) d = 0;
-			else d = 2;
-			break;
-		case 2:
-			if (_G(thor_x2) < actr->x) d = 3;
-			else d = 0;
-			break;
-		case 3:
-			if (_G(thor_x2) > (actr->x)) d = 1;
-			else d = 3;
-			break;
-		case 4:
-			if (_G(thor_x1) > (actr->x + 15)) d = 2;
-			else d = 1;
-			break;
-		}
-	}
-
-	actr->last_dir = d;
-	actr->move = 14;
-	return 0;
+    int d;
+
+    d = _G(thor)->dir;
+
+    if (_G(diag_flag)) {
+        switch (_G(diag)) {
+        case 1:
+            if (_G(thor_x1) < (actr->x + 15)) d = 0;
+            else d = 2;
+            break;
+        case 2:
+            if (_G(thor_x2) < actr->x) d = 3;
+            else d = 0;
+            break;
+        case 3:
+            if (_G(thor_x2) > (actr->x)) d = 1;
+            else d = 3;
+            break;
+        case 4:
+            if (_G(thor_x1) > (actr->x + 15)) d = 2;
+            else d = 1;
+            break;
+        }
+    }
+
+    actr->last_dir = d;
+    actr->move = 14;
+    return 0;
 }
 
 int special_movement_six(ACTOR *actr) {
-	thor_damaged(actr);
-	return 0;
+    thor_damaged(actr);
+    return 0;
 }
 
 int special_movement_seven(ACTOR *actr) {
-	if (actr->shot_cnt != 0) return 0;
-	actr->shot_cnt = 30;
-	actr = actr;
-	_G(switch_flag) = 2;
-	return 0;
+    if (actr->shot_cnt != 0) return 0;
+    actr->shot_cnt = 30;
+    actr = actr;
+    _G(switch_flag) = 2;
+    return 0;
 }
 
 int special_movement_eight(ACTOR *actr) {
-	if (_G(thor)->dir < 2 || _G(diag_flag)) return 0;
-	actr->last_dir = _G(thor)->dir;
-	actr->move = 14;
-	return 0;
+    if (_G(thor)->dir < 2 || _G(diag_flag)) return 0;
+    actr->last_dir = _G(thor)->dir;
+    actr->move = 14;
+    return 0;
 }
 
 int special_movement_nine(ACTOR *actr) {
-	if (_G(thor)->dir > 1 || _G(diag_flag)) return 0;
-	actr->last_dir = _G(thor)->dir;
-	actr->move = 14;
-	return 0;
+    if (_G(thor)->dir > 1 || _G(diag_flag)) return 0;
+    actr->last_dir = _G(thor)->dir;
+    actr->move = 14;
+    return 0;
 }
 
 int special_movement_ten(ACTOR *actr) {
-	byte &actor_ctr = GAME1 ? actr->temp6 : actr->talk_counter;
+    byte &actor_ctr = GAME1 ? actr->temp6 : actr->talk_counter;
 
-	if (actor_ctr) {
-		actor_ctr--;
-		return 0;
-	}
+    if (actor_ctr) {
+        actor_ctr--;
+        return 0;
+    }
 
-	if (_G(thunder_flag))
-		return 0;
+    if (_G(thunder_flag))
+        return 0;
 
-	if (!actor_ctr) {
-		actor_ctr = 10;
-		actor_speaks(actr, 0 - actr->pass_value, 0);
-	}
+    if (!actor_ctr) {
+        actor_ctr = 10;
+        actor_speaks(actr, 0 - actr->pass_value, 0);
+    }
 
-	return 0;
+    return 0;
 }
 
 // Red guard
 int special_movement_eleven(ACTOR *actr) {
-	int t;
+    int t;
 
-	if (actr->talk_counter) {
-		actr->talk_counter--;
-		return 0;
-	}
+    if (actr->talk_counter) {
+        actr->talk_counter--;
+        return 0;
+    }
 
-	t = actr->type;
-	actr->type = 4;
-	actor_speaks(actr, 0, 0);
-	actr->type = t;
-	actr->talk_counter = 10;
+    t = actr->type;
+    actr->type = 4;
+    actor_speaks(actr, 0, 0);
+    actr->type = t;
+    actr->talk_counter = 10;
 
-	return 0;
+    return 0;
 }
 
 // No movement - frame cycle
 int movement_one(ACTOR *actr) {
-	next_frame(actr);
-	return actr->dir;
+    next_frame(actr);
+    return actr->dir;
 }
 
 // Hammer only
 int movement_two(ACTOR *actr) {
-	int d, x1, y1;
-
-	d = actr->last_dir;
-	x1 = actr->x;
-	y1 = actr->y;
-
-	switch (d) {
-	case 0:
-		y1 -= 2;
-		break;
-	case 1:
-		y1 += 2;
-		break;
-	case 2:
-		x1 -= 2;
-		break;
-	case 3:
-		x1 += 2;
-		break;
-	}
-	if (!check_move2(x1, y1, actr)) {
-		if (actr->actor_num == 1) {
-			_G(hammer)->move = 5;
-			d = reverse_direction(_G(hammer));
-			_G(hammer)->dir = d;
-		}
-		if (actr->actor_num == 2) {
-			actr->used = 0;
-			actr->dead = 2;
-			_G(lightning_used) = 0;
-			_G(tornado_used) = 0;
-		}
-	}
-	next_frame(actr);
-	actr->last_dir = d;
-	if (actr->directions == 1) return 0;
-	return d;
+    int d, x1, y1;
+
+    d = actr->last_dir;
+    x1 = actr->x;
+    y1 = actr->y;
+
+    switch (d) {
+    case 0:
+        y1 -= 2;
+        break;
+    case 1:
+        y1 += 2;
+        break;
+    case 2:
+        x1 -= 2;
+        break;
+    case 3:
+        x1 += 2;
+        break;
+    }
+    if (!check_move2(x1, y1, actr)) {
+        if (actr->actor_num == 1) {
+            _G(hammer)->move = 5;
+            d = reverse_direction(_G(hammer));
+            _G(hammer)->dir = d;
+        }
+        if (actr->actor_num == 2) {
+            actr->used = 0;
+            actr->dead = 2;
+            _G(lightning_used) = 0;
+            _G(tornado_used) = 0;
+        }
+    }
+    next_frame(actr);
+    actr->last_dir = d;
+    if (actr->directions == 1) return 0;
+    return d;
 }
 
 // Walk-bump-random turn
 int movement_three(ACTOR *actr) {
-	int d, x1, y1;
-
-	d = actr->last_dir;
-	x1 = actr->x;
-	y1 = actr->y;
-
-	switch (d) {
-	case 0:
-		y1 -= 2;
-		if (!check_move2(x1, y1, actr)) {
-			d = g_events->getRandomNumber(3);
-		}
-		break;
-	case 1:
-		y1 += 2;
-		if (!check_move2(x1, y1, actr)) {
-			d = g_events->getRandomNumber(3);
-		}
-		break;
-	case 2:
-		x1 -= 2;
-		if (!check_move2(x1, y1, actr)) {
-			d = g_events->getRandomNumber(3);
-		}
-		break;
-	case 3:
-		x1 += 2;
-		if (!check_move2(x1, y1, actr)) {
-			d = g_events->getRandomNumber(3);
-		}
-		break;
-	}
-	next_frame(actr);
-	actr->last_dir = d;
-	if (actr->directions == 1) return 0;
-	return d;
+    int d, x1, y1;
+
+    d = actr->last_dir;
+    x1 = actr->x;
+    y1 = actr->y;
+
+    switch (d) {
+    case 0:
+        y1 -= 2;
+        if (!check_move2(x1, y1, actr)) {
+            d = g_events->getRandomNumber(3);
+        }
+        break;
+    case 1:
+        y1 += 2;
+        if (!check_move2(x1, y1, actr)) {
+            d = g_events->getRandomNumber(3);
+        }
+        break;
+    case 2:
+        x1 -= 2;
+        if (!check_move2(x1, y1, actr)) {
+            d = g_events->getRandomNumber(3);
+        }
+        break;
+    case 3:
+        x1 += 2;
+        if (!check_move2(x1, y1, actr)) {
+            d = g_events->getRandomNumber(3);
+        }
+        break;
+    }
+    next_frame(actr);
+    actr->last_dir = d;
+    if (actr->directions == 1) return 0;
+    return d;
 }
 
 // Simple tracking
 int movement_four(ACTOR *actr) {
-	int d, x1, y1, f;
-
-	d = actr->last_dir;
-
-	x1 = actr->x;
-	y1 = actr->y;
-
-	f = 0;
-	if (x1 > _G(thor_x1) - 1) {
-		x1 -= 2; d = 2; f = 1;
-	} else if (x1 < _G(thor_x1) - 1) {
-		x1 += 2; d = 3; f = 1;
-	}
-
-	if (f) f = check_move2(x1, y1, actr);
-
-	if (!f) {
-		if (y1 < (_G(thor_real_y1))) {
-			d = (_G(thor_real_y1))-y1;
-			if (d > 2) d = 2;
-			y1 += d;
-			d = 1;
-			f = 1;
-		} else if (y1 > (_G(thor_real_y1))) {
-			d = y1 - (_G(thor_real_y1));
-			if (d > 2) d = 2;
-			y1 -= d;
-			d = 0;
-			f = 1;
-		}
-		if (f) f = check_move2(actr->x, y1, actr);
-		if (!f) check_move2(actr->x, actr->y, actr);
-	}
-	next_frame(actr);
-	actr->last_dir = d;
-	if (actr->directions == 1) return 0;
-	return d;
+    int d, x1, y1, f;
+
+    d = actr->last_dir;
+
+    x1 = actr->x;
+    y1 = actr->y;
+
+    f = 0;
+    if (x1 > _G(thor_x1) - 1) {
+        x1 -= 2;
+        d = 2;
+        f = 1;
+    } else if (x1 < _G(thor_x1) - 1) {
+        x1 += 2;
+        d = 3;
+        f = 1;
+    }
+
+    if (f) f = check_move2(x1, y1, actr);
+
+    if (!f) {
+        if (y1 < (_G(thor_real_y1))) {
+            d = (_G(thor_real_y1))-y1;
+            if (d > 2) d = 2;
+            y1 += d;
+            d = 1;
+            f = 1;
+        } else if (y1 > (_G(thor_real_y1))) {
+            d = y1 - (_G(thor_real_y1));
+            if (d > 2) d = 2;
+            y1 -= d;
+            d = 0;
+            f = 1;
+        }
+        if (f) f = check_move2(actr->x, y1, actr);
+        if (!f) check_move2(actr->x, actr->y, actr);
+    }
+    next_frame(actr);
+    actr->last_dir = d;
+    if (actr->directions == 1) return 0;
+    return d;
 }
 
 int movement_five(ACTOR *actr) {
-	int x1, y1, xd, yd, d;
-
-	x1 = actr->x;
-	y1 = actr->y;
-	xd = yd = 0;
-	d = actr->last_dir;
-
-	if (x1 > (_G(thor)->x + 1)) xd = -2;  //+1
-	else if (x1 < (_G(thor)->x - 1)) xd = 2;
-
-	if (actr->actor_num == 1) {
-		if (y1 < (_G(thor_y1) - 6)) yd = 2;
-		else if (y1 > (_G(thor_y1) - 6)) yd = -2;
-	} else {
-		if (y1 < (_G(thor_real_y1) - 1)) yd = 2;
-		else if (y1 > (_G(thor_real_y1) + 1)) yd = -2;
-	}
-
-	if (xd && yd) {
-		if (xd == -2 && yd == -2) d = 2;
-		else if (xd == -2 && yd == 2) d = 2;
-		else if (xd == 2 && yd == -2) d = 3;
-		else if (xd == 2 && yd == 2) d = 3;
-		x1 += xd;
-		y1 += yd;
-		if (check_move2(x1, y1, actr)) {
-			next_frame(actr);
-			actr->last_dir = d;
-			if (actr->directions == 1) return 0;
-			return d;
-		}
-	} else {
-		if (xd == 0 && yd == 2) d = 1;
-		else if (xd == 0 && yd == -2) d = 0;
-		else if (xd == 2 && yd == 0) d = 3;
-		else if (xd == -2 && yd == 0) d = 2;
-	}
-	x1 = actr->x;
-	y1 = actr->y;
-	actr->toggle ^= 1;
-
-	if (actr->toggle) {
-		if (xd) {
-			x1 += xd;
-			if (check_move2(x1, y1, actr)) {
-				if (xd > 0) d = 3;
-				else d = 2;
-				next_frame(actr);
-				actr->last_dir = d;
-				if (actr->directions == 1) return 0;
-				return d;
-			}
-			x1 = actr->x;
-		}
-		if (yd) {
-			y1 += yd;
-			if (check_move2(x1, y1, actr)) {
-				if (yd > 0) d = 1;
-				else d = 0;
-				next_frame(actr);
-				actr->last_dir = d;
-				if (actr->directions == 1) return 0;
-				return d;
-			}
-		}
-		y1 = actr->y;
-	} else {
-		if (yd) {
-			y1 += yd;
-			if (check_move2(x1, y1, actr)) {
-				if (yd > 0) d = 1;
-				else d = 0;
-				next_frame(actr);
-				actr->last_dir = d;
-				if (actr->directions == 1) return 0;
-				return d;
-			}
-			y1 = actr->y;
-		}
-		if (xd) {
-			x1 += xd;
-			if (check_move2(x1, y1, actr)) {
-				if (xd > 0) d = 3;
-				else d = 2;
-				next_frame(actr);
-				actr->last_dir = d;
-				if (actr->directions == 1) return 0;
-				return d;
-			}
-		}
-	}
-	check_move2(actr->x, actr->y, actr);
-	next_frame(actr);
-	actr->last_dir = d;
-	if (actr->directions == 1) return 0;
-	return d;
+    int x1, y1, xd, yd, d;
+
+    x1 = actr->x;
+    y1 = actr->y;
+    xd = yd = 0;
+    d = actr->last_dir;
+
+    if (x1 > (_G(thor)->x + 1)) xd = -2;  //+1
+    else if (x1 < (_G(thor)->x - 1)) xd = 2;
+
+    if (actr->actor_num == 1) {
+        if (y1 < (_G(thor_y1) - 6)) yd = 2;
+        else if (y1 > (_G(thor_y1) - 6)) yd = -2;
+    } else {
+        if (y1 < (_G(thor_real_y1) - 1)) yd = 2;
+        else if (y1 > (_G(thor_real_y1) + 1)) yd = -2;
+    }
+
+    if (xd && yd) {
+        if (xd == -2 && yd == -2) d = 2;
+        else if (xd == -2 && yd == 2) d = 2;
+        else if (xd == 2 && yd == -2) d = 3;
+        else if (xd == 2 && yd == 2) d = 3;
+        x1 += xd;
+        y1 += yd;
+        if (check_move2(x1, y1, actr)) {
+            next_frame(actr);
+            actr->last_dir = d;
+            if (actr->directions == 1) return 0;
+            return d;
+        }
+    } else {
+        if (xd == 0 && yd == 2) d = 1;
+        else if (xd == 0 && yd == -2) d = 0;
+        else if (xd == 2 && yd == 0) d = 3;
+        else if (xd == -2 && yd == 0) d = 2;
+    }
+    x1 = actr->x;
+    y1 = actr->y;
+    actr->toggle ^= 1;
+
+    if (actr->toggle) {
+        if (xd) {
+            x1 += xd;
+            if (check_move2(x1, y1, actr)) {
+                if (xd > 0) d = 3;
+                else d = 2;
+                next_frame(actr);
+                actr->last_dir = d;
+                if (actr->directions == 1) return 0;
+                return d;
+            }
+            x1 = actr->x;
+        }
+        if (yd) {
+            y1 += yd;
+            if (check_move2(x1, y1, actr)) {
+                if (yd > 0) d = 1;
+                else d = 0;
+                next_frame(actr);
+                actr->last_dir = d;
+                if (actr->directions == 1) return 0;
+                return d;
+            }
+        }
+        y1 = actr->y;
+    } else {
+        if (yd) {
+            y1 += yd;
+            if (check_move2(x1, y1, actr)) {
+                if (yd > 0) d = 1;
+                else d = 0;
+                next_frame(actr);
+                actr->last_dir = d;
+                if (actr->directions == 1) return 0;
+                return d;
+            }
+            y1 = actr->y;
+        }
+        if (xd) {
+            x1 += xd;
+            if (check_move2(x1, y1, actr)) {
+                if (xd > 0) d = 3;
+                else d = 2;
+                next_frame(actr);
+                actr->last_dir = d;
+                if (actr->directions == 1) return 0;
+                return d;
+            }
+        }
+    }
+    check_move2(actr->x, actr->y, actr);
+    next_frame(actr);
+    actr->last_dir = d;
+    if (actr->directions == 1) return 0;
+    return d;
 }
 
 // Explosion only
 int movement_six(ACTOR *actr) {
-	if (actr->num_shots > 0) {
-		actr->next++;
-		if (actr->next > 2) {
-			actr->next = 0;
-			if (_G(boss_dead)) play_sound(EXPLODE, 0);
-		}
-		actr->num_shots--;
-	} else {
-		actr->dead = 2;
-		actr->used = 0;
-		if (!_G(boss_dead) && !_G(endgame))
-			if (actr->type == 2)
-				drop_object(actr);
-
-	}
-
-	next_frame(actr);
-	return 0;
+    if (actr->num_shots > 0) {
+        actr->next++;
+        if (actr->next > 2) {
+            actr->next = 0;
+            if (_G(boss_dead)) play_sound(EXPLODE, 0);
+        }
+        actr->num_shots--;
+    } else {
+        actr->dead = 2;
+        actr->used = 0;
+        if (!_G(boss_dead) && !_G(endgame))
+            if (actr->type == 2)
+                drop_object(actr);
+
+    }
+
+    next_frame(actr);
+    return 0;
 }
 
 // Walk-bump-random turn (pause also)
 int movement_seven(ACTOR *actr) {
-	if (actr->next == 0 && actr->frame_count == actr->frame_speed) {
-		actr->speed_count = 12;
-		actr->last_dir = g_events->getRandomNumber(3);
-	}
-	return movement_three(actr);
+    if (actr->next == 0 && actr->frame_count == actr->frame_speed) {
+        actr->speed_count = 12;
+        actr->last_dir = g_events->getRandomNumber(3);
+    }
+    return movement_three(actr);
 }
 
 // Follow thor
 int movement_eight(ACTOR *actr) {
-	if (_G(thor)->x > 0) actr->x = _G(thor)->x - 1;
-	else actr->x = _G(thor)->x;
-	actr->y = _G(thor)->y;
-	next_frame(actr);
-	return 0;
+    if (_G(thor)->x > 0) actr->x = _G(thor)->x - 1;
+    else actr->x = _G(thor)->x;
+    actr->y = _G(thor)->y;
+    next_frame(actr);
+    return 0;
 }
 
 // 4-way straight (random length) change
 int movement_nine(ACTOR *actr) {
-	int d, x1, y1, f;
-
-	d = actr->last_dir;
-	x1 = actr->x;
-	y1 = actr->y;
-
-	f = 0;
-	if (actr->counter) {
-		actr->counter--;
-		switch (d) {
-		case 0:
-			y1 -= 2;
-			if (!check_move4(x1, y1, actr)) f = 1;
-			break;
-		case 1:
-			y1 += 2;
-			if (!check_move4(x1, y1, actr)) f = 1;
-			break;
-		case 2:
-			x1 -= 2;
-			if (!check_move4(x1, y1, actr)) f = 1;
-			break;
-		case 3:
-			x1 += 2;
-			if (!check_move4(x1, y1, actr)) f = 1;
-			break;
-		}
-	} else f = 1;
-
-	if (f == 1) {
-		actr->counter = g_events->getRandomNumber(10, 99);
-		d = g_events->getRandomNumber(3);
-	}
-	next_frame(actr);
-	actr->last_dir = d;
-	if (actr->directions == 1) return 0;
-	return d;
+    int d, x1, y1, f;
+
+    d = actr->last_dir;
+    x1 = actr->x;
+    y1 = actr->y;
+
+    f = 0;
+    if (actr->counter) {
+        actr->counter--;
+        switch (d) {
+        case 0:
+            y1 -= 2;
+            if (!check_move4(x1, y1, actr)) f = 1;
+            break;
+        case 1:
+            y1 += 2;
+            if (!check_move4(x1, y1, actr)) f = 1;
+            break;
+        case 2:
+            x1 -= 2;
+            if (!check_move4(x1, y1, actr)) f = 1;
+            break;
+        case 3:
+            x1 += 2;
+            if (!check_move4(x1, y1, actr)) f = 1;
+            break;
+        }
+    } else f = 1;
+
+    if (f == 1) {
+        actr->counter = g_events->getRandomNumber(10, 99);
+        d = g_events->getRandomNumber(3);
+    }
+    next_frame(actr);
+    actr->last_dir = d;
+    if (actr->directions == 1) return 0;
+    return d;
 }
 
 // Vert straight (random length) change
 int movement_ten(ACTOR *actr) {
-	int d, x1, y1, f;
-
-	d = actr->last_dir;
-	x1 = actr->x;
-	y1 = actr->y;
-
-	f = 0;
-	if (actr->counter) {
-		if (actr->pass_value != 1) actr->counter--;
-		switch (d) {
-		case 0:
-			y1 -= 2;
-			if (!check_move2(x1, y1, actr)) f = 1;
-			break;
-		case 1:
-			y1 += 2;
-			if (!check_move2(x1, y1, actr)) f = 1;
-			break;
-		case 2:
-			y1 -= 2;
-			if (!check_move2(x1, y1, actr)) f = 1;
-			break;
-		case 3:
-			y1 += 2;
-			if (!check_move2(x1, y1, actr)) f = 1;
-			break;
-		}
-	} else f = 1;
-
-	if (f == 1) {
-		actr->counter = g_events->getRandomNumber(10, 99);
-		d = g_events->getRandomNumber(1);
-	}
-
-	if (d > 1)
-		d -= 2;
-
-	next_frame(actr);
-	actr->last_dir = d;
-	if (actr->directions == 1) return 0;
-	return d;
+    int d, x1, y1, f;
+
+    d = actr->last_dir;
+    x1 = actr->x;
+    y1 = actr->y;
+
+    f = 0;
+    if (actr->counter) {
+        if (actr->pass_value != 1) actr->counter--;
+        switch (d) {
+        case 0:
+            y1 -= 2;
+            if (!check_move2(x1, y1, actr)) f = 1;
+            break;
+        case 1:
+            y1 += 2;
+            if (!check_move2(x1, y1, actr)) f = 1;
+            break;
+        case 2:
+            y1 -= 2;
+            if (!check_move2(x1, y1, actr)) f = 1;
+            break;
+        case 3:
+            y1 += 2;
+            if (!check_move2(x1, y1, actr)) f = 1;
+            break;
+        }
+    } else f = 1;
+
+    if (f == 1) {
+        actr->counter = g_events->getRandomNumber(10, 99);
+        d = g_events->getRandomNumber(1);
+    }
+
+    if (d > 1)
+        d -= 2;
+
+    next_frame(actr);
+    actr->last_dir = d;
+    if (actr->directions == 1) return 0;
+    return d;
 }
 
 // Horz only (bats)
 int movement_eleven(ACTOR *actr) {
-	int d;
-
-	d = actr->last_dir;
-
-	switch (d) {
-	case 0:
-		if (check_move2(actr->x - 2, actr->y - 2, actr)) break;
-		d = 1;
-		if (check_move2(actr->x - 2, actr->y + 2, actr)) break;
-		d = 2;
-		break;
-	case 1:
-		if (check_move2(actr->x - 2, actr->y + 2, actr)) break;
-		d = 0;
-		if (check_move2(actr->x - 2, actr->y - 2, actr)) break;
-		d = 3;
-		break;
-	case 2:
-		if (check_move2(actr->x + 2, actr->y - 2, actr)) break;
-		d = 3;
-		if (check_move2(actr->x + 2, actr->y + 2, actr)) break;
-		d = 0;
-		break;
-	case 3:
-		if (check_move2(actr->x + 2, actr->y + 2, actr)) break;
-		d = 2;
-		if (check_move2(actr->x + 2, actr->y - 2, actr)) break;
-		d = 1;
-		break;
-	}
-
-	next_frame(actr);
-	actr->last_dir = d;
-	if (actr->directions == 1) return 0;
-	return d;
+    int d;
+
+    d = actr->last_dir;
+
+    switch (d) {
+    case 0:
+        if (check_move2(actr->x - 2, actr->y - 2, actr)) break;
+        d = 1;
+        if (check_move2(actr->x - 2, actr->y + 2, actr)) break;
+        d = 2;
+        break;
+    case 1:
+        if (check_move2(actr->x - 2, actr->y + 2, actr)) break;
+        d = 0;
+        if (check_move2(actr->x - 2, actr->y - 2, actr)) break;
+        d = 3;
+        break;
+    case 2:
+        if (check_move2(actr->x + 2, actr->y - 2, actr)) break;
+        d = 3;
+        if (check_move2(actr->x + 2, actr->y + 2, actr)) break;
+        d = 0;
+        break;
+    case 3:
+        if (check_move2(actr->x + 2, actr->y + 2, actr)) break;
+        d = 2;
+        if (check_move2(actr->x + 2, actr->y - 2, actr)) break;
+        d = 1;
+        break;
+    }
+
+    next_frame(actr);
+    actr->last_dir = d;
+    if (actr->directions == 1) return 0;
+    return d;
 }
 
 // Horz straight until bump
 int movement_twelve(ACTOR *actr) {
-	int d;
-
-	d = actr->last_dir;
-
-	switch (d) {
-	case 0:
-	case 2:
-		if (check_move2(actr->x - 2, actr->y, actr)) break;
-		d = 3;
-		break;
-	case 1:
-	case 3:
-		if (check_move2(actr->x + 2, actr->y, actr)) break;
-		d = 2;
-		break;
-	}
-	next_frame(actr);
-	actr->last_dir = d;
-	if (actr->directions == 1) return 0;
-	return d;
+    int d;
+
+    d = actr->last_dir;
+
+    switch (d) {
+    case 0:
+    case 2:
+        if (check_move2(actr->x - 2, actr->y, actr)) break;
+        d = 3;
+        break;
+    case 1:
+    case 3:
+        if (check_move2(actr->x + 2, actr->y, actr)) break;
+        d = 2;
+        break;
+    }
+    next_frame(actr);
+    actr->last_dir = d;
+    if (actr->directions == 1) return 0;
+    return d;
 }
 
 // Pause-seek (mushroom)
 int movement_thirteen(ACTOR *actr) {
-	int d;
-
-	d = actr->last_dir;
-
-	if (actr->counter == 0 && actr->pause == 0) {
-		actr->pause = 60;
-		return d;
-	}
-	if (actr->pause > 0) {
-		actr->pause--;
-		if (!actr->pause) actr->counter = 60;
-		actr->vunerable = 5;
-		actr->strength = 0;
-		return d;
-	}
-	if (actr->counter > 0) {
-		actr->counter--;
-		if (!actr->counter) actr->pause = 60;
-		actr->strength = 10;
-		return movement_five(actr);
-	}
-	return d;
+    int d;
+
+    d = actr->last_dir;
+
+    if (actr->counter == 0 && actr->pause == 0) {
+        actr->pause = 60;
+        return d;
+    }
+    if (actr->pause > 0) {
+        actr->pause--;
+        if (!actr->pause) actr->counter = 60;
+        actr->vunerable = 5;
+        actr->strength = 0;
+        return d;
+    }
+    if (actr->counter > 0) {
+        actr->counter--;
+        if (!actr->counter) actr->pause = 60;
+        actr->strength = 10;
+        return movement_five(actr);
+    }
+    return d;
 }
 
 // Move-bump-stop (boulder)
 int movement_fourteen(ACTOR *actr) {
-	int d, x1, y1;
-
-	d = actr->last_dir;
-	actr->dir = d;
-	x1 = actr->x;
-	y1 = actr->y;
-
-	switch (d) {
-	case 0:
-		y1 -= 2;
-		if (!check_move2(x1, y1, actr)) {
-			actr->move = 15;
-			return 0;
-		}
-		break;
-	case 1:
-		y1 += 2;
-		if (!check_move2(x1, y1, actr)) {
-			actr->move = 15;
-			return 0;
-		}
-		break;
-	case 2:
-		x1 -= 2;
-		if (!check_move2(x1, y1, actr)) {
-			actr->move = 15;
-			return 0;
-		}
-		break;
-	case 3:
-		x1 += 2;
-		if (!check_move2(x1, y1, actr)) {
-			actr->move = 15;
-			return 0;
-		}
-		break;
-	}
-	next_frame(actr);
-	actr->last_dir = d;
-	if (actr->directions == 1) return 0;
-	return d;
+    int d, x1, y1;
+
+    d = actr->last_dir;
+    actr->dir = d;
+    x1 = actr->x;
+    y1 = actr->y;
+
+    switch (d) {
+    case 0:
+        y1 -= 2;
+        if (!check_move2(x1, y1, actr)) {
+            actr->move = 15;
+            return 0;
+        }
+        break;
+    case 1:
+        y1 += 2;
+        if (!check_move2(x1, y1, actr)) {
+            actr->move = 15;
+            return 0;
+        }
+        break;
+    case 2:
+        x1 -= 2;
+        if (!check_move2(x1, y1, actr)) {
+            actr->move = 15;
+            return 0;
+        }
+        break;
+    case 3:
+        x1 += 2;
+        if (!check_move2(x1, y1, actr)) {
+            actr->move = 15;
+            return 0;
+        }
+        break;
+    }
+    next_frame(actr);
+    actr->last_dir = d;
+    if (actr->directions == 1) return 0;
+    return d;
 }
 
 // No movement - no frame cycle
 int movement_fifteen(ACTOR *actr) {
-	return actr->dir;
+    return actr->dir;
 }
 
 // Tornado 1
 int movement_sixteen(ACTOR *actr) {
-	int d, x1, y1;
-
-	d = actr->last_dir;
-	x1 = actr->x;
-	y1 = actr->y;
-
-	switch (d) {
-	case 0:
-		y1 -= 2;
-		break;
-	case 1:
-		y1 += 2;
-		break;
-	case 2:
-		x1 -= 2;
-		break;
-	case 3:
-		x1 += 2;
-		break;
-	}
-	if (!check_move1(x1, y1, actr)) {
-		actr->move = 17;
-		d = g_events->getRandomNumber(3);
-	}
-
-	next_frame(actr);
-	actr->last_dir = d;
-	if (actr->directions == 1) return 0;
-	return d;
+    int d, x1, y1;
+
+    d = actr->last_dir;
+    x1 = actr->x;
+    y1 = actr->y;
+
+    switch (d) {
+    case 0:
+        y1 -= 2;
+        break;
+    case 1:
+        y1 += 2;
+        break;
+    case 2:
+        x1 -= 2;
+        break;
+    case 3:
+        x1 += 2;
+        break;
+    }
+    if (!check_move1(x1, y1, actr)) {
+        actr->move = 17;
+        d = g_events->getRandomNumber(3);
+    }
+
+    next_frame(actr);
+    actr->last_dir = d;
+    if (actr->directions == 1) return 0;
+    return d;
 }
 
 // Tornado 2
 int movement_seventeen(ACTOR *actr) {
-	int d;
-
-	d = actr->last_dir;
-
-	switch (d) {
-	case 0:
-		if (check_move1(actr->x - 2, actr->y - 2, actr)) break;
-		d = 1;
-		if (check_move1(actr->x - 2, actr->y + 2, actr)) break;
-		d = 2;
-		break;
-	case 1:
-		if (check_move1(actr->x - 2, actr->y + 2, actr)) break;
-		d = 0;
-		if (check_move1(actr->x - 2, actr->y - 2, actr)) break;
-		d = 3;
-		break;
-	case 2:
-		if (check_move1(actr->x + 2, actr->y - 2, actr)) break;
-		d = 3;
-		if (check_move1(actr->x + 2, actr->y + 2, actr)) break;
-		d = 0;
-		break;
-	case 3:
-		if (check_move1(actr->x + 2, actr->y + 2, actr)) break;
-		d = 2;
-		if (check_move1(actr->x + 2, actr->y - 2, actr)) break;
-		d = 1;
-		break;
-	}
-	next_frame(actr);
-	actr->last_dir = d;
-	if (actr->directions == 1) return 0;
-	return d;
+    int d;
+
+    d = actr->last_dir;
+
+    switch (d) {
+    case 0:
+        if (check_move1(actr->x - 2, actr->y - 2, actr)) break;
+        d = 1;
+        if (check_move1(actr->x - 2, actr->y + 2, actr)) break;
+        d = 2;
+        break;
+    case 1:
+        if (check_move1(actr->x - 2, actr->y + 2, actr)) break;
+        d = 0;
+        if (check_move1(actr->x - 2, actr->y - 2, actr)) break;
+        d = 3;
+        break;
+    case 2:
+        if (check_move1(actr->x + 2, actr->y - 2, actr)) break;
+        d = 3;
+        if (check_move1(actr->x + 2, actr->y + 2, actr)) break;
+        d = 0;
+        break;
+    case 3:
+        if (check_move1(actr->x + 2, actr->y + 2, actr)) break;
+        d = 2;
+        if (check_move1(actr->x + 2, actr->y - 2, actr)) break;
+        d = 1;
+        break;
+    }
+    next_frame(actr);
+    actr->last_dir = d;
+    if (actr->directions == 1) return 0;
+    return d;
 }
 
 // No movement - frame cycle
 int movement_eighteen(ACTOR *actr) {
-	int d;
-
-	if (actr->temp5) {
-		actr->temp5--;
-		if (!actr->temp5) actr->num_moves = 1;
-	}
-	if (actr->temp1) {
-		d = movement_five(actr);
-		actr->rand--;
-		if (actr->hit_thor || !actr->rand) {
-			if (actr->hit_thor) {
-				actr->temp5 = 50;
-				actr->num_moves = 2;
-				actr->hit_thor = 0;
-				actr->dir = d;
-				d = reverse_direction(actr);
-			}
-			actr->temp1 = 0;
-			actr->rand = g_events->getRandomNumber(50, 149);
-		}
-	} else {
-		d = movement_three(actr);
-		actr->rand--;
-		if (!actr->rand) {
-			actr->temp5 = 0;
-			actr->temp1 = 1;
-			actr->rand = g_events->getRandomNumber(50, 149);
-		}
-		if (actr->hit_thor) {
-			actr->temp5 = 50;
-			actr->num_moves = 2;
-			actr->hit_thor = 0;
-			actr->dir = d;
-			d = reverse_direction(actr);
-		}
-	}
-	next_frame(actr);
-	return d;
+    int d;
+
+    if (actr->temp5) {
+        actr->temp5--;
+        if (!actr->temp5) actr->num_moves = 1;
+    }
+    if (actr->temp1) {
+        d = movement_five(actr);
+        actr->rand--;
+        if (actr->hit_thor || !actr->rand) {
+            if (actr->hit_thor) {
+                actr->temp5 = 50;
+                actr->num_moves = 2;
+                actr->hit_thor = 0;
+                actr->dir = d;
+                d = reverse_direction(actr);
+            }
+            actr->temp1 = 0;
+            actr->rand = g_events->getRandomNumber(50, 149);
+        }
+    } else {
+        d = movement_three(actr);
+        actr->rand--;
+        if (!actr->rand) {
+            actr->temp5 = 0;
+            actr->temp1 = 1;
+            actr->rand = g_events->getRandomNumber(50, 149);
+        }
+        if (actr->hit_thor) {
+            actr->temp5 = 50;
+            actr->num_moves = 2;
+            actr->hit_thor = 0;
+            actr->dir = d;
+            d = reverse_direction(actr);
+        }
+    }
+    next_frame(actr);
+    return d;
 }
 
 // No movement - frame cycle
 int movement_nineteen(ACTOR *actr) {
-	return movement_seven(actr);
+    return movement_seven(actr);
 }
 
 int movement_twenty(ACTOR *actr) {
-	if (GAME1)
-		// Boss - snake
-		return boss1_movement(actr);
+    if (GAME1)
+        // Boss - snake
+        return boss1_movement(actr);
 
-	return movement_one(actr);
+    return movement_one(actr);
 }
 
 // No movement - frame cycle
 int movement_twentyone(ACTOR *actr) {
-	return movement_three(actr);
+    return movement_three(actr);
 }
 
 // Spear
-int movement_twentytwo(ACTOR *actr) {    
-	int d;
+int movement_twentytwo(ACTOR *actr) {
+    int d;
 
-	d = actr->last_dir;
-	if (actr->directions == 1) d = 0;
+    d = actr->last_dir;
+    if (actr->directions == 1) d = 0;
 
 redo:
 
-	switch (actr->temp2) {
-	case 0:
-		if (bgtile(actr->x, actr->y) >= TILE_SOLID) actr->next = 1;
-		else {
-			actr->temp2 = 6;
-			actr->temp1 = 1;
-			goto redo;
-		}
-		actr->temp2++;
-		break;
-	case 1:
-		actr->next = 2;
-		actr->temp2++;
-		break;
-	case 2:
-		actr->next = 3;
-		actr->strength = 255;
-		actr->temp2++;
-		actr->temp1 = 10;
-		break;
-	case 3:
-		check_move2(actr->x, actr->y, actr);
-		actr->temp1--;


Commit: 93aadd42bcfa3b4e2f891253760ff930046f8925
    https://github.com/scummvm/scummvm/commit/93aadd42bcfa3b4e2f891253760ff930046f8925
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Detections provided by eientei

Changed paths:
    engines/got/detection_tables.h


diff --git a/engines/got/detection_tables.h b/engines/got/detection_tables.h
index 179772c198d..6ab15d33ce7 100644
--- a/engines/got/detection_tables.h
+++ b/engines/got/detection_tables.h
@@ -29,13 +29,40 @@ const PlainGameDescriptor gotGames[] = {
 const ADGameDescription gameDescriptions[] = {
     {
         "got",
-        nullptr,
+        "v1.0:143",
+        AD_ENTRY1s("gotres.dat", "0fe859bcfd06772be0885bf510c2877d", 739732),
+        Common::EN_ANY,
+        Common::kPlatformDOS,
+        ADGF_UNSTABLE,
+        GUIO1(GUIO_NOSPEECH)
+    },
+    {
+        "got",
+        "v1.0:143 Shareware",
+        AD_ENTRY1s("gotres.dat", "c316221a3b9d12a838faef55fde2f34c", 482738),
+        Common::EN_ANY,
+        Common::kPlatformDOS,
+        ADGF_UNSTABLE | ADGF_DEMO,
+        GUIO1(GUIO_NOSPEECH)
+    },
+    {
+        "got",
+        "v1.1:144",
         AD_ENTRY1s("gotres.dat", "747ed508ffa3808156a4eb080e9859f8", 739710),
         Common::EN_ANY,
         Common::kPlatformDOS,
         ADGF_UNSTABLE,
         GUIO1(GUIO_NOSPEECH)
     },
+    {
+        "got",
+        "v1.1:144 Shareware",
+        AD_ENTRY1s("gotres.dat", "c443aa09450566ee32998c3ebb15cbaa", 485858),
+        Common::EN_ANY,
+        Common::kPlatformDOS,
+        ADGF_UNSTABLE | ADGF_DEMO,
+        GUIO1(GUIO_NOSPEECH)
+    },
 
     AD_TABLE_END_MARKER
 };


Commit: c06a08ea2f767c7b3a34ade687ae6d17f7ede3b3
    https://github.com/scummvm/scummvm/commit/c06a08ea2f767c7b3a34ade687ae6d17f7ede3b3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Clang fixes

Changed paths:
    engines/got/data/actor.cpp
    engines/got/game/boss2.cpp
    engines/got/got.h


diff --git a/engines/got/data/actor.cpp b/engines/got/data/actor.cpp
index bf6b2149a2d..e14a995d72b 100644
--- a/engines/got/data/actor.cpp
+++ b/engines/got/data/actor.cpp
@@ -86,9 +86,9 @@ void ACTOR::copyFixedAndPics(const ACTOR &src) {
     Common::copy(src.future1, src.future1 + 4, future1);
 
     // Copy all the surfaces for all the directions over
-    for (int d = 0; d < DIRECTION_COUNT; ++d)
-        for (int f = 0; f < FRAME_COUNT; ++f)
-            pic[d][f] = src.pic[d][f];
+	for (int d = 0; d < DIRECTION_COUNT; ++d)
+		for (int f = 0; f < FRAME_COUNT; ++f)
+			pic[d][f].copyFrom(src.pic[d][f]);
 }
 
 } // namespace Got
diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index e8bb993df1f..f0e3ecffddf 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -180,12 +180,6 @@ void check_boss2_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
                     actor_destroyed(&_G(actor)[rep]);
         }
     }
-    x1 = x1;
-    y1 = y1;
-    x2 = x2;
-    y2 = y2;
-    actr = actr;
-    act_num = act_num;
 }
 
 void boss_level2() {
diff --git a/engines/got/got.h b/engines/got/got.h
index e66b10cb403..69db3332eed 100644
--- a/engines/got/got.h
+++ b/engines/got/got.h
@@ -68,7 +68,7 @@ public:
     ~GotEngine() override;
 
     uint32 getFeatures() const;
-    bool isDemo() const;
+    bool isDemo() const override;
 
     /**
      * Returns the game Id


Commit: 9a09b66a9f5bc59a13665545cd13f8026963f956
    https://github.com/scummvm/scummvm/commit/9a09b66a9f5bc59a13665545cd13f8026963f956
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: More Clang fixes

Changed paths:
    engines/got/game/boss1.cpp
    engines/got/game/boss2.cpp
    engines/got/game/boss3.cpp


diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index 518cba60b6a..50a3309fa11 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -248,7 +248,7 @@ static int boss1_dead() {
             _G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
         }
         play_sound(EXPLODE, 1);
-        _G(boss_dead)++;
+        _G(boss_dead) = true;;
         for (rep = 7; rep < MAX_ACTORS; rep++)
             if (_G(actor)[rep].used)
                 actor_destroyed(&_G(actor)[rep]);
diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index f0e3ecffddf..91febe6a0cd 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -231,7 +231,7 @@ static int boss2_die() {
         }
 
         play_sound(EXPLODE, 1);
-        _G(boss_dead)++;
+        _G(boss_dead) = true;;
     }
 
     return _G(actor)[3].last_dir;
diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index 09dae26b6f1..a35d40b273b 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -492,7 +492,7 @@ static int boss_die() {
         }
 
         play_sound(EXPLODE, 1);
-        _G(boss_dead)++;
+        _G(boss_dead) = true;;
     }
 
     return _G(actor)[3].last_dir;


Commit: dfa699d3dcaf6bb3e1e7045d4072e82ca35b19bc
    https://github.com/scummvm/scummvm/commit/dfa699d3dcaf6bb3e1e7045d4072e82ca35b19bc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Allow the splash screen frame count to vary

Changed paths:
    engines/got/views/splash_screen.cpp
    engines/got/views/splash_screen.h


diff --git a/engines/got/views/splash_screen.cpp b/engines/got/views/splash_screen.cpp
index b8eb56821e0..e4dac7c9130 100644
--- a/engines/got/views/splash_screen.cpp
+++ b/engines/got/views/splash_screen.cpp
@@ -28,7 +28,6 @@ namespace Got {
 namespace Views {
 
 #define SPLASH_FRAME_INTERVAL 2
-#define SPLASH_FRAME_COUNT 36
 
 void SplashScreen::draw() {
     if (_frameCtr == -1) {
@@ -44,11 +43,9 @@ void SplashScreen::draw() {
 
 bool SplashScreen::msgFocus(const FocusMessage &msg) {
     auto chunk = _G(gfx)[93];
-    int frameCount = READ_LE_UINT16(chunk._data);
-    warning("frameCount: %d", frameCount);
-    assert(frameCount == SPLASH_FRAME_COUNT);
+    _frameCount = READ_LE_UINT16(chunk._data);
     _chunkSize = chunk._data + 2;
-    _chunkPtr = chunk._data + 2 + SPLASH_FRAME_COUNT * 4;
+    _chunkPtr = chunk._data + 2 + _frameCount * 4;
 
     _frameCtr = -1;
     _delayCtr = 0;
@@ -74,7 +71,7 @@ bool SplashScreen::tick() {
     if (++_delayCtr == SPLASH_FRAME_INTERVAL) {
         _delayCtr = 0;
 
-        if (++_frameCtr < SPLASH_FRAME_COUNT) {
+        if (++_frameCtr < _frameCount) {
             GfxSurface s = getSurface();
             byte *dest = (byte *)s.getBasePtr(0, 24);
             executeFrame(_chunkPtr, dest);
@@ -82,7 +79,7 @@ bool SplashScreen::tick() {
 
             _chunkPtr += READ_LE_UINT32(_chunkSize);
             _chunkSize += 4;
-        } else if (_frameCtr == (SPLASH_FRAME_COUNT + 50)) {
+        } else if (_frameCtr == (_frameCount + 50)) {
             // Switch to the opening screen showing the game name
             replaceView("Opening", true);
         }
diff --git a/engines/got/views/splash_screen.h b/engines/got/views/splash_screen.h
index 7e11035f6de..34fd728f74b 100644
--- a/engines/got/views/splash_screen.h
+++ b/engines/got/views/splash_screen.h
@@ -31,6 +31,7 @@ class SplashScreen : public View {
 private:
     const byte *_chunkSize = nullptr;
     const byte *_chunkPtr = nullptr;
+	int _frameCount = 0;
     int _delayCtr = 0, _frameCtr = 0;
 
     void executeFrame(const byte *src, byte *dest);


Commit: dc3e8055fb2ecf4d561f2b5a6642cd5f3648d5e1
    https://github.com/scummvm/scummvm/commit/dc3e8055fb2ecf4d561f2b5a6642cd5f3648d5e1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Cleaner implementation of bitflags & saving

Changed paths:
    engines/got/data/setup.cpp
    engines/got/data/setup.h
    engines/got/game/script.cpp


diff --git a/engines/got/data/setup.cpp b/engines/got/data/setup.cpp
index 4145ab7a84a..a12978a31fd 100644
--- a/engines/got/data/setup.cpp
+++ b/engines/got/data/setup.cpp
@@ -19,14 +19,35 @@
  *
  */
 
+#include "common/algorithm.h"
 #include "got/data/setup.h"
 
 namespace Got {
 
+SetupFlags &SetupFlags::operator=(const Got::SetupFlags &src) {
+	Common::copy(src._flags, src._flags + 8, _flags);
+	return *this;
+}
+
+void SetupFlags::sync(Common::Serializer &s) {
+	byte flags[8] = {};
+	int i;
+
+	if (s.isSaving()) {
+		for (i = 0; i < 64; ++i)
+			if (_flags[i])
+				flags[i / 8] = flags[i / 8] | (1 << (i % 8));
+		s.syncBytes(flags, 8);
+	} else {
+		s.syncBytes(flags, 8);
+		for (i = 0; i < 64; ++i)
+			_flags[i] = (flags[i / 8] & (1 << (i % 8))) != 0;
+	}
+}
+
 void SETUP::sync(Common::Serializer &s) {
     // Sync the flags bit-fields
-    assert(((byte *)&value - (byte *)this) == 8);
-    s.syncBytes((byte *)this, 8);
+	SetupFlags::sync(s);
 
     s.syncBytes(value, 16);
     s.syncAsByte(junk);
diff --git a/engines/got/data/setup.h b/engines/got/data/setup.h
index 0eb8de82231..2613ef6c775 100644
--- a/engines/got/data/setup.h
+++ b/engines/got/data/setup.h
@@ -26,89 +26,79 @@
 
 namespace Got {
 
-struct SETUP {
-    SETUP() :
-        f00(0), f01(0), f02(0), f03(0), f04(0), f05(0), f06(0), f07(0), f08(0), f09(0),
-        f10(0), f11(0), f12(0), f13(0), f14(0), f15(0), f16(0), f17(0), f18(0), f19(0),
-        f20(0), f21(0), f22(0), f23(0), f24(0), f25(0), f26(0), f27(0), f28(0), f29(0),
-        f30(0), f31(0), f32(0), f33(0), f34(0), f35(0), f36(0), f37(0), f38(0), f39(0),
-        f40(0), f41(0), f42(0), f43(0), f44(0), f45(0), f46(0), f47(0), f48(0), f49(0),
-        f50(0), f51(0), f52(0), f53(0), f54(0), f55(0), f56(0), f57(0), f58(0), f59(0),
-        f60(0), f61(0), f62(0), f63(0) {
-    }
-
-    unsigned int  f00 : 1;
-    unsigned int  f01 : 1;
-    unsigned int  f02 : 1;
-    unsigned int  f03 : 1;
-    unsigned int  f04 : 1;
-    unsigned int  f05 : 1;
-    unsigned int  f06 : 1;
-    unsigned int  f07 : 1;
-
-    unsigned int  f08 : 1;
-    unsigned int  f09 : 1;
-    unsigned int  f10 : 1;
-    unsigned int  f11 : 1;
-    unsigned int  f12 : 1;
-    unsigned int  f13 : 1;
-    unsigned int  f14 : 1;
-    unsigned int  f15 : 1;
-
-    unsigned int  f16 : 1;
-    unsigned int  f17 : 1;
-    unsigned int  f18 : 1;
-    unsigned int  f19 : 1;
-    unsigned int  f20 : 1;
-    unsigned int  f21 : 1;
-    unsigned int  f22 : 1;
-    unsigned int  f23 : 1;
-
-    unsigned int  f24 : 1;
-    unsigned int  f25 : 1;
-    unsigned int  f26 : 1;
-    unsigned int  f27 : 1;
-    unsigned int  f28 : 1;
-    unsigned int  f29 : 1;
-    unsigned int  f30 : 1;
-    unsigned int  f31 : 1;
-
-    unsigned int  f32 : 1;
-    unsigned int  f33 : 1;
-    unsigned int  f34 : 1;
-    unsigned int  f35 : 1;
-    unsigned int  f36 : 1;
-    unsigned int  f37 : 1;
-    unsigned int  f38 : 1;
-    unsigned int  f39 : 1;
-
-    unsigned int  f40 : 1;
-    unsigned int  f41 : 1;
-    unsigned int  f42 : 1;
-    unsigned int  f43 : 1;
-    unsigned int  f44 : 1;
-    unsigned int  f45 : 1;
-    unsigned int  f46 : 1;
-    unsigned int  f47 : 1;
-
-    unsigned int  f48 : 1;
-    unsigned int  f49 : 1;
-    unsigned int  f50 : 1;
-    unsigned int  f51 : 1;
-    unsigned int  f52 : 1;
-    unsigned int  f53 : 1;
-    unsigned int  f54 : 1;
-    unsigned int  f55 : 1;
-
-    unsigned int  f56 : 1;
-    unsigned int  f57 : 1;
-    unsigned int  f58 : 1;
-    unsigned int  f59 : 1;
-    unsigned int  f60 : 1;
-    unsigned int  f61 : 1;
-    unsigned int  f62 : 1;
-    unsigned int  f63 : 1;
+struct SetupFlags {
+	bool _flags[64] = {};
+	bool &f00 = _flags[0];
+	bool &f01 = _flags[1];
+	bool &f02 = _flags[2];
+	bool &f03 = _flags[3];
+	bool &f04 = _flags[4];
+	bool &f05 = _flags[5];
+	bool &f06 = _flags[6];
+	bool &f07 = _flags[7];
+	bool &f08 = _flags[8];
+	bool &f09 = _flags[9];
+	bool &f10 = _flags[10];
+	bool &f11 = _flags[11];
+	bool &f12 = _flags[12];
+	bool &f13 = _flags[13];
+	bool &f14 = _flags[14];
+	bool &f15 = _flags[15];
+	bool &f16 = _flags[16];
+	bool &f17 = _flags[17];
+	bool &f18 = _flags[18];
+	bool &f19 = _flags[19];
+	bool &f20 = _flags[20];
+	bool &f21 = _flags[21];
+	bool &f22 = _flags[22];
+	bool &f23 = _flags[23];
+	bool &f24 = _flags[24];
+	bool &f25 = _flags[25];
+	bool &f26 = _flags[26];
+	bool &f27 = _flags[27];
+	bool &f28 = _flags[28];
+	bool &f29 = _flags[29];
+	bool &f30 = _flags[30];
+	bool &f31 = _flags[31];
+	bool &f32 = _flags[32];
+	bool &f33 = _flags[33];
+	bool &f34 = _flags[34];
+	bool &f35 = _flags[35];
+	bool &f36 = _flags[36];
+	bool &f37 = _flags[37];
+	bool &f38 = _flags[38];
+	bool &f39 = _flags[39];
+	bool &f40 = _flags[40];
+	bool &f41 = _flags[41];
+	bool &f42 = _flags[42];
+	bool &f43 = _flags[43];
+	bool &f44 = _flags[44];
+	bool &f45 = _flags[45];
+	bool &f46 = _flags[46];
+	bool &f47 = _flags[47];
+	bool &f48 = _flags[48];
+	bool &f49 = _flags[49];
+	bool &f50 = _flags[50];
+	bool &f51 = _flags[51];
+	bool &f52 = _flags[52];
+	bool &f53 = _flags[53];
+	bool &f54 = _flags[54];
+	bool &f55 = _flags[55];
+	bool &f56 = _flags[56];
+	bool &f57 = _flags[57];
+	bool &f58 = _flags[58];
+	bool &f59 = _flags[59];
+	bool &f60 = _flags[60];
+	bool &f61 = _flags[61];
+	bool &f62 = _flags[62];
+	bool &f63 = _flags[63];
+
+	SetupFlags() {}
+	void sync(Common::Serializer &s);
+	SetupFlags &operator=(const Got::SetupFlags &src);
+};
 
+struct SETUP : public SetupFlags {
     byte value[16] = {};
     byte junk = 0;
     byte game = 0;
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 3654e926f00..de023332a9b 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -389,8 +389,6 @@ int Scripts::get_next_val() {
 
 int Scripts::get_internal_variable() {
     int i, len;
-    char b;
-    byte *sp;
 
     i = 0;
     while (1) {
@@ -446,14 +444,7 @@ int Scripts::get_internal_variable() {
         if (i < 1 || i>64)
             return 0;
 
-        sp = (byte *)&_G(setup);
-        sp += (i / 8);
-        b = 1;
-        b = b << (i % 8);
-        if (*sp & b)
-            _lTemp = 1;
-        else
-            _lTemp = 0;
+		_lTemp = _G(setup)._flags[i - 1] ? 1 : 0;
         break;
     case 23:
         if (_G(thor_info).inventory & 64) _lTemp = _G(thor_info).object;
@@ -887,20 +878,16 @@ int Scripts::cmd_itemtake() {
 
 int Scripts::cmd_setflag() {
     int i;
-    char b;
-    byte *sp;
 
     if (!calc_value())
         return 5;
-    i = (int)_lValue;
+
+	i = (int)_lValue;
     if (i < 1 || i>64)
         return 6;
 
-    sp = (byte *)&_G(setup);
-    sp += (i / 8);
-    b = 1;
-    b = b << (i % 8);
-    *sp |= b;
+	_G(setup)._flags[i - 1] = true;
+
     return 0;
 }
 


Commit: 7e77e8003628d8c617b9e0c8dfa02deee7a307d2
    https://github.com/scummvm/scummvm/commit/7e77e8003628d8c617b9e0c8dfa02deee7a307d2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Change blitFrom to simpleBlitFrom

Changed paths:
    engines/got/views/credits.cpp
    engines/got/views/dialogs/dialog.cpp
    engines/got/views/dialogs/high_scores.cpp
    engines/got/views/dialogs/say.cpp
    engines/got/views/dialogs/select_item.cpp
    engines/got/views/dialogs/select_option.cpp
    engines/got/views/game_content.cpp
    engines/got/views/game_status.cpp
    engines/got/views/splash_screen.cpp
    engines/got/views/story.cpp
    engines/got/views/title_background.cpp


diff --git a/engines/got/views/credits.cpp b/engines/got/views/credits.cpp
index ff17b5a83c4..449e6b65a80 100644
--- a/engines/got/views/credits.cpp
+++ b/engines/got/views/credits.cpp
@@ -47,7 +47,7 @@ void Credits::draw() {
     // Draw scroll background
     Graphics::ManagedSurface bg = _G(gfx)[42];
     s.clear(*(byte *)bg.getPixels());
-    s.blitFrom(bg, Common::Point(0, 24));
+    s.simpleBlitFrom(bg, Common::Point(0, 24));
 
     int creditNum = _frameCtr / CREDIT_TIME;
     int subNum = _frameCtr % CREDIT_TIME;
diff --git a/engines/got/views/dialogs/dialog.cpp b/engines/got/views/dialogs/dialog.cpp
index 37fedf5f10e..b9d79ba3dea 100644
--- a/engines/got/views/dialogs/dialog.cpp
+++ b/engines/got/views/dialogs/dialog.cpp
@@ -39,21 +39,21 @@ void Dialog::draw() {
     assert((s.w % 16) == 0 && (s.h % 16) == 0);
 
     // Draw four corners
-    s.blitFrom(_G(bgPics)[192], Common::Point(0, 0));
-    s.blitFrom(_G(bgPics)[193], Common::Point(_bounds.width() - 16, 0));
-    s.blitFrom(_G(bgPics)[194], Common::Point(0, _bounds.height() - 16));
-    s.blitFrom(_G(bgPics)[195], Common::Point(_bounds.width() - 16, _bounds.height() - 16));
+    s.simpleBlitFrom(_G(bgPics)[192], Common::Point(0, 0));
+    s.simpleBlitFrom(_G(bgPics)[193], Common::Point(_bounds.width() - 16, 0));
+    s.simpleBlitFrom(_G(bgPics)[194], Common::Point(0, _bounds.height() - 16));
+    s.simpleBlitFrom(_G(bgPics)[195], Common::Point(_bounds.width() - 16, _bounds.height() - 16));
 
     // Draw top/bottom horizontal lines
     for (int x = 16; x < _bounds.width() - 16; x += 16) {
-        s.blitFrom(_G(bgPics)[196], Common::Point(x, 0));
-        s.blitFrom(_G(bgPics)[197], Common::Point(x, _bounds.height() - 16));
+        s.simpleBlitFrom(_G(bgPics)[196], Common::Point(x, 0));
+        s.simpleBlitFrom(_G(bgPics)[197], Common::Point(x, _bounds.height() - 16));
     }
 
     // Draw left/right vertical lines
     for (int y = 16; y < _bounds.height() - 16; y += 16) {
-        s.blitFrom(_G(bgPics)[198], Common::Point(0, y));
-        s.blitFrom(_G(bgPics)[199], Common::Point(_bounds.width() - 16, y));
+        s.simpleBlitFrom(_G(bgPics)[198], Common::Point(0, y));
+        s.simpleBlitFrom(_G(bgPics)[199], Common::Point(_bounds.width() - 16, y));
     }
 }
 
diff --git a/engines/got/views/dialogs/high_scores.cpp b/engines/got/views/dialogs/high_scores.cpp
index bdfefefed6b..3c7a3ca1d21 100644
--- a/engines/got/views/dialogs/high_scores.cpp
+++ b/engines/got/views/dialogs/high_scores.cpp
@@ -39,7 +39,7 @@ void HighScores::draw() {
 
     for (int col = 0, xp = 0; col < 10; ++col, xp += 32) {
         for (int yp = 0; yp < 240; yp += 32)
-            s.blitFrom(_G(gfx)[26], Common::Point(xp, yp));
+            s.simpleBlitFrom(_G(gfx)[26], Common::Point(xp, yp));
     }
 
     // Draw the dialog frame
diff --git a/engines/got/views/dialogs/say.cpp b/engines/got/views/dialogs/say.cpp
index 6b88a96120c..017114c4ed8 100644
--- a/engines/got/views/dialogs/say.cpp
+++ b/engines/got/views/dialogs/say.cpp
@@ -65,7 +65,7 @@ void Say::draw() {
     GfxSurface s = getSurface();
 
     if (_item)
-        s.blitFrom(_G(objects)[_item], Common::Point(160, 17));
+        s.simpleBlitFrom(_G(objects)[_item], Common::Point(160, 17));
 
     const char *p = _content;
     const char *endP = _content + _contentLength;
@@ -108,7 +108,7 @@ void Say::draw() {
         x += 8;
     }
 
-    s.blitFrom(_speakerIcon[_picIndex], Common::Point(120, 17));
+    s.simpleBlitFrom(_speakerIcon[_picIndex], Common::Point(120, 17));
 
     if (_waitForResponse == WAIT_MORE)
         s.print(Common::Point(184, 86), "More...", 15);
diff --git a/engines/got/views/dialogs/select_item.cpp b/engines/got/views/dialogs/select_item.cpp
index 458b5ff9cb1..ec773d271f4 100644
--- a/engines/got/views/dialogs/select_item.cpp
+++ b/engines/got/views/dialogs/select_item.cpp
@@ -53,10 +53,10 @@ void SelectItem::draw() {
     for (int l = 0; l < 7; l++, b = b << 1) {
         if (_G(thor_info).inventory & b) {
             if (l < 6)
-                s.blitFrom(_G(objects)[l + 26],
+                s.simpleBlitFrom(_G(objects)[l + 26],
                            Common::Point(82 - 56 + (l * _HRZSP), 72 - 48));
             else
-                s.blitFrom(_G(objects)[_G(thor_info).object + 10],
+                s.simpleBlitFrom(_G(objects)[_G(thor_info).object + 10],
                            Common::Point(82 - 56 + (l * _HRZSP), 72 - 48));
         }
     }
diff --git a/engines/got/views/dialogs/select_option.cpp b/engines/got/views/dialogs/select_option.cpp
index 98da2ad2476..a838c71fe16 100644
--- a/engines/got/views/dialogs/select_option.cpp
+++ b/engines/got/views/dialogs/select_option.cpp
@@ -84,10 +84,10 @@ void SelectOption::draw() {
     if (_smackCtr > 0) {
         // Selecting an item
         int xp = 8 + 2 * (_smackCtr < 3 ? (_smackCtr + 1) : (6 - _smackCtr));
-        s.blitFrom(_G(hampic)[0], Common::Point(xp, 24 + (_selectedItem * 16)));
+        s.simpleBlitFrom(_G(hampic)[0], Common::Point(xp, 24 + (_selectedItem * 16)));
     } else {
         // Normal animated cursor
-        s.blitFrom(_G(hampic)[_hammerFrame],
+        s.simpleBlitFrom(_G(hampic)[_hammerFrame],
                    Common::Point(8, 24 + (_selectedItem * 16)));
     }
 }
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index f191518c3d4..33ad88fddbe 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -64,7 +64,7 @@ void GameContent::draw() {
     if (_G(gameMode) == MODE_THUNDER) {
         GfxSurface win = getSurface();
         win.clear();
-        win.blitFrom(s, _moveDelta);
+        win.simpleBlitFrom(s, _moveDelta);
     } else if (_G(gameMode) == MODE_LIGHTNING) {
         drawLightning(s);
 
@@ -75,38 +75,38 @@ void GameContent::draw() {
 
         switch (_G(transitionDir)) {
         case DIR_LEFT:
-            win.blitFrom(s, Common::Rect(320 - _transitionPos, 0, 320, 192),
+            win.simpleBlitFrom(s, Common::Rect(320 - _transitionPos, 0, 320, 192),
                          Common::Point(0, 0));
-            win.blitFrom(_surface, Common::Rect(0, 0, 320 - _transitionPos, 192),
+            win.simpleBlitFrom(_surface, Common::Rect(0, 0, 320 - _transitionPos, 192),
                          Common::Point(_transitionPos, 0));
             break;
         case DIR_RIGHT:
-            win.blitFrom(_surface, Common::Rect(_transitionPos, 0, 320, 192),
+            win.simpleBlitFrom(_surface, Common::Rect(_transitionPos, 0, 320, 192),
                          Common::Point(0, 0));
-            win.blitFrom(s, Common::Rect(0, 0, _transitionPos, 192),
+            win.simpleBlitFrom(s, Common::Rect(0, 0, _transitionPos, 192),
                          Common::Point(320 - _transitionPos, 0));
             break;
         case DIR_UP:
-            win.blitFrom(s, Common::Rect(0, 192 - _transitionPos, 320, 192),
+            win.simpleBlitFrom(s, Common::Rect(0, 192 - _transitionPos, 320, 192),
                          Common::Point(0, 0));
-            win.blitFrom(_surface, Common::Rect(0, 0, 320, 192 - _transitionPos),
+            win.simpleBlitFrom(_surface, Common::Rect(0, 0, 320, 192 - _transitionPos),
                          Common::Point(0, _transitionPos));
             break;
         case DIR_DOWN:
-            win.blitFrom(_surface, Common::Rect(0, _transitionPos, 320, 192),
+            win.simpleBlitFrom(_surface, Common::Rect(0, _transitionPos, 320, 192),
                          Common::Point(0, 0));
-            win.blitFrom(s, Common::Rect(0, 0, 320, _transitionPos),
+            win.simpleBlitFrom(s, Common::Rect(0, 0, 320, _transitionPos),
                          Common::Point(0, 192 - _transitionPos));
             break;
         case DIR_PHASED:
-            win.blitFrom(_surface);		// Copy old surface
+            win.simpleBlitFrom(_surface);		// Copy old surface
 
             // Copy the randomly chosen blocks over from new scene
             for (int i = 0; i < 240; ++i) {
                 int x = (i * 16) % 320;
                 int y = ((i * 16) / 320) * 16;
                 if (_phased[i])
-                    win.blitFrom(s, Common::Rect(x, y, x + 16, y + 16), Common::Point(x, y));
+                    win.simpleBlitFrom(s, Common::Rect(x, y, x + 16, y + 16), Common::Point(x, y));
             }
             break;
         default:
@@ -230,8 +230,8 @@ void GameContent::drawBackground(GfxSurface &s) {
         for (int x = 0; x < TILES_X; x++) {
             if (_G(scrn).icon[y][x] != 0) {
                 const Common::Point pt(x * TILE_SIZE, y * TILE_SIZE);
-                s.blitFrom(_G(bgPics)[_G(scrn).bg_color], pt);
-                s.blitFrom(_G(bgPics)[_G(scrn).icon[y][x]], pt);
+                s.simpleBlitFrom(_G(bgPics)[_G(scrn).bg_color], pt);
+                s.simpleBlitFrom(_G(bgPics)[_G(scrn).icon[y][x]], pt);
             }
         }
     }
@@ -243,7 +243,7 @@ void GameContent::drawObjects(GfxSurface &s) {
             int p = (y * TILES_X) + x;
 
             if (_G(object_map)[p]) {
-                s.blitFrom(_G(objects)[_G(object_map)[p] - 1],
+                s.simpleBlitFrom(_G(objects)[_G(object_map)[p] - 1],
                            Common::Point(x * TILE_SIZE, y * TILE_SIZE));
             }
         }
@@ -262,7 +262,7 @@ void GameContent::drawActors(GfxSurface &s) {
 
             const Graphics::ManagedSurface &frame = actor_ptr->pic[actor_ptr->dir]
                                                     [actor_ptr->frame_sequence[actor_ptr->next]];
-            s.blitFrom(frame, Common::Point(actor_ptr->x, actor_ptr->y));
+            s.simpleBlitFrom(frame, Common::Point(actor_ptr->x, actor_ptr->y));
         }
 
         // Move to the next actor
@@ -278,7 +278,7 @@ void GameContent::drawActors(GfxSurface &s) {
     }
 
     if (_G(gameMode) == MODE_THOR_DIES && _deathCtr >= DEATH_THRESHOLD)
-        s.blitFrom(_G(objects)[10], Common::Point(_G(thor)->x, _G(thor)->y));
+        s.simpleBlitFrom(_G(objects)[10], Common::Point(_G(thor)->x, _G(thor)->y));
 }
 
 void GameContent::drawBossHealth(GfxSurface &s) {
diff --git a/engines/got/views/game_status.cpp b/engines/got/views/game_status.cpp
index da996c8931e..aa0825f0c4c 100644
--- a/engines/got/views/game_status.cpp
+++ b/engines/got/views/game_status.cpp
@@ -34,7 +34,7 @@ void GameStatus::draw() {
 
     // Draw the status background
     const Graphics::ManagedSurface &status = _G(status)[0];
-    s.blitFrom(status);
+    s.simpleBlitFrom(status);
 
     // Draw the elements
     displayHealth(s);
@@ -101,9 +101,9 @@ void GameStatus::displayItem(GfxSurface &s) {
 
     if (_G(thor_info).item) {
         if (_G(thor_info).item == 7)
-            s.blitFrom(_G(objects)[_G(thor_info).object + 10], Common::Point(280, 8));
+            s.simpleBlitFrom(_G(objects)[_G(thor_info).object + 10], Common::Point(280, 8));
         else
-            s.blitFrom(_G(objects)[_G(thor_info).item + 25], Common::Point(280, 8));
+            s.simpleBlitFrom(_G(objects)[_G(thor_info).item + 25], Common::Point(280, 8));
     }
 }
 
diff --git a/engines/got/views/splash_screen.cpp b/engines/got/views/splash_screen.cpp
index e4dac7c9130..5f287e79d74 100644
--- a/engines/got/views/splash_screen.cpp
+++ b/engines/got/views/splash_screen.cpp
@@ -37,7 +37,7 @@ void SplashScreen::draw() {
         // Display background. The rest of the logo animation will be
         // done in the frame routines called from tick
         s.clear();
-        s.blitFrom(_G(gfx)[92], Common::Point(0, 24));
+        s.simpleBlitFrom(_G(gfx)[92], Common::Point(0, 24));
     }
 }
 
diff --git a/engines/got/views/story.cpp b/engines/got/views/story.cpp
index 67a3fe12fdd..6daf32642be 100644
--- a/engines/got/views/story.cpp
+++ b/engines/got/views/story.cpp
@@ -47,7 +47,7 @@ bool Story::msgFocus(const FocusMessage &msg) {
         Gfx::Pics pics(Common::String::format("OPENP%d", i + 1));
         pics.load();
 
-        _surface.blitFrom(pics[0], Common::Point(0, i * 40));
+        _surface.simpleBlitFrom(pics[0], Common::Point(0, i * 40));
     }
 
     // Set up the story text
@@ -93,9 +93,9 @@ bool Story::msgFocus(const FocusMessage &msg) {
 
     // Final two glyphs
     Gfx::Pics glyphs("STORYPIC", 262);
-    _surface.blitFrom(glyphs[0], Common::Point(146, 64));
+    _surface.simpleBlitFrom(glyphs[0], Common::Point(146, 64));
     if (_G(area) == 1)
-        _surface.blitFrom(glyphs[1], Common::Point(24, 88 + 240));
+        _surface.simpleBlitFrom(glyphs[1], Common::Point(24, 88 + 240));
 
     // Play the opening music
     music_play("OPENSONG", 1);
@@ -114,7 +114,7 @@ void Story::draw() {
     GfxSurface s = getSurface();
 
     // Draw the currently visible part of the surface
-    s.blitFrom(_surface, Common::Rect(0, _yp, 320, _yp + 240),
+    s.simpleBlitFrom(_surface, Common::Rect(0, _yp, 320, _yp + 240),
                Common::Point(0, 0));
 }
 
diff --git a/engines/got/views/title_background.cpp b/engines/got/views/title_background.cpp
index bb3a525d666..c26e00d2f53 100644
--- a/engines/got/views/title_background.cpp
+++ b/engines/got/views/title_background.cpp
@@ -44,7 +44,7 @@ void TitleBackground::draw() {
 
     for (int col = 0, xp = 0; col < 10; ++col, xp += 32) {
         for (int yp = 0; yp < 240; yp += 32)
-            s.blitFrom(_G(gfx)[26], Common::Point(xp, yp));
+            s.simpleBlitFrom(_G(gfx)[26], Common::Point(xp, yp));
     }
 }
 


Commit: 3593a2c8e9db46b1b7e026f8a2b4f2cb0ba533fd
    https://github.com/scummvm/scummvm/commit/3593a2c8e9db46b1b7e026f8a2b4f2cb0ba533fd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fixes for story display

Changed paths:
    engines/got/gfx/palette.cpp
    engines/got/gfx/palette.h
    engines/got/views/story.cpp


diff --git a/engines/got/gfx/palette.cpp b/engines/got/gfx/palette.cpp
index b035e4d0da1..dd48d2d49d2 100644
--- a/engines/got/gfx/palette.cpp
+++ b/engines/got/gfx/palette.cpp
@@ -67,6 +67,11 @@ void xsetpal(const byte *pal) {
     g_system->getPaletteManager()->setPalette(pal, 0, PALETTE_COUNT);
 }
 
+void set_palette(const byte *pal) {
+	xsetpal(pal);
+	Common::copy(pal, pal + PALETTE_SIZE, saved_palette);
+}
+
 void xgetpal(byte *pal, int num_colrs, int start_index) {
     g_system->getPaletteManager()->grabPalette(pal, start_index, num_colrs);
 }
diff --git a/engines/got/gfx/palette.h b/engines/got/gfx/palette.h
index 989d00759d1..d605b668c21 100644
--- a/engines/got/gfx/palette.h
+++ b/engines/got/gfx/palette.h
@@ -39,6 +39,7 @@ struct Palette63 {
 
 extern void load_palette();
 extern void set_screen_pal();
+extern void set_palette(const byte *pal);
 extern void xsetpal(byte color, byte R, byte G, byte B);
 extern void xsetpal(const byte *pal);
 extern void xgetpal(byte *pal, int num_colrs, int start_index);
diff --git a/engines/got/views/story.cpp b/engines/got/views/story.cpp
index 6daf32642be..3e3ad0e7f40 100644
--- a/engines/got/views/story.cpp
+++ b/engines/got/views/story.cpp
@@ -36,9 +36,9 @@ bool Story::msgFocus(const FocusMessage &msg) {
     _G(pbuff)[1] = 0;
     _G(pbuff)[0] = 0;
 
-    for (int i = 0; i < 768; ++i)
-        _G(pbuff)[i] = (_G(pbuff)[i] * 255 + 31) / 63;
-    Gfx::xsetpal(_G(pbuff));
+    for (int i = 0; i < PALETTE_SIZE; ++i)
+        _G(pbuff)[i] = ((int)_G(pbuff)[i] * 255 + 31) / 63;
+    Gfx::set_palette(_G(pbuff));
 
     // Create story image and load in it's fragments
     _surface.create(320, 240 * 2);
@@ -93,13 +93,20 @@ bool Story::msgFocus(const FocusMessage &msg) {
 
     // Final two glyphs
     Gfx::Pics glyphs("STORYPIC", 262);
-    _surface.simpleBlitFrom(glyphs[0], Common::Point(146, 64));
-    if (_G(area) == 1)
-        _surface.simpleBlitFrom(glyphs[1], Common::Point(24, 88 + 240));
+
+	if (_G(area) == 1) {
+		_surface.simpleBlitFrom(glyphs[0], Common::Point(146, 64));
+		_surface.simpleBlitFrom(glyphs[1], Common::Point(24, 88 + 240));
+	} else {
+		_surface.simpleBlitFrom(glyphs[0], Common::Point(146, 16));
+	}
 
     // Play the opening music
     music_play("OPENSONG", 1);
 
+	_yp = 0;
+	_scrolling = false;
+
     return true;
 }
 


Commit: a2bb5c89b20bab619282bf8aee33f53b9242427d
    https://github.com/scummvm/scummvm/commit/a2bb5c89b20bab619282bf8aee33f53b9242427d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Further fixes for Story display

Changed paths:
    engines/got/gfx/font.cpp
    engines/got/gfx/font.h
    engines/got/gfx/gfx_surface.cpp
    engines/got/gfx/gfx_surface.h
    engines/got/views/story.cpp


diff --git a/engines/got/gfx/font.cpp b/engines/got/gfx/font.cpp
index db52d08c001..f9d47ef4105 100644
--- a/engines/got/gfx/font.cpp
+++ b/engines/got/gfx/font.cpp
@@ -72,22 +72,23 @@ void Font::drawString(Graphics::ManagedSurface *src, const Common::Point &pos,
 }
 
 void Font::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const {
-    const Graphics::ManagedSurface &glyph = _font[chr];
+	// Character drawing is done twice in the original:
+	// first at y + 1 with color 0, then at y with the given color
+	rawDrawChar(dst, chr, x, y + 1, 0);
+	rawDrawChar(dst, chr, x, y, color);
+}
 
-    // Character drawing is done twice in the original:
-    // first at y + 1 with color 0, then at y with the given color
-    for (int pass = 0; pass < 2; ++pass) {
-        int col = (pass == 0) ? 0 : color;
+void Font::rawDrawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const {
+	const Graphics::ManagedSurface &glyph = _font[chr];
 
-        for (int yp = 0; yp < glyph.h; ++yp) {
-            int startY = y + yp + (pass == 0 ? 1 : 0);
-            const byte *srcP = (const byte *)glyph.getBasePtr(0, yp);
-            byte *destP = (byte *)dst->getBasePtr(x, startY);
+    for (int yp = 0; yp < glyph.h; ++yp) {
+        int startY = y + yp;
+        const byte *srcP = (const byte *)glyph.getBasePtr(0, yp);
+        byte *destP = (byte *)dst->getBasePtr(x, startY);
 
-            for (int xp = 0; xp < glyph.w; ++xp, ++srcP, ++destP) {
-                if (*srcP)
-                    *destP = col;
-            }
+        for (int xp = 0; xp < glyph.w; ++xp, ++srcP, ++destP) {
+            if (*srcP)
+                *destP = color;
         }
     }
 }
diff --git a/engines/got/gfx/font.h b/engines/got/gfx/font.h
index f1cf46681fe..744d446ce05 100644
--- a/engines/got/gfx/font.h
+++ b/engines/got/gfx/font.h
@@ -51,6 +51,7 @@ public:
     void drawChar(Graphics::ManagedSurface *dst, uint32 chr, int x, int y, uint32 color) const override {
         Graphics::Font::drawChar(dst, chr, x, y, color);
     }
+	void rawDrawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const;
 
     void drawString(Graphics::ManagedSurface *src, const Common::Point &pos,
                     const Common::String &text, int color);
diff --git a/engines/got/gfx/gfx_surface.cpp b/engines/got/gfx/gfx_surface.cpp
index ab6ffc69ae2..bc2924aabf8 100644
--- a/engines/got/gfx/gfx_surface.cpp
+++ b/engines/got/gfx/gfx_surface.cpp
@@ -34,5 +34,9 @@ void GfxSurface::printChar(uint32 chr, int x, int y, uint32 color) {
     _G(font).drawChar(this, chr, x, y, color);
 }
 
+void GfxSurface::rawPrintChar(uint32 chr, int x, int y, uint32 color) {
+	_G(font).rawDrawChar(surfacePtr(), chr, x, y, color);
+}
+
 } // namespace Gfx
 } // namespace Got
diff --git a/engines/got/gfx/gfx_surface.h b/engines/got/gfx/gfx_surface.h
index 6f9071ad811..ee40855082c 100644
--- a/engines/got/gfx/gfx_surface.h
+++ b/engines/got/gfx/gfx_surface.h
@@ -40,6 +40,7 @@ public:
      */
     void print(const Common::Point &pos, const Common::String &text, int color);
     void printChar(uint32 chr, int x, int y, uint32 color);
+	void rawPrintChar(uint32 chr, int x, int y, uint32 color);
 };
 
 } // namespace Gfx
diff --git a/engines/got/views/story.cpp b/engines/got/views/story.cpp
index 3e3ad0e7f40..8efa0566017 100644
--- a/engines/got/views/story.cpp
+++ b/engines/got/views/story.cpp
@@ -32,9 +32,6 @@ bool Story::msgFocus(const FocusMessage &msg) {
     res_read(Common::String::format("STORY%d", _G(area)), _G(tmp_buff));
 
     res_read("STORYPAL", _G(pbuff));
-    _G(pbuff)[2] = 0;
-    _G(pbuff)[1] = 0;
-    _G(pbuff)[0] = 0;
 
     for (int i = 0; i < PALETTE_SIZE; ++i)
         _G(pbuff)[i] = ((int)_G(pbuff)[i] * 255 + 31) / 63;
@@ -76,15 +73,15 @@ bool Story::msgFocus(const FocusMessage &msg) {
             s[3] = 0;
             color = atoi(s);
         } else if (*p != '\r') {
-            _surface.printChar(*p, x - 1, y - 1, 255);
-            _surface.printChar(*p, x + 1, y + 1, 255);
-            _surface.printChar(*p, x - 1, y + 1, 255);
-            _surface.printChar(*p, x + 1, y - 1, 255);
-            _surface.printChar(*p, x, y - 1, 255);
-            _surface.printChar(*p, x, y + 1, 255);
-            _surface.printChar(*p, x - 1, y, 255);
-            _surface.printChar(*p, x + 1, y, 255);
-            _surface.printChar(*p, x, y, color);
+            _surface.rawPrintChar(*p, x - 1, y - 1, 255);
+            _surface.rawPrintChar(*p, x + 1, y + 1, 255);
+            _surface.rawPrintChar(*p, x - 1, y + 1, 255);
+            _surface.rawPrintChar(*p, x + 1, y - 1, 255);
+            _surface.rawPrintChar(*p, x, y - 1, 255);
+            _surface.rawPrintChar(*p, x, y + 1, 255);
+            _surface.rawPrintChar(*p, x - 1, y, 255);
+            _surface.rawPrintChar(*p, x + 1, y, 255);
+			_surface.rawPrintChar(*p, x, y, color);
             x += 8;
         }
 


Commit: 3d62dedbc6e8876a1f48b435ce9b63828b97b838
    https://github.com/scummvm/scummvm/commit/3d62dedbc6e8876a1f48b435ce9b63828b97b838
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Remove unused file_size methods

Changed paths:
    engines/got/utils/file.cpp
    engines/got/utils/file.h


diff --git a/engines/got/utils/file.cpp b/engines/got/utils/file.cpp
index d354f3b7bd0..c4c2952f963 100644
--- a/engines/got/utils/file.cpp
+++ b/engines/got/utils/file.cpp
@@ -33,12 +33,6 @@ bool File::open(const Common::Path &filename) {
     return true;
 }
 
-
-long file_size(char *path) {
-    Common::File f;
-    return f.open(Common::Path(path)) ? f.size() : -1;
-}
-
 bool load_actor(int /*file*/, int num) {
     Common::String fname = Common::String::format("ACTOR%d", num);
 
diff --git a/engines/got/utils/file.h b/engines/got/utils/file.h
index de136c62792..c292d0df3fa 100644
--- a/engines/got/utils/file.h
+++ b/engines/got/utils/file.h
@@ -27,12 +27,9 @@
 
 namespace Got {
 
-extern long file_size(const char *path);
-
 extern bool load_actor(int, int num);
 extern void setup_filenames(int level);
 extern bool  load_speech(int index);
-extern long file_size(const char *path);
 extern long res_read(const Common::String &name, void *buff,
                      bool failAllowed = false);
 extern void *res_falloc_read(const Common::String &name);


Commit: dec0a1fa7f9424780de968330a5e6338cafbc631
    https://github.com/scummvm/scummvm/commit/dec0a1fa7f9424780de968330a5e6338cafbc631
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Rework high score defaults to avoid x64 build error

Changed paths:
    engines/got/data/high_scores.cpp
    engines/got/data/high_scores.h
    engines/got/events.cpp
    engines/got/views/dialogs/main_menu.cpp


diff --git a/engines/got/data/high_scores.cpp b/engines/got/data/high_scores.cpp
index 7e836644927..0b9f9fb4b3b 100644
--- a/engines/got/data/high_scores.cpp
+++ b/engines/got/data/high_scores.cpp
@@ -27,14 +27,9 @@
 
 namespace Got {
 
-static const HighScore DEFAULTS[HIGH_SCORES_PER_AREA] = {
-    { 0, 10000, "Ron Davis" },
-    { 0,  9000, "Gary Sirois" },
-    { 0,  8000, "Adam Pedersen" },
-    { 0,  7000, "Jason Blochowiak" },
-    { 0,  6000, "Roy Davis" },
-    { 0,  5000, "Wayne Timmerman" },
-    { 0,  4000, "Dan Linton" }
+static const char *DEFAULT_NAMES[HIGH_SCORES_PER_AREA] = {
+	"Ron Davis", "Gary Sirois", "Adam Pedersen", "Jason Blochowiak",
+	"Roy Davis", "Wayne Timmerman", "Dan Linton"
 };
 
 void HighScore::sync(Common::Serializer &s) {
@@ -66,9 +61,10 @@ void HighScores::load() {
         sync(s);
     } else {
         // Generate new data
-        for (int area = 0; area < 3; ++area)
-            for (int num = 0; num < HIGH_SCORES_PER_AREA; ++num)
-                _scores[area][num] = DEFAULTS[num];
+		for (int area = 0; area < 3; ++area)
+			for (int num = 0; num < HIGH_SCORES_PER_AREA; ++num)
+				_scores[area][num] = HighScore(DEFAULT_NAMES[num],
+					10000 - (num * 1000));
     }
 }
 
diff --git a/engines/got/data/high_scores.h b/engines/got/data/high_scores.h
index 2ea739a8e4f..16a40432720 100644
--- a/engines/got/data/high_scores.h
+++ b/engines/got/data/high_scores.h
@@ -29,10 +29,14 @@ namespace Got {
 #define HIGH_SCORES_PER_AREA 7
 
 struct HighScore {
-    uint16 _unused;
-    uint32 _total;
-    char _name[32];
-
+    uint16 _unused = 0;
+    uint32 _total = 0;
+	char _name[32] = {};
+
+	HighScore() {}
+	HighScore(const char *name, uint32 total) : _total(total) {
+		Common::strcpy_s(_name, name);
+	}
     void sync(Common::Serializer &s);
 };
 
diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index e871e20e91e..b4faccace01 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -117,10 +117,11 @@ void Events::nextFrame() {
     _G(magic_cnt)++;
 
     // In demo mode, handle the next key
-    if (_G(demo) && _G(gameMode) == MODE_NORMAL) {
+    if (_G(demo)) {
         if (_G(demoKeys).empty()) {
-            _views.clear();
-            return;
+			_G(demo) = false;
+			send("TitleBackground", GameMessage("MAIN_MENU"));
+			return;
         } else {
             processDemoEvent(_G(demoKeys).pop());
         }
diff --git a/engines/got/views/dialogs/main_menu.cpp b/engines/got/views/dialogs/main_menu.cpp
index fb556999697..63bd01235b5 100644
--- a/engines/got/views/dialogs/main_menu.cpp
+++ b/engines/got/views/dialogs/main_menu.cpp
@@ -65,9 +65,9 @@ void MainMenu::selected() {
         break;
 
     case 4:
-        _G(demo) = true;
         initialize_game();
-        replaceView("Game", true, true);
+		_G(demo) = true;
+		replaceView("Game", true, true);
         break;
 
     case 5:


Commit: b9da85266341d9903a2bca4cf8808d32b41affa4
    https://github.com/scummvm/scummvm/commit/b9da85266341d9903a2bca4cf8808d32b41affa4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Preliminary fixes for demo mode

Changed paths:
    engines/got/events.cpp
    engines/got/vars.cpp
    engines/got/views/dialogs/main_menu.cpp


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index b4faccace01..1bba280a0c6 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -77,9 +77,9 @@ void Events::runGame() {
                     e.type == Common::EVENT_RETURN_TO_LAUNCHER) {
                 _views.clear();
                 break;
-            } else if (!_G(demo)) {
-                processEvent(e);
-            }
+			} else {
+				processEvent(e);
+			}
         }
 
         if (_views.empty())
@@ -117,7 +117,7 @@ void Events::nextFrame() {
     _G(magic_cnt)++;
 
     // In demo mode, handle the next key
-    if (_G(demo)) {
+    if (_G(demo) && focusedView()->getName() == "Game") {
         if (_G(demoKeys).empty()) {
 			_G(demo) = false;
 			send("TitleBackground", GameMessage("MAIN_MENU"));
@@ -180,35 +180,47 @@ void Events::rotatePalette() {
 void Events::processEvent(Common::Event &ev) {
     switch (ev.type) {
     case Common::EVENT_KEYDOWN:
-        if (ev.kbd.keycode < 100)
-            _G(key_flag)[ev.kbd.keycode] = true;
+		if (!_G(demo)) {
+			if (ev.kbd.keycode < 100)
+				_G(key_flag)[ev.kbd.keycode] = true;
 
-        if (ev.kbd.keycode < Common::KEYCODE_NUMLOCK)
-            msgKeypress(KeypressMessage(ev.kbd));
+			if (ev.kbd.keycode < Common::KEYCODE_NUMLOCK)
+				msgKeypress(KeypressMessage(ev.kbd));
+		}
         break;
     case Common::EVENT_KEYUP:
-        if (ev.kbd.keycode < 100)
+        if (!_G(demo) && ev.kbd.keycode < 100)
             _G(key_flag)[ev.kbd.keycode] = false;
         break;
     case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
-        _G(key_flag)[actionToKeyFlag(ev.customType)] = true;
-        msgAction(ActionMessage(ev.customType));
+		if (!_G(demo)) {
+			_G(key_flag)[actionToKeyFlag(ev.customType)] = true;
+			msgAction(ActionMessage(ev.customType));
+		} else {
+			// The Escape action will return to main menu from demo
+			_G(demo) = false;
+			send("TitleBackground", GameMessage("MAIN_MENU"));
+		}
         break;
     case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
-        _G(key_flag)[actionToKeyFlag(ev.customType)] = false;
+		if (!_G(demo))
+			_G(key_flag)[actionToKeyFlag(ev.customType)] = false;
         break;
     case Common::EVENT_LBUTTONDOWN:
     case Common::EVENT_RBUTTONDOWN:
     case Common::EVENT_MBUTTONDOWN:
-        msgMouseDown(MouseDownMessage(ev.type, ev.mouse));
+		if (!_G(demo))
+			msgMouseDown(MouseDownMessage(ev.type, ev.mouse));
         break;
     case Common::EVENT_LBUTTONUP:
     case Common::EVENT_RBUTTONUP:
     case Common::EVENT_MBUTTONUP:
-        msgMouseUp(MouseUpMessage(ev.type, ev.mouse));
+		if (!_G(demo))
+			msgMouseUp(MouseUpMessage(ev.type, ev.mouse));
         break;
     case Common::EVENT_MOUSEMOVE:
-        msgMouseMove(MouseMoveMessage(ev.type, ev.mouse));
+		if (!_G(demo))
+			msgMouseMove(MouseMoveMessage(ev.type, ev.mouse));
         break;
     default:
         break;
@@ -216,13 +228,14 @@ void Events::processEvent(Common::Event &ev) {
 }
 
 void Events::processDemoEvent(byte ev) {
+	if (!ev)
+		return;
+
     bool flag = ev & 0x80;
     ev &= 0x7f;
 
     int action = -1;
     switch (ev) {
-    case 0:
-        return;
     case 72:
         ev = key_up;
         action = KEYBIND_UP;
@@ -244,6 +257,10 @@ void Events::processDemoEvent(byte ev) {
         ev = key_magic;
         action = KEYBIND_MAGIC;
         break;
+	case 39:
+		ev = key_select;
+		action = KEYBIND_SELECT;
+		break;
     default:
         break;
     }
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index e0c73814dff..348dcb70824 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -115,7 +115,6 @@ void Vars::clearKeyFlags() {
 
 void Vars::resetEndgameFlags() {
     _gameMode = MODE_NORMAL;
-    _demo = false;
     _auto_load = false;
     _end_tile = false;
     _boss_dead = false;
diff --git a/engines/got/views/dialogs/main_menu.cpp b/engines/got/views/dialogs/main_menu.cpp
index 63bd01235b5..fb556999697 100644
--- a/engines/got/views/dialogs/main_menu.cpp
+++ b/engines/got/views/dialogs/main_menu.cpp
@@ -65,9 +65,9 @@ void MainMenu::selected() {
         break;
 
     case 4:
+        _G(demo) = true;
         initialize_game();
-		_G(demo) = true;
-		replaceView("Game", true, true);
+        replaceView("Game", true, true);
         break;
 
     case 5:


Commit: c96bf9840fa15201c4f5ba1ea496d64e1bfd7dde
    https://github.com/scummvm/scummvm/commit/c96bf9840fa15201c4f5ba1ea496d64e1bfd7dde
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Hide Demo main menu option for now

Changed paths:
    engines/got/events.cpp
    engines/got/game/init.cpp
    engines/got/views/dialogs/main_menu.cpp


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 1bba280a0c6..2737758ece5 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -196,7 +196,7 @@ void Events::processEvent(Common::Event &ev) {
 		if (!_G(demo)) {
 			_G(key_flag)[actionToKeyFlag(ev.customType)] = true;
 			msgAction(ActionMessage(ev.customType));
-		} else {
+		} else if (ev.customType == KEYBIND_ESCAPE) {
 			// The Escape action will return to main menu from demo
 			_G(demo) = false;
 			send("TitleBackground", GameMessage("MAIN_MENU"));
diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index 3184c10b143..ed05ef95ff2 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -94,6 +94,11 @@ void initialize_game() {
         for (int i = 0; i < DEMO_LEN; ++i)
             _G(demoKeys).push(f.readByte());
 
+		// Drop the first six bytes off. This comprises of
+		// the "part I" display in the original, and ScummVM
+		// doesn't do demo key processing until the game view
+		for (int i = 0; i < 6; ++i)
+			_G(demoKeys).pop();
     }
 
     _G(thor)->speed_count = 6;
diff --git a/engines/got/views/dialogs/main_menu.cpp b/engines/got/views/dialogs/main_menu.cpp
index fb556999697..741354cd18c 100644
--- a/engines/got/views/dialogs/main_menu.cpp
+++ b/engines/got/views/dialogs/main_menu.cpp
@@ -30,8 +30,12 @@ namespace Dialogs {
 static const char *OPTIONS[] = {
     "Play Game", "Load Game", "High Scores", "Credits", "Demo", "Quit", nullptr
 };
+static const char *OPTIONS_NO_DEMO[] = {
+	"Play Game", "Load Game", "High Scores", "Credits", "Quit", nullptr
+};
 
-MainMenu::MainMenu() : SelectOption("MainMenu", "God of Thunder Menu", OPTIONS) {
+MainMenu::MainMenu() : SelectOption("MainMenu", "God of Thunder Menu",
+	gDebugLevel > 0 ? OPTIONS : OPTIONS_NO_DEMO) {
 }
 
 bool MainMenu::msgFocus(const FocusMessage &msg) {
@@ -65,9 +69,13 @@ void MainMenu::selected() {
         break;
 
     case 4:
-        _G(demo) = true;
-        initialize_game();
-        replaceView("Game", true, true);
+		if (gDebugLevel > 0) {
+			_G(demo) = true;
+			initialize_game();
+			replaceView("PartTitle", true, true);
+		} else {
+			addView("Quit");
+		}
         break;
 
     case 5:


Commit: b3ef91d3b58703eeaf7f7b5863f749a2d32eb15e
    https://github.com/scummvm/scummvm/commit/b3ef91d3b58703eeaf7f7b5863f749a2d32eb15e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Create ACTOR::operator=

This will hopefully fix some of the reported x64 build warnings

Changed paths:
    engines/got/data/actor.cpp
    engines/got/data/actor.h


diff --git a/engines/got/data/actor.cpp b/engines/got/data/actor.cpp
index e14a995d72b..aaf26b36a5d 100644
--- a/engines/got/data/actor.cpp
+++ b/engines/got/data/actor.cpp
@@ -91,4 +91,61 @@ void ACTOR::copyFixedAndPics(const ACTOR &src) {
 			pic[d][f].copyFrom(src.pic[d][f]);
 }
 
+ACTOR &ACTOR::operator=(const ACTOR &src) {
+	// First copy the fixed portion and the pics
+	copyFixedAndPics(src);
+
+	// Copy temporary fields
+	frame_count = src.frame_count;
+	dir = src.dir;
+	last_dir = src.last_dir;
+	x = src.x;
+	y = src.y;
+	center = src.center;
+	Common::copy(src.last_x, src.last_x + 2, last_x);
+	Common::copy(src.last_y, src.last_y + 2, last_y);
+	used = src.used;
+	next = src.next;
+	speed_count = src.speed_count;
+	vunerable = src.vunerable;
+	shot_cnt = src.shot_cnt;
+	num_shots = src.num_shots;
+	creator = src.creator;
+	pause = src.pause;
+	actor_num = src.actor_num;
+	move_count = src.move_count;
+	dead = src.dead;
+	toggle = src.toggle;
+	center_x = src.center_x;
+	center_y = src.center_y;
+	show = src.show;
+	temp1 = src.temp1;
+	temp2 = src.temp2;
+	counter = src.counter;
+	move_counter = src.move_counter;
+	edge_counter = src.edge_counter;
+	temp3 = src.temp3;
+	temp4 = src.temp4;
+	temp5 = src.temp5;
+	hit_thor = src.hit_thor;
+	rand = src.rand;
+	init_dir = src.init_dir;
+	pass_value = src.pass_value;
+	shot_actor = src.shot_actor;
+	magic_hit = src.magic_hit;
+	temp6 = src.temp6;
+	i1 = src.i1;
+	i2 = src.i2;
+	i3 = src.i3;
+	i4 = src.i4;
+	i5 = src.i5;
+	i6 = src.i6;
+	init_health = src.init_health;
+	talk_counter = src.talk_counter;
+	etype = src.etype;
+	Common::copy(src.future2, src.future2 + 25, future2);
+
+	return *this;
+}
+
 } // namespace Got
diff --git a/engines/got/data/actor.h b/engines/got/data/actor.h
index 55be93a775e..7fab2cce78c 100644
--- a/engines/got/data/actor.h
+++ b/engines/got/data/actor.h
@@ -114,6 +114,8 @@ struct ACTOR {                      // Size=256
      */
     void copyFixedAndPics(const ACTOR &src);
 
+	ACTOR &operator=(const ACTOR &src);
+
     int getPos() const {
         return ((x + 7) / 16) + (((y + 8) / 16) * 20);
     }


Commit: 1ad616231a4258ecb88317ebf104e62771df1584
    https://github.com/scummvm/scummvm/commit/1ad616231a4258ecb88317ebf104e62771df1584
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: More x64 build warning fixes

Changed paths:
    engines/got/data/thor_info.cpp
    engines/got/data/thor_info.h
    engines/got/game/boss3.cpp
    engines/got/game/init.cpp


diff --git a/engines/got/data/thor_info.cpp b/engines/got/data/thor_info.cpp
index f9dda0f048a..7f55b472a59 100644
--- a/engines/got/data/thor_info.cpp
+++ b/engines/got/data/thor_info.cpp
@@ -19,11 +19,39 @@
  *
  */
 
+#include "common/algorithm.h"
 #include "got/data/thor_info.h"
 #include "got/game/back.h"
 
 namespace Got {
 
+void THOR_INFO::clear() {
+	magic = 0;
+	keys = 0;
+	jewels = 0;
+	last_area = 0;
+	last_screen = 0;
+	last_icon = 0;
+	last_dir = 0;
+	inventory = 0;
+	item = 0;
+	last_health = 0;
+	last_magic = 0;
+	last_jewels = 0;
+	last_keys = 0;
+	last_item = 0;
+	last_inventory = 0;
+	level = 0;
+	score = 0;
+	last_score = 0;
+	object = 0;
+	object_name = nullptr;
+	last_object = 0;
+	last_object_name = nullptr;
+	armor = 0;
+	Common::fill(future, future + 65, 0);
+}
+
 void THOR_INFO::sync(Common::Serializer &s) {
     uint32 ptr = 0;
 
diff --git a/engines/got/data/thor_info.h b/engines/got/data/thor_info.h
index 0115fc033a9..99d9a38bdc6 100644
--- a/engines/got/data/thor_info.h
+++ b/engines/got/data/thor_info.h
@@ -52,6 +52,7 @@ struct THOR_INFO {
     byte armor = 0;
     byte future[65] = {};
 
+	void clear();
     void sync(Common::Serializer &s);
 };
 
diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index a35d40b273b..ae34b7a05a4 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -36,7 +36,7 @@ namespace Got {
 #define LFC 10
 
 static int  boss_mode;
-static int  num_pods, num_pods1;
+static int  num_pods1;
 static byte pod_speed;
 static const byte EXPLOSION[4][8] = {
     {126,127,128,129,130,131,132,133},
diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index ed05ef95ff2..4532d6028fa 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -33,7 +33,7 @@
 namespace Got {
 
 void setup_player() {
-    memset(&_G(thor_info), 0, sizeof(_G(thor_info)));
+	_G(thor_info).clear();
     _G(thor_info).inventory = 0;
     if (_G(area) > 1)
         _G(thor_info).inventory |= APPLE_MAGIC + LIGHTNING_MAGIC;


Commit: b3564a1d74e7af107822c2ade0a96b6b3ee7ef66
    https://github.com/scummvm/scummvm/commit/b3564a1d74e7af107822c2ade0a96b6b3ee7ef66
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Janitorial for script.cpp

Changed paths:
    engines/got/game/script.cpp


diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index de023332a9b..1cb84f3b646 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -359,8 +359,10 @@ int Scripts::get_next_val() {
     int t;
 
     ch = *_buffPtr;
-    if (ch == 0 || ch == ':') return 0;
-    if (ch == 64) return get_internal_variable();
+    if (ch == 0 || ch == ':')
+		return 0;
+    if (ch == 64)
+		return get_internal_variable();
 
     if (Common::isAlpha(ch)) {
         _buffPtr++;
@@ -524,7 +526,8 @@ int Scripts::read_script_file() {
             ret = 2;
             goto done;
         }
-        if (!strcmp(tmps, temp_buff)) break;
+        if (!strcmp(tmps, temp_buff))
+			break;
     }
     _numLabels = 0;
     while (1) {
@@ -600,7 +603,8 @@ void Scripts::script_error(int err_num) {
 
     while (1) {
         if (*tb == 0) line_num++;
-        if (tb >= _buffPtr) break;
+        if (tb >= _buffPtr)
+			break;
         tb++;
     }
 
@@ -621,7 +625,8 @@ int Scripts::cmd_goto() {
 
     for (i = 0; i < _numLabels; i++) {
         len = strlen(s);
-        if (len == 0) break;
+        if (len == 0)
+			break;
         if (!strcmp(s, _lineLabel[i])) {
             _newPtr = _linePtr[i];
             _buffPtr += len;
@@ -635,21 +640,26 @@ int Scripts::cmd_if() {
     long tmpval1, tmpval2;
     char exptype, ch;
 
-    if (!calc_value()) return 5;
+    if (!calc_value())
+		return 5;
     tmpval1 = _lValue;
     exptype = *_buffPtr;
     _buffPtr++;
 
     ch = *_buffPtr;
     if (ch == 60 || ch == 61 || ch == 62) {
-        if (exptype == *_buffPtr) return 5;
+        if (exptype == *_buffPtr)
+			return 5;
         exptype += *_buffPtr;
         _buffPtr++;
     }
-    if (!calc_value()) return 5;
-    tmpval2 = _lValue;
+    if (!calc_value())
+		return 5;
+
+	tmpval2 = _lValue;
     _buffPtr += 4;
-    switch (exptype) {
+
+	switch (exptype) {
     case 60:                              /* less than */
         if (tmpval1 < tmpval2) goto iftrue;
         goto iffalse;
@@ -676,14 +686,17 @@ iffalse:
     while (*_buffPtr != 0) _buffPtr++;
     while (*_buffPtr == 0) _buffPtr++;
 
-    if (!strncmp(_buffPtr, "ELSE", 4)) _buffPtr += 4;
+    if (!strncmp(_buffPtr, "ELSE", 4))
+		_buffPtr += 4;
 
 iftrue:
     return 0;
 }
 
 int Scripts::cmd_run() {
-    if (!calc_value()) return 5;
+    if (!calc_value())
+		return 5;
+
     _buffPtr++;
     _scrIndex = _lValue;
     return -100;
@@ -700,30 +713,36 @@ int Scripts::cmd_addjewels() {
 }
 
 int Scripts::cmd_addhealth() {
-    if (!calc_value()) return 5;
+    if (!calc_value())
+		return 5;
+
     _buffPtr++;
     add_health((int)_lValue);
     return 0;
 }
 
 int Scripts::cmd_addmagic() {
-    if (!calc_value()) return 5;
+    if (!calc_value())
+		return 5;
+
     _buffPtr++;
     add_magic((int)_lValue);
     return 0;
 }
 
 int Scripts::cmd_addkeys() {
+    if (!calc_value())
+		return 5;
 
-    if (!calc_value()) return 5;
     _buffPtr++;
     add_keys((int)_lValue);
     return 0;
 }
 
 int Scripts::cmd_addscore() {
+    if (!calc_value())
+		return 5;
 
-    if (!calc_value()) return 5;
     _buffPtr++;
     add_score((int)_lValue);
     return 0;
@@ -734,10 +753,12 @@ int Scripts::cmd_say(int mode, int type) {
     int obj;
 
     if (mode) {
-        if (!calc_value()) return 5;
+        if (!calc_value())
+			return 5;
         _buffPtr++;
         obj = (int)_lValue;
-        if (obj < 0 || obj>32) return 6;
+        if (obj < 0 || obj>32)
+			return 6;
         if (obj) obj += 10;
     } else obj = 0;
 
@@ -821,7 +842,9 @@ void Scripts::setAskResponse(int option) {
 }
 
 int Scripts::cmd_sound() {
-    if (!calc_value()) return 5;
+    if (!calc_value())
+		return 5;
+
     _buffPtr++;
     if (_lValue < 1 || _lValue>16) return 6;
     play_sound((int)_lValue - 1, 1);
@@ -831,18 +854,26 @@ int Scripts::cmd_sound() {
 int Scripts::cmd_settile() {
     int screen, pos, tile;
 
-    if (!calc_value()) return 5;
+    if (!calc_value())
+		return 5;
     _buffPtr++;
     screen = (int)_lValue;
-    if (!calc_value()) return 5;
+    if (!calc_value())
+		return 5;
     _buffPtr++;
     pos = (int)_lValue;
-    if (!calc_value()) return 5;
+    if (!calc_value())
+		return 5;
     tile = (int)_lValue;
-    if (screen < 0 || screen>119) return 6;
-    if (pos < 0 || pos>239) return 6;
-    if (tile < 0 || tile>230) return 6;
-    if (screen == _G(current_level)) {
+
+	if (screen < 0 || screen > 119)
+		return 6;
+    if (pos < 0 || pos > 239)
+		return 6;
+    if (tile < 0 || tile > 230)
+		return 6;
+
+	if (screen == _G(current_level)) {
         place_tile(pos % 20, pos / 20, tile);
     } else {
         LEVEL tmp;
@@ -861,7 +892,8 @@ int Scripts::cmd_itemgive() {
 
     _buffPtr++;
     i = (int)_lValue;
-    if (i < 1 || i > 15) return 6;
+    if (i < 1 || i > 15)
+		return 6;
 
     _G(thor_info).inventory |= 64;
     _G(thor_info).item = 7;
@@ -877,36 +909,41 @@ int Scripts::cmd_itemtake() {
 }
 
 int Scripts::cmd_setflag() {
-    int i;
+	int i;
 
-    if (!calc_value())
-        return 5;
+	if (!calc_value())
+		return 5;
 
 	i = (int)_lValue;
-    if (i < 1 || i>64)
-        return 6;
+	if (i < 1 || i>64)
+		return 6;
 
 	_G(setup)._flags[i - 1] = true;
 
-    return 0;
+	return 0;
 }
 
 int Scripts::cmd_ltoa() {
-    int sv;
-
-    if (!calc_value()) return 5;
-    _buffPtr++;
-
-    if (Common::isAlpha(*_buffPtr)) {
-        if (*(_buffPtr + 1) == '$') {
-            sv = (*_buffPtr) - 65;
-            _buffPtr += 2;
-        } else return 5;
-    } else return 5;
-
-    Common::String str = Common::String::format("%ld", _lValue);
-    Common::strcpy_s(_strVar[sv], str.c_str());
-    return 0;
+	int sv;
+
+	if (!calc_value())
+		return 5;
+	_buffPtr++;
+
+	if (Common::isAlpha(*_buffPtr)) {
+		if (*(_buffPtr + 1) == '$') {
+			sv = (*_buffPtr) - 65;
+			_buffPtr += 2;
+		} else {
+			return 5;
+		}
+	} else {
+		return 5;
+	}
+
+	Common::String str = Common::String::format("%ld", _lValue);
+	Common::strcpy_s(_strVar[sv], str.c_str());
+	return 0;
 }
 
 int Scripts::cmd_pause() {
@@ -935,14 +972,19 @@ int Scripts::cmd_random() {
     if (Common::isAlpha(*_buffPtr)) {
         v = *_buffPtr - 65;
         _buffPtr++;
-        if (*_buffPtr != ',') return 5;
+        if (*_buffPtr != ',')
+			return 5;
         _buffPtr++;
-    } else return 5;
+	} else {
+		return 5;
+	}
 
-    if (!calc_value()) return 5;
+    if (!calc_value())
+		return 5;
     _buffPtr++;
     r = (int)_lValue;
-    if (r < 1 || r>1000) return 6;
+    if (r < 1 || r>1000)
+		return 6;
 
     _numVar[v] = g_events->getRandomNumber(r - 1);
     return 0;
@@ -1026,7 +1068,8 @@ void Scripts::scr_func5() {
 }
 
 int Scripts::cmd_exec() {
-    if (!calc_value()) return 5;
+    if (!calc_value())
+		return 5;
     _buffPtr++;
     if (_lValue < 1 || _lValue>10)
         return 6;
@@ -1173,10 +1216,12 @@ int Scripts::exec_command(int num) {
     default:
         ret = 5;
     }
-    if (ret > 0) {
+
+	if (ret > 0) {
         script_error(ret);
         return 0;
     }
+
     return 1;
 }
 


Commit: 860070f223822784b4e99ddbcc823b6b2b3494db
    https://github.com/scummvm/scummvm/commit/860070f223822784b4e99ddbcc823b6b2b3494db
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Further x64 warning fixes

Changed paths:
    engines/got/game/special_tile.cpp
    engines/got/gfx/font.cpp
    engines/got/utils/file.cpp
    engines/got/views/credits.cpp
    engines/got/views/dialogs/say.cpp
    engines/got/views/game_status.cpp


diff --git a/engines/got/game/special_tile.cpp b/engines/got/game/special_tile.cpp
index 781ea711208..da156ec988e 100644
--- a/engines/got/game/special_tile.cpp
+++ b/engines/got/game/special_tile.cpp
@@ -151,8 +151,10 @@ int special_tile_thor(int x, int y, int icon) {
         return 0;
     case 218:
     case 219:
+		// Hole tiles
         f = 1;
-    case 220:     // Hole tiles
+		// fall through
+    case 220:
     case 221:
     case 222:
     case 223:
@@ -162,6 +164,7 @@ int special_tile_thor(int x, int y, int icon) {
     case 227:
     case 228:
     case 229:
+		// Hole tiles
         cx = (_G(thor_x1) + 7) / 16;
         cy = (_G(thor_real_y1) + 8) / 16;
         if (_G(scrn).icon[cy][cx] == icon) {
diff --git a/engines/got/gfx/font.cpp b/engines/got/gfx/font.cpp
index f9d47ef4105..083c7d1067b 100644
--- a/engines/got/gfx/font.cpp
+++ b/engines/got/gfx/font.cpp
@@ -61,7 +61,7 @@ void Font::drawString(Graphics::ManagedSurface *src, const Common::Point &pos,
             } else {
                 ch = toupper(ch) - 55;
             }
-            color = DIALOG_COLOR[ch];
+            color = DIALOG_COLOR[(byte)ch];
             continue;
         }
         if (ch > 31 && ch < 127)
diff --git a/engines/got/utils/file.cpp b/engines/got/utils/file.cpp
index c4c2952f963..eed61089a40 100644
--- a/engines/got/utils/file.cpp
+++ b/engines/got/utils/file.cpp
@@ -25,8 +25,6 @@
 
 namespace Got {
 
-static const char *gotres = "GOTRES.00";
-
 bool File::open(const Common::Path &filename) {
     if (!Common::File::open(filename))
         error("Could not open - %s", filename.baseName().c_str());
diff --git a/engines/got/views/credits.cpp b/engines/got/views/credits.cpp
index 449e6b65a80..9cba2569b85 100644
--- a/engines/got/views/credits.cpp
+++ b/engines/got/views/credits.cpp
@@ -45,7 +45,7 @@ void Credits::draw() {
     GfxSurface s = getSurface();
 
     // Draw scroll background
-    Graphics::ManagedSurface bg = _G(gfx)[42];
+    const Graphics::ManagedSurface &bg = _G(gfx)[42];
     s.clear(*(byte *)bg.getPixels());
     s.simpleBlitFrom(bg, Common::Point(0, 24));
 
diff --git a/engines/got/views/dialogs/say.cpp b/engines/got/views/dialogs/say.cpp
index 017114c4ed8..0a2b74f72d8 100644
--- a/engines/got/views/dialogs/say.cpp
+++ b/engines/got/views/dialogs/say.cpp
@@ -26,8 +26,6 @@ namespace Got {
 namespace Views {
 namespace Dialogs {
 
-#define _HRZSP 24
-
 Say::Say() : Dialog("Say") {
     setBounds(Common::Rect(32, 48, 288, 160));
 }
diff --git a/engines/got/views/game_status.cpp b/engines/got/views/game_status.cpp
index aa0825f0c4c..14d2ba925e7 100644
--- a/engines/got/views/game_status.cpp
+++ b/engines/got/views/game_status.cpp
@@ -74,7 +74,7 @@ void GameStatus::displayJewels(GfxSurface &s) {
 }
 
 void GameStatus::displayScore(GfxSurface &s) {
-    Common::String str = Common::String::format("%d", _G(thor_info).score);
+    Common::String str = Common::String::format("%ld", _G(thor_info).score);
     int x = 276 - (str.size() * 8);
 
     s.fillRect(Common::Rect(223, 32, 279, 42), STAT_COLOR);


Commit: fb2666a57a22251745ddd8e4387dba6df02f0d9c
    https://github.com/scummvm/scummvm/commit/fb2666a57a22251745ddd8e4387dba6df02f0d9c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: More x64 warning fixes

Changed paths:
    engines/got/gfx/font.cpp
    engines/got/views/credits.cpp


diff --git a/engines/got/gfx/font.cpp b/engines/got/gfx/font.cpp
index 083c7d1067b..fb90a4df1fa 100644
--- a/engines/got/gfx/font.cpp
+++ b/engines/got/gfx/font.cpp
@@ -47,11 +47,9 @@ void Font::load() {
 void Font::drawString(Graphics::ManagedSurface *src, const Common::Point &pos,
                       const Common::String &text, int color) {
     char ch;
-    char str[4];
     const char *string = text.c_str();
     Common::Point pt = pos;
 
-    str[3] = 0;
     while (*string) {
         ch = *string++;
         if (ch == '~' && Common::isXDigit(*string)) {
diff --git a/engines/got/views/credits.cpp b/engines/got/views/credits.cpp
index 9cba2569b85..5e163b198e3 100644
--- a/engines/got/views/credits.cpp
+++ b/engines/got/views/credits.cpp
@@ -46,7 +46,7 @@ void Credits::draw() {
 
     // Draw scroll background
     const Graphics::ManagedSurface &bg = _G(gfx)[42];
-    s.clear(*(byte *)bg.getPixels());
+    s.clear(*(const byte *)bg.getPixels());
     s.simpleBlitFrom(bg, Common::Point(0, 24));
 
     int creditNum = _frameCtr / CREDIT_TIME;


Commit: deff5a3137f8bfee7a746ef32d31f37273385ea7
    https://github.com/scummvm/scummvm/commit/deff5a3137f8bfee7a746ef32d31f37273385ea7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Refactor Common::Array GfxPics to use raw array

This will hopefully work around an x64 warning for not
using ManagedSurface::copyFrom in array resizing code

Changed paths:
    engines/got/gfx/gfx_pics.cpp
    engines/got/gfx/gfx_pics.h


diff --git a/engines/got/gfx/gfx_pics.cpp b/engines/got/gfx/gfx_pics.cpp
index a8a4e80ba54..7b65dd610f2 100644
--- a/engines/got/gfx/gfx_pics.cpp
+++ b/engines/got/gfx/gfx_pics.cpp
@@ -47,6 +47,17 @@ void convertPaneDataToSurface(const byte *src, Graphics::ManagedSurface &surf) {
 }
 
 
+void GfxPics::clear() {
+	delete[] _array;
+	_array = nullptr;
+}
+
+void GfxPics::resize(uint newSize) {
+	assert(!_array);	// Don't support multiple resizes
+	_array = new Graphics::ManagedSurface[newSize];
+	_size = newSize;
+}
+
 void GfxPics::load(const Common::String &name, int blockSize) {
     File f(name);
 
diff --git a/engines/got/gfx/gfx_pics.h b/engines/got/gfx/gfx_pics.h
index 8cf680e4866..1c3bb481b70 100644
--- a/engines/got/gfx/gfx_pics.h
+++ b/engines/got/gfx/gfx_pics.h
@@ -38,9 +38,28 @@ namespace Gfx {
 extern void convertPaneDataToSurface(const byte *src, Graphics::ManagedSurface &surf);
 
 
-class GfxPics : public Common::Array<Graphics::ManagedSurface> {
+class GfxPics {
+private:
+	Graphics::ManagedSurface *_array = nullptr;
+	size_t _size = 0;
+
+protected:
+
 public:
+	~GfxPics() {
+		clear();
+	}	
+
+	void clear();
+	void resize(uint newSize);
     void load(const Common::String &name, int blockSize);
+
+	Graphics::ManagedSurface &operator[](uint idx) {
+		return _array[idx];
+	}
+	size_t size() const {
+		return _size;
+	}
 };
 
 class BgPics : public GfxPics {


Commit: d93bcf3c81ea3c2ce204880f152319b18ed5458a
    https://github.com/scummvm/scummvm/commit/d93bcf3c81ea3c2ce204880f152319b18ed5458a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Fix blank lines at bottom of Story display

Changed paths:
    engines/got/views/story.cpp


diff --git a/engines/got/views/story.cpp b/engines/got/views/story.cpp
index 8efa0566017..2408178ecfd 100644
--- a/engines/got/views/story.cpp
+++ b/engines/got/views/story.cpp
@@ -28,6 +28,8 @@
 namespace Got {
 namespace Views {
 
+#define MAX_Y 236
+
 bool Story::msgFocus(const FocusMessage &msg) {
     res_read(Common::String::format("STORY%d", _G(area)), _G(tmp_buff));
 
@@ -123,18 +125,18 @@ void Story::draw() {
 }
 
 bool Story::msgAction(const ActionMessage &msg) {
-    if (msg._action == KEYBIND_ESCAPE || _yp == 240)
+    if (msg._action == KEYBIND_ESCAPE || _yp == MAX_Y)
         done();
     else if (!_scrolling)
         _scrolling = true;
     else
-        _yp = 240;
+        _yp = MAX_Y;
 
     return true;
 }
 
 bool Story::msgKeypress(const KeypressMessage &msg) {
-    if (_yp == 240)
+    if (_yp == MAX_Y)
         done();
     else if (!_scrolling)
         _scrolling = true;
@@ -145,8 +147,8 @@ bool Story::msgKeypress(const KeypressMessage &msg) {
 }
 
 bool Story::tick() {
-    if (_scrolling && _yp < 240) {
-        _yp += 4;
+    if (_scrolling && _yp < MAX_Y) {
+        _yp = MIN(_yp + 4, MAX_Y);
         redraw();
     }
 


Commit: 2b6d0ac7b9155b5494e2b48ff7fe9d2966939f3a
    https://github.com/scummvm/scummvm/commit/2b6d0ac7b9155b5494e2b48ff7fe9d2966939f3a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Slightly increase the Part title timeout

Changed paths:
    engines/got/views/part_title.cpp


diff --git a/engines/got/views/part_title.cpp b/engines/got/views/part_title.cpp
index 8278d6c1e7b..4c89fc7b945 100644
--- a/engines/got/views/part_title.cpp
+++ b/engines/got/views/part_title.cpp
@@ -54,7 +54,7 @@ bool PartTitle::msgAction(const ActionMessage &msg) {
 }
 
 bool PartTitle::tick() {
-    if (++_timeoutCtr == 40) {
+    if (++_timeoutCtr == 80) {
         _timeoutCtr = 0;
         done();
     }


Commit: 2e578f8c83a12530316a4d1f50acadac4990840e
    https://github.com/scummvm/scummvm/commit/2e578f8c83a12530316a4d1f50acadac4990840e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Removed unneeded arrays, variables assigned to themselves

Changed paths:
    engines/got/game/back.cpp
    engines/got/game/move_patterns.cpp
    engines/got/game/shot_pattern.cpp


diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index 4e195b1a798..b9b3b7956ec 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -351,8 +351,6 @@ int actor_speaks(ACTOR *actr, int index, int item) {
     }
 
     d_restore();
-    index = index;
-    item = item;
 
     return 1;
 }
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index bf7a30cd138..0dc7207248d 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -38,10 +38,6 @@ namespace Got {
 #define TILE_FLY     140
 #define TILE_SPECIAL 200
 
-static const int bomb_x[] = { 0,-16,32,-32,32,-16,-16, 32,-16 };
-static const int bomb_y[] = { 0,-16,16,  0,16,-32, 32,-32, 32 };
-static const int8 rotate_pat[] = { 0,3,1,2 };
-
 extern int (*dialog_func[]) (ACTOR *actr);
 
 int check_special_move1(int x, int y, ACTOR *actr);
@@ -916,7 +912,7 @@ int special_movement_three(ACTOR *actr) {
 int special_movement_four(ACTOR *actr) {
     if (actr->shot_cnt != 0) return 0;
     actr->shot_cnt = 30;
-    actr = actr;
+
     _G(switch_flag) = 1;
     return 0;
 }
@@ -961,7 +957,7 @@ int special_movement_six(ACTOR *actr) {
 int special_movement_seven(ACTOR *actr) {
     if (actr->shot_cnt != 0) return 0;
     actr->shot_cnt = 30;
-    actr = actr;
+
     _G(switch_flag) = 2;
     return 0;
 }
@@ -2106,19 +2102,16 @@ done:
 
 // Unused
 int movement_thirtytwo(ACTOR *actr) {
-    actr = actr;
     return 0;
 }
 
 // Unused
 int movement_thirtythree(ACTOR *actr) {
-    actr = actr;
     return 0;
 }
 
 // Unused
 int movement_thirtyfour(ACTOR *actr) {
-    actr = actr;
     return 0;
 }
 
diff --git a/engines/got/game/shot_pattern.cpp b/engines/got/game/shot_pattern.cpp
index d20b05f52ef..8aa291413af 100644
--- a/engines/got/game/shot_pattern.cpp
+++ b/engines/got/game/shot_pattern.cpp
@@ -49,7 +49,6 @@ int (*const shot_pattern_func[])(ACTOR *actr) = {
 
 // No shooting
 int shot_pattern_none(ACTOR *actr) {
-    actr = actr;
     return 0;
 }
 
@@ -195,7 +194,6 @@ int shot_pattern_six(ACTOR *actr) {
 
 // none
 int shot_pattern_seven(ACTOR *actr) {
-    actr = actr;
     return 0;
 }
 


Commit: 99302bd8e90d0bb5c6e624e6c2a07d2f60ef2e4d
    https://github.com/scummvm/scummvm/commit/99302bd8e90d0bb5c6e624e6c2a07d2f60ef2e4d
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Reduce some variable scopes (CppCheck), enforce the use of boolean with play_sound()

Changed paths:
    engines/got/events.cpp
    engines/got/game/back.cpp
    engines/got/game/boss1.cpp
    engines/got/game/boss2.cpp
    engines/got/game/boss3.cpp
    engines/got/game/move.cpp
    engines/got/game/move_patterns.cpp
    engines/got/game/object.cpp
    engines/got/game/script.cpp
    engines/got/game/shot_pattern.cpp
    engines/got/game/special_tile.cpp
    engines/got/metaengine.cpp
    engines/got/sound.cpp


diff --git a/engines/got/events.cpp b/engines/got/events.cpp
index 2737758ece5..9292664fd06 100644
--- a/engines/got/events.cpp
+++ b/engines/got/events.cpp
@@ -25,7 +25,6 @@
 #include "got/got.h"
 #include "got/gfx/palette.h"
 #include "got/views/views.h"
-#include "got/views/game.h"
 
 namespace Got {
 
@@ -141,13 +140,13 @@ void Events::nextFrame() {
 #define LOOP_THRESHOLD 5
 
 void Events::rotatePalette() {
-    const uint16 *entry;
     ++_palLoop;
 
     if (_palLoop > LOOP_THRESHOLD) {
         _palLoop = 0;
     } else {
-        switch (_palLoop) {
+		const uint16 *entry;
+		switch (_palLoop) {
         case LOOP_THRESHOLD - 4:
             entry = &PAL_CLR2[_palCnt2];
             break;
@@ -476,9 +475,9 @@ UIElement *UIElement::findView(const Common::String &name) {
     if (_name.equalsIgnoreCase(name))
         return this;
 
-    UIElement *result;
     for (size_t i = 0; i < _children.size(); ++i) {
-        if ((result = _children[i]->findView(name)) != nullptr)
+		UIElement *result = _children[i]->findView(name);
+		if (result != nullptr)
             return result;
     }
 
diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index b9b3b7956ec..d80f14d2ef1 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -167,12 +167,12 @@ void show_level_done() {
             if (!_G(setup).boss_dead[2]) {
                 if (!_G(auto_load))
                     boss_level3();
-                f = 0;
+                f = false;
             }
         }
         if (_G(current_level) == ENDING_SCREEN) {
             ending_screen();
-            f = 0;
+            f = false;
         }
     }
 
@@ -204,12 +204,12 @@ void odin_speaks(int index, int item, const char *endMessage) {
 
 
 int switch_icons() {
-    int x, y, ix, iy;
+    int ix, iy;
 
-    play_sound(WOOP, 0);
+    play_sound(WOOP, false);
 
-    for (y = 0; y < 12; y++) {
-        for (x = 0; x < 20; x++) {
+    for (int y = 0; y < 12; y++) {
+        for (int x = 0; x < 20; x++) {
             ix = x * 16;
             iy = y * 16;
             if (_G(scrn).icon[y][x] == 93) {
@@ -233,7 +233,7 @@ int switch_icons() {
 int rotate_arrows() {
     int x, y;
 
-    play_sound(WOOP, 0);
+    play_sound(WOOP, false);
 
     for (y = 0; y < 12; y++) {
         for (x = 0; x < 20; x++) {
diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index 50a3309fa11..abc6bf415dc 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -55,7 +55,9 @@ int boss1_movement(ACTOR *actr) {
     }
     if (actr->temp3) {  //start striking
         actr->temp3--;
-        if (!actr->temp3) play_sound(BOSS11, 0);
+        if (!actr->temp3)
+			play_sound(BOSS11, false);
+    	
         if (_G(hourglass_flag))
             actr->num_moves = 3;
         else
@@ -194,7 +196,7 @@ void check_boss1_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
             _G(actor)[3].speed_count = 50;
             boss_status(_G(actor)[3].health);
             _G(actor)[3].vunerable = 100;
-            play_sound(BOSS13, 1);
+            play_sound(BOSS13, true);
             _G(actor)[3].next = 1;
 
             for (rep = 4; rep < 7; rep++) {
@@ -212,7 +214,7 @@ void boss_level1() {
     setup_boss(1);
     _G(boss_active) = 1;
     music_pause();
-    play_sound(BOSS11, 1);
+    play_sound(BOSS11, true);
     g_events->send("Game", GameMessage("PAUSE", 40));
     music_play(5, 1);
 }
@@ -247,7 +249,7 @@ static int boss1_dead() {
             _G(actor)[3 + rep].num_shots = (10 - _G(actor)[3 + rep].speed) * 10;
             _G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
         }
-        play_sound(EXPLODE, 1);
+        play_sound(EXPLODE, true);
         _G(boss_dead) = true;;
         for (rep = 7; rep < MAX_ACTORS; rep++)
             if (_G(actor)[rep].used)
@@ -279,14 +281,16 @@ void closing_sequence1_3() {
 
 void closing_sequence1_4() {
     int rep;
-    REPEAT(16) _G(scrn).actor_type[rep] = 0;
+	for (rep = 0; rep < 16; rep++)
+		_G(scrn).actor_type[rep] = 0;
+	
     _G(boss_dead) = 0;
     _G(setup).boss_dead[0] = 1;
     _G(boss_active) = 0;
     _G(scrn).type = 4;
     show_level(BOSS_LEVEL1);
 
-    play_sound(ANGEL, 1);
+    play_sound(ANGEL, true);
     place_tile(18, 6, 148);
     place_tile(19, 6, 202);
     actor_visible(1);
diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index 91febe6a0cd..ece731d646c 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -115,7 +115,7 @@ int boss2_movement(ACTOR *actr) {
             _G(actor)[3].temp6 = 40;
 
             actor_always_shoots(actr, 1);
-            play_sound(FALL, 0);
+            play_sound(FALL, false);
             _G(actor)[actr->shot_actor].x = actr->x + 12;
             _G(actor)[actr->shot_actor].y = actr->y + 32;
             _G(actor)[actr->shot_actor].temp2 = 0;
@@ -164,7 +164,7 @@ void check_boss2_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
                 if (_G(actor)[rep].used)
                     actor_destroyed(&_G(actor)[rep]);
             _G(actor)[3].num_shots = 0;
-        } else play_sound(BOSS13, 1);
+        } else play_sound(BOSS13, true);
         _G(actor)[3].speed_count = 75;
         boss_status(_G(actor)[3].health);
         _G(actor)[3].vunerable = 75;
@@ -187,7 +187,7 @@ void boss_level2() {
     _G(boss_active) = 1;
     boss_status(-1);
     music_pause();
-    play_sound(BOSS11, 1);
+    play_sound(BOSS11, true);
     _G(timer_cnt) = 0;
 
     drop_flag = false;
@@ -230,7 +230,7 @@ static int boss2_die() {
             _G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
         }
 
-        play_sound(EXPLODE, 1);
+        play_sound(EXPLODE, true);
         _G(boss_dead) = true;;
     }
 
@@ -249,7 +249,7 @@ static int boss2a_movement(ACTOR *actr) {
     if (actr->num_shots) return 0;
     if (_G(actor)[5].num_shots) return 0;
 
-    play_sound(EXPLODE, 1);
+    play_sound(EXPLODE, true);
     actor_always_shoots(&_G(actor)[5], 0);
     an = _G(actor)[5].shot_actor;
     _G(actor)[an].move = 9;
@@ -320,7 +320,7 @@ static int boss2b_movement(ACTOR *actr) {
     if (actr->x < 20 || actr->x>270) {
         _G(thunder_flag) = 100;
         actr->i4 = 50;
-        play_sound(EXPLODE, 1);
+        play_sound(EXPLODE, true);
         actr->i2 = 0;
         hx = _G(thor)->x;
 
@@ -386,7 +386,7 @@ void closing_sequence2_4() {
     //	_G(game_is_over) = 1;
     show_level(BOSS_LEVEL2);
 
-    play_sound(ANGEL, 1);
+    play_sound(ANGEL, true);
     place_tile(18, 10, 152);
     place_tile(19, 10, 202);
     actor_visible(1);
diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index ae34b7a05a4..188277b619e 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -102,7 +102,7 @@ static int boss_movement_one(ACTOR *actr) {
         _G(actor)[4].solid |= 128;
         _G(actor)[5].solid |= 128;
         _G(actor)[6].solid |= 128;
-        play_sound(EXPLODE, 1);
+        play_sound(EXPLODE, true);
         goto done;
     }
     if (actr->i6) {
@@ -139,7 +139,7 @@ static int boss_movement_one(ACTOR *actr) {
         actr->frame_count = LFC;
         actr->temp4 = 40;
         actr->temp3 = 0;
-        play_sound(EXPLODE, 1);
+        play_sound(EXPLODE, true);
         goto done1;
     }
 
@@ -364,7 +364,7 @@ new_dir:
     _G(actor)[actr->shot_actor].temp1 = g_events->getRandomNumber(90, 189);
     _G(actor)[actr->shot_actor].temp5 = 30;
     _G(actor)[actr->shot_actor].speed = 2;
-    play_sound(BOSS12, 1);
+    play_sound(BOSS12, true);
 
 new_dir1:
     actr->temp5 = _G(rand1) % 8;
@@ -395,7 +395,7 @@ static void check_boss_hit() {
 
             boss_status(_G(actor)[3].health);
             _G(actor)[3].vunerable = 50;
-            play_sound(BOSS13, 1);
+            play_sound(BOSS13, true);
 
             for (rep = 4; rep < 7; rep++) {
                 _G(actor)[rep].magic_hit = 0;
@@ -443,7 +443,7 @@ void boss_level3() {
     _G(boss_active) = 1;
     boss_status(-1);
     music_pause();
-    play_sound(BOSS11, 1);
+    play_sound(BOSS11, true);
     _G(timer_cnt) = 0;
 
     g_events->send("Game", GameMessage("PAUSE", 40));
@@ -461,16 +461,14 @@ void boss_level3() {
 }
 
 static int boss_die() {
-    int rep, n, x, y, r, x1, y1;
-
-    if (_G(boss_dead) == 1) {
-        REPEAT(4) {
-            x1 = _G(actor)[3 + rep].last_x[_G(pge)];
-            y1 = _G(actor)[3 + rep].last_y[_G(pge)];
-            x = _G(actor)[3 + rep].x;
-            y = _G(actor)[3 + rep].y;
-            n = _G(actor)[3 + rep].actor_num;
-            r = _G(actor)[3 + rep].rating;
+	if (_G(boss_dead) == 1) {
+        for(int rep = 0; rep < 4; rep++) {
+            int x1 = _G(actor)[3 + rep].last_x[_G(pge)];
+            int y1 = _G(actor)[3 + rep].last_y[_G(pge)];
+            int x = _G(actor)[3 + rep].x;
+            int y = _G(actor)[3 + rep].y;
+            int n = _G(actor)[3 + rep].actor_num;
+            int r = _G(actor)[3 + rep].rating;
 
             _G(actor)[3 + rep] = _G(explosion);
 
@@ -491,7 +489,7 @@ static int boss_die() {
             _G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
         }
 
-        play_sound(EXPLODE, 1);
+        play_sound(EXPLODE, true);
         _G(boss_dead) = true;;
     }
 
@@ -508,13 +506,13 @@ void closing_sequence3_2() {
 }
 
 void closing_sequence3_3() {
-    int rep;
-
-    fill_health();
+	fill_health();
     fill_magic();
 
-    REPEAT(16) _G(scrn).actor_type[rep] = 0;
-    _G(boss_dead) = 0;
+    for (int rep = 0; rep < 16; rep++)
+		_G(scrn).actor_type[rep] = 0;
+	
+    _G(boss_dead) = false;
     _G(setup).boss_dead[2] = 1;
     _G(game_over) = 1;
     _G(boss_active) = 0;
@@ -531,9 +529,7 @@ void closing_sequence3_3() {
 }
 
 void ending_screen() {
-    int i;
-
-    for (i = 3; i < MAX_ACTORS; i++)
+	for (int i = 3; i < MAX_ACTORS; i++)
         _G(actor)[i].move = 1;
     music_play(6, 1);
     _G(timer_cnt) = 0;
@@ -555,24 +551,22 @@ void ending_screen() {
 
 // Explode
 int endgame_one() {
-    int x, y, r;
-
-    if (_G(actor)[34].i2) {
+	if (_G(actor)[34].i2) {
         _G(actor)[34].i2--;
         return 0;
     }
 
     _G(actor)[34].i2 = 6;
-    play_sound(EXPLODE, 1);
+    play_sound(EXPLODE, true);
 
-    r = _G(rand1) % 32;
+    int r = _G(rand1) % 32;
     while (expf[r / 8][r % 8]) {
         r++;
         if (r > 31) r = 0;
     }
     expf[r / 8][r % 8] = 1;
-    x = (EXPLOSION[r / 8][r % 8] % 20) * 16;
-    y = (EXPLOSION[r / 8][r % 8] / 20) * 16;
+    int x = (EXPLOSION[r / 8][r % 8] % 20) * 16;
+    int y = (EXPLOSION[r / 8][r % 8] / 20) * 16;
     _G(actor)[34].x = x;
     _G(actor)[34].y = y;
     _G(actor)[34].used = 1;
@@ -591,9 +585,7 @@ int endgame_one() {
 
 // Explode
 int endgame_movement() {
-    int x, y, r;
-
-    if (!_G(endgame))
+	if (!_G(endgame))
         return 0;
     if (expcnt > 3) {
         endgame_one();
@@ -604,16 +596,16 @@ int endgame_movement() {
         return 0;
     }
     _G(actor)[34].i2 = 6;
-    play_sound(EXPLODE, 1);
+    play_sound(EXPLODE, true);
 
-    r = _G(rand1) % 8;
+    int r = _G(rand1) % 8;
     while (expf[_G(exprow)][r]) {
         r++;
         if (r > 7) r = 0;
     }
     expf[_G(exprow)][r] = 1;
-    x = (EXPLOSION[_G(exprow)][r] % 20) * 16;
-    y = (EXPLOSION[_G(exprow)][r] / 20) * 16;
+    int x = (EXPLOSION[_G(exprow)][r] % 20) * 16;
+    int y = (EXPLOSION[_G(exprow)][r] / 20) * 16;
     _G(actor)[34].x = x;
     _G(actor)[34].y = y;
     _G(actor)[34].used = 1;
diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index 089ec56abd4..bc7c1973050 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -68,7 +68,7 @@ int reverse_direction(ACTOR *actr) {
 
 void thor_shoots() {
     if ((_G(hammer)->used != 1) && (!_G(hammer)->dead) && (!_G(thor)->shot_cnt)) {
-        play_sound(SWISH, 0);
+        play_sound(SWISH, false);
         _G(thor)->shot_cnt = 20;
         _G(hammer)->used = 1;
         _G(hammer)->dir = _G(thor)->dir;
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 0dc7207248d..97c8d56ef19 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -316,7 +316,9 @@ int check_move0(int x, int y, ACTOR *actr) {
                 _G(thor_special_flag) = 0;
                 thor_damaged(act);
                 if (act->solid < 2) {
-                    if (!act->vunerable && (!(act->type & 1))) play_sound(PUNCH1, 0);
+                    if (!act->vunerable && (!(act->type & 1)))
+						play_sound(PUNCH1, false);
+                	
                     if (!_G(hammer)->used && _G(key_flag)[key_fire])
                         actor_damaged(act, _G(hammer)->strength);
                     else
@@ -356,7 +358,9 @@ int check_move1(int x, int y, ACTOR *actr) {
     icn3 = _G(scrn).icon[y1][x2];
     icn4 = _G(scrn).icon[y2][x2];
     if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) {
-        if (actr->actor_num == 1 && actr->move == 2) play_sound(CLANG, 0);
+        if (actr->actor_num == 1 && actr->move == 2)
+			play_sound(CLANG, false);
+    	
         return 0;
     }
 
@@ -642,7 +646,9 @@ int movement_zero(ACTOR *actr) {
     if (actr->move_counter) actr->move_counter--;
 
     if (_G(slipping)) {
-        if (_G(slip_cnt) == 8) play_sound(FALL, 1);
+        if (_G(slip_cnt) == 8)
+			play_sound(FALL, true);
+    	
         y += 2;
         _G(slip_cnt)--;
         if (!_G(slip_cnt))
@@ -879,13 +885,13 @@ int special_movement_two(ACTOR *actr) {
     }
     if (!actr->func_pass) {
         if (_G(thor)->health < 150) {
-            if (!sound_playing()) play_sound(ANGEL, 0);
+            if (!sound_playing()) play_sound(ANGEL, false);
             _G(thor)->health += 1;
             display_health();
         }
     } else {
         if (_G(thor_info).magic < 150) {
-            if (!sound_playing()) play_sound(ANGEL, 0);
+            if (!sound_playing()) play_sound(ANGEL, false);
             _G(thor_info).magic += 1;
             display_magic();
         }
@@ -1250,15 +1256,17 @@ int movement_six(ACTOR *actr) {
         actr->next++;
         if (actr->next > 2) {
             actr->next = 0;
-            if (_G(boss_dead)) play_sound(EXPLODE, 0);
+            if (_G(boss_dead))
+				play_sound(EXPLODE, false);
         }
         actr->num_shots--;
     } else {
         actr->dead = 2;
         actr->used = 0;
-        if (!_G(boss_dead) && !_G(endgame))
+		if (!_G(boss_dead) && !_G(endgame)) {
             if (actr->type == 2)
                 drop_object(actr);
+		}
 
     }
 
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index 313cc66865b..f10de76d444 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -86,12 +86,12 @@ void pick_up_object(int p) {
             cannot_carry_more();
             return;
         }
-        play_sound(GULP, 0);
+        play_sound(GULP, false);
         s = 1;
         add_health(5);
         break;
     case 6:           // Bad apple
-        play_sound(OW, 0);
+        play_sound(OW, false);
         s = 1;
         add_health(-10);
         break;
@@ -173,7 +173,7 @@ void pick_up_object(int p) {
     r = 1;
     s = 0;
     if (!s)
-        play_sound(YAH, 0);
+        play_sound(YAH, false);
     _G(object_map)[p] = 0;
 
     if (r) {
@@ -233,13 +233,13 @@ int use_apple(int flag) {
             _G(magic_cnt) = 0;
             add_magic(-2);
             add_health(1);
-            play_sound(ANGEL, 0);
+            play_sound(ANGEL, false);
         } else if (_G(magic_cnt) > 8) {
             _G(magic_cnt) = 0;
             add_magic(-2);
             add_health(1);
             if (!sound_playing())
-                play_sound(ANGEL, 0);
+                play_sound(ANGEL, false);
         }
         _G(apple_flag) = 1;
         return 1;
@@ -257,7 +257,7 @@ int use_thunder(int flag) {
     if (flag && _G(thor_info).magic > 29) {
         if (!_G(thunder_flag)) {
             add_magic(-30);
-            play_sound(THUNDER, 0);
+            play_sound(THUNDER, false);
             _G(thunder_flag) = 60;
         }
         return 1;
@@ -279,7 +279,7 @@ int use_hourglass(int flag) {
                 _G(hourglass_flag) = 0;
                 music_resume();
             }
-            play_sound(WOOP, 1);
+            play_sound(WOOP, true);
         }
         return 1;
     }
@@ -289,7 +289,7 @@ int use_hourglass(int flag) {
             _G(magic_cnt) = 0;
             add_magic(-30);
             music_pause();
-            play_sound(WOOP, 1);
+            play_sound(WOOP, true);
             _G(hourglass_flag) = 1;
             return 1;
         }
@@ -393,7 +393,7 @@ int use_tornado(int flag) {
                 _G(actor)[2].last_dir = _G(thor)->dir;
                 _G(actor)[2].move = 16;
                 _G(tornado_used) = 1;
-                play_sound(WIND, 0);
+                play_sound(WIND, false);
             }
         } else if (_G(tornado_used) == 0) {
             not_enough_magic();
@@ -463,7 +463,7 @@ void use_item() {
     if (kf) {
         if ((!ret) && (!_G(useItemFlag))) {
             if (mf)
-                play_sound(BRAAPP, 0);
+                play_sound(BRAAPP, false);
             _G(useItemFlag) = true;
         }
     } else {
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 1cb84f3b646..ae7e22dae9f 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -847,7 +847,7 @@ int Scripts::cmd_sound() {
 
     _buffPtr++;
     if (_lValue < 1 || _lValue>16) return 6;
-    play_sound((int)_lValue - 1, 1);
+    play_sound((int)_lValue - 1, true);
     return 0;
 }
 
@@ -991,7 +991,7 @@ int Scripts::cmd_random() {
 }
 
 void Scripts::scr_func1() {
-    play_sound(FALL, 1);
+    play_sound(FALL, true);
 
     _G(new_level) = 109;
     _G(new_level_tile) = 215;
@@ -1021,18 +1021,18 @@ void Scripts::scr_func3() {
     x = p % 20;
 
     if (y < 0 || x < 0 || y>11 || x>19) {
-        play_sound(BRAAPP, 1);
+        play_sound(BRAAPP, true);
         _G(key_flag)[key_magic] = false;
         return;
     }
     if (_G(scrn).icon[y][x] < 174 || _G(scrn).icon[y][x]>178) {
-        play_sound(BRAAPP, 1);
+        play_sound(BRAAPP, true);
         _G(key_flag)[key_magic] = false;
         return;
     }
 
     _numVar[0] = 1;
-    play_sound(WOOP, 1);
+    play_sound(WOOP, true);
     if (_G(current_level) == 106 && p == 69) {
         place_tile(x, y, 220);
         _G(key_flag)[key_magic] = false;
diff --git a/engines/got/game/shot_pattern.cpp b/engines/got/game/shot_pattern.cpp
index 8aa291413af..9e17bdc7000 100644
--- a/engines/got/game/shot_pattern.cpp
+++ b/engines/got/game/shot_pattern.cpp
@@ -148,16 +148,14 @@ int shot_pattern_four(ACTOR *actr) {
 
 // Boss - snake
 int shot_pattern_five(ACTOR *actr) {
-    int num;
-
-    if (_G(rand1) < 15) {
+	if (_G(rand1) < 15) {
         if ((actr->temp1 == 0) && (actr->temp2 == 0)) {
             actr->y += 16;
             actr->shots_allowed = 3 + _G(setup).skill;
             actor_shoots(actr, 2);
-            play_sound(BOSS12, 0);
+            play_sound(BOSS12, false);
 
-            num = actr->shot_actor;
+            int num = actr->shot_actor;
             actr->shot_cnt = 50;
             _G(actor)[num].temp3 = 120;
             _G(actor)[num].temp4 = 5 + (_G(rand2) % 17);
@@ -172,9 +170,7 @@ int shot_pattern_five(ACTOR *actr) {
 
 // 4 surrounding squares
 int shot_pattern_six(ACTOR *actr) {
-    int pos;
-
-    pos = ((actr->x) / 16) + (((actr->y) / 16) * 20);
+	int pos = ((actr->x) / 16) + (((actr->y) / 16) * 20);
 
     if (_G(thor_pos) == pos - 20)
         actor_shoots(actr, 0);
diff --git a/engines/got/game/special_tile.cpp b/engines/got/game/special_tile.cpp
index da156ec988e..1761244457c 100644
--- a/engines/got/game/special_tile.cpp
+++ b/engines/got/game/special_tile.cpp
@@ -112,7 +112,7 @@ int special_tile_thor(int x, int y, int icon) {
                 actor_visible(5);
                 Common::fill(_G(scrn).actor_invis, _G(scrn).actor_invis + 16, 0);
                 _G(thunder_flag) = 60;
-                play_sound(THUNDER, 1);
+                play_sound(THUNDER, true);
                 _G(setup).f22 = 1;
             }
         } else {
@@ -132,7 +132,7 @@ int special_tile_thor(int x, int y, int icon) {
             cy = (_G(thor_real_y1) + 8) / 16;
             if (_G(scrn).icon[cy][cx] == icon) {
                 _G(thor)->vunerable = STAMINA;
-                play_sound(WOOP, 0);
+                play_sound(WOOP, false);
 
                 int nt = _G(scrn).new_level_loc[icon - 214];
                 int display_page = _G(pge);
@@ -169,7 +169,9 @@ int special_tile_thor(int x, int y, int icon) {
         cy = (_G(thor_real_y1) + 8) / 16;
         if (_G(scrn).icon[cy][cx] == icon) {
             _G(thor)->vunerable = STAMINA;
-            if (icon < 224 && icon>219) play_sound(FALL, 0);
+            if (icon < 224 && icon>219)
+				play_sound(FALL, false);
+        	
             _G(new_level) = _G(scrn).new_level[icon - 220 + (f * 6)];
             _G(warp_scroll) = 0;
             if (_G(new_level) > 119) {
@@ -236,7 +238,7 @@ int special_tile(ACTOR *actr, int x, int y, int icon) {
 }
 
 void erase_door(int x, int y) {
-    play_sound(DOOR, 0);
+    play_sound(DOOR, false);
     _G(scrn).icon[y][x] = _G(scrn).bg_color;
 }
 
diff --git a/engines/got/metaengine.cpp b/engines/got/metaengine.cpp
index bbfda4e3c60..9c4c38bb647 100644
--- a/engines/got/metaengine.cpp
+++ b/engines/got/metaengine.cpp
@@ -88,15 +88,11 @@ bool GotMetaEngine::hasFeature(MetaEngineFeature f) const {
 
 Common::Array<Common::Keymap *> GotMetaEngine::initKeymaps(const char *target) const {
     Common::KeymapArray keymapArray;
-    Common::Keymap *keyMap;
-    Common::Action *act;
-
-    keyMap = new Common::Keymap(Common::Keymap::kKeymapTypeGame,
-                                "got", _s("Game Keys"));
+    Common::Keymap *keyMap = new Common::Keymap(Common::Keymap::kKeymapTypeGame, "got", _s("Game Keys"));
     keymapArray.push_back(keyMap);
 
     for (const Got::KeybindingRecord *r = Got::GAME_KEYS; r->_id; ++r) {
-        act = new Common::Action(r->_id, _(r->_desc));
+	    Common::Action *act = new Common::Action(r->_id, _(r->_desc));
         act->setCustomEngineActionEvent(r->_action);
         act->addDefaultInputMapping(r->_key);
         if (r->_joy)
diff --git a/engines/got/sound.cpp b/engines/got/sound.cpp
index c8cf3565f0d..c83f8ebe8e2 100644
--- a/engines/got/sound.cpp
+++ b/engines/got/sound.cpp
@@ -146,15 +146,13 @@ void Sound::music_play(const char *name, bool override) {
         int hdrCount = file.readUint16LE();
         file.skip((hdrCount - 1) * 2);
 
-        int pause, duration, freq;
-
         while (!file.eos()) {
-            pause = file.readByte();
+            int pause = file.readByte();
             if (pause & 0x80)
                 pause = ((pause & 0x7f) << 8) | file.readByte();
 
-            freq = file.readByte();
-            duration = file.readByte();
+            int freq = file.readByte();
+            int duration = file.readByte();
             if (freq == 0 && duration == 0) {
                 debug(1, "End of song");
                 break;


Commit: 0fd2b986202c1f6e71526bf1e96fad9d863e603b
    https://github.com/scummvm/scummvm/commit/0fd2b986202c1f6e71526bf1e96fad9d863e603b
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Some more work on booleans in vars.h

Changed paths:
    engines/got/game/boss3.cpp
    engines/got/game/move_patterns.cpp
    engines/got/game/script.cpp
    engines/got/game/special_tile.cpp
    engines/got/vars.h


diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index 188277b619e..160c76e2323 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -404,7 +404,7 @@ static void check_boss_hit() {
             }
 
             if (_G(actor)[3].health == 0) {
-                _G(boss_dead) = 1;
+                _G(boss_dead) = true;
                 for (rep = 7; rep < MAX_ACTORS; rep++)
                     if (_G(actor)[rep].used)
                         actor_destroyed(&_G(actor)[rep]);
@@ -461,7 +461,7 @@ void boss_level3() {
 }
 
 static int boss_die() {
-	if (_G(boss_dead) == 1) {
+	if (_G(boss_dead)) {
         for(int rep = 0; rep < 4; rep++) {
             int x1 = _G(actor)[3 + rep].last_x[_G(pge)];
             int y1 = _G(actor)[3 + rep].last_y[_G(pge)];
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 97c8d56ef19..45b014e5b28 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -229,7 +229,7 @@ int check_move0(int x, int y, ACTOR *actr) {
     else x2 = (x + 10) >> 4;
     y2 = (y + 15) >> 4;
 
-    _G(slip_flag) = 0;
+    _G(slip_flag) = false;
 
     // Check for cheat flying mode
     if (!actr->flying) {
@@ -278,14 +278,14 @@ int check_move0(int x, int y, ACTOR *actr) {
     }
 
     if (!_G(slip_flag)) {
-        _G(slipping) = 0;
+        _G(slipping) = false;
         _G(slip_cnt) = 0;
     }
     if (_G(slip_flag) && !_G(slipping))
         _G(slip_cnt)++;
     if (_G(slip_cnt) > 8)
-        _G(slipping) = 1;
-    _G(slip_flag) = 0;
+        _G(slipping) = true;
+    _G(slip_flag) = false;
 
 
     x1 = x + 1;
@@ -294,7 +294,7 @@ int check_move0(int x, int y, ACTOR *actr) {
     else x2 = x + 12;
     y2 = y + 15;
 
-    _G(thor_special_flag) = 0;
+    _G(thor_special_flag) = false;
     for (i = 3; i < MAX_ACTORS; i++) {
         act = &_G(actor)[i];
         if (act->solid & 128) continue;
@@ -310,10 +310,10 @@ int check_move0(int x, int y, ACTOR *actr) {
                 if (act->func_num == 255) return 0;
                 act->temp1 = x;
                 act->temp2 = y;
-                _G(thor_special_flag) = 1;
+                _G(thor_special_flag) = true;
                 return special_movement_func[act->func_num](act);
             } else {
-                _G(thor_special_flag) = 0;
+                _G(thor_special_flag) = false;
                 thor_damaged(act);
                 if (act->solid < 2) {
                     if (!act->vunerable && (!(act->type & 1)))
@@ -407,7 +407,9 @@ int check_move1(int x, int y, ACTOR *actr) {
             f++;
         }
     }
-    if (f && actr->move == 2) return 0;
+    if (f && actr->move == 2)
+		return 0;
+	
     actr->x = x;
     actr->y = y;
     return 1;
@@ -442,7 +444,8 @@ int check_move2(int x, int y, ACTOR *actr) {
     icn2 = _G(scrn).icon[y2][x1];
     icn3 = _G(scrn).icon[y1][x2];
     icn4 = _G(scrn).icon[y2][x2];
-    if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) return 0;
+    if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn)
+		return 0;
 
     if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
     if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
@@ -456,10 +459,15 @@ int check_move2(int x, int y, ACTOR *actr) {
 
     for (i = 0; i < MAX_ACTORS; i++) {
         act = &_G(actor)[i];
-        if (act->actor_num == actr->actor_num) continue;
-        if (act->actor_num == 1) continue;
-        if (!act->used) continue;
-        if (act->type == 3) continue;   // Shot
+        if (act->actor_num == actr->actor_num)
+			continue;
+        if (act->actor_num == 1)
+			continue;
+        if (!act->used)
+			continue;
+        if (act->type == 3)
+			continue;   // Shot
+    	
         if (i == 0) {
             if (overlap(x1, y1, x2, y2, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
                 thor_damaged(actr);
@@ -467,9 +475,13 @@ int check_move2(int x, int y, ACTOR *actr) {
             }
         } else {
             x3 = act->x;
-            if ((ABS(x3 - x1)) > 16) continue;
+            if ((ABS(x3 - x1)) > 16)
+				continue;
+        	
             y3 = act->y;
-            if ((ABS(y3 - y1)) > 16) continue;
+            if ((ABS(y3 - y1)) > 16)
+				continue;
+        	
             x4 = act->x + act->size_x;
             y4 = act->y + act->size_y;
             if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
@@ -497,7 +509,8 @@ int check_move3(int x, int y, ACTOR *actr) {
 
     int icn;
 
-    if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175) return 0;
+    if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175)
+		return 0;
 
     x1 = (x + 1) >> 4;
     y1 = (y + (actr->size_y / 2)) >> 4;
@@ -507,13 +520,15 @@ int check_move3(int x, int y, ACTOR *actr) {
     // Check for solid or fly over
 
     icn = TILE_FLY;
-    if (actr->flying) icn = TILE_SOLID;
+    if (actr->flying)
+		icn = TILE_SOLID;
 
     icn1 = _G(scrn).icon[y1][x1];
     icn2 = _G(scrn).icon[y2][x1];
     icn3 = _G(scrn).icon[y1][x2];
     icn4 = _G(scrn).icon[y2][x2];
-    if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) return 0;
+    if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn)
+		return 0;
 
     if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
     if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
@@ -531,19 +546,32 @@ int check_move3(int x, int y, ACTOR *actr) {
         return 0;
     }
     for (i = 3; i < MAX_ACTORS; i++) {
-        if (i == actr->actor_num) continue;
+        if (i == actr->actor_num)
+			continue;
+    	
         act = &_G(actor)[i];
-        if (!act->used) continue;
-        if (act->solid < 2) continue;
-        if (act->type == 3) continue;   // Shot
-        if (act->actor_num == actr->creator) continue;
+    	
+        if (!act->used)
+			continue;
+        if (act->solid < 2)
+			continue;
+        if (act->type == 3)
+			continue;   // Shot
+        if (act->actor_num == actr->creator)
+			continue;
+    	
         x3 = act->x;
-        if ((ABS(x3 - x1)) > 16) continue;
+        if ((ABS(x3 - x1)) > 16)
+			continue;
+    	
         y3 = act->y;
-        if ((ABS(y3 - y1)) > 16) continue;
+        if ((ABS(y3 - y1)) > 16)
+			continue;
+    	
         x4 = x3 + 15;
         y4 = y3 + 15;
-        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) return 0;
+        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4))
+			return 0;
     }
     actr->x = x;
     actr->y = y;
@@ -571,6 +599,7 @@ int  check_thor_move(int x, int y, ACTOR *actr) {
         return 1;
     if (_G(diag_flag) || _G(thor_special_flag))
         return 0;
+	
     if ((_G(thor_icon1) + _G(thor_icon2) + _G(thor_icon3) + _G(thor_icon4)) > 1)
         return 0;
 
@@ -642,7 +671,7 @@ int movement_zero(ACTOR *actr) {
     }
     x = actr->x;
     y = actr->y;
-    _G(diag_flag) = 0;
+    _G(diag_flag) = false;
     if (actr->move_counter) actr->move_counter--;
 
     if (_G(slipping)) {
@@ -663,7 +692,7 @@ int movement_zero(ACTOR *actr) {
         d = 2;
         actr->dir = d;
         _G(diag) = 1;
-        _G(diag_flag) = 1;
+        _G(diag_flag) = true;
         if (check_thor_move(x - 2, y - 2, actr)) {
             next_frame(actr);
             return d;
@@ -672,7 +701,7 @@ int movement_zero(ACTOR *actr) {
         d = 3;
         actr->dir = d;
         _G(diag) = 2;
-        _G(diag_flag) = 1;
+        _G(diag_flag) = true;
         if (check_thor_move(x + 2, y - 2, actr)) {
             next_frame(actr);
             return d;
@@ -681,7 +710,7 @@ int movement_zero(ACTOR *actr) {
         d = 2;
         actr->dir = d;
         _G(diag) = 4;
-        _G(diag_flag) = 1;
+        _G(diag_flag) = true;
         if (check_thor_move(x - 2, y + 2, actr)) {
             next_frame(actr);
             return d;
@@ -690,7 +719,7 @@ int movement_zero(ACTOR *actr) {
         d = 3;
         actr->dir = d;
         _G(diag) = 3;
-        _G(diag_flag) = 1;
+        _G(diag_flag) = true;
         if (check_thor_move(x + 2, y + 2, actr)) {
             next_frame(actr);
             return d;
@@ -818,7 +847,9 @@ int check_special_move1(int x, int y, ACTOR *actr) {
 int special_movement_one(ACTOR *actr) {
     int d, x1, y1, sd;
 
-    if (_G(diag_flag)) return 0;
+    if (_G(diag_flag))
+		return 0;
+	
     d = _G(thor)->dir;
     x1 = actr->x;
     y1 = actr->y;
@@ -961,7 +992,9 @@ int special_movement_six(ACTOR *actr) {
 }
 
 int special_movement_seven(ACTOR *actr) {
-    if (actr->shot_cnt != 0) return 0;
+    if (actr->shot_cnt != 0)
+		return 0;
+	
     actr->shot_cnt = 30;
 
     _G(switch_flag) = 2;
@@ -969,14 +1002,18 @@ int special_movement_seven(ACTOR *actr) {
 }
 
 int special_movement_eight(ACTOR *actr) {
-    if (_G(thor)->dir < 2 || _G(diag_flag)) return 0;
+    if (_G(thor)->dir < 2 || _G(diag_flag))
+		return 0;
+	
     actr->last_dir = _G(thor)->dir;
     actr->move = 14;
     return 0;
 }
 
 int special_movement_nine(ACTOR *actr) {
-    if (_G(thor)->dir > 1 || _G(diag_flag)) return 0;
+    if (_G(thor)->dir > 1 || _G(diag_flag))
+		return 0;
+	
     actr->last_dir = _G(thor)->dir;
     actr->move = 14;
     return 0;
@@ -1003,14 +1040,12 @@ int special_movement_ten(ACTOR *actr) {
 
 // Red guard
 int special_movement_eleven(ACTOR *actr) {
-    int t;
-
-    if (actr->talk_counter) {
+	if (actr->talk_counter) {
         actr->talk_counter--;
         return 0;
     }
 
-    t = actr->type;
+    int t = actr->type;
     actr->type = 4;
     actor_speaks(actr, 0, 0);
     actr->type = t;
diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index ae7e22dae9f..3b2cdb2e93e 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -153,7 +153,9 @@ void Scripts::scriptLoop() {
     int ret;
 
     while (!_paused) {
-        if (_G(cheat) && _G(key_flag)[_B]) break;
+        if (_G(cheat) && _G(key_flag)[_B])
+			break;
+    	
         ret = get_command();
         if (ret == -1)
             break;       // Ignore NO END error
diff --git a/engines/got/game/special_tile.cpp b/engines/got/game/special_tile.cpp
index 1761244457c..c7aaa71d431 100644
--- a/engines/got/game/special_tile.cpp
+++ b/engines/got/game/special_tile.cpp
@@ -53,7 +53,7 @@ int special_tile_thor(int x, int y, int icon) {
 
         if (_G(thor)->x > 300)
             // Ending bridge
-            _G(end_tile) = 1;
+            _G(end_tile) = true;
         return 1;
     case 203:
         if (!GAME1) {
@@ -75,7 +75,7 @@ int special_tile_thor(int x, int y, int icon) {
             return 1;
         } else if (GAME3) {
             if (_G(thor)->x < 4)
-                _G(end_tile) = 1;
+                _G(end_tile) = true;
             return 1;
         }
         return 0;
diff --git a/engines/got/vars.h b/engines/got/vars.h
index cedf0f335b4..d41d69bda86 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -127,8 +127,6 @@ public:
 
     uint _timer_cnt = 0, _vbl_cnt = 0, _magic_cnt = 0, _extra_cnt = 0;
 
-    //union REGS in, out = 0;
-    //struct SREGS seg = 0;
     int _ox = 0, _oy = 0, _of = 0;
     byte _object_map[TILES_COUNT] = {};
     byte _object_index[TILES_COUNT] = {};
@@ -213,7 +211,7 @@ public:
     int8 _auto_load = 0;
     int8 _ide_run = 0, _fast_exit = 0, _nojoy = 0, _gr = 0, _xdos = 0;
     int8 _main_loop = 0;
-    int8 _end_tile = 0;
+    bool _end_tile = false;
     byte _pbuff[PALETTE_SIZE] = {};
     int _current_level = 23;
     int _new_level = 0;


Commit: d2639d4e7214cb6fb2a21fb3baabba7b37259f9e
    https://github.com/scummvm/scummvm/commit/d2639d4e7214cb6fb2a21fb3baabba7b37259f9e
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: more work n vars.h - Remove unused variables, more work on booleans

Changed paths:
    engines/got/data/defines.h
    engines/got/game/back.cpp
    engines/got/game/boss1.cpp
    engines/got/game/boss2.cpp
    engines/got/game/boss3.cpp
    engines/got/game/main.cpp
    engines/got/game/move.cpp
    engines/got/game/move_patterns.cpp
    engines/got/game/object.cpp
    engines/got/game/special_tile.cpp
    engines/got/got.cpp
    engines/got/vars.cpp
    engines/got/vars.h
    engines/got/views/game_content.cpp


diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index 3531c65aa06..2bbc77df174 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -36,13 +36,13 @@ namespace Got {
 #define IN_RANGE(v,l,h) (v>=l && v<=h)
 
 struct HEADER {
-    long offset = 0;
-    long length = 0;
+	long offset = 0;
+	long length = 0;
 
-    void load(Common::SeekableReadStream *src) {
-        offset = src->readUint32LE();
-        length = src->readUint32LE();
-    }
+	void load(Common::SeekableReadStream *src) {
+		offset = src->readUint32LE();
+		length = src->readUint32LE();
+	}
 };
 
 //==========================================================================
@@ -96,65 +96,69 @@ struct HEADER {
 #define TMP_SIZE 5800
 
 #define sc_Index 0x3C4
+
 enum {
-    sc_Reset,
-    sc_Clock,
-    sc_MapMask,
-    sc_CharMap,
-    sc_MemMode
+	sc_Reset,
+	sc_Clock,
+	sc_MapMask,
+	sc_CharMap,
+	sc_MemMode
 };
 
 #define crtc_Index 0x3D4
 
 enum {
-    crtc_H_Total,
-    crtc_H_DispEnd,
-    crtc_H_Blank,
-    crtc_H_EndBlank,
-    crtc_H_Retrace,
-    crtc_H_EndRetrace,
-    crtc_V_Total,
-    crtc_OverFlow,
-    crtc_RowScan,
-    crtc_MaxScanLine,
-    crtc_CursorStart,
-    crtc_CursorEnd,
-    crtc_StartHigh,
-    crtc_StartLow,
-    crtc_CursorHigh,
-    crtc_CursorLow,
-    crtc_V_Retrace,
-    crtc_V_EndRetrace,
-    crtc_V_DispEnd,
-    crtc_Offset,
-    crtc_Underline,
-    crtc_V_Blank,
-    crtc_V_EndBlank,
-    crtc_Mode,
-    crtc_LineCompare
+	crtc_H_Total,
+	crtc_H_DispEnd,
+	crtc_H_Blank,
+	crtc_H_EndBlank,
+	crtc_H_Retrace,
+	crtc_H_EndRetrace,
+	crtc_V_Total,
+	crtc_OverFlow,
+	crtc_RowScan,
+	crtc_MaxScanLine,
+	crtc_CursorStart,
+	crtc_CursorEnd,
+	crtc_StartHigh,
+	crtc_StartLow,
+	crtc_CursorHigh,
+	crtc_CursorLow,
+	crtc_V_Retrace,
+	crtc_V_EndRetrace,
+	crtc_V_DispEnd,
+	crtc_Offset,
+	crtc_Underline,
+	crtc_V_Blank,
+	crtc_V_EndBlank,
+	crtc_Mode,
+	crtc_LineCompare
 };
 
 #define gc_Index 0x3CE
+
 enum {
-    gc_SetReset,
-    gc_EnableSetReset,
-    gc_ColorCompare,
-    gc_DataRotate,
-    gc_ReadMap,
-    gc_Mode,
-    gc_Misc,
-    gc_ColorDontCare,
-    gc_BitMask
+	gc_SetReset,
+	gc_EnableSetReset,
+	gc_ColorCompare,
+	gc_DataRotate,
+	gc_ReadMap,
+	gc_Mode,
+	gc_Misc,
+	gc_ColorDontCare,
+	gc_BitMask
 };
 
 #define atr_Index 0x3c0
+
 enum {
-    atr_Mode = 16,
-    atr_Overscan,
-    atr_ColorPlaneEnable,
-    atr_PelPan,
-    atr_ColorSelect
+	atr_Mode = 16,
+	atr_Overscan,
+	atr_ColorPlaneEnable,
+	atr_PelPan,
+	atr_ColorSelect
 };
+
 #define	status_Reg1 0x3da
 
 #define GAME1 (_G(area)==1)
diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index d80f14d2ef1..aad8d25cc99 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -49,15 +49,13 @@ const char *ITEM_NAMES[] = {
 static const char *odinEndMessage;
 
 void show_level(int new_level) {
-    int save_d;
-
-    _G(boss_active) = 0;
+	_G(boss_active) = false;
     if (!_G(shield_on))
         _G(actor)[2].used = 0;
-    _G(bomb_flag) = 0;
+    _G(bomb_flag) = false;
     _G(slipping) = false;
 
-    save_d = _G(thor)->dir;
+    int save_d = _G(thor)->dir;
     if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154)
         _G(thor)->dir = 0;
 
@@ -80,10 +78,10 @@ void show_level(int new_level) {
 
     if (_G(warp_flag))
         _G(current_level) = new_level - 5;   // Force phase
-    _G(warp_flag) = 0;
+    _G(warp_flag) = false;
 
     if (_G(warp_scroll)) {
-        _G(warp_scroll) = 0;
+        _G(warp_scroll) = false;
         if (_G(thor)->dir == 0)
             _G(current_level) = new_level + 10;
         else if (_G(thor)->dir == 1)
@@ -179,7 +177,7 @@ void show_level_done() {
     if (_G(startup))
         f = false;
     if (f)
-        music_play(_G(level_type), 0);
+        music_play(_G(level_type), false);
 }
 
 static void odin_speaks_end() {
diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index abc6bf415dc..885674201db 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -177,14 +177,13 @@ done1:
     _G(actor)[5].num_moves = actr->num_moves;
     _G(actor)[6].num_moves = actr->num_moves;
 
-    if (actr->directions == 1) return 0;
+    if (actr->directions == 1)
+		return 0;
     return d;
 }
 
 void check_boss1_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
-    int rep;
-
-    if (actr->move == 15 && act_num == 4) {
+	if (actr->move == 15 && act_num == 4) {
         if ((!_G(actor)[3].vunerable) && (_G(actor)[3].next != 3) &&
                 overlap(x1, y1, x2, y2, actr->x + 6, actr->y + 4, actr->x + 14, actr->y + 20)) {
             actor_damaged(&_G(actor)[3], _G(hammer)->strength);
@@ -199,24 +198,24 @@ void check_boss1_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
             play_sound(BOSS13, true);
             _G(actor)[3].next = 1;
 
-            for (rep = 4; rep < 7; rep++) {
+            for (int rep = 4; rep < 7; rep++) {
                 _G(actor)[rep].next = 1;
                 _G(actor)[rep].speed_count = 50;
             }
 
             if (_G(actor)[3].health == 0)
-                _G(boss_dead) = 1;
+                _G(boss_dead) = true;
         }
     }
 }
 
 void boss_level1() {
     setup_boss(1);
-    _G(boss_active) = 1;
+    _G(boss_active) = true;
     music_pause();
     play_sound(BOSS11, true);
     g_events->send("Game", GameMessage("PAUSE", 40));
-    music_play(5, 1);
+    music_play(5, true);
 }
 
 static int boss1_dead() {
@@ -260,8 +259,8 @@ static int boss1_dead() {
 }
 
 void closing_sequence1() {
-    _G(game_over) = 1;
-    music_play(4, 1);
+    _G(game_over) = true;
+    music_play(4, true);
     odin_speaks(1001, 13, "CLOSING");
 }
 
@@ -280,13 +279,12 @@ void closing_sequence1_3() {
 }
 
 void closing_sequence1_4() {
-    int rep;
-	for (rep = 0; rep < 16; rep++)
+	for (int rep = 0; rep < 16; rep++)
 		_G(scrn).actor_type[rep] = 0;
 	
-    _G(boss_dead) = 0;
+    _G(boss_dead) = false;
     _G(setup).boss_dead[0] = 1;
-    _G(boss_active) = 0;
+    _G(boss_active) = false;
     _G(scrn).type = 4;
     show_level(BOSS_LEVEL1);
 
diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index ece731d646c..3451680f9c4 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -184,7 +184,7 @@ void check_boss2_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
 
 void boss_level2() {
     setup_boss(2);
-    _G(boss_active) = 1;
+    _G(boss_active) = true;
     boss_status(-1);
     music_pause();
     play_sound(BOSS11, true);
@@ -194,16 +194,16 @@ void boss_level2() {
     Common::fill(su, su + 18, 0);
 
     g_events->send("Game", GameMessage("PAUSE", 40));
-    music_play(7, 1);
+    music_play(7, true);
 }
 
 static int boss2_die() {
-    int rep, n, x, y, r, x1, y1;
+    int n, x, y, r, x1, y1;
 
     _G(hourglass_flag) = 0;
     _G(thunder_flag) = 0;
     if (_G(boss_dead) == 1) {
-        REPEAT(4) {
+        for (int rep = 0; rep < 4; rep++) {
             x1 = _G(actor)[3 + rep].last_x[_G(pge)];
             y1 = _G(actor)[3 + rep].last_y[_G(pge)];
             x = _G(actor)[3 + rep].x;
@@ -354,7 +354,7 @@ done:
 }
 
 void closing_sequence2() {
-    music_play(6, 1);
+    music_play(6, true);
     odin_speaks(1001, 0, "CLOSING");
 }
 
@@ -375,16 +375,17 @@ void closing_sequence2_3() {
 
 void closing_sequence2_4() {
     LEVEL lvl;
-    int rep;
 
-    REPEAT(16) _G(scrn).actor_type[rep] = 0;
-    _G(boss_dead) = 0;
+    for (int rep = 0; rep < 16; rep++)
+		_G(scrn).actor_type[rep] = 0;
+	
+    _G(boss_dead) = false;
     _G(setup).boss_dead[1] = 1;
-    _G(game_over) = 1;
-    _G(boss_active) = 0;
+    _G(game_over) = true;
+    _G(boss_active) = false;
     _G(scrn).type = 6;
-    //	_G(game_is_over) = 1;
-    show_level(BOSS_LEVEL2);
+
+	show_level(BOSS_LEVEL2);
 
     play_sound(ANGEL, true);
     place_tile(18, 10, 152);
diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index 160c76e2323..d22849edbd2 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -379,8 +379,10 @@ static void check_boss_hit() {
     int rep;
 
     if (_G(actor)[3].solid & 128) {
-        for (rep = 3; rep < 7; rep++) _G(actor)[rep].magic_hit = 0;
-        return;
+        for (rep = 3; rep < 7; rep++)
+			_G(actor)[rep].magic_hit = 0;
+
+    	return;
     }
     if (_G(actor)[3].magic_hit || _G(actor)[4].magic_hit ||
             _G(actor)[5].magic_hit || _G(actor)[6].magic_hit) {
@@ -405,10 +407,11 @@ static void check_boss_hit() {
 
             if (_G(actor)[3].health == 0) {
                 _G(boss_dead) = true;
-                for (rep = 7; rep < MAX_ACTORS; rep++)
+				for (rep = 7; rep < MAX_ACTORS; rep++) {
                     if (_G(actor)[rep].used)
                         actor_destroyed(&_G(actor)[rep]);
-            }
+				}
+			}
 
             if (_G(actor)[3].health == 50) {
                 boss_change_mode();
@@ -440,7 +443,7 @@ static void boss_change_mode() {
 
 void boss_level3() {
     setup_boss(3);
-    _G(boss_active) = 1;
+    _G(boss_active) = true;
     boss_status(-1);
     music_pause();
     play_sound(BOSS11, true);
@@ -455,7 +458,7 @@ void boss_level3() {
         _G(boss_intro1) = true;
     }
 
-    music_play(7, 1);
+    music_play(7, true);
     _G(apple_drop) = 0;
     boss_mode = 1;
 }
@@ -497,7 +500,7 @@ static int boss_die() {
 }
 
 void closing_sequence3() {
-    music_play(6, 1);
+    music_play(6, true);
     odin_speaks(1001, 0, "CLOSING");
 }
 
@@ -514,8 +517,8 @@ void closing_sequence3_3() {
 	
     _G(boss_dead) = false;
     _G(setup).boss_dead[2] = 1;
-    _G(game_over) = 1;
-    _G(boss_active) = 0;
+    _G(game_over) = true;
+    _G(boss_active) = false;
     _G(scrn).type = 6;
     show_level(BOSS_LEVEL3);
 
@@ -531,7 +534,7 @@ void closing_sequence3_3() {
 void ending_screen() {
 	for (int i = 3; i < MAX_ACTORS; i++)
         _G(actor)[i].move = 1;
-    music_play(6, 1);
+    music_play(6, true);
     _G(timer_cnt) = 0;
 
     memset(expf, 0, 4 * 8);
diff --git a/engines/got/game/main.cpp b/engines/got/game/main.cpp
index cc249358eed..65c79a17c9c 100644
--- a/engines/got/game/main.cpp
+++ b/engines/got/game/main.cpp
@@ -51,12 +51,12 @@ void setup_load() {
     _G(thor)->vunerable = 60;
     _G(thor)->show = 60;
     _G(hourglass_flag) = 0;
-    _G(apple_flag) = 0;
-    _G(bomb_flag) = 0;
+    _G(apple_flag) = false;
+    _G(bomb_flag) = false;
     _G(thunder_flag) = 0;
-    _G(lightning_used) = 0;
-    _G(tornado_used) = 0;
-    _G(shield_on) = 0;
+    _G(lightning_used) = false;
+    _G(tornado_used) = false;
+    _G(shield_on) = false;
     _G(actor)[1].used = 0;
     _G(actor)[2].used = 0;
     _G(thor)->speed_count = 6;
diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index bc7c1973050..ffb83fe780d 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -87,7 +87,7 @@ void thor_shoots() {
 int kill_good_guy(void) {
     if (!_G(killgg_inform) && !_G(thunder_flag)) {
         odin_speaks(2010, 0);
-        _G(killgg_inform) = 1;
+        _G(killgg_inform) = true;
     }
 
     add_score(-1000);
@@ -251,7 +251,7 @@ int _actor_shoots(ACTOR *actr, int dir) {
             actr->shot_actor = i;
             actr->num_shots++;
             actr->shot_cnt = 20;
-            _G(shot_ok) = 0;
+            _G(shot_ok) = false;
             return 1;
         }
     }
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 45b014e5b28..2307db68d0e 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -1091,8 +1091,8 @@ int movement_two(ACTOR *actr) {
         if (actr->actor_num == 2) {
             actr->used = 0;
             actr->dead = 2;
-            _G(lightning_used) = 0;
-            _G(tornado_used) = 0;
+            _G(lightning_used) = false;
+            _G(tornado_used) = false;
         }
     }
     next_frame(actr);
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index f10de76d444..536a9dc3433 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -35,14 +35,12 @@ void not_enough_magic();
 void cannot_carry_more();
 
 void show_objects() {
-    int i, p;
-
-    Common::fill(_G(object_map), _G(object_map) + TILES_COUNT, 0);
+	Common::fill(_G(object_map), _G(object_map) + TILES_COUNT, 0);
     Common::fill(_G(object_index), _G(object_index) + TILES_COUNT, 0);
 
-    for (i = 0; i < OBJECTS_COUNT; i++) {
+    for (int i = 0; i < OBJECTS_COUNT; i++) {
         if (_G(scrn).static_obj[i]) {
-            p = _G(scrn).static_x[i] + (_G(scrn).static_y[i] * TILES_X);
+            int p = _G(scrn).static_x[i] + (_G(scrn).static_y[i] * TILES_X);
             _G(object_index)[p] = i;
             _G(object_map)[p] = _G(scrn).static_obj[i];
         }
@@ -130,8 +128,8 @@ void pick_up_object(int p) {
         _G(thor)->num_moves = 1;
         _G(hammer)->num_moves = 2;
         _G(actor)[2].used = 0;
-        _G(shield_on) = 0;
-        _G(tornado_used) = 0;
+        _G(shield_on) = false;
+        _G(tornado_used) = false;
         _G(thor_info).inventory |= 64;
         _G(thor_info).item = 7;
         _G(thor_info).object = _G(object_map)[p] - 11;
@@ -147,9 +145,9 @@ void pick_up_object(int p) {
     case 32:
         _G(hourglass_flag) = 0;
         _G(thunder_flag) = 0;
-        _G(shield_on) = 0;
-        _G(lightning_used) = 0;
-        _G(tornado_used) = 0;
+        _G(shield_on) = false;
+        _G(lightning_used) = false;
+        _G(tornado_used) = false;
         _G(hammer)->num_moves = 2;
         _G(thor)->num_moves = 1;
         _G(actor)[2].used = 0;
@@ -185,10 +183,10 @@ void pick_up_object(int p) {
 }
 
 int drop_object(ACTOR *actr) {
-    int o, rnd1, rnd2;
+    int o;
 
-    rnd1 = g_events->getRandomNumber(99);
-    rnd2 = g_events->getRandomNumber(99);
+    int rnd1 = g_events->getRandomNumber(99);
+    int rnd2 = g_events->getRandomNumber(99);
 
     if (rnd1 < 25)
         o = 5;      // Apple
@@ -211,9 +209,7 @@ int drop_object(ACTOR *actr) {
 }
 
 int _drop_obj(ACTOR *actr, int o) {
-    int p;
-
-    p = (actr->x + (actr->size_x / 2)) / 16 + (((actr->y + (actr->size_y / 2)) / 16) * 20);
+	int p = (actr->x + (actr->size_x / 2)) / 16 + (((actr->y + (actr->size_y / 2)) / 16) * 20);
     if (!_G(object_map)[p] && _G(scrn).icon[p / 20][p % 20] >= 140) {  //nothing there and solid
         _G(object_map)[p] = o;
         _G(object_index)[p] = 27 + actr->actor_num;  //actor is 3-15
@@ -241,15 +237,16 @@ int use_apple(int flag) {
             if (!sound_playing())
                 play_sound(ANGEL, false);
         }
-        _G(apple_flag) = 1;
-        return 1;
+		_G(apple_flag) = true;
+		return 1;
 
-    } else {
-        _G(apple_flag) = 0;
-        if (flag)
-            not_enough_magic();
     }
-    return 0;
+
+	_G(apple_flag) = false;
+	if (flag)
+		not_enough_magic();
+
+	return 0;
 }
 
 int use_thunder(int flag) {
@@ -261,9 +258,13 @@ int use_thunder(int flag) {
             _G(thunder_flag) = 60;
         }
         return 1;
-    } else if (flag && !_G(thunder_flag)) not_enough_magic();
+    }
+
+	if (flag && !_G(thunder_flag))
+		not_enough_magic();
 
-    if (_G(thunder_flag)) return 1;
+    if (_G(thunder_flag))
+		return 1;
     return 0;
 }
 
@@ -392,10 +393,10 @@ int use_tornado(int flag) {
                 setup_actor(&_G(actor)[2], 2, 0, _G(thor)->x, _G(thor)->y);
                 _G(actor)[2].last_dir = _G(thor)->dir;
                 _G(actor)[2].move = 16;
-                _G(tornado_used) = 1;
+                _G(tornado_used) = true;
                 play_sound(WIND, false);
             }
-        } else if (_G(tornado_used) == 0) {
+        } else if (!_G(tornado_used)) {
             not_enough_magic();
             return 0;
         }
@@ -407,7 +408,7 @@ int use_tornado(int flag) {
         }
         if (_G(thor_info).magic < 1) {
             actor_destroyed(&_G(actor)[2]);
-            _G(tornado_used) = 0;
+            _G(tornado_used) = false;
             not_enough_magic();
             return 0;
         }
@@ -426,16 +427,16 @@ int use_object(int flag) {
 }
 
 void use_item() {
-    int kf, ret = 0, mf;
+    int ret = 0;
 
-    kf = _G(key_flag)[key_magic];
+    int kf = _G(key_flag)[key_magic];
 
     if (!kf && _G(tornado_used)) {
         actor_destroyed(&_G(actor)[2]);
-        _G(tornado_used) = 0;
+        _G(tornado_used) = false;
     }
 
-    mf = _G(magic_inform);
+    bool mf = _G(magic_inform);
     switch (_G(thor_info).item) {
     case 1:
         ret = use_apple(kf);
@@ -475,13 +476,13 @@ void not_enough_magic() {
     if (!_G(magic_inform))
         odin_speaks(2006, 0);
 
-    _G(magic_inform) = 1;
+    _G(magic_inform) = true;
 }
 
 void cannot_carry_more() {
     if (!_G(carry_inform))
         odin_speaks(2007, 0);
-    _G(carry_inform) = 1;
+    _G(carry_inform) = true;
 }
 
 void delete_object() {
diff --git a/engines/got/game/special_tile.cpp b/engines/got/game/special_tile.cpp
index c7aaa71d431..cf79c78795f 100644
--- a/engines/got/game/special_tile.cpp
+++ b/engines/got/game/special_tile.cpp
@@ -173,14 +173,14 @@ int special_tile_thor(int x, int y, int icon) {
 				play_sound(FALL, false);
         	
             _G(new_level) = _G(scrn).new_level[icon - 220 + (f * 6)];
-            _G(warp_scroll) = 0;
+            _G(warp_scroll) = false;
             if (_G(new_level) > 119) {
-                _G(warp_scroll) = 1;
+                _G(warp_scroll) = true;
                 _G(new_level) -= 128;
             }
 
             _G(new_level_tile) = _G(scrn).new_level_loc[icon - 220 + (f * 6)];
-            _G(warp_flag) = 1;
+            _G(warp_flag) = true;
 
             if (_G(warp_scroll)) {
                 if (_G(thor)->dir == 0) _G(thor)->y = 175;
@@ -251,7 +251,7 @@ int open_door1(int y, int x) {
     } else {
         if (!_G(door_inform)) {
             odin_speaks(2003, 0);
-            _G(door_inform) = 1;
+            _G(door_inform) = true;
         }
     }
 
@@ -267,11 +267,11 @@ int cash_door1(int y, int x, int amount) {
     } else {
         if (amount == 10 && !_G(cash1_inform)) {
             odin_speaks(2005, 0);
-            _G(cash1_inform) = 1;
+            _G(cash1_inform) = true;
         }
         if (amount == 100 && !_G(cash2_inform)) {
             odin_speaks(2004, 0);
-            _G(cash2_inform) = 1;
+            _G(cash2_inform) = true;
         }
     }
 
diff --git a/engines/got/got.cpp b/engines/got/got.cpp
index 0b3c1708b61..b59a23d4190 100644
--- a/engines/got/got.cpp
+++ b/engines/got/got.cpp
@@ -163,10 +163,10 @@ void GotEngine::savegameLoaded() {
     if (_G(setup).music == 1) {
         if (GAME1 == 1 && _G(current_area) == 59) {
 //				if (flag)
-            music_play(5, 1);
+            music_play(5, true);
         } else {
             //if (flag)
-            music_play(_G(level_type), 1);
+            music_play(_G(level_type), true);
         }
     } else {
         _G(setup).music = 1;
@@ -174,7 +174,7 @@ void GotEngine::savegameLoaded() {
         _G(setup).music = 0;
     }
 
-    _G(game_over) = _G(setup).game_over;
+    _G(game_over) = _G(setup).game_over != 0;
     _G(slow_mode) = _G(setup).speed;
 
     g_events->replaceView("Game", true);
@@ -233,8 +233,8 @@ void GotEngine::pauseEngineIntern(bool pause) {
     }
 
     _G(lightning_used) = false;
-    _G(thunder_flag) = false;
-    _G(hourglass_flag) = false;
+    _G(thunder_flag) = 0;
+    _G(hourglass_flag) = 0;
 
     Engine::pauseEngineIntern(pause);
 }
diff --git a/engines/got/vars.cpp b/engines/got/vars.cpp
index 348dcb70824..bafd80971d3 100644
--- a/engines/got/vars.cpp
+++ b/engines/got/vars.cpp
@@ -59,7 +59,7 @@ void Vars::load() {
     }
 
     if (_current_level != 23)
-        _story_flag = 0;
+        _story_flag = false;
 
     _setup.music = _music_flag;
     _setup.dig_sound = _sound_flag;
diff --git a/engines/got/vars.h b/engines/got/vars.h
index d41d69bda86..904037638cc 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -105,21 +105,14 @@ public:
     int _slip_cnt = 0;
     bool _boss_intro1 = false, _boss_intro2 = false;
 
-    uint _page[3] = { PAGE0,PAGE1,PAGE2 };
-    uint _display_page = 0, _draw_page = 0;
-    uint _page3_offset = 0;
     int8 _pge = 0;
     int _exit_flag = 0;
 
     byte _key_flag[100] = {};
-    byte _joy_flag[100] = {};
-    byte _tmp_flag[100] = {};
-    int8 _break_code = 0;
-    int8 _scan_code = 0, _last_scan_code = 0;
     int8 _diag = 0;
     bool _diag_flag = false;
     bool _slow_mode = false, _startup = true;
-    int8 _shot_ok = 0;
+    bool _shot_ok = false;
     int _thor_x1 = 0, _thor_y1 = 0, _thor_x2 = 0, _thor_y2 = 0,
                                                   _thor_real_y1 = 0;
     int _thor_pos = 0;
@@ -130,7 +123,6 @@ public:
     int _ox = 0, _oy = 0, _of = 0;
     byte _object_map[TILES_COUNT] = {};
     byte _object_index[TILES_COUNT] = {};
-    byte *_bleep = nullptr;
     int8 _thor_icon1 = 0, _thor_icon2 = 0, _thor_icon3 = 0,
                                            _thor_icon4 = 0;
     int8 _level_type = 0;
@@ -145,7 +137,6 @@ public:
     SETUP _setup;
     SETUP _last_setup;
     byte *_tmp_buff = nullptr;
-    int _reps = 0;
 
     ACTOR _actor[MAX_ACTORS] = {};   //current actors
     ACTOR _enemy[MAX_ENEMIES] = {};  //current enemies
@@ -155,7 +146,7 @@ public:
 
     ACTOR _magic_item[2] = {};
     byte _magic_pic[2][1024] = {};
-    int8 _warp_scroll = 0;
+    bool _warp_scroll = false;
 
     ACTOR *_thor = nullptr;
     ACTOR *_hammer = nullptr;
@@ -165,7 +156,7 @@ public:
     bool _boss_dead = false;
     byte _endgame = 0;
 
-    int _warp_flag = 0;
+    bool _warp_flag = false;
 
     int8 *_std_sound_start = nullptr;
     int8 *_pcstd_sound_start = nullptr;
@@ -175,42 +166,35 @@ public:
     byte *_boss_pcsound[3] = {};
     long _pcsound_length[NUM_SOUNDS] = {};
     int _rand1 = 0, _rand2 = 0;
-    int _restore_screen = 0;
-    int _last_oracle = 0;
-    int _hourglass_flag = 0, _thunder_flag = 0, _shield_on = 0,
-                                                _lightning_used = 0, _tornado_used = 0;
-    int _apple_flag = 0, _bomb_flag = 0;
+	int _hourglass_flag = 0, _thunder_flag = 0;
+	bool _lightning_used = false, _tornado_used = false;
+	bool _shield_on = false;
+	bool _apple_flag = false;
+	bool _bomb_flag = false;
     int _switch_flag = 0;
-    uint _joy_x = 0, _joy_y = 0;
-    int8 _joy_b1 = 0, _joy_b2 = 0;
-    int _joystick = 0, _joylx = 0, _joyly = 0,
-                                   _joyhx = 0, _joyhy = 0;
+
     byte _res_file[16] = {};
-    int _load_game_flag = 0;
     bool _music_flag = false, _sound_flag = false, _pcsound_flag = false;
-    int _cash1_inform = 0, _cash2_inform = 0, _door_inform = 0,
-                                              _magic_inform = 0, _carry_inform = 0;
-    int _killgg_inform = 0;
+	bool _cash1_inform = false;
+	bool _cash2_inform = false;
+	bool _door_inform = false;
+	bool _magic_inform = false;
+	bool _carry_inform = false;
+    bool _killgg_inform = false;
 
-    int8 *_std_sounds = nullptr;
     byte *_pc_sound[NUM_SOUNDS] = {};
     byte *_dig_sound[NUM_SOUNDS] = {};
-    int  _boss_active = 0;
-    int8 _story_flag = 1;
+    bool _boss_active = false;
+    bool _story_flag = true;
     int8 *_scr = nullptr;
     bool _demo = false;
-    int8 _demo_enable = 1;
     int  _rnd_index = 0;
     int  _rnd_array[100] = {};
-    int8 _rdemo = 0;
+    bool _rdemo = false;
     int8 _test_sdf[80] = {};
-    int8 _lzss_buff = 0;
-    int8 _game_over = 0;
-    int8 _noal = 0, _nosb = 0, _ret = 0;
+    bool _game_over = false;
     char _tempstr[80] = {};
-    int8 _auto_load = 0;
-    int8 _ide_run = 0, _fast_exit = 0, _nojoy = 0, _gr = 0, _xdos = 0;
-    int8 _main_loop = 0;
+    bool _auto_load = false;
     bool _end_tile = false;
     byte _pbuff[PALETTE_SIZE] = {};
     int _current_level = 23;
diff --git a/engines/got/views/game_content.cpp b/engines/got/views/game_content.cpp
index 33ad88fddbe..aafb0e78960 100644
--- a/engines/got/views/game_content.cpp
+++ b/engines/got/views/game_content.cpp
@@ -416,7 +416,7 @@ void GameContent::checkForBossDead() {
                     break;
                 }
 
-                _G(boss_active) = 0;
+                _G(boss_active) = false;
             }
         }
     }
@@ -472,7 +472,7 @@ void GameContent::checkForAreaChange() {
         _G(thor)->show = 0;
         _G(thor)->used = 0;
         _G(hammer)->used = 0;
-        _G(tornado_used) = 0;
+        _G(tornado_used) = false;
 
         // Draws the old area without Thor, and then save a copy of it.
         // This will be used to scroll old area off-screen as new area scrolls in
@@ -547,12 +547,12 @@ void GameContent::thorDead() {
     _G(thor)->vunerable = 60;
     _G(thor)->show = 60;
     _G(hourglass_flag) = 0;
-    _G(apple_flag) = 0;
-    _G(bomb_flag) = 0;
+    _G(apple_flag) = false;
+    _G(bomb_flag) = false;
     _G(thunder_flag) = 0;
-    _G(lightning_used) = 0;
-    _G(tornado_used) = 0;
-    _G(shield_on) = 0;
+    _G(lightning_used) = false;
+    _G(tornado_used) = false;
+    _G(shield_on) = false;
     music_resume();
     _G(actor)[1].used = 0;
     _G(actor)[2].used = 0;


Commit: bcfabf0a620a7a07975365c76f31f10ce2b4027c
    https://github.com/scummvm/scummvm/commit/bcfabf0a620a7a07975365c76f31f10ce2b4027c
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: remove REPEAT and IN_RANGE macros, remove unused #defines

Changed paths:
    engines/got/data/defines.h
    engines/got/game/boss1.cpp
    engines/got/game/boss2.cpp
    engines/got/game/init.cpp
    engines/got/vars.h


diff --git a/engines/got/data/defines.h b/engines/got/data/defines.h
index 2bbc77df174..cffc806084e 100644
--- a/engines/got/data/defines.h
+++ b/engines/got/data/defines.h
@@ -25,15 +25,9 @@
 #include "common/scummsys.h"
 #include "common/serializer.h"
 #include "got/data/actor.h"
-#include "got/data/level.h"
-#include "got/data/sd_data.h"
-#include "got/data/setup.h"
-#include "got/data/thor_info.h"
 
-namespace Got {
 
-#define REPEAT(a) for(rep=0;rep<a;rep++)
-#define IN_RANGE(v,l,h) (v>=l && v<=h)
+namespace Got {
 
 struct HEADER {
 	long offset = 0;
@@ -48,125 +42,17 @@ struct HEADER {
 //==========================================================================
 // Defines
 
-#define PAGES 0u
-#define PAGE0 3840u
-#define PAGE1 19280u
-#define PAGE2 34720u
-#define PAGE3 50160u
-
-#define X_MAX  319
-#define Y_MAX  191
-#define MO_BUFF 56688u
-#define MO_OFFSET 55968u
-#define ENEMY_OFFSET 59664u
-#define ENEMY_SHOT_OFFSET 64272u
 #define MAX_ACTORS  35
 #define MAX_ENEMIES 16
-#define MAX_SHOTS   16
 #define STAMINA 20
 
-#define THOR 0
-#define UP     72
-#define DOWN   80
-#define LEFT   75
-#define RIGHT  77
-#define HOME   71
-#define PGUP   73
-#define END    79
-#define PGDN   81
-#define ESC     1
-#define SPACE  57
-#define ENTER  28
-#define ALT    56
-#define CTRL   29
-#define TAB    15
-#define LSHIFT 42
-#define _Z     44
-#define _ONE   2
-#define _TWO   3
-#define _THREE 4
-#define _FOUR  5
-#define _S     31
-#define _L     38
-#define _K     37
-#define _D     32
-#define _B     48
-#define _F1    59
-#define AMI_LEN 1800
+#define _Z 44
+#define _B 48
 #define TMP_SIZE 5800
 
-#define sc_Index 0x3C4
-
-enum {
-	sc_Reset,
-	sc_Clock,
-	sc_MapMask,
-	sc_CharMap,
-	sc_MemMode
-};
-
-#define crtc_Index 0x3D4
-
-enum {
-	crtc_H_Total,
-	crtc_H_DispEnd,
-	crtc_H_Blank,
-	crtc_H_EndBlank,
-	crtc_H_Retrace,
-	crtc_H_EndRetrace,
-	crtc_V_Total,
-	crtc_OverFlow,
-	crtc_RowScan,
-	crtc_MaxScanLine,
-	crtc_CursorStart,
-	crtc_CursorEnd,
-	crtc_StartHigh,
-	crtc_StartLow,
-	crtc_CursorHigh,
-	crtc_CursorLow,
-	crtc_V_Retrace,
-	crtc_V_EndRetrace,
-	crtc_V_DispEnd,
-	crtc_Offset,
-	crtc_Underline,
-	crtc_V_Blank,
-	crtc_V_EndBlank,
-	crtc_Mode,
-	crtc_LineCompare
-};
-
-#define gc_Index 0x3CE
-
-enum {
-	gc_SetReset,
-	gc_EnableSetReset,
-	gc_ColorCompare,
-	gc_DataRotate,
-	gc_ReadMap,
-	gc_Mode,
-	gc_Misc,
-	gc_ColorDontCare,
-	gc_BitMask
-};
-
-#define atr_Index 0x3c0
-
-enum {
-	atr_Mode = 16,
-	atr_Overscan,
-	atr_ColorPlaneEnable,
-	atr_PelPan,
-	atr_ColorSelect
-};
-
-#define	status_Reg1 0x3da
-
 #define GAME1 (_G(area)==1)
 #define GAME2 (_G(area)==2)
 #define GAME3 (_G(area)==3)
-#define BP    (_G(key_flag)[_B])
-
-#define NUM_OBJECTS 32
 
 #define APPLE_MAGIC      1
 #define LIGHTNING_MAGIC  2
@@ -180,9 +66,6 @@ enum {
 #define BOSS_LEVEL3 95
 #define ENDING_SCREEN 106
 
-//#define DEBUG 1
-//#define IDE 1
-//#define CRIPPLED 1
 #define DEMO_LEN 3600
 
 } // namespace Got
diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index 885674201db..998495a7bf2 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -223,7 +223,7 @@ static int boss1_dead() {
 
     _G(hourglass_flag) = 0;
     if (_G(boss_dead) == 1) {
-        REPEAT(4) {
+        for (rep = 0; rep < 4; rep++) {
             x1 = _G(actor)[3 + rep].last_x[_G(pge)];
             y1 = _G(actor)[3 + rep].last_y[_G(pge)];
             x = _G(actor)[3 + rep].x;
diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index 3451680f9c4..012397e84ef 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -333,7 +333,7 @@ static int boss2b_movement(ACTOR *actr) {
 
         su[hx] = 1;
         _G(actor)[an].next = g_events->getRandomNumber(3);
-        REPEAT(num_spikes) {
+        for(rep = 0; rep < num_spikes; rep++) {
             while (1) {
                 hx = g_events->getRandomNumber(17);
                 if (!su[hx]) break;
diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index 4532d6028fa..ff2b9418e3c 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -120,15 +120,14 @@ void deinitialize_game() {
 }
 
 int setup_boss(int num) {
-    int rep;
-    Common::String ress, prefix;
+	Common::String ress, prefix;
     Common::File f;
 
     if (_G(boss_loaded) == num)
         return 1;
 
     if (_G(boss_loaded)) {
-        REPEAT(3) {
+        for(int rep = 0; rep < 3; rep++) {
             if (_G(boss_sound)[rep])
                 free(_G(boss_sound)[rep]);
             if (_G(boss_pcsound)[rep])
diff --git a/engines/got/vars.h b/engines/got/vars.h
index 904037638cc..3c9fc4aef6b 100644
--- a/engines/got/vars.h
+++ b/engines/got/vars.h
@@ -34,6 +34,9 @@
 #include "got/gfx/gfx_pics.h"
 #include "got/metaengine.h"
 #include "got/sound.h"
+#include "got/data/level.h"
+#include "got/data/setup.h"
+#include "got/data/thor_info.h"
 
 namespace Got {
 
@@ -113,8 +116,7 @@ public:
     bool _diag_flag = false;
     bool _slow_mode = false, _startup = true;
     bool _shot_ok = false;
-    int _thor_x1 = 0, _thor_y1 = 0, _thor_x2 = 0, _thor_y2 = 0,
-                                                  _thor_real_y1 = 0;
+    int _thor_x1 = 0, _thor_y1 = 0, _thor_x2 = 0, _thor_y2 = 0, _thor_real_y1 = 0;
     int _thor_pos = 0;
     int _max_shot = 0;
 
@@ -123,8 +125,7 @@ public:
     int _ox = 0, _oy = 0, _of = 0;
     byte _object_map[TILES_COUNT] = {};
     byte _object_index[TILES_COUNT] = {};
-    int8 _thor_icon1 = 0, _thor_icon2 = 0, _thor_icon3 = 0,
-                                           _thor_icon4 = 0;
+    int8 _thor_icon1 = 0, _thor_icon2 = 0, _thor_icon3 = 0, _thor_icon4 = 0;
     int8 _level_type = 0;
     int8 _music_current = -1;
     int8 _boss_loaded = 0;
@@ -200,10 +201,10 @@ public:
     int _current_level = 23;
     int _new_level = 0;
     int _new_level_tile = 0, _current_area = 0;
-    char _sd_header[128] = {};
-    char _play_speed = 0;
-    bool _thor_special_flag = false;
-    byte _exprow = 0;
+	char _sd_header[128] = {};
+	char _play_speed = 0;
+	bool _thor_special_flag = false;
+	byte _exprow = 0;
 };
 
 #define _G(X) (g_vars->_##X)


Commit: 064b42fde4685da944865205ace93fdd4fedf168
    https://github.com/scummvm/scummvm/commit/064b42fde4685da944865205ace93fdd4fedf168
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: more work on CppCheck issues

Changed paths:
    engines/got/game/boss1.cpp
    engines/got/game/boss2.cpp
    engines/got/game/init.cpp
    engines/got/game/init.h
    engines/got/game/move.cpp


diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index 998495a7bf2..9371af9762a 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -36,12 +36,12 @@ namespace Got {
 static int boss1_dead();
 
 int boss1_movement(ACTOR *actr) {
-    int d, x1, y1, f;
+    int x1, y1, f;
 
     if (_G(boss_dead))
         return boss1_dead();
 
-    d = actr->last_dir;
+    int d = actr->last_dir;
     if (actr->edge_counter) {
         actr->edge_counter--;
         goto done;
@@ -130,7 +130,8 @@ int boss1_movement(ACTOR *actr) {
             x1 = _G(actor)[5].x;
             y1 = _G(actor)[5].y;
             y1 += 2;
-            if (!check_move2(x1, y1, &_G(actor)[5])) f = 1;
+            if (!check_move2(x1, y1, &_G(actor)[5]))
+				f = 1;
             else {
                 actr->x = _G(actor)[5].x;
                 actr->y = _G(actor)[5].y - 16;
@@ -150,11 +151,13 @@ int boss1_movement(ACTOR *actr) {
     }
 
 done:
-    if (d > 1) d -= 2;
+    if (d > 1)
+		d -= 2;
 
 done0:
     next_frame(actr);
-    if (actr->next == 3) actr->next = 0;
+    if (actr->next == 3)
+		actr->next = 0;
 
 done1:
     actr->last_dir = d;
@@ -219,17 +222,17 @@ void boss_level1() {
 }
 
 static int boss1_dead() {
-    int rep, n, x, y, r, x1, y1;
-
     _G(hourglass_flag) = 0;
-    if (_G(boss_dead) == 1) {
-        for (rep = 0; rep < 4; rep++) {
-            x1 = _G(actor)[3 + rep].last_x[_G(pge)];
-            y1 = _G(actor)[3 + rep].last_y[_G(pge)];
-            x = _G(actor)[3 + rep].x;
-            y = _G(actor)[3 + rep].y;
-            n = _G(actor)[3 + rep].actor_num;
-            r = _G(actor)[3 + rep].rating;
+    if (_G(boss_dead)) {
+		int rep;
+    	
+		for (rep = 0; rep < 4; rep++) {
+            int x1 = _G(actor)[3 + rep].last_x[_G(pge)];
+            int y1 = _G(actor)[3 + rep].last_y[_G(pge)];
+            int x = _G(actor)[3 + rep].x;
+            int y = _G(actor)[3 + rep].y;
+            int n = _G(actor)[3 + rep].actor_num;
+            int r = _G(actor)[3 + rep].rating;
 
             _G(actor)[3 + rep] = _G(explosion);
             _G(actor)[3 + rep].actor_num = n;
diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index 012397e84ef..0001efdd340 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -23,7 +23,6 @@
 #include "got/game/back.h"
 #include "got/game/init.h"
 #include "got/game/move.h"
-#include "got/game/move_patterns.h"
 #include "got/game/status.h"
 #include "got/gfx/image.h"
 #include "got/gfx/panel.h"
@@ -53,9 +52,7 @@ static int boss2_die();
 static void boss_set(int d, int x, int y);
 
 int boss2_movement(ACTOR *actr) {
-    int d, f, x;
-
-    switch (_G(setup).skill) {
+	switch (_G(setup).skill) {
     case 0:
         num_skulls = 3;
         num_spikes = 5;
@@ -73,39 +70,54 @@ int boss2_movement(ACTOR *actr) {
         return boss2_die();
 
     if (actr->i1) {
-        if (actr->i1 == 1) return boss2a_movement(actr);
-        else return boss2b_movement(actr);
-    }
-    d = actr->last_dir;
-
-    x = actr->x;
+        if (actr->i1 == 1)
+			return boss2a_movement(actr);
 
-    f = 0;
-    if (actr->temp6) actr->temp6--;
-    if (!actr->temp6) {
-        drop_flag = false;
-        if (actr->temp5) actr->temp5--;
-        if (!actr->temp5) f = 1;
-        else {
+		return boss2b_movement(actr);
+    }
+	
+    int d = actr->last_dir;
+    int x = actr->x;
+	
+    if (actr->temp6)
+		actr->temp6--;
+
+	if (!actr->temp6) {
+		bool f = false;
+		drop_flag = false;
+		
+        if (actr->temp5)
+			actr->temp5--;
+
+		if (!actr->temp5)
+			f = true;
+		else {
             if (d == 2) {
-                if (x > 18) actr->x -= 2;
-                else f = 1;
+                if (x > 18)
+					actr->x -= 2;
+                else
+					f = true;
             } else if (d == 3) {
-                if (x < 272) actr->x += 2;
-                else f = 1;
+                if (x < 272)
+					actr->x += 2;
+                else
+					f = true;
             }
         }
         if (f) {
             actr->temp5 = _G(rand1) + 60;
-            if (d == 2) d = 3;
-            else d = 2;
+            if (d == 2)
+				d = 3;
+            else
+				d = 2;
         }
     }
 
     actr->frame_count--;
     if (actr->frame_count <= 0) {
         actr->next++;
-        if (actr->next > 2) actr->next = 0;
+        if (actr->next > 2)
+			actr->next = 0;
         actr->frame_count = actr->frame_speed;
     }
     x = actr->x;
@@ -126,7 +138,9 @@ int boss2_movement(ACTOR *actr) {
 
     boss_set(d, x, actr->y);
 
-    if (actr->directions == 1) return 0;
+    if (actr->directions == 1)
+		return 0;
+
     return d;
 }
 
@@ -147,10 +161,10 @@ static void boss_set(int d, int x, int y) {
 }
 
 void check_boss2_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
-    int rep;
-
     if ((!_G(actor)[3].vunerable)) {
-        actor_damaged(&_G(actor)[3], _G(hammer)->strength);
+		int rep;
+
+		actor_damaged(&_G(actor)[3], _G(hammer)->strength);
         _G(actor)[3].health -= 10;
         if (_G(actor)[3].health == 50) {
             play_sound(BOSS12, 1);
@@ -174,11 +188,12 @@ void check_boss2_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
             _G(actor)[rep].speed_count = 50;
         }
         if (_G(actor)[3].health == 0) {
-            _G(boss_dead) = 1;
-            for (rep = 7; rep < MAX_ACTORS; rep++)
+            _G(boss_dead) = true;
+			for (rep = 7; rep < MAX_ACTORS; rep++) {
                 if (_G(actor)[rep].used)
                     actor_destroyed(&_G(actor)[rep]);
-        }
+			}
+		}
     }
 }
 
@@ -198,18 +213,16 @@ void boss_level2() {
 }
 
 static int boss2_die() {
-    int n, x, y, r, x1, y1;
-
-    _G(hourglass_flag) = 0;
+	_G(hourglass_flag) = 0;
     _G(thunder_flag) = 0;
-    if (_G(boss_dead) == 1) {
+    if (_G(boss_dead)) {
         for (int rep = 0; rep < 4; rep++) {
-            x1 = _G(actor)[3 + rep].last_x[_G(pge)];
-            y1 = _G(actor)[3 + rep].last_y[_G(pge)];
-            x = _G(actor)[3 + rep].x;
-            y = _G(actor)[3 + rep].y;
-            n = _G(actor)[3 + rep].actor_num;
-            r = _G(actor)[3 + rep].rating;
+            int x1 = _G(actor)[3 + rep].last_x[_G(pge)];
+            int y1 = _G(actor)[3 + rep].last_y[_G(pge)];
+            int x = _G(actor)[3 + rep].x;
+            int y = _G(actor)[3 + rep].y;
+            int n = _G(actor)[3 + rep].actor_num;
+            int r = _G(actor)[3 + rep].rating;
 
             _G(actor)[3 + rep] = _G(explosion);
 
@@ -239,29 +252,29 @@ static int boss2_die() {
 
 // Boss - skull (explode)
 static int boss2a_movement(ACTOR *actr) {
-    int an, x, y, r;
-
-    next_frame(actr);
+	next_frame(actr);
     _G(actor)[4].next = actr->next;
     _G(actor)[5].next = actr->next;
     _G(actor)[6].next = actr->next;
     actr->vunerable = 20;
-    if (actr->num_shots) return 0;
-    if (_G(actor)[5].num_shots) return 0;
+    if (actr->num_shots)
+		return 0;
+    if (_G(actor)[5].num_shots)
+		return 0;
 
     play_sound(EXPLODE, true);
     actor_always_shoots(&_G(actor)[5], 0);
-    an = _G(actor)[5].shot_actor;
+    int an = _G(actor)[5].shot_actor;
     _G(actor)[an].move = 9;
 
-    r = _G(rand1) % 60;
+    int r = _G(rand1) % 60;
     while (expf[r]) {
         r++;
         if (r > 59) r = 0;
     }
     expf[r] = 1;
-    x = (EXPLOSION[r] % 20) * 16;
-    y = (EXPLOSION[r] / 20) * 16;
+    int x = (EXPLOSION[r] % 20) * 16;
+    int y = (EXPLOSION[r] / 20) * 16;
     _G(actor)[an].x = x;
     _G(actor)[an].y = y;
 
@@ -279,17 +292,17 @@ static int boss2a_movement(ACTOR *actr) {
 
 // Boss - skull - shake
 static int boss2b_movement(ACTOR *actr) {
-    int rep, an, hx, hy, d;
+    int rep, an, hx;
 
     if (_G(hammer)->used && _G(hammer)->move != 5) {
         hx = _G(hammer)->x;
-        hy = _G(hammer)->y;
+        int hy = _G(hammer)->y;
         for (rep = 7; rep < 15; rep++) {
             if (!_G(actor)[rep].used) continue;
             if (overlap(hx + 1, hy + 1, hx + 10, hy + 10, _G(actor)[rep].x, _G(actor)[rep].y,
                         _G(actor)[rep].x + _G(actor)[rep].size_x - 1, _G(actor)[rep].y + _G(actor)[rep].size_y - 1)) {
                 _G(hammer)->move = 5;
-                d = reverse_direction(_G(hammer));
+                int d = reverse_direction(_G(hammer));
                 _G(hammer)->dir = d;
                 break;
             }
@@ -322,7 +335,6 @@ static int boss2b_movement(ACTOR *actr) {
         actr->i4 = 50;
         play_sound(EXPLODE, true);
         actr->i2 = 0;
-        hx = _G(thor)->x;
 
         Common::fill(su, su + 18, 0);
         actor_always_shoots(&_G(actor)[4], 1);
diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index ff2b9418e3c..7350531a2d8 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -116,13 +116,7 @@ void initialize_game() {
     _G(startup) = false;
 }
 
-void deinitialize_game() {
-}
-
 int setup_boss(int num) {
-	Common::String ress, prefix;
-    Common::File f;
-
     if (_G(boss_loaded) == num)
         return 1;
 
@@ -135,7 +129,7 @@ int setup_boss(int num) {
         }
     }
 
-    ress = Common::String::format("BOSSV%d1", num);
+    Common::String ress = Common::String::format("BOSSV%d1", num);
     _G(boss_sound)[0] = (byte *)res_falloc_read(ress);
     if (!_G(boss_sound)[0]) return 0;
     _G(dig_sound)[NUM_SOUNDS - 3] = _G(boss_sound)[0];
@@ -150,7 +144,7 @@ int setup_boss(int num) {
     if (!_G(boss_sound)[2]) return 0;
     _G(dig_sound)[NUM_SOUNDS - 1] = _G(boss_sound)[2];
 
-    prefix = (num == 2) ? "BOSSP1" : Common::String::format("BOSSP%d", num);
+    Common::String prefix = (num == 2) ? "BOSSP1" : Common::String::format("BOSSP%d", num);
     ress = prefix + "1";
     _G(boss_pcsound)[0] = (byte *)res_falloc_read(ress);
     if (!_G(boss_pcsound)[0]) return 0;
@@ -159,7 +153,8 @@ int setup_boss(int num) {
     _G(pc_sound)[NUM_SOUNDS - 3][0] = 0;
     _G(pc_sound)[NUM_SOUNDS - 3][1] = 0;
 
-    if (!f.open(Common::Path(ress)))
+	Common::File f;
+	if (!f.open(Common::Path(ress)))
         return 0;
     _G(pcsound_length)[NUM_SOUNDS - 3] = f.size();
     f.close();
diff --git a/engines/got/game/init.h b/engines/got/game/init.h
index 0c4c583e122..bf8b87048b0 100644
--- a/engines/got/game/init.h
+++ b/engines/got/game/init.h
@@ -22,15 +22,12 @@
 #ifndef GOT_GAME_INIT_H
 #define GOT_GAME_INIT_H
 
-#include "got/data/defines.h"
-
 namespace Got {
 
 /**
  * Handles in-game initialization the first time
  */
 extern void initialize_game();
-extern void deinitialize_game();
 extern int setup_boss(int num);
 
 } // namespace Got
diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index ffb83fe780d..7659e2f3e23 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -174,17 +174,16 @@ void thor_damaged(ACTOR *actr) {
 }
 
 void actor_destroyed(ACTOR *actr) {
-    int x, y, x1, y1, r, n, t;
-    int pge = _G(pge);
-
     if (actr->actor_num > 2) {
-        x = actr->last_x[pge ^ 1];
-        y = actr->last_y[pge ^ 1];
-        x1 = actr->last_x[pge];
-        y1 = actr->last_y[pge];
-        r = actr->rating;
-        n = actr->actor_num;
-        t = actr->type;
+		int pge = _G(pge);
+
+		int x = actr->last_x[pge ^ 1];
+        int y = actr->last_y[pge ^ 1];
+        int x1 = actr->last_x[pge];
+        int y1 = actr->last_y[pge];
+        int r = actr->rating;
+        int n = actr->actor_num;
+        int t = actr->type;
 
         if (actr->func_num == 255)
             actr->copyFixedAndPics(_G(explosion));
@@ -211,27 +210,38 @@ void actor_destroyed(ACTOR *actr) {
 }
 
 int _actor_shoots(ACTOR *actr, int dir) {
-    int t, i, cx, cy;
+    int cx, cy;
     ACTOR *act;
 
-    t = actr->shot_type - 1;
-    for (i = MAX_ENEMIES + 3; i < MAX_ACTORS; i++) {
+    int t = actr->shot_type - 1;
+    for (int i = MAX_ENEMIES + 3; i < MAX_ACTORS; i++) {
         if ((!_G(actor)[i].used) && (!_G(actor)[i].dead)) {
             act = &_G(actor)[i];
             *act = _G(shot)[t];
 
-            if (actr->size_y < act->size_y) cy = actr->y - ((act->size_y - actr->size_y) / 2);
-            else cy = actr->y + ((actr->size_y - act->size_y) / 2);
-            if (actr->size_x < act->size_x) cx = actr->x - ((act->size_x - actr->size_x) / 2);
-            else cx = actr->x + ((actr->size_x - act->size_x) / 2);
-            if (cy > 174) cy = 174;
-            if (cx > 304) cx = 304;
+            if (actr->size_y < act->size_y)
+				cy = actr->y - ((act->size_y - actr->size_y) / 2);
+            else
+				cy = actr->y + ((actr->size_y - act->size_y) / 2);
+        	
+            if (actr->size_x < act->size_x)
+				cx = actr->x - ((act->size_x - actr->size_x) / 2);
+            else
+				cx = actr->x + ((actr->size_x - act->size_x) / 2);
+        	
+            if (cy > 174)
+				cy = 174;
+        	
+            if (cx > 304)
+				cx = 304;
+        	
             act->x = cx;
             act->y = cy;
             act->last_dir = dir;
             act->next = 0;
             act->dir = dir;
-            if (act->directions == 1) act->dir = 0;
+            if (act->directions == 1)
+				act->dir = 0;
             else if (act->directions == 4 && act->frames == 1) {
                 act->next = dir;
                 act->dir = 0;
@@ -263,35 +273,44 @@ void actor_always_shoots(ACTOR *actr, int dir) {
 }
 
 int actor_shoots(ACTOR *actr, int dir) {
-    int i, cx, cy, tx, ty;
-    int icn;
+    int i;
 
-    cx = (actr->x + (actr->size_x / 2)) >> 4;
-    cy = ((actr->y + actr->size_y) - 2) >> 4;
+    int cx = (actr->x + (actr->size_x / 2)) >> 4;
+    int cy = ((actr->y + actr->size_y) - 2) >> 4;
 
-    tx = _G(thor)->center_x;
-    ty = _G(thor)->center_y;
+    int tx = _G(thor)->center_x;
+    int ty = _G(thor)->center_y;
 
-    icn = 140;
-    if (_G(shot)[actr->shot_type - 1].flying == 1) icn = 80;
+    int icn = 140;
+	
+    if (_G(shot)[actr->shot_type - 1].flying == 1)
+		icn = 80;
 
     switch (dir) {
     case 0:
-        for (i = ty + 1; i <= cy; i++)
-            if (_G(scrn).icon[i][cx] < icn) return 0;
-        break;
+		for (i = ty + 1; i <= cy; i++) {
+            if (_G(scrn).icon[i][cx] < icn)
+				return 0;
+		}
+		break;
     case 1:
-        for (i = cy; i <= ty; i++)
-            if (_G(scrn).icon[i][cx] < icn) return 0;
-        break;
+		for (i = cy; i <= ty; i++) {
+            if (_G(scrn).icon[i][cx] < icn)
+				return 0;
+		}
+		break;
     case 2:
-        for (i = tx; i < cx; i++)
-            if (_G(scrn).icon[cy][i] < icn) return 0;
-        break;
+		for (i = tx; i < cx; i++) {
+            if (_G(scrn).icon[cy][i] < icn)
+				return 0;
+		}
+		break;
     case 3:
-        for (i = cx; i < tx; i++)
-            if (_G(scrn).icon[cy][i] < icn) return 0;
-        break;
+		for (i = cx; i < tx; i++) {
+            if (_G(scrn).icon[cy][i] < icn)
+				return 0;
+		}
+		break;
     }
     return _actor_shoots(actr, dir);
 }
@@ -299,9 +318,12 @@ int actor_shoots(ACTOR *actr, int dir) {
 void move_actor(ACTOR *actr) {
     int i;
 
-    if (actr->vunerable != 0) actr->vunerable--;
-    if (actr->shot_cnt != 0) actr->shot_cnt--;
-    if (actr->show != 0) actr->show--;
+    if (actr->vunerable != 0)
+		actr->vunerable--;
+    if (actr->shot_cnt != 0)
+		actr->shot_cnt--;
+    if (actr->show != 0)
+		actr->show--;
 
     if (!actr->shot_cnt && _G(shot_ok)) {
         if (actr->shots_allowed) {
@@ -313,23 +335,30 @@ void move_actor(ACTOR *actr) {
 
     actr->speed_count--;
     if (actr->speed_count <= 0) {
-        if (!actr->move_counter) actr->speed_count = actr->speed;
-        else actr->speed_count = (actr->speed << 1);
-        if (actr->type == 3) i = shot_movement_func[actr->move](actr);
-        else i = movement_func[actr->move](actr);
-        if (actr->directions == 2) i &= 1;
-        if (i != actr->dir) actr->dir = i;
+        if (!actr->move_counter)
+			actr->speed_count = actr->speed;
+        else
+			actr->speed_count = (actr->speed << 1);
+        if (actr->type == 3)
+			i = shot_movement_func[actr->move](actr);
+        else
+			i = movement_func[actr->move](actr);
+        if (actr->directions == 2)
+			i &= 1;
+        if (i != actr->dir)
+			actr->dir = i;
 
         if (actr->move == 0 && _G(current_level) != _G(new_level) && _G(shield_on)) {
             _G(actor)[2].x = actr->x - 2;
-            if (_G(actor)[2].x < 0) _G(actor)[2].x = 0;
+            if (_G(actor)[2].x < 0)
+				_G(actor)[2].x = 0;
             _G(actor)[2].y = actr->y;
             _G(actor)[2].last_x[0] = _G(actor)[2].x;
             _G(actor)[2].last_x[1] = _G(actor)[2].x;
             _G(actor)[2].last_y[0] = _G(actor)[2].y;
             _G(actor)[2].last_y[1] = _G(actor)[2].y;
         }
-    } else i = actr->dir;
+    }
 
     actr->x &= 0xfffe;
 }


Commit: 08732af25abaa5dedc0311fb2149de46964b8f27
    https://github.com/scummvm/scummvm/commit/08732af25abaa5dedc0311fb2149de46964b8f27
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
NEWS: Added God of Thunder support line

Changed paths:
    NEWS.md


diff --git a/NEWS.md b/NEWS.md
index 88f9fe321e2..1e28aef201d 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -5,6 +5,7 @@ For a more comprehensive changelog of the latest experimental code, see:
 
  New games:
    - Added support for Dark Seed.
+   - Added support for God of Thunder.
 
  Nuvie:
    - Added "Transfer a Character" feature to main menu.


Commit: 370c72e268f3987abf498e2e42432c3f2555e69d
    https://github.com/scummvm/scummvm/commit/370c72e268f3987abf498e2e42432c3f2555e69d
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Some cleanup in move_patterns()

Changed paths:
    engines/got/game/move_patterns.cpp


diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 2307db68d0e..73375b3eac0 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -147,7 +147,7 @@ int special_movement_ten(ACTOR *actr);
 int special_movement_eleven(ACTOR *actr);
 
 int (*special_movement_func[])(ACTOR *actr) = {
-    NULL,
+    nullptr,
     special_movement_one,
     special_movement_two,
     special_movement_three,
@@ -164,12 +164,6 @@ int (*special_movement_func[])(ACTOR *actr) = {
 
 // Check Thor move
 int check_move0(int x, int y, ACTOR *actr) {
-    int x1, x2, y1, y2;
-    int x3, x4, y3, y4;
-    int i, ti;
-    ACTOR *act;
-    byte icn1, icn2, icn3, icn4;
-
     _G(thor_icon1) = 0;
     _G(thor_icon2) = 0;
     _G(thor_icon3) = 0;
@@ -185,7 +179,8 @@ int check_move0(int x, int y, ACTOR *actr) {
             actr->move_count = 0;
             set_thor_vars();
             return 1;
-        } else return 0;
+        } else
+			return 0;
     }
     if (x > 306) {
         if (_G(current_level) < 119) {
@@ -197,7 +192,8 @@ int check_move0(int x, int y, ACTOR *actr) {
             actr->move_count = 0;
             set_thor_vars();
             return 1;
-        } else return 0;
+        } else
+    		return 0;
     }
     if (y < 0) {
         if (_G(current_level) > 9) {
@@ -209,7 +205,8 @@ int check_move0(int x, int y, ACTOR *actr) {
             actr->move_count = 0;
             set_thor_vars();
             return 1;
-        } else return 0;
+        } else
+			return 0;
     }
     if (y > 175) {
         if (_G(current_level) < 110) {
@@ -221,23 +218,23 @@ int check_move0(int x, int y, ACTOR *actr) {
             actr->move_count = 0;
             set_thor_vars();
             return 1;
-        } else return 0;
+        } else
+			return 0;
     }
-    x1 = (x + 1) >> 4;
-    y1 = (y + 8) >> 4;
-    if (_G(thor)->dir > 1) x2 = (x + 12) >> 4;
-    else x2 = (x + 10) >> 4;
-    y2 = (y + 15) >> 4;
+	int x1 = (x + 1) >> 4;
+    int y1 = (y + 8) >> 4;
+	int x2 = (_G(thor)->dir > 1) ? (x + 12) >> 4 : (x + 10) >> 4;
+    int y2 = (y + 15) >> 4;
 
     _G(slip_flag) = false;
 
     // Check for cheat flying mode
     if (!actr->flying) {
-        icn1 = _G(scrn).icon[y1][x1];
-        icn2 = _G(scrn).icon[y2][x1];
-        icn3 = _G(scrn).icon[y1][x2];
-        icn4 = _G(scrn).icon[y2][x2];
-        ti = 0;
+        byte icn1 = _G(scrn).icon[y1][x1];
+        byte icn2 = _G(scrn).icon[y2][x1];
+        byte icn3 = _G(scrn).icon[y1][x2];
+        byte icn4 = _G(scrn).icon[y2][x2];
+        int ti = 0;
 
         if (icn1 < TILE_FLY) {
             _G(thor_icon1) = 1;
@@ -295,16 +292,21 @@ int check_move0(int x, int y, ACTOR *actr) {
     y2 = y + 15;
 
     _G(thor_special_flag) = false;
-    for (i = 3; i < MAX_ACTORS; i++) {
-        act = &_G(actor)[i];
-        if (act->solid & 128) continue;
-        if (!act->used) continue;
-        x3 = act->x + 1;
-        if ((ABS(x3 - x1)) > 16) continue;
-        y3 = act->y + 1;
-        if ((ABS(y3 - y1)) > 16) continue;
-        x4 = act->x + act->size_x - 1;
-        y4 = act->y + act->size_y - 1;
+    for (int i = 3; i < MAX_ACTORS; i++) {
+        ACTOR *act = &_G(actor)[i];
+        if (act->solid & 128)
+			continue;
+        if (!act->used)
+			continue;
+    	
+        int x3 = act->x + 1;
+        if ((ABS(x3 - x1)) > 16)
+			continue;
+        int y3 = act->y + 1;
+        if ((ABS(y3 - y1)) > 16)
+			continue;
+        int x4 = act->x + act->size_x - 1;
+        int y4 = act->y + act->size_y - 1;
         if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
             if (act->func_num > 0) { // 255=explosion
                 if (act->func_num == 255) return 0;
@@ -502,38 +504,35 @@ int check_move2(int x, int y, ACTOR *actr) {
 
 // Check enemy shot move
 int check_move3(int x, int y, ACTOR *actr) {
-    int x1, x2, y1, y2;
-    int x3, x4, y3, y4, i;
-    byte icn1, icn2, icn3, icn4;
-    ACTOR *act;
-
-    int icn;
-
-    if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175)
+	if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175)
 		return 0;
 
-    x1 = (x + 1) >> 4;
-    y1 = (y + (actr->size_y / 2)) >> 4;
-    x2 = ((x + actr->size_x) - 1) >> 4;
-    y2 = ((y + actr->size_y) - 1) >> 4;
+    int x1 = (x + 1) >> 4;
+    int y1 = (y + (actr->size_y / 2)) >> 4;
+    int x2 = ((x + actr->size_x) - 1) >> 4;
+    int y2 = ((y + actr->size_y) - 1) >> 4;
 
     // Check for solid or fly over
 
-    icn = TILE_FLY;
+    int icn = TILE_FLY;
     if (actr->flying)
 		icn = TILE_SOLID;
 
-    icn1 = _G(scrn).icon[y1][x1];
-    icn2 = _G(scrn).icon[y2][x1];
-    icn3 = _G(scrn).icon[y1][x2];
-    icn4 = _G(scrn).icon[y2][x2];
+    byte icn1 = _G(scrn).icon[y1][x1];
+    byte icn2 = _G(scrn).icon[y2][x1];
+    byte icn3 = _G(scrn).icon[y1][x2];
+    byte icn4 = _G(scrn).icon[y2][x2];
     if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn)
 		return 0;
 
-    if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
-    if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
-    if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
-    if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
+    if (icn1 > TILE_SPECIAL && !special_tile(actr, y1, x1, icn1))
+		return 0;
+    if (icn2 > TILE_SPECIAL && !special_tile(actr, y2, x1, icn2))
+		return 0;
+    if (icn3 > TILE_SPECIAL && !special_tile(actr, y1, x2, icn3))
+		return 0;
+    if (icn4 > TILE_SPECIAL && !special_tile(actr, y2, x2, icn4))
+		return 0;
 
     // Check for solid or fly over
     x1 = x + 1;
@@ -545,11 +544,11 @@ int check_move3(int x, int y, ACTOR *actr) {
         thor_damaged(actr);
         return 0;
     }
-    for (i = 3; i < MAX_ACTORS; i++) {
+    for (int i = 3; i < MAX_ACTORS; i++) {
         if (i == actr->actor_num)
 			continue;
     	
-        act = &_G(actor)[i];
+        ACTOR *act = &_G(actor)[i];
     	
         if (!act->used)
 			continue;
@@ -560,16 +559,16 @@ int check_move3(int x, int y, ACTOR *actr) {
         if (act->actor_num == actr->creator)
 			continue;
     	
-        x3 = act->x;
+        int x3 = act->x;
         if ((ABS(x3 - x1)) > 16)
 			continue;
     	
-        y3 = act->y;
+        int y3 = act->y;
         if ((ABS(y3 - y1)) > 16)
 			continue;
     	
-        x4 = x3 + 15;
-        y4 = y3 + 15;
+        int x4 = x3 + 15;
+        int y4 = y3 + 15;
         if (overlap(x1, y1, x2, y2, x3, y3, x4, y4))
 			return 0;
     }
@@ -580,7 +579,8 @@ int check_move3(int x, int y, ACTOR *actr) {
 
 // Flying enemies
 int check_move4(int x, int y, ACTOR *actr) {
-    if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175) return 0;
+    if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175)
+		return 0;
     if (overlap(x, y, x + actr->size_x - 1, y + actr->size_y - 1,
                 _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
         if (actr->type == 3) thor_damaged(actr);
@@ -638,16 +638,20 @@ int  check_thor_move(int x, int y, ACTOR *actr) {
         break;
     case 2:
         if (_G(thor_icon1)) {
-            if (check_move0(x + 2, y + THOR_PAD1, actr)) return 1;
+            if (check_move0(x + 2, y + THOR_PAD1, actr))
+				return 1;
         } else if (_G(thor_icon2)) {
-            if (check_move0(x + 2, y - THOR_PAD1, actr)) return 1;
+            if (check_move0(x + 2, y - THOR_PAD1, actr))
+				return 1;
         }
         break;
     case 3:
         if (_G(thor_icon3)) {
-            if (check_move0(x - 2, y + THOR_PAD1, actr)) return 1;
+            if (check_move0(x - 2, y + THOR_PAD1, actr))
+				return 1;
         } else if (_G(thor_icon4)) {
-            if (check_move0(x - 2, y - THOR_PAD1, actr)) return 1;
+            if (check_move0(x - 2, y - THOR_PAD1, actr))
+				return 1;
         }
         break;
     }
@@ -657,9 +661,9 @@ int  check_thor_move(int x, int y, ACTOR *actr) {
 
 // Player control
 int movement_zero(ACTOR *actr) {
-    int d, x, y, od;
-    d = actr->dir;
-    od = d;
+    int x, y;
+    int d = actr->dir;
+    int od = d;
 
     set_thor_vars();
 
@@ -773,37 +777,42 @@ int movement_zero(ACTOR *actr) {
 }
 
 int check_special_move1(int x, int y, ACTOR *actr) {
-    int x1, x2, y1, y2, i;
+    int i;
     int x3, y3, x4, y4;
-    int icn;
-    byte icn1, icn2, icn3, icn4;
 
     ACTOR *act;
 
-    if (actr->actor_num < 3) return check_move1(x, y, actr);
+    if (actr->actor_num < 3)
+		return check_move1(x, y, actr);
 
-    if (x < 0 || x>304 || y < 0 || y>176) return 0;
+    if (x < 0 || x>304 || y < 0 || y>176)
+		return 0;
 
-    x1 = x >> 4;
-    y1 = y >> 4;
-    x2 = (x + 15) >> 4;
-    y2 = (y + 15) >> 4;
+    int x1 = x >> 4;
+    int y1 = y >> 4;
+    int x2 = (x + 15) >> 4;
+    int y2 = (y + 15) >> 4;
 
     // Check for solid or fly over
 
-    icn = TILE_FLY;
+    int icn = TILE_FLY;
     if (actr->flying) icn = TILE_SOLID;
 
-    icn1 = _G(scrn).icon[y1][x1];
-    icn2 = _G(scrn).icon[y2][x1];
-    icn3 = _G(scrn).icon[y1][x2];
-    icn4 = _G(scrn).icon[y2][x2];
-    if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) return 0;
+    byte icn1 = _G(scrn).icon[y1][x1];
+    byte icn2 = _G(scrn).icon[y2][x1];
+    byte icn3 = _G(scrn).icon[y1][x2];
+    byte icn4 = _G(scrn).icon[y2][x2];
+    if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn)
+		return 0;
 
-    if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
-    if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
-    if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
-    if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
+    if (icn1 > TILE_SPECIAL && !special_tile(actr, y1, x1, icn1))
+		return 0;
+    if (icn2 > TILE_SPECIAL && !special_tile(actr, y2, x1, icn2))
+		return 0;
+    if (icn3 > TILE_SPECIAL && !special_tile(actr, y1, x2, icn3))
+		return 0;
+    if (icn4 > TILE_SPECIAL && !special_tile(actr, y2, x2, icn4))
+		return 0;
 
     x1 = x;
     y1 = y;
@@ -812,26 +821,37 @@ int check_special_move1(int x, int y, ACTOR *actr) {
 
     for (i = 3; i < MAX_ACTORS; i++) {
         act = &_G(actor)[i];
-        if (act->actor_num == actr->actor_num) continue;
-        if (!act->used) continue;
-        if (act->type == 3) continue;   //shot
+        if (act->actor_num == actr->actor_num)
+			continue;
+        if (!act->used)
+			continue;
+        if (act->type == 3)
+			continue;   //shot
         x3 = act->x;
-        if ((ABS(x3 - x1)) > 16) continue;
+        if ((ABS(x3 - x1)) > 16)
+			continue;
         y3 = act->y;
-        if ((ABS(y3 - y1)) > 16) continue;
+        if ((ABS(y3 - y1)) > 16)
+			continue;
         x4 = act->x + act->size_x;
         y4 = act->y + 15;
-        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) return 0;
+        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4))
+			return 0;
     }
     for (i = 3; i < MAX_ACTORS; i++) {
         act = &_G(actor)[i];
-        if (act->actor_num == actr->actor_num) continue;
-        if (!act->used) continue;
-        if (act->type == 3) continue;   // Shot
+        if (act->actor_num == actr->actor_num)
+			continue;
+        if (!act->used)
+			continue;
+        if (act->type == 3)
+			continue;   // Shot
         x3 = act->x;
-        if ((ABS(x3 - x1)) > 16) continue;
+        if ((ABS(x3 - x1)) > 16)
+			continue;
         y3 = act->y;
-        if ((ABS(y3 - y1)) > 16) continue;
+        if ((ABS(y3 - y1)) > 16)
+			continue;
         x4 = act->x + act->size_x;
         y4 = act->y + act->size_y;
         if (overlap(_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2), x3, y3, x4, y4)) return 0;
@@ -845,15 +865,13 @@ int check_special_move1(int x, int y, ACTOR *actr) {
 
 // Block
 int special_movement_one(ACTOR *actr) {
-    int d, x1, y1, sd;
-
-    if (_G(diag_flag))
+	if (_G(diag_flag))
 		return 0;
 	
-    d = _G(thor)->dir;
-    x1 = actr->x;
-    y1 = actr->y;
-    sd = actr->last_dir;
+    int d = _G(thor)->dir;
+    int x1 = actr->x;
+    int y1 = actr->y;
+    int sd = actr->last_dir;
     actr->last_dir = d;
 
     switch (d) {
@@ -893,26 +911,27 @@ int special_movement_one(ACTOR *actr) {
 
 // Angle
 int special_movement_two(ACTOR *actr) {
-    int x1, y1, x2, y2, i;
-    int x3, y3, x4, y4;
-    ACTOR *act;
-
-    x1 = actr->temp1;       // Calc thor pos
-    y1 = actr->temp2;
-    x2 = x1 + 13;
-    y2 = y1 + 14;
-
-    for (i = 3; i < MAX_ACTORS; i++) {
-        act = &_G(actor)[i];
-        if (actr->actor_num == act->actor_num) continue;
-        if (!act->used) continue;
-        x3 = act->x;
-        if ((ABS(x3 - x1)) > 16) continue;
-        y3 = act->y;
-        if ((ABS(y3 - y1)) > 16) continue;
-        x4 = act->x + act->size_x;
-        y4 = act->y + act->size_y;
-        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) return 0;
+	int x1 = actr->temp1;       // Calc thor pos
+    int y1 = actr->temp2;
+    int x2 = x1 + 13;
+    int y2 = y1 + 14;
+
+    for (int i = 3; i < MAX_ACTORS; i++) {
+        ACTOR *act = &_G(actor)[i];
+        if (actr->actor_num == act->actor_num)
+			continue;
+        if (!act->used)
+			continue;
+        int x3 = act->x;
+        if ((ABS(x3 - x1)) > 16)
+			continue;
+        int y3 = act->y;
+        if ((ABS(y3 - y1)) > 16)
+			continue;
+        int x4 = act->x + act->size_x;
+        int y4 = act->y + act->size_y;
+        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4))
+			return 0;
     }
     if (!actr->func_pass) {
         if (_G(thor)->health < 150) {
@@ -932,13 +951,12 @@ int special_movement_two(ACTOR *actr) {
 
 // Yellow globe
 int special_movement_three(ACTOR *actr) {
-    long lind;
 
-    if (_G(thunder_flag))
+	if (_G(thunder_flag))
         return 0;
 
-    lind = (long)_G(current_level);
-    lind = lind * 1000;
+    long lind = (long)_G(current_level);
+    lind *= 1000;
     lind += (long)actr->actor_num;
     execute_script(lind, _G(odin));
 
@@ -947,7 +965,8 @@ int special_movement_three(ACTOR *actr) {
 
 // Peg switch
 int special_movement_four(ACTOR *actr) {
-    if (actr->shot_cnt != 0) return 0;
+    if (actr->shot_cnt != 0)
+		return 0;
     actr->shot_cnt = 30;
 
     _G(switch_flag) = 1;
@@ -956,9 +975,7 @@ int special_movement_four(ACTOR *actr) {
 
 // Boulder roll
 int special_movement_five(ACTOR *actr) {
-    int d;
-
-    d = _G(thor)->dir;
+	int d = _G(thor)->dir;
 
     if (_G(diag_flag)) {
         switch (_G(diag)) {
@@ -1062,11 +1079,9 @@ int movement_one(ACTOR *actr) {
 
 // Hammer only
 int movement_two(ACTOR *actr) {
-    int d, x1, y1;
-
-    d = actr->last_dir;
-    x1 = actr->x;
-    y1 = actr->y;
+	int d = actr->last_dir;
+    int x1 = actr->x;
+    int y1 = actr->y;
 
     switch (d) {
     case 0:
@@ -1103,11 +1118,9 @@ int movement_two(ACTOR *actr) {
 
 // Walk-bump-random turn
 int movement_three(ACTOR *actr) {
-    int d, x1, y1;
-
-    d = actr->last_dir;
-    x1 = actr->x;
-    y1 = actr->y;
+	int d = actr->last_dir;
+    int x1 = actr->x;
+    int y1 = actr->y;
 
     switch (d) {
     case 0:
@@ -1143,14 +1156,13 @@ int movement_three(ACTOR *actr) {
 
 // Simple tracking
 int movement_four(ACTOR *actr) {
-    int d, x1, y1, f;
 
-    d = actr->last_dir;
+	int d = actr->last_dir;
 
-    x1 = actr->x;
-    y1 = actr->y;
+    int x1 = actr->x;
+    int y1 = actr->y;
 
-    f = 0;
+    int f = 0;
     if (x1 > _G(thor_x1) - 1) {
         x1 -= 2;
         d = 2;
@@ -1161,68 +1173,88 @@ int movement_four(ACTOR *actr) {
         f = 1;
     }
 
-    if (f) f = check_move2(x1, y1, actr);
+    if (f)
+		f = check_move2(x1, y1, actr);
 
     if (!f) {
         if (y1 < (_G(thor_real_y1))) {
-            d = (_G(thor_real_y1))-y1;
-            if (d > 2) d = 2;
+            d = (_G(thor_real_y1)) - y1;
+            if (d > 2)
+				d = 2;
             y1 += d;
             d = 1;
             f = 1;
         } else if (y1 > (_G(thor_real_y1))) {
             d = y1 - (_G(thor_real_y1));
-            if (d > 2) d = 2;
+            if (d > 2)
+				d = 2;
             y1 -= d;
             d = 0;
             f = 1;
         }
-        if (f) f = check_move2(actr->x, y1, actr);
-        if (!f) check_move2(actr->x, actr->y, actr);
+        if (f)
+			f = check_move2(actr->x, y1, actr);
+        if (!f)
+			check_move2(actr->x, actr->y, actr);
     }
     next_frame(actr);
     actr->last_dir = d;
-    if (actr->directions == 1) return 0;
+    if (actr->directions == 1)
+		return 0;
     return d;
 }
 
 int movement_five(ACTOR *actr) {
-    int x1, y1, xd, yd, d;
-
-    x1 = actr->x;
-    y1 = actr->y;
-    xd = yd = 0;
-    d = actr->last_dir;
+    int x1 = actr->x;
+    int y1 = actr->y;
+    int xd = 0;
+	int yd = 0;
+	int d = actr->last_dir;
 
-    if (x1 > (_G(thor)->x + 1)) xd = -2;  //+1
-    else if (x1 < (_G(thor)->x - 1)) xd = 2;
+    if (x1 > (_G(thor)->x + 1))
+		xd = -2;  //+1
+    else if (x1 < (_G(thor)->x - 1))
+		xd = 2;
 
     if (actr->actor_num == 1) {
-        if (y1 < (_G(thor_y1) - 6)) yd = 2;
-        else if (y1 > (_G(thor_y1) - 6)) yd = -2;
+        if (y1 < (_G(thor_y1) - 6))
+			yd = 2;
+        else if (y1 > (_G(thor_y1) - 6))
+			yd = -2;
     } else {
-        if (y1 < (_G(thor_real_y1) - 1)) yd = 2;
-        else if (y1 > (_G(thor_real_y1) + 1)) yd = -2;
+        if (y1 < (_G(thor_real_y1) - 1))
+			yd = 2;
+        else if (y1 > (_G(thor_real_y1) + 1))
+			yd = -2;
     }
 
     if (xd && yd) {
-        if (xd == -2 && yd == -2) d = 2;
-        else if (xd == -2 && yd == 2) d = 2;
-        else if (xd == 2 && yd == -2) d = 3;
-        else if (xd == 2 && yd == 2) d = 3;
+        if (xd == -2 && yd == -2)
+			d = 2;
+        else if (xd == -2 && yd == 2)
+			d = 2;
+        else if (xd == 2 && yd == -2)
+			d = 3;
+        else if (xd == 2 && yd == 2)
+			d = 3;
         x1 += xd;
         y1 += yd;
         if (check_move2(x1, y1, actr)) {
             next_frame(actr);
             actr->last_dir = d;
-            if (actr->directions == 1) return 0;
+            if (actr->directions == 1)
+				return 0;
             return d;
         }
     } else {
-        if (xd == 0 && yd == 2) d = 1;
-        else if (xd == 0 && yd == -2) d = 0;
-        else if (xd == 2 && yd == 0) d = 3;
-        else if (xd == -2 && yd == 0) d = 2;
+        if (xd == 0 && yd == 2)
+			d = 1;
+        else if (xd == 0 && yd == -2)
+			d = 0;
+        else if (xd == 2 && yd == 0)
+			d = 3;
+        else if (xd == -2 && yd == 0)
+			d = 2;
     }
     x1 = actr->x;
     y1 = actr->y;


Commit: 14df0afe1ae152a9d2060b02e062c17562ab13f6
    https://github.com/scummvm/scummvm/commit/14df0afe1ae152a9d2060b02e062c17562ab13f6
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: modify access to global arrays in move and move_patterns to avoid formatting issues

Changed paths:
    engines/got/game/move.cpp
    engines/got/game/move_patterns.cpp


diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index 7659e2f3e23..5bbed8ab858 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -215,9 +215,9 @@ int _actor_shoots(ACTOR *actr, int dir) {
 
     int t = actr->shot_type - 1;
     for (int i = MAX_ENEMIES + 3; i < MAX_ACTORS; i++) {
-        if ((!_G(actor)[i].used) && (!_G(actor)[i].dead)) {
-            act = &_G(actor)[i];
-            *act = _G(shot)[t];
+        if ((!_G(actor[i]).used) && (!_G(actor[i]).dead)) {
+            act = &_G(actor[i]);
+            *act = _G(shot[t]);
 
             if (actr->size_y < act->size_y)
 				cy = actr->y - ((act->size_y - actr->size_y) / 2);
@@ -283,7 +283,7 @@ int actor_shoots(ACTOR *actr, int dir) {
 
     int icn = 140;
 	
-    if (_G(shot)[actr->shot_type - 1].flying == 1)
+    if (_G(shot[actr->shot_type - 1]).flying == 1)
 		icn = 80;
 
     switch (dir) {
@@ -349,14 +349,14 @@ void move_actor(ACTOR *actr) {
 			actr->dir = i;
 
         if (actr->move == 0 && _G(current_level) != _G(new_level) && _G(shield_on)) {
-            _G(actor)[2].x = actr->x - 2;
-            if (_G(actor)[2].x < 0)
-				_G(actor)[2].x = 0;
-            _G(actor)[2].y = actr->y;
-            _G(actor)[2].last_x[0] = _G(actor)[2].x;
-            _G(actor)[2].last_x[1] = _G(actor)[2].x;
-            _G(actor)[2].last_y[0] = _G(actor)[2].y;
-            _G(actor)[2].last_y[1] = _G(actor)[2].y;
+            _G(actor[2]).x = actr->x - 2;
+            if (_G(actor[2]).x < 0)
+				_G(actor[2]).x = 0;
+            _G(actor[2]).y = actr->y;
+            _G(actor[2]).last_x[0] = _G(actor[2]).x;
+            _G(actor[2]).last_x[1] = _G(actor[2]).x;
+            _G(actor[2]).last_y[0] = _G(actor[2]).y;
+            _G(actor[2]).last_y[1] = _G(actor[2]).y;
         }
     }
 
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 73375b3eac0..4d21a5651f5 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -293,7 +293,7 @@ int check_move0(int x, int y, ACTOR *actr) {
 
     _G(thor_special_flag) = false;
     for (int i = 3; i < MAX_ACTORS; i++) {
-        ACTOR *act = &_G(actor)[i];
+        ACTOR *act = &_G(actor[i]);
         if (act->solid & 128)
 			continue;
         if (!act->used)
@@ -321,7 +321,7 @@ int check_move0(int x, int y, ACTOR *actr) {
                     if (!act->vunerable && (!(act->type & 1)))
 						play_sound(PUNCH1, false);
                 	
-                    if (!_G(hammer)->used && _G(key_flag)[key_fire])
+                    if (!_G(hammer)->used && _G(key_flag[key_fire]))
                         actor_damaged(act, _G(hammer)->strength);
                     else
                         actor_damaged(act, _G(thor)->strength);
@@ -378,7 +378,7 @@ int check_move1(int x, int y, ACTOR *actr) {
 
     f = 0;
     for (i = 3; i < MAX_ACTORS; i++) {
-        act = &_G(actor)[i];
+        act = &_G(actor[i]);
         if (!act->used) continue;
         if (act->type == 3) continue;
         x3 = act->x;
@@ -460,7 +460,7 @@ int check_move2(int x, int y, ACTOR *actr) {
     y2 = (y + actr->size_y) - 1;
 
     for (i = 0; i < MAX_ACTORS; i++) {
-        act = &_G(actor)[i];
+        act = &_G(actor[i]);
         if (act->actor_num == actr->actor_num)
 			continue;
         if (act->actor_num == 1)
@@ -548,7 +548,7 @@ int check_move3(int x, int y, ACTOR *actr) {
         if (i == actr->actor_num)
 			continue;
     	
-        ACTOR *act = &_G(actor)[i];
+        ACTOR *act = &_G(actor[i]);
     	
         if (!act->used)
 			continue;
@@ -692,7 +692,7 @@ int movement_zero(ACTOR *actr) {
         return d;
     }
 
-    if (_G(key_flag)[key_up] && _G(key_flag)[key_left]) {
+    if (_G(key_flag[key_up]) && _G(key_flag[key_left])) {
         d = 2;
         actr->dir = d;
         _G(diag) = 1;
@@ -701,7 +701,7 @@ int movement_zero(ACTOR *actr) {
             next_frame(actr);
             return d;
         }
-    } else if (_G(key_flag)[key_up] && _G(key_flag)[key_right]) {
+    } else if (_G(key_flag[key_up]) && _G(key_flag[key_right])) {
         d = 3;
         actr->dir = d;
         _G(diag) = 2;
@@ -710,7 +710,7 @@ int movement_zero(ACTOR *actr) {
             next_frame(actr);
             return d;
         }
-    } else if (_G(key_flag)[key_down] && _G(key_flag)[key_left]) {
+    } else if (_G(key_flag[key_down]) && _G(key_flag[key_left])) {
         d = 2;
         actr->dir = d;
         _G(diag) = 4;
@@ -719,7 +719,7 @@ int movement_zero(ACTOR *actr) {
             next_frame(actr);
             return d;
         }
-    } else if (_G(key_flag)[key_down] && _G(key_flag)[key_right]) {
+    } else if (_G(key_flag[key_down]) && _G(key_flag[key_right])) {
         d = 3;
         actr->dir = d;
         _G(diag) = 3;
@@ -730,8 +730,8 @@ int movement_zero(ACTOR *actr) {
         }
     }
     _G(diag) = 0;
-    if (_G(key_flag)[key_right]) {
-        if (!_G(key_flag)[key_left]) {
+    if (_G(key_flag[key_right])) {
+        if (!_G(key_flag[key_left])) {
             d = 3;
             actr->dir = d;
             if (check_thor_move(x + 2, y, actr)) {
@@ -740,8 +740,8 @@ int movement_zero(ACTOR *actr) {
             }
         }
     }
-    if (_G(key_flag)[key_left]) {
-        if (!_G(key_flag)[key_right]) {
+    if (_G(key_flag[key_left])) {
+        if (!_G(key_flag[key_right])) {
             d = 2;
             actr->dir = d;
             if (check_thor_move(x - 2, y, actr)) {
@@ -750,8 +750,8 @@ int movement_zero(ACTOR *actr) {
             }
         }
     }
-    if (_G(key_flag)[key_down]) {
-        if (!_G(key_flag)[key_up]) {
+    if (_G(key_flag[key_down])) {
+        if (!_G(key_flag[key_up])) {
             d = 1;
             actr->dir = d;
             if (check_thor_move(x, y + 2, actr)) {
@@ -760,8 +760,8 @@ int movement_zero(ACTOR *actr) {
             }
         }
     }
-    if (_G(key_flag)[key_up]) {
-        if (!_G(key_flag)[key_down]) {
+    if (_G(key_flag[key_up])) {
+        if (!_G(key_flag[key_down])) {
             d = 0;
             actr->dir = d;
             if (check_thor_move(x, y - 2, actr)) {
@@ -820,7 +820,7 @@ int check_special_move1(int x, int y, ACTOR *actr) {
     y2 = (y + 15);
 
     for (i = 3; i < MAX_ACTORS; i++) {
-        act = &_G(actor)[i];
+        act = &_G(actor[i]);
         if (act->actor_num == actr->actor_num)
 			continue;
         if (!act->used)
@@ -839,7 +839,7 @@ int check_special_move1(int x, int y, ACTOR *actr) {
 			return 0;
     }
     for (i = 3; i < MAX_ACTORS; i++) {
-        act = &_G(actor)[i];
+        act = &_G(actor[i]);
         if (act->actor_num == actr->actor_num)
 			continue;
         if (!act->used)
@@ -917,7 +917,7 @@ int special_movement_two(ACTOR *actr) {
     int y2 = y1 + 14;
 
     for (int i = 3; i < MAX_ACTORS; i++) {
-        ACTOR *act = &_G(actor)[i];
+        ACTOR *act = &_G(actor[i]);
         if (actr->actor_num == act->actor_num)
 			continue;
         if (!act->used)
@@ -2202,7 +2202,7 @@ int movement_thirtysix(ACTOR *actr) {
     next_frame(actr);
     if (actr->next == 0 && actr->frame_count == actr->frame_speed) {
         actor_always_shoots(actr, 1);
-        _G(actor)[actr->shot_actor].x -= 2;
+        _G(actor[actr->shot_actor]).x -= 2;
     }
     return 0;
 }
@@ -2366,15 +2366,15 @@ int movement_thirtynine(ACTOR *actr) {
         actr->i1--;
         actr->x -= 2;
         check_move2(actr->x, actr->y, actr);
-        _G(actor)[4].x -= 2;
-        _G(actor)[5].x -= 2;
-        _G(actor)[6].x -= 2;
+        _G(actor[4]).x -= 2;
+        _G(actor[5]).x -= 2;
+        _G(actor[6]).x -= 2;
     }
     next_frame(actr);
     if (actr->next == 3) actr->next = 0;
-    _G(actor)[4].next = _G(actor)[3].next;
-    _G(actor)[5].next = 0;
-    _G(actor)[6].next = 0;
+    _G(actor[4]).next = _G(actor[3]).next;
+    _G(actor[5]).next = 0;
+    _G(actor[6]).next = 0;
     return actr->dir;
 }
 
@@ -2389,46 +2389,46 @@ int movement_forty(ACTOR *actr) {
     }
     a = 5 + (actr->pass_value * 4);
     x1 = actr->x;
-    x2 = _G(actor)[a + 1].x;
+    x2 = _G(actor[a + 1]).x;
     d = actr->last_dir;
 
     if (actr->last_dir == 2) {
         f = 1;
         if (bgtile(x1 - 2, actr->y) >= TILE_SOLID) {
-            _G(actor)[a].x -= 2;
-            _G(actor)[a - 1].x -= 2;
-            _G(actor)[a - 2].x -= 2;
-            _G(actor)[a + 1].x -= 2;
+            _G(actor[a].x) -= 2;
+            _G(actor[a - 1]).x -= 2;
+            _G(actor[a - 2]).x -= 2;
+            _G(actor[a + 1]).x -= 2;
         } else f = 0;
         if (!f)
             d = 3;
     } else {
         f = 1;
-        if (bgtile(_G(actor)[a + 1].x + 14, _G(actor)[a + 1].y) >= TILE_SOLID) {
-            _G(actor)[a].x += 2;
-            _G(actor)[a - 1].x += 2;
-            _G(actor)[a - 2].x += 2;
-            _G(actor)[a + 1].x += 2;
+        if (bgtile(_G(actor[a + 1]).x + 14, _G(actor[a + 1]).y) >= TILE_SOLID) {
+            _G(actor[a]).x += 2;
+            _G(actor[a - 1]).x += 2;
+            _G(actor[a - 2]).x += 2;
+            _G(actor[a + 1]).x += 2;
         } else f = 0;
         if (!f) d = 2;
     }
     if (!f) {
         actr->x = x1;
-        _G(actor)[a + 1].x = x2;
+        _G(actor[a + 1]).x = x2;
     }
 
     if (actr->next == 3 && !actr->num_shots && actr->frame_count == actr->frame_speed) {
         actor_always_shoots(actr, 1);
-        _G(actor)[actr->shot_actor].x += 6;
+        _G(actor[actr->shot_actor]).x += 6;
     }
 
     next_frame(actr);
-    _G(actor)[a - 2].next = actr->next;
-    _G(actor)[a - 1].next = actr->next;
-    _G(actor)[a + 1].next = actr->next;
-    _G(actor)[a - 2].last_dir = d;
-    _G(actor)[a - 1].last_dir = d;
-    _G(actor)[a + 1].last_dir = d;
+    _G(actor[a - 2]).next = actr->next;
+    _G(actor[a - 1]).next = actr->next;
+    _G(actor[a + 1]).next = actr->next;
+    _G(actor[a - 2]).last_dir = d;
+    _G(actor[a - 1]).last_dir = d;
+    _G(actor[a + 1]).last_dir = d;
     actr->last_dir = d;
     if (actr->directions == 1) return 0;
     return d;


Commit: a44be565aea7983091d79d07e0bcfcec5eb1a49e
    https://github.com/scummvm/scummvm/commit/a44be565aea7983091d79d07e0bcfcec5eb1a49e
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Code formatting in move and move_patterns

Changed paths:
    engines/got/game/move.cpp
    engines/got/game/move_patterns.cpp


diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index 5bbed8ab858..c65c10eafee 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -20,347 +20,359 @@
  */
 
 #include "got/game/move.h"
+#include "got/events.h"
 #include "got/game/back.h"
 #include "got/game/move_patterns.h"
 #include "got/game/shot_movement.h"
 #include "got/game/shot_pattern.h"
 #include "got/game/status.h"
-#include "got/events.h"
 #include "got/vars.h"
 
 namespace Got {
 
 void next_frame(ACTOR *actr) {
-    actr->frame_count--;
+	actr->frame_count--;
 
-    if (actr->frame_count <= 0) {
-        actr->next++;
+	if (actr->frame_count <= 0) {
+		actr->next++;
 
-        if (actr->next > 3)
-            actr->next = 0;
+		if (actr->next > 3)
+			actr->next = 0;
 
-        actr->frame_count = actr->frame_speed;
-    }
+		actr->frame_count = actr->frame_speed;
+	}
 }
 
 bool point_within(int x, int y, int x1, int y1, int x2, int y2) {
-    return ((x >= x1) && (x <= x2) && (y >= y1) && (y <= y2));
+	return ((x >= x1) && (x <= x2) && (y >= y1) && (y <= y2));
 }
 
 bool overlap(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
-    if ((x1 >= x3) && (x1 <= x4) && (y1 >= y3) && (y1 <= y4)) return true;
-    if ((x2 >= x3) && (x2 <= x4) && (y2 >= y3) && (y2 <= y4)) return true;
-    if ((x1 >= x3) && (x1 <= x4) && (y2 >= y3) && (y2 <= y4)) return true;
-    if ((x2 >= x3) && (x2 <= x4) && (y1 >= y3) && (y1 <= y4)) return true;
-    if ((x3 >= x1) && (x3 <= x2) && (y3 >= y1) && (y3 <= y2)) return true;
-    if ((x4 >= x1) && (x4 <= x2) && (y4 >= y1) && (y4 <= y2)) return true;
-    if ((x3 >= x1) && (x3 <= x2) && (y4 >= y1) && (y4 <= y2)) return true;
-    if ((x4 >= x1) && (x4 <= x2) && (y3 >= y1) && (y3 <= y2)) return true;
-    return false;
+	if ((x1 >= x3) && (x1 <= x4) && (y1 >= y3) && (y1 <= y4))
+		return true;
+	if ((x2 >= x3) && (x2 <= x4) && (y2 >= y3) && (y2 <= y4))
+		return true;
+	if ((x1 >= x3) && (x1 <= x4) && (y2 >= y3) && (y2 <= y4))
+		return true;
+	if ((x2 >= x3) && (x2 <= x4) && (y1 >= y3) && (y1 <= y4))
+		return true;
+	if ((x3 >= x1) && (x3 <= x2) && (y3 >= y1) && (y3 <= y2))
+		return true;
+	if ((x4 >= x1) && (x4 <= x2) && (y4 >= y1) && (y4 <= y2))
+		return true;
+	if ((x3 >= x1) && (x3 <= x2) && (y4 >= y1) && (y4 <= y2))
+		return true;
+	if ((x4 >= x1) && (x4 <= x2) && (y3 >= y1) && (y3 <= y2))
+		return true;
+	return false;
 }
 
 int reverse_direction(ACTOR *actr) {
-    if (actr->dir == 1) return 0;
-    if (actr->dir == 2) return 3;
-    if (actr->dir == 3) return 2;
-    return 1;
+	if (actr->dir == 1)
+		return 0;
+	if (actr->dir == 2)
+		return 3;
+	if (actr->dir == 3)
+		return 2;
+	return 1;
 }
 
 void thor_shoots() {
-    if ((_G(hammer)->used != 1) && (!_G(hammer)->dead) && (!_G(thor)->shot_cnt)) {
-        play_sound(SWISH, false);
-        _G(thor)->shot_cnt = 20;
-        _G(hammer)->used = 1;
-        _G(hammer)->dir = _G(thor)->dir;
-        _G(hammer)->last_dir = _G(thor)->dir;
-        _G(hammer)->x = _G(thor)->x;
-        _G(hammer)->y = _G(thor)->y + 2;
-        _G(hammer)->move = 2;
-        _G(hammer)->next = 0;
-        _G(hammer)->last_x[0] = _G(hammer)->x;
-        _G(hammer)->last_x[1] = _G(hammer)->x;
-        _G(hammer)->last_y[0] = _G(hammer)->y;
-        _G(hammer)->last_y[1] = _G(hammer)->y;
-    }
+	if ((_G(hammer)->used != 1) && (!_G(hammer)->dead) && (!_G(thor)->shot_cnt)) {
+		play_sound(SWISH, false);
+		_G(thor)->shot_cnt = 20;
+		_G(hammer)->used = 1;
+		_G(hammer)->dir = _G(thor)->dir;
+		_G(hammer)->last_dir = _G(thor)->dir;
+		_G(hammer)->x = _G(thor)->x;
+		_G(hammer)->y = _G(thor)->y + 2;
+		_G(hammer)->move = 2;
+		_G(hammer)->next = 0;
+		_G(hammer)->last_x[0] = _G(hammer)->x;
+		_G(hammer)->last_x[1] = _G(hammer)->x;
+		_G(hammer)->last_y[0] = _G(hammer)->y;
+		_G(hammer)->last_y[1] = _G(hammer)->y;
+	}
 }
 
 int kill_good_guy(void) {
-    if (!_G(killgg_inform) && !_G(thunder_flag)) {
-        odin_speaks(2010, 0);
-        _G(killgg_inform) = true;
-    }
+	if (!_G(killgg_inform) && !_G(thunder_flag)) {
+		odin_speaks(2010, 0);
+		_G(killgg_inform) = true;
+	}
 
-    add_score(-1000);
-    return 0;
+	add_score(-1000);
+	return 0;
 }
 
 void actor_damaged(ACTOR *actr, int damage) {
-    if (!_G(setup).skill)
-        damage *= 2;
-    else if (_G(setup).skill == 2)
-        damage /= 2;
-
-    if (!actr->vunerable && actr->type != 3 && (actr->solid & 0x7f) != 2) {
-        actr->vunerable = STAMINA;
-        if (damage >= actr->health) {
-            if (actr->type != 4) {
-                add_score(actr->init_health * 10);
-
-            } else {
-                kill_good_guy();
-            }
-
-            actor_destroyed(actr);
-        } else {
-            actr->show = 10;
-            actr->health -= damage;
-            actr->speed_count += 8;
-        }
-    } else if (!actr->vunerable) {
-        actr->vunerable = STAMINA;
-
-        if (actr->func_num == 4) {
-            switch_icons();
-        }
-        if (actr->func_num == 7) {
-            rotate_arrows();
-        }
-    }
+	if (!_G(setup).skill)
+		damage *= 2;
+	else if (_G(setup).skill == 2)
+		damage /= 2;
+
+	if (!actr->vunerable && actr->type != 3 && (actr->solid & 0x7f) != 2) {
+		actr->vunerable = STAMINA;
+		if (damage >= actr->health) {
+			if (actr->type != 4) {
+				add_score(actr->init_health * 10);
+
+			} else {
+				kill_good_guy();
+			}
+
+			actor_destroyed(actr);
+		} else {
+			actr->show = 10;
+			actr->health -= damage;
+			actr->speed_count += 8;
+		}
+	} else if (!actr->vunerable) {
+		actr->vunerable = STAMINA;
 
+		if (actr->func_num == 4) {
+			switch_icons();
+		}
+		if (actr->func_num == 7) {
+			rotate_arrows();
+		}
+	}
 }
 
 void thor_damaged(ACTOR *actr) {
-    int damage;
-
-    actr->hit_thor = 1;
-
-    // If we're invincible, ignore any damage
-    if (_G(cheats).freezeHealth)
-        return;
-
-    if (GAME3 && actr->func_num == 11) {
-        if (actr->talk_counter) {
-            actr->talk_counter--;
-            return;
-        }
-
-        int t = actr->type;
-        actr->type = 4;
-        actor_speaks(actr, 0, 0);
-        actr->type = t;
-        actr->talk_counter = 30;
-        return;
-    }
-
-    damage = actr->strength;
-    if (damage != 255) {
-        if (!_G(setup).skill) damage /= 2;
-        else if (_G(setup).skill == 2) damage *= 2;
-    }
-    if ((!_G(thor)->vunerable && !_G(shield_on)) || damage == 255) {
-        if (damage >= _G(thor)->health) {
-            _G(thor)->vunerable = 40;
-            _G(thor)->show = 0;
-            _G(thor)->health = 0;
-            _G(exit_flag) = 2;
-            g_events->send(GameMessage("THOR_DIES"));
-        } else if (damage) {
-            _G(thor)->vunerable = 40;
-            _G(sound).play_sound(OW, 0);
-            _G(thor)->show = 10;
-            _G(thor)->health -= damage;
-        }
-    }
+	int damage;
+
+	actr->hit_thor = 1;
+
+	// If we're invincible, ignore any damage
+	if (_G(cheats).freezeHealth)
+		return;
+
+	if (GAME3 && actr->func_num == 11) {
+		if (actr->talk_counter) {
+			actr->talk_counter--;
+			return;
+		}
+
+		int t = actr->type;
+		actr->type = 4;
+		actor_speaks(actr, 0, 0);
+		actr->type = t;
+		actr->talk_counter = 30;
+		return;
+	}
+
+	damage = actr->strength;
+	if (damage != 255) {
+		if (!_G(setup).skill)
+			damage /= 2;
+		else if (_G(setup).skill == 2)
+			damage *= 2;
+	}
+	if ((!_G(thor)->vunerable && !_G(shield_on)) || damage == 255) {
+		if (damage >= _G(thor)->health) {
+			_G(thor)->vunerable = 40;
+			_G(thor)->show = 0;
+			_G(thor)->health = 0;
+			_G(exit_flag) = 2;
+			g_events->send(GameMessage("THOR_DIES"));
+		} else if (damage) {
+			_G(thor)->vunerable = 40;
+			_G(sound).play_sound(OW, 0);
+			_G(thor)->show = 10;
+			_G(thor)->health -= damage;
+		}
+	}
 }
 
 void actor_destroyed(ACTOR *actr) {
-    if (actr->actor_num > 2) {
+	if (actr->actor_num > 2) {
 		int pge = _G(pge);
 
 		int x = actr->last_x[pge ^ 1];
-        int y = actr->last_y[pge ^ 1];
-        int x1 = actr->last_x[pge];
-        int y1 = actr->last_y[pge];
-        int r = actr->rating;
-        int n = actr->actor_num;
-        int t = actr->type;
-
-        if (actr->func_num == 255)
-            actr->copyFixedAndPics(_G(explosion));
-        else
-            actr->copyFixedAndPics(_G(sparkle));
-
-        actr->type = t;
-        actr->actor_num = n;
-        actr->rating = r;
-        actr->x = x;
-        actr->y = y;
-        actr->last_x[pge] = x1;
-        actr->last_x[pge ^ 1] = x;
-        actr->last_y[pge] = y1;
-        actr->last_y[pge ^ 1] = y;
-        actr->speed_count = actr->speed;
-        actr->used = 1;
-        actr->num_shots = 3;  // used to reverse explosion
-        actr->vunerable = 255;
-    } else {
-        actr->dead = 2;
-        actr->used = 0;
-    }
+		int y = actr->last_y[pge ^ 1];
+		int x1 = actr->last_x[pge];
+		int y1 = actr->last_y[pge];
+		int r = actr->rating;
+		int n = actr->actor_num;
+		int t = actr->type;
+
+		if (actr->func_num == 255)
+			actr->copyFixedAndPics(_G(explosion));
+		else
+			actr->copyFixedAndPics(_G(sparkle));
+
+		actr->type = t;
+		actr->actor_num = n;
+		actr->rating = r;
+		actr->x = x;
+		actr->y = y;
+		actr->last_x[pge] = x1;
+		actr->last_x[pge ^ 1] = x;
+		actr->last_y[pge] = y1;
+		actr->last_y[pge ^ 1] = y;
+		actr->speed_count = actr->speed;
+		actr->used = 1;
+		actr->num_shots = 3; // used to reverse explosion
+		actr->vunerable = 255;
+	} else {
+		actr->dead = 2;
+		actr->used = 0;
+	}
 }
 
 int _actor_shoots(ACTOR *actr, int dir) {
-    int cx, cy;
-    ACTOR *act;
+	int cx, cy;
+	ACTOR *act;
 
-    int t = actr->shot_type - 1;
-    for (int i = MAX_ENEMIES + 3; i < MAX_ACTORS; i++) {
-        if ((!_G(actor[i]).used) && (!_G(actor[i]).dead)) {
-            act = &_G(actor[i]);
-            *act = _G(shot[t]);
+	int t = actr->shot_type - 1;
+	for (int i = MAX_ENEMIES + 3; i < MAX_ACTORS; i++) {
+		if ((!_G(actor[i]).used) && (!_G(actor[i]).dead)) {
+			act = &_G(actor[i]);
+			*act = _G(shot[t]);
 
-            if (actr->size_y < act->size_y)
+			if (actr->size_y < act->size_y)
 				cy = actr->y - ((act->size_y - actr->size_y) / 2);
-            else
+			else
 				cy = actr->y + ((actr->size_y - act->size_y) / 2);
-        	
-            if (actr->size_x < act->size_x)
+
+			if (actr->size_x < act->size_x)
 				cx = actr->x - ((act->size_x - actr->size_x) / 2);
-            else
+			else
 				cx = actr->x + ((actr->size_x - act->size_x) / 2);
-        	
-            if (cy > 174)
+
+			if (cy > 174)
 				cy = 174;
-        	
-            if (cx > 304)
+
+			if (cx > 304)
 				cx = 304;
-        	
-            act->x = cx;
-            act->y = cy;
-            act->last_dir = dir;
-            act->next = 0;
-            act->dir = dir;
-            if (act->directions == 1)
+
+			act->x = cx;
+			act->y = cy;
+			act->last_dir = dir;
+			act->next = 0;
+			act->dir = dir;
+			if (act->directions == 1)
+				act->dir = 0;
+			else if (act->directions == 4 && act->frames == 1) {
+				act->next = dir;
 				act->dir = 0;
-            else if (act->directions == 4 && act->frames == 1) {
-                act->next = dir;
-                act->dir = 0;
-            }
-            act->frame_count = act->frame_speed;
-            act->speed_count = act->speed;
-            act->last_x[0] = cx;
-            act->last_x[1] = cx;
-            act->last_x[0] = actr->x;
-            act->last_x[1] = actr->x;
-            act->last_y[0] = cy;
-            act->last_y[1] = cy;
-            act->used = 1;
-            act->creator = actr->actor_num;
-            act->move_count = act->num_moves;
-            act->dead = 0;
-            actr->shot_actor = i;
-            actr->num_shots++;
-            actr->shot_cnt = 20;
-            _G(shot_ok) = false;
-            return 1;
-        }
-    }
-    return 0;
+			}
+			act->frame_count = act->frame_speed;
+			act->speed_count = act->speed;
+			act->last_x[0] = cx;
+			act->last_x[1] = cx;
+			act->last_x[0] = actr->x;
+			act->last_x[1] = actr->x;
+			act->last_y[0] = cy;
+			act->last_y[1] = cy;
+			act->used = 1;
+			act->creator = actr->actor_num;
+			act->move_count = act->num_moves;
+			act->dead = 0;
+			actr->shot_actor = i;
+			actr->num_shots++;
+			actr->shot_cnt = 20;
+			_G(shot_ok) = false;
+			return 1;
+		}
+	}
+	return 0;
 }
 
 void actor_always_shoots(ACTOR *actr, int dir) {
-    _actor_shoots(actr, dir);
+	_actor_shoots(actr, dir);
 }
 
 int actor_shoots(ACTOR *actr, int dir) {
-    int i;
+	int i;
 
-    int cx = (actr->x + (actr->size_x / 2)) >> 4;
-    int cy = ((actr->y + actr->size_y) - 2) >> 4;
+	int cx = (actr->x + (actr->size_x / 2)) >> 4;
+	int cy = ((actr->y + actr->size_y) - 2) >> 4;
 
-    int tx = _G(thor)->center_x;
-    int ty = _G(thor)->center_y;
+	int tx = _G(thor)->center_x;
+	int ty = _G(thor)->center_y;
 
-    int icn = 140;
-	
-    if (_G(shot[actr->shot_type - 1]).flying == 1)
+	int icn = 140;
+
+	if (_G(shot[actr->shot_type - 1]).flying == 1)
 		icn = 80;
 
-    switch (dir) {
-    case 0:
+	switch (dir) {
+	case 0:
 		for (i = ty + 1; i <= cy; i++) {
-            if (_G(scrn).icon[i][cx] < icn)
+			if (_G(scrn).icon[i][cx] < icn)
 				return 0;
 		}
 		break;
-    case 1:
+	case 1:
 		for (i = cy; i <= ty; i++) {
-            if (_G(scrn).icon[i][cx] < icn)
+			if (_G(scrn).icon[i][cx] < icn)
 				return 0;
 		}
 		break;
-    case 2:
+	case 2:
 		for (i = tx; i < cx; i++) {
-            if (_G(scrn).icon[cy][i] < icn)
+			if (_G(scrn).icon[cy][i] < icn)
 				return 0;
 		}
 		break;
-    case 3:
+	case 3:
 		for (i = cx; i < tx; i++) {
-            if (_G(scrn).icon[cy][i] < icn)
+			if (_G(scrn).icon[cy][i] < icn)
 				return 0;
 		}
 		break;
-    }
-    return _actor_shoots(actr, dir);
+	}
+	return _actor_shoots(actr, dir);
 }
 
 void move_actor(ACTOR *actr) {
-    int i;
+	int i;
 
-    if (actr->vunerable != 0)
+	if (actr->vunerable != 0)
 		actr->vunerable--;
-    if (actr->shot_cnt != 0)
+	if (actr->shot_cnt != 0)
 		actr->shot_cnt--;
-    if (actr->show != 0)
+	if (actr->show != 0)
 		actr->show--;
 
-    if (!actr->shot_cnt && _G(shot_ok)) {
-        if (actr->shots_allowed) {
-            if (actr->num_shots < actr->shots_allowed) {
-                shot_pattern_func[actr->shot_pattern](actr);
-            }
-        }
-    }
-
-    actr->speed_count--;
-    if (actr->speed_count <= 0) {
-        if (!actr->move_counter)
+	if (!actr->shot_cnt && _G(shot_ok)) {
+		if (actr->shots_allowed) {
+			if (actr->num_shots < actr->shots_allowed) {
+				shot_pattern_func[actr->shot_pattern](actr);
+			}
+		}
+	}
+
+	actr->speed_count--;
+	if (actr->speed_count <= 0) {
+		if (!actr->move_counter)
 			actr->speed_count = actr->speed;
-        else
+		else
 			actr->speed_count = (actr->speed << 1);
-        if (actr->type == 3)
+		if (actr->type == 3)
 			i = shot_movement_func[actr->move](actr);
-        else
+		else
 			i = movement_func[actr->move](actr);
-        if (actr->directions == 2)
+		if (actr->directions == 2)
 			i &= 1;
-        if (i != actr->dir)
+		if (i != actr->dir)
 			actr->dir = i;
 
-        if (actr->move == 0 && _G(current_level) != _G(new_level) && _G(shield_on)) {
-            _G(actor[2]).x = actr->x - 2;
-            if (_G(actor[2]).x < 0)
+		if (actr->move == 0 && _G(current_level) != _G(new_level) && _G(shield_on)) {
+			_G(actor[2]).x = actr->x - 2;
+			if (_G(actor[2]).x < 0)
 				_G(actor[2]).x = 0;
-            _G(actor[2]).y = actr->y;
-            _G(actor[2]).last_x[0] = _G(actor[2]).x;
-            _G(actor[2]).last_x[1] = _G(actor[2]).x;
-            _G(actor[2]).last_y[0] = _G(actor[2]).y;
-            _G(actor[2]).last_y[1] = _G(actor[2]).y;
-        }
-    }
-
-    actr->x &= 0xfffe;
+			_G(actor[2]).y = actr->y;
+			_G(actor[2]).last_x[0] = _G(actor[2]).x;
+			_G(actor[2]).last_x[1] = _G(actor[2]).x;
+			_G(actor[2]).last_y[0] = _G(actor[2]).y;
+			_G(actor[2]).last_y[1] = _G(actor[2]).y;
+		}
+	}
+
+	actr->x &= 0xfffe;
 }
 
 } // namespace Got
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index 4d21a5651f5..a200ce91031 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -20,33 +20,33 @@
  */
 
 #include "got/game/move_patterns.h"
+#include "got/events.h"
 #include "got/game/back.h"
 #include "got/game/boss1.h"
 #include "got/game/boss2.h"
 #include "got/game/boss3.h"
 #include "got/game/move.h"
 #include "got/game/object.h"
-#include "got/gfx/panel.h"
 #include "got/game/script.h"
 #include "got/game/special_tile.h"
-#include "got/events.h"
+#include "got/gfx/panel.h"
 #include "got/vars.h"
 
 namespace Got {
 
-#define TILE_SOLID   80
-#define TILE_FLY     140
+#define TILE_SOLID 80
+#define TILE_FLY 140
 #define TILE_SPECIAL 200
 
-extern int (*dialog_func[]) (ACTOR *actr);
+extern int (*dialog_func[])(ACTOR *actr);
 
 int check_special_move1(int x, int y, ACTOR *actr);
 
-int  check_move0(int x, int y, ACTOR *actr);
-int  check_move1(int x, int y, ACTOR *actr);
-int  check_move2(int x, int y, ACTOR *actr);
-int  check_move3(int x, int y, ACTOR *actr);
-int  check_move4(int x, int y, ACTOR *actr);
+int check_move0(int x, int y, ACTOR *actr);
+int check_move1(int x, int y, ACTOR *actr);
+int check_move2(int x, int y, ACTOR *actr);
+int check_move3(int x, int y, ACTOR *actr);
+int check_move4(int x, int y, ACTOR *actr);
 
 int movement_zero(ACTOR *actr);
 int movement_one(ACTOR *actr);
@@ -60,79 +60,78 @@ int movement_eight(ACTOR *actr);
 int movement_nine(ACTOR *actr);
 int movement_ten(ACTOR *actr);
 int movement_eleven(ACTOR *actr);
-int movement_twelve(ACTOR *actr);         // Horz straight until bump
-int movement_thirteen(ACTOR *actr);       // Pause-seek (mushroom)
-int movement_fourteen(ACTOR *actr);       // Move-bump-stop (boulder)
-int movement_fifteen(ACTOR *actr);        // No move, no frame cycle
-int movement_sixteen(ACTOR *actr);        // Tornado 1
-int movement_seventeen(ACTOR *actr);      // Tornado 2
-int movement_eighteen(ACTOR *actr);       // Random-seek-bite-run
-int movement_nineteen(ACTOR *actr);       // Tornado 2
-int movement_twenty(ACTOR *actr);         // Tornado 2
-int movement_twentyone(ACTOR *actr);      // Eyeball
-int movement_twentytwo(ACTOR *actr);      // Spear
-int movement_twentythree(ACTOR *actr);    // Spinball cw
-int movement_twentyfour(ACTOR *actr);     // Spinball ccw
-int movement_twentyfive(ACTOR *actr);     //
-int movement_twentysix(ACTOR *actr);      //
-int movement_twentyseven(ACTOR *actr);    //
-int movement_twentyeight(ACTOR *actr);    // Tree boss
-int movement_twentynine(ACTOR *actr);     // Horz or vert (pass_val)
-int movement_thirty(ACTOR *actr);         // Vert straight
-int movement_thirtyone(ACTOR *actr);      // Drop (stalagtite)
-int movement_thirtytwo(ACTOR *actr);      // Bomb 1
-int movement_thirtythree(ACTOR *actr);    // Bomb 2
-int movement_thirtyfour(ACTOR *actr);     // Gun (4-dir)
-int movement_thirtyfive(ACTOR *actr);     // Gun (4-dir)
-int movement_thirtysix(ACTOR *actr);      // Acid drop
-int movement_thirtyseven(ACTOR *actr);    // 4-way rnd,rnd len
-int movement_thirtyeight(ACTOR *actr);    // Timed darting
-int movement_thirtynine(ACTOR *actr);     // Troll 1
-int movement_forty(ACTOR *actr);          // Troll 2
-
-int (*const movement_func[]) (ACTOR *actr) = {
-    movement_zero,
-    movement_one,
-    movement_two,
-    movement_three,
-    movement_four,
-    movement_five,
-    movement_six,
-    movement_seven,
-    movement_eight,
-    movement_nine,
-    movement_ten,
-    movement_eleven,
-    movement_twelve,
-    movement_thirteen,
-    movement_fourteen,
-    movement_fifteen,
-    movement_sixteen,
-    movement_seventeen,
-    movement_eighteen,
-    movement_nineteen,
-    movement_twenty,
-    movement_twentyone,
-    movement_twentytwo,
-    movement_twentythree,
-    movement_twentyfour,
-    movement_twentyfive,
-    movement_twentysix,
-    movement_twentyseven,
-    movement_twentyeight,
-    movement_twentynine,
-    movement_thirty,
-    movement_thirtyone,
-    movement_thirtytwo,
-    movement_thirtythree,
-    movement_thirtyfour,
-    movement_thirtyfive,
-    movement_thirtysix,
-    movement_thirtyseven,
-    movement_thirtyeight,
-    movement_thirtynine,
-    movement_forty
-};
+int movement_twelve(ACTOR *actr);      // Horz straight until bump
+int movement_thirteen(ACTOR *actr);    // Pause-seek (mushroom)
+int movement_fourteen(ACTOR *actr);    // Move-bump-stop (boulder)
+int movement_fifteen(ACTOR *actr);     // No move, no frame cycle
+int movement_sixteen(ACTOR *actr);     // Tornado 1
+int movement_seventeen(ACTOR *actr);   // Tornado 2
+int movement_eighteen(ACTOR *actr);    // Random-seek-bite-run
+int movement_nineteen(ACTOR *actr);    // Tornado 2
+int movement_twenty(ACTOR *actr);      // Tornado 2
+int movement_twentyone(ACTOR *actr);   // Eyeball
+int movement_twentytwo(ACTOR *actr);   // Spear
+int movement_twentythree(ACTOR *actr); // Spinball cw
+int movement_twentyfour(ACTOR *actr);  // Spinball ccw
+int movement_twentyfive(ACTOR *actr);  //
+int movement_twentysix(ACTOR *actr);   //
+int movement_twentyseven(ACTOR *actr); //
+int movement_twentyeight(ACTOR *actr); // Tree boss
+int movement_twentynine(ACTOR *actr);  // Horz or vert (pass_val)
+int movement_thirty(ACTOR *actr);      // Vert straight
+int movement_thirtyone(ACTOR *actr);   // Drop (stalagtite)
+int movement_thirtytwo(ACTOR *actr);   // Bomb 1
+int movement_thirtythree(ACTOR *actr); // Bomb 2
+int movement_thirtyfour(ACTOR *actr);  // Gun (4-dir)
+int movement_thirtyfive(ACTOR *actr);  // Gun (4-dir)
+int movement_thirtysix(ACTOR *actr);   // Acid drop
+int movement_thirtyseven(ACTOR *actr); // 4-way rnd,rnd len
+int movement_thirtyeight(ACTOR *actr); // Timed darting
+int movement_thirtynine(ACTOR *actr);  // Troll 1
+int movement_forty(ACTOR *actr);       // Troll 2
+
+int (*const movement_func[])(ACTOR *actr) = {
+	movement_zero,
+	movement_one,
+	movement_two,
+	movement_three,
+	movement_four,
+	movement_five,
+	movement_six,
+	movement_seven,
+	movement_eight,
+	movement_nine,
+	movement_ten,
+	movement_eleven,
+	movement_twelve,
+	movement_thirteen,
+	movement_fourteen,
+	movement_fifteen,
+	movement_sixteen,
+	movement_seventeen,
+	movement_eighteen,
+	movement_nineteen,
+	movement_twenty,
+	movement_twentyone,
+	movement_twentytwo,
+	movement_twentythree,
+	movement_twentyfour,
+	movement_twentyfive,
+	movement_twentysix,
+	movement_twentyseven,
+	movement_twentyeight,
+	movement_twentynine,
+	movement_thirty,
+	movement_thirtyone,
+	movement_thirtytwo,
+	movement_thirtythree,
+	movement_thirtyfour,
+	movement_thirtyfive,
+	movement_thirtysix,
+	movement_thirtyseven,
+	movement_thirtyeight,
+	movement_thirtynine,
+	movement_forty};
 
 int special_movement_one(ACTOR *actr);
 int special_movement_two(ACTOR *actr);
@@ -147,718 +146,753 @@ int special_movement_ten(ACTOR *actr);
 int special_movement_eleven(ACTOR *actr);
 
 int (*special_movement_func[])(ACTOR *actr) = {
-    nullptr,
-    special_movement_one,
-    special_movement_two,
-    special_movement_three,
-    special_movement_four,
-    special_movement_five,
-    special_movement_six,
-    special_movement_seven,
-    special_movement_eight,
-    special_movement_nine,
-    special_movement_ten,
-    special_movement_eleven
-};
-
+	nullptr,
+	special_movement_one,
+	special_movement_two,
+	special_movement_three,
+	special_movement_four,
+	special_movement_five,
+	special_movement_six,
+	special_movement_seven,
+	special_movement_eight,
+	special_movement_nine,
+	special_movement_ten,
+	special_movement_eleven};
 
 // Check Thor move
 int check_move0(int x, int y, ACTOR *actr) {
-    _G(thor_icon1) = 0;
-    _G(thor_icon2) = 0;
-    _G(thor_icon3) = 0;
-    _G(thor_icon4) = 0;
-
-    if (x < 0) {
-        if (_G(current_level) > 0) {
-            _G(new_level) = _G(current_level) - 1;
-            actr->x = 304;
-            actr->last_x[0] = 304;
-            actr->last_x[1] = 304;
-            actr->show = 0;
-            actr->move_count = 0;
-            set_thor_vars();
-            return 1;
-        } else
+	_G(thor_icon1) = 0;
+	_G(thor_icon2) = 0;
+	_G(thor_icon3) = 0;
+	_G(thor_icon4) = 0;
+
+	if (x < 0) {
+		if (_G(current_level) > 0) {
+			_G(new_level) = _G(current_level) - 1;
+			actr->x = 304;
+			actr->last_x[0] = 304;
+			actr->last_x[1] = 304;
+			actr->show = 0;
+			actr->move_count = 0;
+			set_thor_vars();
+			return 1;
+		} else
+			return 0;
+	}
+	if (x > 306) {
+		if (_G(current_level) < 119) {
+			_G(new_level) = _G(current_level) + 1;
+			actr->x = 0;
+			actr->last_x[0] = 0;
+			actr->last_x[1] = 0;
+			actr->show = 0;
+			actr->move_count = 0;
+			set_thor_vars();
+			return 1;
+		} else
 			return 0;
-    }
-    if (x > 306) {
-        if (_G(current_level) < 119) {
-            _G(new_level) = _G(current_level) + 1;
-            actr->x = 0;
-            actr->last_x[0] = 0;
-            actr->last_x[1] = 0;
-            actr->show = 0;
-            actr->move_count = 0;
-            set_thor_vars();
-            return 1;
-        } else
-    		return 0;
-    }
-    if (y < 0) {
-        if (_G(current_level) > 9) {
-            _G(new_level) = _G(current_level) - 10;
-            actr->y = 175;
-            actr->last_y[0] = 175;
-            actr->show = 0;
-            actr->last_y[1] = 175;
-            actr->move_count = 0;
-            set_thor_vars();
-            return 1;
-        } else
+	}
+	if (y < 0) {
+		if (_G(current_level) > 9) {
+			_G(new_level) = _G(current_level) - 10;
+			actr->y = 175;
+			actr->last_y[0] = 175;
+			actr->show = 0;
+			actr->last_y[1] = 175;
+			actr->move_count = 0;
+			set_thor_vars();
+			return 1;
+		} else
 			return 0;
-    }
-    if (y > 175) {
-        if (_G(current_level) < 110) {
-            _G(new_level) = _G(current_level) + 10;
-            actr->y = 0;
-            actr->last_y[0] = 0;
-            actr->last_y[1] = 0;
-            actr->show = 0;
-            actr->move_count = 0;
-            set_thor_vars();
-            return 1;
-        } else
+	}
+	if (y > 175) {
+		if (_G(current_level) < 110) {
+			_G(new_level) = _G(current_level) + 10;
+			actr->y = 0;
+			actr->last_y[0] = 0;
+			actr->last_y[1] = 0;
+			actr->show = 0;
+			actr->move_count = 0;
+			set_thor_vars();
+			return 1;
+		} else
 			return 0;
-    }
+	}
 	int x1 = (x + 1) >> 4;
-    int y1 = (y + 8) >> 4;
+	int y1 = (y + 8) >> 4;
 	int x2 = (_G(thor)->dir > 1) ? (x + 12) >> 4 : (x + 10) >> 4;
-    int y2 = (y + 15) >> 4;
-
-    _G(slip_flag) = false;
-
-    // Check for cheat flying mode
-    if (!actr->flying) {
-        byte icn1 = _G(scrn).icon[y1][x1];
-        byte icn2 = _G(scrn).icon[y2][x1];
-        byte icn3 = _G(scrn).icon[y1][x2];
-        byte icn4 = _G(scrn).icon[y2][x2];
-        int ti = 0;
-
-        if (icn1 < TILE_FLY) {
-            _G(thor_icon1) = 1;
-            ti = 1;
-        }
-        if (icn2 < TILE_FLY) {
-            _G(thor_icon2) = 1;
-            ti = 1;
-        }
-        if (icn3 < TILE_FLY) {
-            _G(thor_icon3) = 1;
-            ti = 1;
-        }
-        if (icn4 < TILE_FLY) {
-            _G(thor_icon4) = 1;
-            ti = 1;
-        }
-        if (ti) return 0;
-
-        if (icn1 > TILE_SPECIAL) {
-            if (!special_tile_thor(y1, x1, icn1)) return 0;
-            icn2 = _G(scrn).icon[y2][x1];
-            icn3 = _G(scrn).icon[y1][x2];
-            icn4 = _G(scrn).icon[y2][x2];
-        }
-        if (icn2 > TILE_SPECIAL) {
-            if (!special_tile_thor(y2, x1, icn2)) return 0;
-            icn3 = _G(scrn).icon[y1][x2];
-            icn4 = _G(scrn).icon[y2][x2];
-        }
-        if (icn3 > TILE_SPECIAL) {
-            if (!special_tile_thor(y1, x2, icn3)) return 0;
-            icn4 = _G(scrn).icon[y2][x2];
-        }
-        if (icn4 > TILE_SPECIAL) {
-            if (!special_tile_thor(y2, x2, icn4)) return 0;
-        }
-    }
-
-    if (!_G(slip_flag)) {
-        _G(slipping) = false;
-        _G(slip_cnt) = 0;
-    }
-    if (_G(slip_flag) && !_G(slipping))
-        _G(slip_cnt)++;
-    if (_G(slip_cnt) > 8)
-        _G(slipping) = true;
-    _G(slip_flag) = false;
-
-
-    x1 = x + 1;
-    y1 = y + 8;
-    if (_G(thor)->dir > 1) x2 = x + 12;
-    else x2 = x + 12;
-    y2 = y + 15;
-
-    _G(thor_special_flag) = false;
-    for (int i = 3; i < MAX_ACTORS; i++) {
-        ACTOR *act = &_G(actor[i]);
-        if (act->solid & 128)
+	int y2 = (y + 15) >> 4;
+
+	_G(slip_flag) = false;
+
+	// Check for cheat flying mode
+	if (!actr->flying) {
+		byte icn1 = _G(scrn).icon[y1][x1];
+		byte icn2 = _G(scrn).icon[y2][x1];
+		byte icn3 = _G(scrn).icon[y1][x2];
+		byte icn4 = _G(scrn).icon[y2][x2];
+		int ti = 0;
+
+		if (icn1 < TILE_FLY) {
+			_G(thor_icon1) = 1;
+			ti = 1;
+		}
+		if (icn2 < TILE_FLY) {
+			_G(thor_icon2) = 1;
+			ti = 1;
+		}
+		if (icn3 < TILE_FLY) {
+			_G(thor_icon3) = 1;
+			ti = 1;
+		}
+		if (icn4 < TILE_FLY) {
+			_G(thor_icon4) = 1;
+			ti = 1;
+		}
+		if (ti)
+			return 0;
+
+		if (icn1 > TILE_SPECIAL) {
+			if (!special_tile_thor(y1, x1, icn1))
+				return 0;
+			icn2 = _G(scrn).icon[y2][x1];
+			icn3 = _G(scrn).icon[y1][x2];
+			icn4 = _G(scrn).icon[y2][x2];
+		}
+		if (icn2 > TILE_SPECIAL) {
+			if (!special_tile_thor(y2, x1, icn2))
+				return 0;
+			icn3 = _G(scrn).icon[y1][x2];
+			icn4 = _G(scrn).icon[y2][x2];
+		}
+		if (icn3 > TILE_SPECIAL) {
+			if (!special_tile_thor(y1, x2, icn3))
+				return 0;
+			icn4 = _G(scrn).icon[y2][x2];
+		}
+		if (icn4 > TILE_SPECIAL) {
+			if (!special_tile_thor(y2, x2, icn4))
+				return 0;
+		}
+	}
+
+	if (!_G(slip_flag)) {
+		_G(slipping) = false;
+		_G(slip_cnt) = 0;
+	}
+	if (_G(slip_flag) && !_G(slipping))
+		_G(slip_cnt++);
+	if (_G(slip_cnt) > 8)
+		_G(slipping) = true;
+	_G(slip_flag) = false;
+
+	x1 = x + 1;
+	y1 = y + 8;
+	if (_G(thor)->dir > 1)
+		x2 = x + 12;
+	else
+		x2 = x + 12;
+	y2 = y + 15;
+
+	_G(thor_special_flag) = false;
+	for (int i = 3; i < MAX_ACTORS; i++) {
+		ACTOR *act = &_G(actor[i]);
+		if (act->solid & 128)
 			continue;
-        if (!act->used)
+		if (!act->used)
 			continue;
-    	
-        int x3 = act->x + 1;
-        if ((ABS(x3 - x1)) > 16)
+
+		int x3 = act->x + 1;
+		if ((ABS(x3 - x1)) > 16)
 			continue;
-        int y3 = act->y + 1;
-        if ((ABS(y3 - y1)) > 16)
+		int y3 = act->y + 1;
+		if ((ABS(y3 - y1)) > 16)
 			continue;
-        int x4 = act->x + act->size_x - 1;
-        int y4 = act->y + act->size_y - 1;
-        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
-            if (act->func_num > 0) { // 255=explosion
-                if (act->func_num == 255) return 0;
-                act->temp1 = x;
-                act->temp2 = y;
-                _G(thor_special_flag) = true;
-                return special_movement_func[act->func_num](act);
-            } else {
-                _G(thor_special_flag) = false;
-                thor_damaged(act);
-                if (act->solid < 2) {
-                    if (!act->vunerable && (!(act->type & 1)))
+		int x4 = act->x + act->size_x - 1;
+		int y4 = act->y + act->size_y - 1;
+		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
+			if (act->func_num > 0) { // 255=explosion
+				if (act->func_num == 255)
+					return 0;
+				act->temp1 = x;
+				act->temp2 = y;
+				_G(thor_special_flag) = true;
+				return special_movement_func[act->func_num](act);
+			} else {
+				_G(thor_special_flag) = false;
+				thor_damaged(act);
+				if (act->solid < 2) {
+					if (!act->vunerable && (!(act->type & 1)))
 						play_sound(PUNCH1, false);
-                	
-                    if (!_G(hammer)->used && _G(key_flag[key_fire]))
-                        actor_damaged(act, _G(hammer)->strength);
-                    else
-                        actor_damaged(act, _G(thor)->strength);
-                }
-            }
-            return 1;
-        }
-    }
-    actr->x = x;
-    actr->y = y;
-    return 1;
+
+					if (!_G(hammer)->used && _G(key_flag[key_fire]))
+						actor_damaged(act, _G(hammer)->strength);
+					else
+						actor_damaged(act, _G(thor)->strength);
+				}
+			}
+			return 1;
+		}
+	}
+	actr->x = x;
+	actr->y = y;
+	return 1;
 }
 
 // Check hammer move
 int check_move1(int x, int y, ACTOR *actr) {
-    int  x1, x2, y1, y2, i;
-    int  x3, y3, x4, y4;
-    int  icn, f;
-    byte icn1, icn2, icn3, icn4;
-
-    ACTOR *act;
-
-    if (x < 0 || x>306 || y < 0 || y>177) return 0;
-
-    x1 = (x + 1) >> 4;
-    y1 = (y + 6) >> 4;
-    x2 = (x + 10) >> 4;
-    y2 = (y + 10) >> 4;
-
-    // Check for solid or fly over
-    icn = TILE_FLY;
-    if (actr->flying) icn = TILE_SOLID;
-
-    icn1 = _G(scrn).icon[y1][x1];
-    icn2 = _G(scrn).icon[y2][x1];
-    icn3 = _G(scrn).icon[y1][x2];
-    icn4 = _G(scrn).icon[y2][x2];
-    if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) {
-        if (actr->actor_num == 1 && actr->move == 2)
+	int x1, x2, y1, y2, i;
+	int x3, y3, x4, y4;
+	int icn, f;
+	byte icn1, icn2, icn3, icn4;
+
+	ACTOR *act;
+
+	if (x < 0 || x > 306 || y < 0 || y > 177)
+		return 0;
+
+	x1 = (x + 1) >> 4;
+	y1 = (y + 6) >> 4;
+	x2 = (x + 10) >> 4;
+	y2 = (y + 10) >> 4;
+
+	// Check for solid or fly over
+	icn = TILE_FLY;
+	if (actr->flying)
+		icn = TILE_SOLID;
+
+	icn1 = _G(scrn).icon[y1][x1];
+	icn2 = _G(scrn).icon[y2][x1];
+	icn3 = _G(scrn).icon[y1][x2];
+	icn4 = _G(scrn).icon[y2][x2];
+	if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) {
+		if (actr->actor_num == 1 && actr->move == 2)
 			play_sound(CLANG, false);
-    	
-        return 0;
-    }
-
-    if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
-    if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
-    if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
-    if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
-
-    x1 = x + 1;
-    y1 = y + 1;
-    x2 = x + 10;
-    y2 = y + 10;
-
-    f = 0;
-    for (i = 3; i < MAX_ACTORS; i++) {
-        act = &_G(actor[i]);
-        if (!act->used) continue;
-        if (act->type == 3) continue;
-        x3 = act->x;
-        if ((ABS(x3 - x1)) > 16) continue;
-        y3 = act->y;
-        if ((ABS(y3 - y1)) > 16) continue;
-        x4 = act->x + act->size_x - 1;
-        y4 = act->y + act->size_y - 1;
-
-        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
-            if (_G(boss_active) && !GAME3) {
-                switch (_G(area)) {
-                case 1:
-                    check_boss1_hit(act, x1, y1, x2, y2, i);
-                    break;
-                case 2:
-                    check_boss2_hit(act, x1, y1, x2, y2, i);
-                    break;
-                default:
-                    // Area 3 boss Loki isn't checked here
-                    break;
-                }
-            } else {
-                if (act->solid == 2 && (actr->move == 16 || actr->move == 17))
-                    return 0;
-                actor_damaged(act, actr->strength);
-            }
-            f++;
-        }
-    }
-    if (f && actr->move == 2)
+
+		return 0;
+	}
+
+	if (icn1 > TILE_SPECIAL)
+		if (!special_tile(actr, y1, x1, icn1))
+			return 0;
+	if (icn2 > TILE_SPECIAL)
+		if (!special_tile(actr, y2, x1, icn2))
+			return 0;
+	if (icn3 > TILE_SPECIAL)
+		if (!special_tile(actr, y1, x2, icn3))
+			return 0;
+	if (icn4 > TILE_SPECIAL)
+		if (!special_tile(actr, y2, x2, icn4))
+			return 0;
+
+	x1 = x + 1;
+	y1 = y + 1;
+	x2 = x + 10;
+	y2 = y + 10;
+
+	f = 0;
+	for (i = 3; i < MAX_ACTORS; i++) {
+		act = &_G(actor[i]);
+		if (!act->used)
+			continue;
+		if (act->type == 3)
+			continue;
+		x3 = act->x;
+		if ((ABS(x3 - x1)) > 16)
+			continue;
+		y3 = act->y;
+		if ((ABS(y3 - y1)) > 16)
+			continue;
+		x4 = act->x + act->size_x - 1;
+		y4 = act->y + act->size_y - 1;
+
+		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
+			if (_G(boss_active) && !GAME3) {
+				switch (_G(area)) {
+				case 1:
+					check_boss1_hit(act, x1, y1, x2, y2, i);
+					break;
+				case 2:
+					check_boss2_hit(act, x1, y1, x2, y2, i);
+					break;
+				default:
+					// Area 3 boss Loki isn't checked here
+					break;
+				}
+			} else {
+				if (act->solid == 2 && (actr->move == 16 || actr->move == 17))
+					return 0;
+				actor_damaged(act, actr->strength);
+			}
+			f++;
+		}
+	}
+	if (f && actr->move == 2)
 		return 0;
-	
-    actr->x = x;
-    actr->y = y;
-    return 1;
+
+	actr->x = x;
+	actr->y = y;
+	return 1;
 }
 
 // Check enemy move
 int check_move2(int x, int y, ACTOR *actr) {
-    int x1, x2, y1, y2, i;
-    int x3, y3, x4, y4;
-    int icn;
-    byte icn1, icn2, icn3, icn4;
-
-    ACTOR *act;
+	int x1, x2, y1, y2, i;
+	int x3, y3, x4, y4;
+	int icn;
+	byte icn1, icn2, icn3, icn4;
 
-    if (actr->actor_num < 3) return check_move1(x, y, actr);
+	ACTOR *act;
 
-    if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175) return 0;
+	if (actr->actor_num < 3)
+		return check_move1(x, y, actr);
 
-    x1 = (x + 1) >> 4;
-    if (!actr->func_num) y1 = (y + (actr->size_y / 2)) >> 4;
-    else y1 = (y + 1) >> 4;
-    x2 = ((x + actr->size_x) - 1) >> 4;
-    y2 = ((y + actr->size_y) - 1) >> 4;
+	if (x < 0 || x > (319 - actr->size_x) || y < 0 || y > 175)
+		return 0;
 
-    // Check for solid or fly over
+	x1 = (x + 1) >> 4;
+	if (!actr->func_num)
+		y1 = (y + (actr->size_y / 2)) >> 4;
+	else
+		y1 = (y + 1) >> 4;
+	x2 = ((x + actr->size_x) - 1) >> 4;
+	y2 = ((y + actr->size_y) - 1) >> 4;
 
-    icn = TILE_FLY;
-    if (actr->flying) icn = TILE_SOLID;
+	// Check for solid or fly over
 
+	icn = TILE_FLY;
+	if (actr->flying)
+		icn = TILE_SOLID;
 
-    icn1 = _G(scrn).icon[y1][x1];
-    icn2 = _G(scrn).icon[y2][x1];
-    icn3 = _G(scrn).icon[y1][x2];
-    icn4 = _G(scrn).icon[y2][x2];
-    if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn)
+	icn1 = _G(scrn).icon[y1][x1];
+	icn2 = _G(scrn).icon[y2][x1];
+	icn3 = _G(scrn).icon[y1][x2];
+	icn4 = _G(scrn).icon[y2][x2];
+	if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn)
 		return 0;
 
-    if (icn1 > TILE_SPECIAL) if (!special_tile(actr, y1, x1, icn1)) return 0;
-    if (icn2 > TILE_SPECIAL) if (!special_tile(actr, y2, x1, icn2)) return 0;
-    if (icn3 > TILE_SPECIAL) if (!special_tile(actr, y1, x2, icn3)) return 0;
-    if (icn4 > TILE_SPECIAL) if (!special_tile(actr, y2, x2, icn4)) return 0;
+	if (icn1 > TILE_SPECIAL)
+		if (!special_tile(actr, y1, x1, icn1))
+			return 0;
+	if (icn2 > TILE_SPECIAL)
+		if (!special_tile(actr, y2, x1, icn2))
+			return 0;
+	if (icn3 > TILE_SPECIAL)
+		if (!special_tile(actr, y1, x2, icn3))
+			return 0;
+	if (icn4 > TILE_SPECIAL)
+		if (!special_tile(actr, y2, x2, icn4))
+			return 0;
 
-    x1 = x + 1;
-    y1 = y + 1;
-    x2 = (x + actr->size_x) - 1;
-    y2 = (y + actr->size_y) - 1;
+	x1 = x + 1;
+	y1 = y + 1;
+	x2 = (x + actr->size_x) - 1;
+	y2 = (y + actr->size_y) - 1;
 
-    for (i = 0; i < MAX_ACTORS; i++) {
-        act = &_G(actor[i]);
-        if (act->actor_num == actr->actor_num)
+	for (i = 0; i < MAX_ACTORS; i++) {
+		act = &_G(actor[i]);
+		if (act->actor_num == actr->actor_num)
 			continue;
-        if (act->actor_num == 1)
+		if (act->actor_num == 1)
 			continue;
-        if (!act->used)
+		if (!act->used)
 			continue;
-        if (act->type == 3)
-			continue;   // Shot
-    	
-        if (i == 0) {
-            if (overlap(x1, y1, x2, y2, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
-                thor_damaged(actr);
-                return 0;
-            }
-        } else {
-            x3 = act->x;
-            if ((ABS(x3 - x1)) > 16)
+		if (act->type == 3)
+			continue; // Shot
+
+		if (i == 0) {
+			if (overlap(x1, y1, x2, y2, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
+				thor_damaged(actr);
+				return 0;
+			}
+		} else {
+			x3 = act->x;
+			if ((ABS(x3 - x1)) > 16)
 				continue;
-        	
-            y3 = act->y;
-            if ((ABS(y3 - y1)) > 16)
+
+			y3 = act->y;
+			if ((ABS(y3 - y1)) > 16)
 				continue;
-        	
-            x4 = act->x + act->size_x;
-            y4 = act->y + act->size_y;
-            if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
-                if (actr->move == 38) {
-                    if (act->func_num == 4)
-                        _G(switch_flag) = 1;
-                    else if (act->func_num == 7)
-                        _G(switch_flag) = 2;
-                }
-                return 0;
-            }
-        }
-    }
-    actr->x = x;
-    actr->y = y;
-    return 1;
+
+			x4 = act->x + act->size_x;
+			y4 = act->y + act->size_y;
+			if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
+				if (actr->move == 38) {
+					if (act->func_num == 4)
+						_G(switch_flag) = 1;
+					else if (act->func_num == 7)
+						_G(switch_flag) = 2;
+				}
+				return 0;
+			}
+		}
+	}
+	actr->x = x;
+	actr->y = y;
+	return 1;
 }
 
 // Check enemy shot move
 int check_move3(int x, int y, ACTOR *actr) {
-	if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175)
+	if (x < 0 || x > (319 - actr->size_x) || y < 0 || y > 175)
 		return 0;
 
-    int x1 = (x + 1) >> 4;
-    int y1 = (y + (actr->size_y / 2)) >> 4;
-    int x2 = ((x + actr->size_x) - 1) >> 4;
-    int y2 = ((y + actr->size_y) - 1) >> 4;
+	int x1 = (x + 1) >> 4;
+	int y1 = (y + (actr->size_y / 2)) >> 4;
+	int x2 = ((x + actr->size_x) - 1) >> 4;
+	int y2 = ((y + actr->size_y) - 1) >> 4;
 
-    // Check for solid or fly over
+	// Check for solid or fly over
 
-    int icn = TILE_FLY;
-    if (actr->flying)
+	int icn = TILE_FLY;
+	if (actr->flying)
 		icn = TILE_SOLID;
 
-    byte icn1 = _G(scrn).icon[y1][x1];
-    byte icn2 = _G(scrn).icon[y2][x1];
-    byte icn3 = _G(scrn).icon[y1][x2];
-    byte icn4 = _G(scrn).icon[y2][x2];
-    if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn)
+	byte icn1 = _G(scrn).icon[y1][x1];
+	byte icn2 = _G(scrn).icon[y2][x1];
+	byte icn3 = _G(scrn).icon[y1][x2];
+	byte icn4 = _G(scrn).icon[y2][x2];
+	if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn)
 		return 0;
 
-    if (icn1 > TILE_SPECIAL && !special_tile(actr, y1, x1, icn1))
+	if (icn1 > TILE_SPECIAL && !special_tile(actr, y1, x1, icn1))
 		return 0;
-    if (icn2 > TILE_SPECIAL && !special_tile(actr, y2, x1, icn2))
+	if (icn2 > TILE_SPECIAL && !special_tile(actr, y2, x1, icn2))
 		return 0;
-    if (icn3 > TILE_SPECIAL && !special_tile(actr, y1, x2, icn3))
+	if (icn3 > TILE_SPECIAL && !special_tile(actr, y1, x2, icn3))
 		return 0;
-    if (icn4 > TILE_SPECIAL && !special_tile(actr, y2, x2, icn4))
+	if (icn4 > TILE_SPECIAL && !special_tile(actr, y2, x2, icn4))
 		return 0;
 
-    // Check for solid or fly over
-    x1 = x + 1;
-    y1 = y + 1;
-    x2 = (x + actr->size_x) - 1;
-    y2 = (y + actr->size_y) - 1;
-
-    if (overlap(x1, y1, x2, y2, _G(thor_x1), _G(thor_real_y1), _G(thor_x2), _G(thor_y2))) {
-        thor_damaged(actr);
-        return 0;
-    }
-    for (int i = 3; i < MAX_ACTORS; i++) {
-        if (i == actr->actor_num)
+	// Check for solid or fly over
+	x1 = x + 1;
+	y1 = y + 1;
+	x2 = (x + actr->size_x) - 1;
+	y2 = (y + actr->size_y) - 1;
+
+	if (overlap(x1, y1, x2, y2, _G(thor_x1), _G(thor_real_y1), _G(thor_x2), _G(thor_y2))) {
+		thor_damaged(actr);
+		return 0;
+	}
+	for (int i = 3; i < MAX_ACTORS; i++) {
+		if (i == actr->actor_num)
 			continue;
-    	
-        ACTOR *act = &_G(actor[i]);
-    	
-        if (!act->used)
+
+		ACTOR *act = &_G(actor[i]);
+
+		if (!act->used)
 			continue;
-        if (act->solid < 2)
+		if (act->solid < 2)
 			continue;
-        if (act->type == 3)
-			continue;   // Shot
-        if (act->actor_num == actr->creator)
+		if (act->type == 3)
+			continue; // Shot
+		if (act->actor_num == actr->creator)
 			continue;
-    	
-        int x3 = act->x;
-        if ((ABS(x3 - x1)) > 16)
+
+		int x3 = act->x;
+		if ((ABS(x3 - x1)) > 16)
 			continue;
-    	
-        int y3 = act->y;
-        if ((ABS(y3 - y1)) > 16)
+
+		int y3 = act->y;
+		if ((ABS(y3 - y1)) > 16)
 			continue;
-    	
-        int x4 = x3 + 15;
-        int y4 = y3 + 15;
-        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4))
+
+		int x4 = x3 + 15;
+		int y4 = y3 + 15;
+		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4))
 			return 0;
-    }
-    actr->x = x;
-    actr->y = y;
-    return 1;
+	}
+	actr->x = x;
+	actr->y = y;
+	return 1;
 }
 
 // Flying enemies
 int check_move4(int x, int y, ACTOR *actr) {
-    if (x<0 || x>(319 - actr->size_x) || y < 0 || y>175)
+	if (x < 0 || x > (319 - actr->size_x) || y < 0 || y > 175)
 		return 0;
-    if (overlap(x, y, x + actr->size_x - 1, y + actr->size_y - 1,
-                _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
-        if (actr->type == 3) thor_damaged(actr);
-        return 0;
-    }
-    actr->x = x;
-    actr->y = y;
-    return 1;
+	if (overlap(x, y, x + actr->size_x - 1, y + actr->size_y - 1,
+				_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
+		if (actr->type == 3)
+			thor_damaged(actr);
+		return 0;
+	}
+	actr->x = x;
+	actr->y = y;
+	return 1;
 }
 
 #define THOR_PAD1 2
 #define THOR_PAD2 4
 
-int  check_thor_move(int x, int y, ACTOR *actr) {
-    if (check_move0(x, y, actr))
-        return 1;
-    if (_G(diag_flag) || _G(thor_special_flag))
-        return 0;
-	
-    if ((_G(thor_icon1) + _G(thor_icon2) + _G(thor_icon3) + _G(thor_icon4)) > 1)
-        return 0;
-
-    switch (actr->dir) {
-    case 0:
-        if (_G(thor_icon1)) {
-            actr->dir = 3;
-            if (check_move0(x + THOR_PAD1, y + 2, actr)) {
-                actr->dir = 0;
-                return 1;
-            }
-        } else if (_G(thor_icon3)) {
-            actr->dir = 2;
-            if (check_move0(x - THOR_PAD1, y + 2, actr)) {
-                actr->dir = 0;
-                return 1;
-            }
-        }
-        actr->dir = 0;
-        break;
-    case 1:
-        if (_G(thor_icon2)) {
-            actr->dir = 3;
-            if (check_move0(x + THOR_PAD1, y - 2, actr)) {
-                actr->dir = 1;
-                return 1;
-            }
-        } else if (_G(thor_icon4)) {
-            actr->dir = 2;
-            if (check_move0(x - THOR_PAD1, y - 2, actr)) {
-                actr->dir = 1;
-                return 1;
-            }
-        }
-        actr->dir = 1;
-        break;
-    case 2:
-        if (_G(thor_icon1)) {
-            if (check_move0(x + 2, y + THOR_PAD1, actr))
+int check_thor_move(int x, int y, ACTOR *actr) {
+	if (check_move0(x, y, actr))
+		return 1;
+	if (_G(diag_flag) || _G(thor_special_flag))
+		return 0;
+
+	if ((_G(thor_icon1) + _G(thor_icon2) + _G(thor_icon3) + _G(thor_icon4)) > 1)
+		return 0;
+
+	switch (actr->dir) {
+	case 0:
+		if (_G(thor_icon1)) {
+			actr->dir = 3;
+			if (check_move0(x + THOR_PAD1, y + 2, actr)) {
+				actr->dir = 0;
+				return 1;
+			}
+		} else if (_G(thor_icon3)) {
+			actr->dir = 2;
+			if (check_move0(x - THOR_PAD1, y + 2, actr)) {
+				actr->dir = 0;
+				return 1;
+			}
+		}
+		actr->dir = 0;
+		break;
+	case 1:
+		if (_G(thor_icon2)) {
+			actr->dir = 3;
+			if (check_move0(x + THOR_PAD1, y - 2, actr)) {
+				actr->dir = 1;
+				return 1;
+			}
+		} else if (_G(thor_icon4)) {
+			actr->dir = 2;
+			if (check_move0(x - THOR_PAD1, y - 2, actr)) {
+				actr->dir = 1;
 				return 1;
-        } else if (_G(thor_icon2)) {
-            if (check_move0(x + 2, y - THOR_PAD1, actr))
+			}
+		}
+		actr->dir = 1;
+		break;
+	case 2:
+		if (_G(thor_icon1)) {
+			if (check_move0(x + 2, y + THOR_PAD1, actr))
+				return 1;
+		} else if (_G(thor_icon2)) {
+			if (check_move0(x + 2, y - THOR_PAD1, actr))
 				return 1;
-        }
-        break;
-    case 3:
-        if (_G(thor_icon3)) {
-            if (check_move0(x - 2, y + THOR_PAD1, actr))
+		}
+		break;
+	case 3:
+		if (_G(thor_icon3)) {
+			if (check_move0(x - 2, y + THOR_PAD1, actr))
 				return 1;
-        } else if (_G(thor_icon4)) {
-            if (check_move0(x - 2, y - THOR_PAD1, actr))
+		} else if (_G(thor_icon4)) {
+			if (check_move0(x - 2, y - THOR_PAD1, actr))
 				return 1;
-        }
-        break;
-    }
+		}
+		break;
+	}
 
-    return 0;
+	return 0;
 }
 
 // Player control
 int movement_zero(ACTOR *actr) {
-    int x, y;
-    int d = actr->dir;
-    int od = d;
-
-    set_thor_vars();
-
-    if ((_G(hammer)->used) && (_G(hammer)->move == 5)) {
-        if (overlap(_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2),
-                    _G(hammer)->x, _G(hammer)->y, _G(hammer)->x + 13, _G(hammer)->y + 13)) {
-            actor_destroyed(_G(hammer));
-        }
-    }
-    x = actr->x;
-    y = actr->y;
-    _G(diag_flag) = false;
-    if (actr->move_counter) actr->move_counter--;
-
-    if (_G(slipping)) {
-        if (_G(slip_cnt) == 8)
+	int x, y;
+	int d = actr->dir;
+	int od = d;
+
+	set_thor_vars();
+
+	if ((_G(hammer)->used) && (_G(hammer)->move == 5)) {
+		if (overlap(_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2),
+					_G(hammer)->x, _G(hammer)->y, _G(hammer)->x + 13, _G(hammer)->y + 13)) {
+			actor_destroyed(_G(hammer));
+		}
+	}
+	x = actr->x;
+	y = actr->y;
+	_G(diag_flag) = false;
+	if (actr->move_counter)
+		actr->move_counter--;
+
+	if (_G(slipping)) {
+		if (_G(slip_cnt) == 8)
 			play_sound(FALL, true);
-    	
-        y += 2;
-        _G(slip_cnt)--;
-        if (!_G(slip_cnt))
-            _G(slipping) = false;
-
-        check_thor_move(x, y, actr);
-        _G(thor)->speed_count = 4;
-        return d;
-    }
-
-    if (_G(key_flag[key_up]) && _G(key_flag[key_left])) {
-        d = 2;
-        actr->dir = d;
-        _G(diag) = 1;
-        _G(diag_flag) = true;
-        if (check_thor_move(x - 2, y - 2, actr)) {
-            next_frame(actr);
-            return d;
-        }
-    } else if (_G(key_flag[key_up]) && _G(key_flag[key_right])) {
-        d = 3;
-        actr->dir = d;
-        _G(diag) = 2;
-        _G(diag_flag) = true;
-        if (check_thor_move(x + 2, y - 2, actr)) {
-            next_frame(actr);
-            return d;
-        }
-    } else if (_G(key_flag[key_down]) && _G(key_flag[key_left])) {
-        d = 2;
-        actr->dir = d;
-        _G(diag) = 4;
-        _G(diag_flag) = true;
-        if (check_thor_move(x - 2, y + 2, actr)) {
-            next_frame(actr);
-            return d;
-        }
-    } else if (_G(key_flag[key_down]) && _G(key_flag[key_right])) {
-        d = 3;
-        actr->dir = d;
-        _G(diag) = 3;
-        _G(diag_flag) = true;
-        if (check_thor_move(x + 2, y + 2, actr)) {
-            next_frame(actr);
-            return d;
-        }
-    }
-    _G(diag) = 0;
-    if (_G(key_flag[key_right])) {
-        if (!_G(key_flag[key_left])) {
-            d = 3;
-            actr->dir = d;
-            if (check_thor_move(x + 2, y, actr)) {
-                next_frame(actr);
-                return d;
-            }
-        }
-    }
-    if (_G(key_flag[key_left])) {
-        if (!_G(key_flag[key_right])) {
-            d = 2;
-            actr->dir = d;
-            if (check_thor_move(x - 2, y, actr)) {
-                next_frame(actr);
-                return d;
-            }
-        }
-    }
-    if (_G(key_flag[key_down])) {
-        if (!_G(key_flag[key_up])) {
-            d = 1;
-            actr->dir = d;
-            if (check_thor_move(x, y + 2, actr)) {
-                next_frame(actr);
-                return d;
-            }
-        }
-    }
-    if (_G(key_flag[key_up])) {
-        if (!_G(key_flag[key_down])) {
-            d = 0;
-            actr->dir = d;
-            if (check_thor_move(x, y - 2, actr)) {
-                next_frame(actr);
-                return d;
-            }
-        }
-    }
-    actr->move_counter = 5;
-    actr->next = 0;
-    actr->dir = od;
-    return d;
+
+		y += 2;
+		_G(slip_cnt--);
+		if (!_G(slip_cnt))
+			_G(slipping) = false;
+
+		check_thor_move(x, y, actr);
+		_G(thor)->speed_count = 4;
+		return d;
+	}
+
+	if (_G(key_flag[key_up]) && _G(key_flag[key_left])) {
+		d = 2;
+		actr->dir = d;
+		_G(diag) = 1;
+		_G(diag_flag) = true;
+		if (check_thor_move(x - 2, y - 2, actr)) {
+			next_frame(actr);
+			return d;
+		}
+	} else if (_G(key_flag[key_up]) && _G(key_flag[key_right])) {
+		d = 3;
+		actr->dir = d;
+		_G(diag) = 2;
+		_G(diag_flag) = true;
+		if (check_thor_move(x + 2, y - 2, actr)) {
+			next_frame(actr);
+			return d;
+		}
+	} else if (_G(key_flag[key_down]) && _G(key_flag[key_left])) {
+		d = 2;
+		actr->dir = d;
+		_G(diag) = 4;
+		_G(diag_flag) = true;
+		if (check_thor_move(x - 2, y + 2, actr)) {
+			next_frame(actr);
+			return d;
+		}
+	} else if (_G(key_flag[key_down]) && _G(key_flag[key_right])) {
+		d = 3;
+		actr->dir = d;
+		_G(diag) = 3;
+		_G(diag_flag) = true;
+		if (check_thor_move(x + 2, y + 2, actr)) {
+			next_frame(actr);
+			return d;
+		}
+	}
+	_G(diag) = 0;
+	if (_G(key_flag[key_right])) {
+		if (!_G(key_flag[key_left])) {
+			d = 3;
+			actr->dir = d;
+			if (check_thor_move(x + 2, y, actr)) {
+				next_frame(actr);
+				return d;
+			}
+		}
+	}
+	if (_G(key_flag[key_left])) {
+		if (!_G(key_flag[key_right])) {
+			d = 2;
+			actr->dir = d;
+			if (check_thor_move(x - 2, y, actr)) {
+				next_frame(actr);
+				return d;
+			}
+		}
+	}
+	if (_G(key_flag[key_down])) {
+		if (!_G(key_flag[key_up])) {
+			d = 1;
+			actr->dir = d;
+			if (check_thor_move(x, y + 2, actr)) {
+				next_frame(actr);
+				return d;
+			}
+		}
+	}
+	if (_G(key_flag[key_up])) {
+		if (!_G(key_flag[key_down])) {
+			d = 0;
+			actr->dir = d;
+			if (check_thor_move(x, y - 2, actr)) {
+				next_frame(actr);
+				return d;
+			}
+		}
+	}
+	actr->move_counter = 5;
+	actr->next = 0;
+	actr->dir = od;
+	return d;
 }
 
 int check_special_move1(int x, int y, ACTOR *actr) {
-    int i;
-    int x3, y3, x4, y4;
+	int i;
+	int x3, y3, x4, y4;
 
-    ACTOR *act;
+	ACTOR *act;
 
-    if (actr->actor_num < 3)
+	if (actr->actor_num < 3)
 		return check_move1(x, y, actr);
 
-    if (x < 0 || x>304 || y < 0 || y>176)
+	if (x < 0 || x > 304 || y < 0 || y > 176)
 		return 0;
 
-    int x1 = x >> 4;
-    int y1 = y >> 4;
-    int x2 = (x + 15) >> 4;
-    int y2 = (y + 15) >> 4;
+	int x1 = x >> 4;
+	int y1 = y >> 4;
+	int x2 = (x + 15) >> 4;
+	int y2 = (y + 15) >> 4;
 
-    // Check for solid or fly over
+	// Check for solid or fly over
 
-    int icn = TILE_FLY;
-    if (actr->flying) icn = TILE_SOLID;
+	int icn = TILE_FLY;
+	if (actr->flying)
+		icn = TILE_SOLID;
 
-    byte icn1 = _G(scrn).icon[y1][x1];
-    byte icn2 = _G(scrn).icon[y2][x1];
-    byte icn3 = _G(scrn).icon[y1][x2];
-    byte icn4 = _G(scrn).icon[y2][x2];
-    if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn)
+	byte icn1 = _G(scrn).icon[y1][x1];
+	byte icn2 = _G(scrn).icon[y2][x1];
+	byte icn3 = _G(scrn).icon[y1][x2];
+	byte icn4 = _G(scrn).icon[y2][x2];
+	if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn)
 		return 0;
 
-    if (icn1 > TILE_SPECIAL && !special_tile(actr, y1, x1, icn1))
+	if (icn1 > TILE_SPECIAL && !special_tile(actr, y1, x1, icn1))
 		return 0;
-    if (icn2 > TILE_SPECIAL && !special_tile(actr, y2, x1, icn2))
+	if (icn2 > TILE_SPECIAL && !special_tile(actr, y2, x1, icn2))
 		return 0;
-    if (icn3 > TILE_SPECIAL && !special_tile(actr, y1, x2, icn3))
+	if (icn3 > TILE_SPECIAL && !special_tile(actr, y1, x2, icn3))
 		return 0;
-    if (icn4 > TILE_SPECIAL && !special_tile(actr, y2, x2, icn4))
+	if (icn4 > TILE_SPECIAL && !special_tile(actr, y2, x2, icn4))
 		return 0;
 
-    x1 = x;
-    y1 = y;
-    x2 = (x + 15);
-    y2 = (y + 15);
+	x1 = x;
+	y1 = y;
+	x2 = (x + 15);
+	y2 = (y + 15);
 
-    for (i = 3; i < MAX_ACTORS; i++) {
-        act = &_G(actor[i]);
-        if (act->actor_num == actr->actor_num)
+	for (i = 3; i < MAX_ACTORS; i++) {
+		act = &_G(actor[i]);
+		if (act->actor_num == actr->actor_num)
 			continue;
-        if (!act->used)
+		if (!act->used)
 			continue;
-        if (act->type == 3)
-			continue;   //shot
-        x3 = act->x;
-        if ((ABS(x3 - x1)) > 16)
+		if (act->type == 3)
+			continue; //shot
+		x3 = act->x;
+		if ((ABS(x3 - x1)) > 16)
 			continue;
-        y3 = act->y;
-        if ((ABS(y3 - y1)) > 16)
+		y3 = act->y;
+		if ((ABS(y3 - y1)) > 16)
 			continue;
-        x4 = act->x + act->size_x;
-        y4 = act->y + 15;
-        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4))
+		x4 = act->x + act->size_x;
+		y4 = act->y + 15;
+		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4))
 			return 0;
-    }
-    for (i = 3; i < MAX_ACTORS; i++) {
-        act = &_G(actor[i]);
-        if (act->actor_num == actr->actor_num)
+	}
+	for (i = 3; i < MAX_ACTORS; i++) {
+		act = &_G(actor[i]);
+		if (act->actor_num == actr->actor_num)
 			continue;
-        if (!act->used)
+		if (!act->used)
 			continue;
-        if (act->type == 3)
-			continue;   // Shot
-        x3 = act->x;
-        if ((ABS(x3 - x1)) > 16)
+		if (act->type == 3)
+			continue; // Shot
+		x3 = act->x;
+		if ((ABS(x3 - x1)) > 16)
 			continue;
-        y3 = act->y;
-        if ((ABS(y3 - y1)) > 16)
+		y3 = act->y;
+		if ((ABS(y3 - y1)) > 16)
 			continue;
-        x4 = act->x + act->size_x;
-        y4 = act->y + act->size_y;
-        if (overlap(_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2), x3, y3, x4, y4)) return 0;
-    }
-    actr->x = x;
-    actr->y = y;
-    return 1;
+		x4 = act->x + act->size_x;
+		y4 = act->y + act->size_y;
+		if (overlap(_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2), x3, y3, x4, y4))
+			return 0;
+	}
+	actr->x = x;
+	actr->y = y;
+	return 1;
 }
 
 //*==========================================================================
@@ -867,291 +901,303 @@ int check_special_move1(int x, int y, ACTOR *actr) {
 int special_movement_one(ACTOR *actr) {
 	if (_G(diag_flag))
 		return 0;
-	
-    int d = _G(thor)->dir;
-    int x1 = actr->x;
-    int y1 = actr->y;
-    int sd = actr->last_dir;
-    actr->last_dir = d;
-
-    switch (d) {
-    case 0:
-        y1 -= 2;
-        if (!check_special_move1(x1, y1, actr)) {
-            actr->last_dir = sd;
-            return 0;
-        }
-        break;
-    case 1:
-        y1 += 2;
-        if (!check_special_move1(x1, y1, actr)) {
-            actr->last_dir = sd;
-            return 0;
-        }
-        break;
-    case 2:
-        x1 -= 2;
-        if (!check_special_move1(x1, y1, actr)) {
-            actr->last_dir = sd;
-            return 0;
-        }
-        break;
-    case 3:
-        x1 += 2;
-        if (!check_special_move1(x1, y1, actr)) {
-            actr->last_dir = sd;
-            return 0;
-        }
-        break;
-    }
-    next_frame(actr);
-    actr->last_dir = d;
-    return 1;
+
+	int d = _G(thor)->dir;
+	int x1 = actr->x;
+	int y1 = actr->y;
+	int sd = actr->last_dir;
+	actr->last_dir = d;
+
+	switch (d) {
+	case 0:
+		y1 -= 2;
+		if (!check_special_move1(x1, y1, actr)) {
+			actr->last_dir = sd;
+			return 0;
+		}
+		break;
+	case 1:
+		y1 += 2;
+		if (!check_special_move1(x1, y1, actr)) {
+			actr->last_dir = sd;
+			return 0;
+		}
+		break;
+	case 2:
+		x1 -= 2;
+		if (!check_special_move1(x1, y1, actr)) {
+			actr->last_dir = sd;
+			return 0;
+		}
+		break;
+	case 3:
+		x1 += 2;
+		if (!check_special_move1(x1, y1, actr)) {
+			actr->last_dir = sd;
+			return 0;
+		}
+		break;
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	return 1;
 }
 
 // Angle
 int special_movement_two(ACTOR *actr) {
-	int x1 = actr->temp1;       // Calc thor pos
-    int y1 = actr->temp2;
-    int x2 = x1 + 13;
-    int y2 = y1 + 14;
-
-    for (int i = 3; i < MAX_ACTORS; i++) {
-        ACTOR *act = &_G(actor[i]);
-        if (actr->actor_num == act->actor_num)
+	int x1 = actr->temp1; // Calc thor pos
+	int y1 = actr->temp2;
+	int x2 = x1 + 13;
+	int y2 = y1 + 14;
+
+	for (int i = 3; i < MAX_ACTORS; i++) {
+		ACTOR *act = &_G(actor[i]);
+		if (actr->actor_num == act->actor_num)
 			continue;
-        if (!act->used)
+		if (!act->used)
 			continue;
-        int x3 = act->x;
-        if ((ABS(x3 - x1)) > 16)
+		int x3 = act->x;
+		if ((ABS(x3 - x1)) > 16)
 			continue;
-        int y3 = act->y;
-        if ((ABS(y3 - y1)) > 16)
+		int y3 = act->y;
+		if ((ABS(y3 - y1)) > 16)
 			continue;
-        int x4 = act->x + act->size_x;
-        int y4 = act->y + act->size_y;
-        if (overlap(x1, y1, x2, y2, x3, y3, x4, y4))
+		int x4 = act->x + act->size_x;
+		int y4 = act->y + act->size_y;
+		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4))
 			return 0;
-    }
-    if (!actr->func_pass) {
-        if (_G(thor)->health < 150) {
-            if (!sound_playing()) play_sound(ANGEL, false);
-            _G(thor)->health += 1;
-            display_health();
-        }
-    } else {
-        if (_G(thor_info).magic < 150) {
-            if (!sound_playing()) play_sound(ANGEL, false);
-            _G(thor_info).magic += 1;
-            display_magic();
-        }
-    }
-    return 1;
+	}
+	if (!actr->func_pass) {
+		if (_G(thor)->health < 150) {
+			if (!sound_playing())
+				play_sound(ANGEL, false);
+			_G(thor)->health += 1;
+			display_health();
+		}
+	} else {
+		if (_G(thor_info).magic < 150) {
+			if (!sound_playing())
+				play_sound(ANGEL, false);
+			_G(thor_info).magic += 1;
+			display_magic();
+		}
+	}
+	return 1;
 }
 
 // Yellow globe
 int special_movement_three(ACTOR *actr) {
 
 	if (_G(thunder_flag))
-        return 0;
+		return 0;
 
-    long lind = (long)_G(current_level);
-    lind *= 1000;
-    lind += (long)actr->actor_num;
-    execute_script(lind, _G(odin));
+	long lind = (long)_G(current_level);
+	lind *= 1000;
+	lind += (long)actr->actor_num;
+	execute_script(lind, _G(odin));
 
-    return 0;
+	return 0;
 }
 
 // Peg switch
 int special_movement_four(ACTOR *actr) {
-    if (actr->shot_cnt != 0)
+	if (actr->shot_cnt != 0)
 		return 0;
-    actr->shot_cnt = 30;
+	actr->shot_cnt = 30;
 
-    _G(switch_flag) = 1;
-    return 0;
+	_G(switch_flag) = 1;
+	return 0;
 }
 
 // Boulder roll
 int special_movement_five(ACTOR *actr) {
 	int d = _G(thor)->dir;
 
-    if (_G(diag_flag)) {
-        switch (_G(diag)) {
-        case 1:
-            if (_G(thor_x1) < (actr->x + 15)) d = 0;
-            else d = 2;
-            break;
-        case 2:
-            if (_G(thor_x2) < actr->x) d = 3;
-            else d = 0;
-            break;
-        case 3:
-            if (_G(thor_x2) > (actr->x)) d = 1;
-            else d = 3;
-            break;
-        case 4:
-            if (_G(thor_x1) > (actr->x + 15)) d = 2;
-            else d = 1;
-            break;
-        }
-    }
-
-    actr->last_dir = d;
-    actr->move = 14;
-    return 0;
+	if (_G(diag_flag)) {
+		switch (_G(diag)) {
+		case 1:
+			if (_G(thor_x1) < (actr->x + 15))
+				d = 0;
+			else
+				d = 2;
+			break;
+		case 2:
+			if (_G(thor_x2) < actr->x)
+				d = 3;
+			else
+				d = 0;
+			break;
+		case 3:
+			if (_G(thor_x2) > (actr->x))
+				d = 1;
+			else
+				d = 3;
+			break;
+		case 4:
+			if (_G(thor_x1) > (actr->x + 15))
+				d = 2;
+			else
+				d = 1;
+			break;
+		}
+	}
+
+	actr->last_dir = d;
+	actr->move = 14;
+	return 0;
 }
 
 int special_movement_six(ACTOR *actr) {
-    thor_damaged(actr);
-    return 0;
+	thor_damaged(actr);
+	return 0;
 }
 
 int special_movement_seven(ACTOR *actr) {
-    if (actr->shot_cnt != 0)
+	if (actr->shot_cnt != 0)
 		return 0;
-	
-    actr->shot_cnt = 30;
 
-    _G(switch_flag) = 2;
-    return 0;
+	actr->shot_cnt = 30;
+
+	_G(switch_flag) = 2;
+	return 0;
 }
 
 int special_movement_eight(ACTOR *actr) {
-    if (_G(thor)->dir < 2 || _G(diag_flag))
+	if (_G(thor)->dir < 2 || _G(diag_flag))
 		return 0;
-	
-    actr->last_dir = _G(thor)->dir;
-    actr->move = 14;
-    return 0;
+
+	actr->last_dir = _G(thor)->dir;
+	actr->move = 14;
+	return 0;
 }
 
 int special_movement_nine(ACTOR *actr) {
-    if (_G(thor)->dir > 1 || _G(diag_flag))
+	if (_G(thor)->dir > 1 || _G(diag_flag))
 		return 0;
-	
-    actr->last_dir = _G(thor)->dir;
-    actr->move = 14;
-    return 0;
+
+	actr->last_dir = _G(thor)->dir;
+	actr->move = 14;
+	return 0;
 }
 
 int special_movement_ten(ACTOR *actr) {
-    byte &actor_ctr = GAME1 ? actr->temp6 : actr->talk_counter;
+	byte &actor_ctr = GAME1 ? actr->temp6 : actr->talk_counter;
 
-    if (actor_ctr) {
-        actor_ctr--;
-        return 0;
-    }
+	if (actor_ctr) {
+		actor_ctr--;
+		return 0;
+	}
 
-    if (_G(thunder_flag))
-        return 0;
+	if (_G(thunder_flag))
+		return 0;
 
-    if (!actor_ctr) {
-        actor_ctr = 10;
-        actor_speaks(actr, 0 - actr->pass_value, 0);
-    }
+	if (!actor_ctr) {
+		actor_ctr = 10;
+		actor_speaks(actr, 0 - actr->pass_value, 0);
+	}
 
-    return 0;
+	return 0;
 }
 
 // Red guard
 int special_movement_eleven(ACTOR *actr) {
 	if (actr->talk_counter) {
-        actr->talk_counter--;
-        return 0;
-    }
+		actr->talk_counter--;
+		return 0;
+	}
 
-    int t = actr->type;
-    actr->type = 4;
-    actor_speaks(actr, 0, 0);
-    actr->type = t;
-    actr->talk_counter = 10;
+	int t = actr->type;
+	actr->type = 4;
+	actor_speaks(actr, 0, 0);
+	actr->type = t;
+	actr->talk_counter = 10;
 
-    return 0;
+	return 0;
 }
 
 // No movement - frame cycle
 int movement_one(ACTOR *actr) {
-    next_frame(actr);
-    return actr->dir;
+	next_frame(actr);
+	return actr->dir;
 }
 
 // Hammer only
 int movement_two(ACTOR *actr) {
 	int d = actr->last_dir;
-    int x1 = actr->x;
-    int y1 = actr->y;
-
-    switch (d) {
-    case 0:
-        y1 -= 2;
-        break;
-    case 1:
-        y1 += 2;
-        break;
-    case 2:
-        x1 -= 2;
-        break;
-    case 3:
-        x1 += 2;
-        break;
-    }
-    if (!check_move2(x1, y1, actr)) {
-        if (actr->actor_num == 1) {
-            _G(hammer)->move = 5;
-            d = reverse_direction(_G(hammer));
-            _G(hammer)->dir = d;
-        }
-        if (actr->actor_num == 2) {
-            actr->used = 0;
-            actr->dead = 2;
-            _G(lightning_used) = false;
-            _G(tornado_used) = false;
-        }
-    }
-    next_frame(actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	int x1 = actr->x;
+	int y1 = actr->y;
+
+	switch (d) {
+	case 0:
+		y1 -= 2;
+		break;
+	case 1:
+		y1 += 2;
+		break;
+	case 2:
+		x1 -= 2;
+		break;
+	case 3:
+		x1 += 2;
+		break;
+	}
+	if (!check_move2(x1, y1, actr)) {
+		if (actr->actor_num == 1) {
+			_G(hammer)->move = 5;
+			d = reverse_direction(_G(hammer));
+			_G(hammer)->dir = d;
+		}
+		if (actr->actor_num == 2) {
+			actr->used = 0;
+			actr->dead = 2;
+			_G(lightning_used) = false;
+			_G(tornado_used) = false;
+		}
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Walk-bump-random turn
 int movement_three(ACTOR *actr) {
 	int d = actr->last_dir;
-    int x1 = actr->x;
-    int y1 = actr->y;
-
-    switch (d) {
-    case 0:
-        y1 -= 2;
-        if (!check_move2(x1, y1, actr)) {
-            d = g_events->getRandomNumber(3);
-        }
-        break;
-    case 1:
-        y1 += 2;
-        if (!check_move2(x1, y1, actr)) {
-            d = g_events->getRandomNumber(3);
-        }
-        break;
-    case 2:
-        x1 -= 2;
-        if (!check_move2(x1, y1, actr)) {
-            d = g_events->getRandomNumber(3);
-        }
-        break;
-    case 3:
-        x1 += 2;
-        if (!check_move2(x1, y1, actr)) {
-            d = g_events->getRandomNumber(3);
-        }
-        break;
-    }
-    next_frame(actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	int x1 = actr->x;
+	int y1 = actr->y;
+
+	switch (d) {
+	case 0:
+		y1 -= 2;
+		if (!check_move2(x1, y1, actr)) {
+			d = g_events->getRandomNumber(3);
+		}
+		break;
+	case 1:
+		y1 += 2;
+		if (!check_move2(x1, y1, actr)) {
+			d = g_events->getRandomNumber(3);
+		}
+		break;
+	case 2:
+		x1 -= 2;
+		if (!check_move2(x1, y1, actr)) {
+			d = g_events->getRandomNumber(3);
+		}
+		break;
+	case 3:
+		x1 += 2;
+		if (!check_move2(x1, y1, actr)) {
+			d = g_events->getRandomNumber(3);
+		}
+		break;
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Simple tracking
@@ -1159,1279 +1205,1386 @@ int movement_four(ACTOR *actr) {
 
 	int d = actr->last_dir;
 
-    int x1 = actr->x;
-    int y1 = actr->y;
-
-    int f = 0;
-    if (x1 > _G(thor_x1) - 1) {
-        x1 -= 2;
-        d = 2;
-        f = 1;
-    } else if (x1 < _G(thor_x1) - 1) {
-        x1 += 2;
-        d = 3;
-        f = 1;
-    }
-
-    if (f)
+	int x1 = actr->x;
+	int y1 = actr->y;
+
+	int f = 0;
+	if (x1 > _G(thor_x1) - 1) {
+		x1 -= 2;
+		d = 2;
+		f = 1;
+	} else if (x1 < _G(thor_x1) - 1) {
+		x1 += 2;
+		d = 3;
+		f = 1;
+	}
+
+	if (f)
 		f = check_move2(x1, y1, actr);
 
-    if (!f) {
-        if (y1 < (_G(thor_real_y1))) {
-            d = (_G(thor_real_y1)) - y1;
-            if (d > 2)
+	if (!f) {
+		if (y1 < (_G(thor_real_y1))) {
+			d = (_G(thor_real_y1)) - y1;
+			if (d > 2)
 				d = 2;
-            y1 += d;
-            d = 1;
-            f = 1;
-        } else if (y1 > (_G(thor_real_y1))) {
-            d = y1 - (_G(thor_real_y1));
-            if (d > 2)
+			y1 += d;
+			d = 1;
+			f = 1;
+		} else if (y1 > (_G(thor_real_y1))) {
+			d = y1 - (_G(thor_real_y1));
+			if (d > 2)
 				d = 2;
-            y1 -= d;
-            d = 0;
-            f = 1;
-        }
-        if (f)
+			y1 -= d;
+			d = 0;
+			f = 1;
+		}
+		if (f)
 			f = check_move2(actr->x, y1, actr);
-        if (!f)
+		if (!f)
 			check_move2(actr->x, actr->y, actr);
-    }
-    next_frame(actr);
-    actr->last_dir = d;
-    if (actr->directions == 1)
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
 		return 0;
-    return d;
+	return d;
 }
 
 int movement_five(ACTOR *actr) {
-    int x1 = actr->x;
-    int y1 = actr->y;
-    int xd = 0;
+	int x1 = actr->x;
+	int y1 = actr->y;
+	int xd = 0;
 	int yd = 0;
 	int d = actr->last_dir;
 
-    if (x1 > (_G(thor)->x + 1))
-		xd = -2;  //+1
-    else if (x1 < (_G(thor)->x - 1))
+	if (x1 > (_G(thor)->x + 1))
+		xd = -2; //+1
+	else if (x1 < (_G(thor)->x - 1))
 		xd = 2;
 
-    if (actr->actor_num == 1) {
-        if (y1 < (_G(thor_y1) - 6))
+	if (actr->actor_num == 1) {
+		if (y1 < (_G(thor_y1) - 6))
 			yd = 2;
-        else if (y1 > (_G(thor_y1) - 6))
+		else if (y1 > (_G(thor_y1) - 6))
 			yd = -2;
-    } else {
-        if (y1 < (_G(thor_real_y1) - 1))
+	} else {
+		if (y1 < (_G(thor_real_y1) - 1))
 			yd = 2;
-        else if (y1 > (_G(thor_real_y1) + 1))
+		else if (y1 > (_G(thor_real_y1) + 1))
 			yd = -2;
-    }
+	}
 
-    if (xd && yd) {
-        if (xd == -2 && yd == -2)
+	if (xd && yd) {
+		if (xd == -2 && yd == -2)
 			d = 2;
-        else if (xd == -2 && yd == 2)
+		else if (xd == -2 && yd == 2)
 			d = 2;
-        else if (xd == 2 && yd == -2)
+		else if (xd == 2 && yd == -2)
 			d = 3;
-        else if (xd == 2 && yd == 2)
+		else if (xd == 2 && yd == 2)
 			d = 3;
-        x1 += xd;
-        y1 += yd;
-        if (check_move2(x1, y1, actr)) {
-            next_frame(actr);
-            actr->last_dir = d;
-            if (actr->directions == 1)
+		x1 += xd;
+		y1 += yd;
+		if (check_move2(x1, y1, actr)) {
+			next_frame(actr);
+			actr->last_dir = d;
+			if (actr->directions == 1)
 				return 0;
-            return d;
-        }
-    } else {
-        if (xd == 0 && yd == 2)
+			return d;
+		}
+	} else {
+		if (xd == 0 && yd == 2)
 			d = 1;
-        else if (xd == 0 && yd == -2)
+		else if (xd == 0 && yd == -2)
 			d = 0;
-        else if (xd == 2 && yd == 0)
+		else if (xd == 2 && yd == 0)
 			d = 3;
-        else if (xd == -2 && yd == 0)
+		else if (xd == -2 && yd == 0)
 			d = 2;
-    }
-    x1 = actr->x;
-    y1 = actr->y;
-    actr->toggle ^= 1;
-
-    if (actr->toggle) {
-        if (xd) {
-            x1 += xd;
-            if (check_move2(x1, y1, actr)) {
-                if (xd > 0) d = 3;
-                else d = 2;
-                next_frame(actr);
-                actr->last_dir = d;
-                if (actr->directions == 1) return 0;
-                return d;
-            }
-            x1 = actr->x;
-        }
-        if (yd) {
-            y1 += yd;
-            if (check_move2(x1, y1, actr)) {
-                if (yd > 0) d = 1;
-                else d = 0;
-                next_frame(actr);
-                actr->last_dir = d;
-                if (actr->directions == 1) return 0;
-                return d;
-            }
-        }
-        y1 = actr->y;
-    } else {
-        if (yd) {
-            y1 += yd;
-            if (check_move2(x1, y1, actr)) {
-                if (yd > 0) d = 1;
-                else d = 0;
-                next_frame(actr);
-                actr->last_dir = d;
-                if (actr->directions == 1) return 0;
-                return d;
-            }
-            y1 = actr->y;
-        }
-        if (xd) {
-            x1 += xd;
-            if (check_move2(x1, y1, actr)) {
-                if (xd > 0) d = 3;
-                else d = 2;
-                next_frame(actr);
-                actr->last_dir = d;
-                if (actr->directions == 1) return 0;
-                return d;
-            }
-        }
-    }
-    check_move2(actr->x, actr->y, actr);
-    next_frame(actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	}
+	x1 = actr->x;
+	y1 = actr->y;
+	actr->toggle ^= 1;
+
+	if (actr->toggle) {
+		if (xd) {
+			x1 += xd;
+			if (check_move2(x1, y1, actr)) {
+				if (xd > 0)
+					d = 3;
+				else
+					d = 2;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1)
+					return 0;
+				return d;
+			}
+			x1 = actr->x;
+		}
+		if (yd) {
+			y1 += yd;
+			if (check_move2(x1, y1, actr)) {
+				if (yd > 0)
+					d = 1;
+				else
+					d = 0;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1)
+					return 0;
+				return d;
+			}
+		}
+		y1 = actr->y;
+	} else {
+		if (yd) {
+			y1 += yd;
+			if (check_move2(x1, y1, actr)) {
+				if (yd > 0)
+					d = 1;
+				else
+					d = 0;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1)
+					return 0;
+				return d;
+			}
+			y1 = actr->y;
+		}
+		if (xd) {
+			x1 += xd;
+			if (check_move2(x1, y1, actr)) {
+				if (xd > 0)
+					d = 3;
+				else
+					d = 2;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1)
+					return 0;
+				return d;
+			}
+		}
+	}
+	check_move2(actr->x, actr->y, actr);
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Explosion only
 int movement_six(ACTOR *actr) {
-    if (actr->num_shots > 0) {
-        actr->next++;
-        if (actr->next > 2) {
-            actr->next = 0;
-            if (_G(boss_dead))
+	if (actr->num_shots > 0) {
+		actr->next++;
+		if (actr->next > 2) {
+			actr->next = 0;
+			if (_G(boss_dead))
 				play_sound(EXPLODE, false);
-        }
-        actr->num_shots--;
-    } else {
-        actr->dead = 2;
-        actr->used = 0;
+		}
+		actr->num_shots--;
+	} else {
+		actr->dead = 2;
+		actr->used = 0;
 		if (!_G(boss_dead) && !_G(endgame)) {
-            if (actr->type == 2)
-                drop_object(actr);
+			if (actr->type == 2)
+				drop_object(actr);
 		}
+	}
 
-    }
-
-    next_frame(actr);
-    return 0;
+	next_frame(actr);
+	return 0;
 }
 
 // Walk-bump-random turn (pause also)
 int movement_seven(ACTOR *actr) {
-    if (actr->next == 0 && actr->frame_count == actr->frame_speed) {
-        actr->speed_count = 12;
-        actr->last_dir = g_events->getRandomNumber(3);
-    }
-    return movement_three(actr);
+	if (actr->next == 0 && actr->frame_count == actr->frame_speed) {
+		actr->speed_count = 12;
+		actr->last_dir = g_events->getRandomNumber(3);
+	}
+	return movement_three(actr);
 }
 
 // Follow thor
 int movement_eight(ACTOR *actr) {
-    if (_G(thor)->x > 0) actr->x = _G(thor)->x - 1;
-    else actr->x = _G(thor)->x;
-    actr->y = _G(thor)->y;
-    next_frame(actr);
-    return 0;
+	if (_G(thor)->x > 0)
+		actr->x = _G(thor)->x - 1;
+	else
+		actr->x = _G(thor)->x;
+	actr->y = _G(thor)->y;
+	next_frame(actr);
+	return 0;
 }
 
 // 4-way straight (random length) change
 int movement_nine(ACTOR *actr) {
-    int d, x1, y1, f;
-
-    d = actr->last_dir;
-    x1 = actr->x;
-    y1 = actr->y;
-
-    f = 0;
-    if (actr->counter) {
-        actr->counter--;
-        switch (d) {
-        case 0:
-            y1 -= 2;
-            if (!check_move4(x1, y1, actr)) f = 1;
-            break;
-        case 1:
-            y1 += 2;
-            if (!check_move4(x1, y1, actr)) f = 1;
-            break;
-        case 2:
-            x1 -= 2;
-            if (!check_move4(x1, y1, actr)) f = 1;
-            break;
-        case 3:
-            x1 += 2;
-            if (!check_move4(x1, y1, actr)) f = 1;
-            break;
-        }
-    } else f = 1;
-
-    if (f == 1) {
-        actr->counter = g_events->getRandomNumber(10, 99);
-        d = g_events->getRandomNumber(3);
-    }
-    next_frame(actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	int d, x1, y1, f;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	f = 0;
+	if (actr->counter) {
+		actr->counter--;
+		switch (d) {
+		case 0:
+			y1 -= 2;
+			if (!check_move4(x1, y1, actr))
+				f = 1;
+			break;
+		case 1:
+			y1 += 2;
+			if (!check_move4(x1, y1, actr))
+				f = 1;
+			break;
+		case 2:
+			x1 -= 2;
+			if (!check_move4(x1, y1, actr))
+				f = 1;
+			break;
+		case 3:
+			x1 += 2;
+			if (!check_move4(x1, y1, actr))
+				f = 1;
+			break;
+		}
+	} else
+		f = 1;
+
+	if (f == 1) {
+		actr->counter = g_events->getRandomNumber(10, 99);
+		d = g_events->getRandomNumber(3);
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Vert straight (random length) change
 int movement_ten(ACTOR *actr) {
-    int d, x1, y1, f;
-
-    d = actr->last_dir;
-    x1 = actr->x;
-    y1 = actr->y;
-
-    f = 0;
-    if (actr->counter) {
-        if (actr->pass_value != 1) actr->counter--;
-        switch (d) {
-        case 0:
-            y1 -= 2;
-            if (!check_move2(x1, y1, actr)) f = 1;
-            break;
-        case 1:
-            y1 += 2;
-            if (!check_move2(x1, y1, actr)) f = 1;
-            break;
-        case 2:
-            y1 -= 2;
-            if (!check_move2(x1, y1, actr)) f = 1;
-            break;
-        case 3:
-            y1 += 2;
-            if (!check_move2(x1, y1, actr)) f = 1;
-            break;
-        }
-    } else f = 1;
-
-    if (f == 1) {
-        actr->counter = g_events->getRandomNumber(10, 99);
-        d = g_events->getRandomNumber(1);
-    }
-
-    if (d > 1)
-        d -= 2;
-
-    next_frame(actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	int d, x1, y1, f;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	f = 0;
+	if (actr->counter) {
+		if (actr->pass_value != 1)
+			actr->counter--;
+		switch (d) {
+		case 0:
+			y1 -= 2;
+			if (!check_move2(x1, y1, actr))
+				f = 1;
+			break;
+		case 1:
+			y1 += 2;
+			if (!check_move2(x1, y1, actr))
+				f = 1;
+			break;
+		case 2:
+			y1 -= 2;
+			if (!check_move2(x1, y1, actr))
+				f = 1;
+			break;
+		case 3:
+			y1 += 2;
+			if (!check_move2(x1, y1, actr))
+				f = 1;
+			break;
+		}
+	} else
+		f = 1;
+
+	if (f == 1) {
+		actr->counter = g_events->getRandomNumber(10, 99);
+		d = g_events->getRandomNumber(1);
+	}
+
+	if (d > 1)
+		d -= 2;
+
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Horz only (bats)
 int movement_eleven(ACTOR *actr) {
-    int d;
-
-    d = actr->last_dir;
-
-    switch (d) {
-    case 0:
-        if (check_move2(actr->x - 2, actr->y - 2, actr)) break;
-        d = 1;
-        if (check_move2(actr->x - 2, actr->y + 2, actr)) break;
-        d = 2;
-        break;
-    case 1:
-        if (check_move2(actr->x - 2, actr->y + 2, actr)) break;
-        d = 0;
-        if (check_move2(actr->x - 2, actr->y - 2, actr)) break;
-        d = 3;
-        break;
-    case 2:
-        if (check_move2(actr->x + 2, actr->y - 2, actr)) break;
-        d = 3;
-        if (check_move2(actr->x + 2, actr->y + 2, actr)) break;
-        d = 0;
-        break;
-    case 3:
-        if (check_move2(actr->x + 2, actr->y + 2, actr)) break;
-        d = 2;
-        if (check_move2(actr->x + 2, actr->y - 2, actr)) break;
-        d = 1;
-        break;
-    }
-
-    next_frame(actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	int d;
+
+	d = actr->last_dir;
+
+	switch (d) {
+	case 0:
+		if (check_move2(actr->x - 2, actr->y - 2, actr))
+			break;
+		d = 1;
+		if (check_move2(actr->x - 2, actr->y + 2, actr))
+			break;
+		d = 2;
+		break;
+	case 1:
+		if (check_move2(actr->x - 2, actr->y + 2, actr))
+			break;
+		d = 0;
+		if (check_move2(actr->x - 2, actr->y - 2, actr))
+			break;
+		d = 3;
+		break;
+	case 2:
+		if (check_move2(actr->x + 2, actr->y - 2, actr))
+			break;
+		d = 3;
+		if (check_move2(actr->x + 2, actr->y + 2, actr))
+			break;
+		d = 0;
+		break;
+	case 3:
+		if (check_move2(actr->x + 2, actr->y + 2, actr))
+			break;
+		d = 2;
+		if (check_move2(actr->x + 2, actr->y - 2, actr))
+			break;
+		d = 1;
+		break;
+	}
+
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Horz straight until bump
 int movement_twelve(ACTOR *actr) {
-    int d;
-
-    d = actr->last_dir;
-
-    switch (d) {
-    case 0:
-    case 2:
-        if (check_move2(actr->x - 2, actr->y, actr)) break;
-        d = 3;
-        break;
-    case 1:
-    case 3:
-        if (check_move2(actr->x + 2, actr->y, actr)) break;
-        d = 2;
-        break;
-    }
-    next_frame(actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	int d;
+
+	d = actr->last_dir;
+
+	switch (d) {
+	case 0:
+	case 2:
+		if (check_move2(actr->x - 2, actr->y, actr))
+			break;
+		d = 3;
+		break;
+	case 1:
+	case 3:
+		if (check_move2(actr->x + 2, actr->y, actr))
+			break;
+		d = 2;
+		break;
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Pause-seek (mushroom)
 int movement_thirteen(ACTOR *actr) {
-    int d;
-
-    d = actr->last_dir;
-
-    if (actr->counter == 0 && actr->pause == 0) {
-        actr->pause = 60;
-        return d;
-    }
-    if (actr->pause > 0) {
-        actr->pause--;
-        if (!actr->pause) actr->counter = 60;
-        actr->vunerable = 5;
-        actr->strength = 0;
-        return d;
-    }
-    if (actr->counter > 0) {
-        actr->counter--;
-        if (!actr->counter) actr->pause = 60;
-        actr->strength = 10;
-        return movement_five(actr);
-    }
-    return d;
+	int d;
+
+	d = actr->last_dir;
+
+	if (actr->counter == 0 && actr->pause == 0) {
+		actr->pause = 60;
+		return d;
+	}
+	if (actr->pause > 0) {
+		actr->pause--;
+		if (!actr->pause)
+			actr->counter = 60;
+		actr->vunerable = 5;
+		actr->strength = 0;
+		return d;
+	}
+	if (actr->counter > 0) {
+		actr->counter--;
+		if (!actr->counter)
+			actr->pause = 60;
+		actr->strength = 10;
+		return movement_five(actr);
+	}
+	return d;
 }
 
 // Move-bump-stop (boulder)
 int movement_fourteen(ACTOR *actr) {
-    int d, x1, y1;
-
-    d = actr->last_dir;
-    actr->dir = d;
-    x1 = actr->x;
-    y1 = actr->y;
-
-    switch (d) {
-    case 0:
-        y1 -= 2;
-        if (!check_move2(x1, y1, actr)) {
-            actr->move = 15;
-            return 0;
-        }
-        break;
-    case 1:
-        y1 += 2;
-        if (!check_move2(x1, y1, actr)) {
-            actr->move = 15;
-            return 0;
-        }
-        break;
-    case 2:
-        x1 -= 2;
-        if (!check_move2(x1, y1, actr)) {
-            actr->move = 15;
-            return 0;
-        }
-        break;
-    case 3:
-        x1 += 2;
-        if (!check_move2(x1, y1, actr)) {
-            actr->move = 15;
-            return 0;
-        }
-        break;
-    }
-    next_frame(actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	int d, x1, y1;
+
+	d = actr->last_dir;
+	actr->dir = d;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	switch (d) {
+	case 0:
+		y1 -= 2;
+		if (!check_move2(x1, y1, actr)) {
+			actr->move = 15;
+			return 0;
+		}
+		break;
+	case 1:
+		y1 += 2;
+		if (!check_move2(x1, y1, actr)) {
+			actr->move = 15;
+			return 0;
+		}
+		break;
+	case 2:
+		x1 -= 2;
+		if (!check_move2(x1, y1, actr)) {
+			actr->move = 15;
+			return 0;
+		}
+		break;
+	case 3:
+		x1 += 2;
+		if (!check_move2(x1, y1, actr)) {
+			actr->move = 15;
+			return 0;
+		}
+		break;
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // No movement - no frame cycle
 int movement_fifteen(ACTOR *actr) {
-    return actr->dir;
+	return actr->dir;
 }
 
 // Tornado 1
 int movement_sixteen(ACTOR *actr) {
-    int d, x1, y1;
-
-    d = actr->last_dir;
-    x1 = actr->x;
-    y1 = actr->y;
-
-    switch (d) {
-    case 0:
-        y1 -= 2;
-        break;
-    case 1:
-        y1 += 2;
-        break;
-    case 2:
-        x1 -= 2;
-        break;
-    case 3:
-        x1 += 2;
-        break;
-    }
-    if (!check_move1(x1, y1, actr)) {
-        actr->move = 17;
-        d = g_events->getRandomNumber(3);
-    }
-
-    next_frame(actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	int d, x1, y1;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	switch (d) {
+	case 0:
+		y1 -= 2;
+		break;
+	case 1:
+		y1 += 2;
+		break;
+	case 2:
+		x1 -= 2;
+		break;
+	case 3:
+		x1 += 2;
+		break;
+	}
+	if (!check_move1(x1, y1, actr)) {
+		actr->move = 17;
+		d = g_events->getRandomNumber(3);
+	}
+
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Tornado 2
 int movement_seventeen(ACTOR *actr) {
-    int d;
-
-    d = actr->last_dir;
-
-    switch (d) {
-    case 0:
-        if (check_move1(actr->x - 2, actr->y - 2, actr)) break;
-        d = 1;
-        if (check_move1(actr->x - 2, actr->y + 2, actr)) break;
-        d = 2;
-        break;
-    case 1:
-        if (check_move1(actr->x - 2, actr->y + 2, actr)) break;
-        d = 0;
-        if (check_move1(actr->x - 2, actr->y - 2, actr)) break;
-        d = 3;
-        break;
-    case 2:
-        if (check_move1(actr->x + 2, actr->y - 2, actr)) break;
-        d = 3;
-        if (check_move1(actr->x + 2, actr->y + 2, actr)) break;
-        d = 0;
-        break;
-    case 3:
-        if (check_move1(actr->x + 2, actr->y + 2, actr)) break;
-        d = 2;
-        if (check_move1(actr->x + 2, actr->y - 2, actr)) break;
-        d = 1;
-        break;
-    }
-    next_frame(actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	int d;
+
+	d = actr->last_dir;
+
+	switch (d) {
+	case 0:
+		if (check_move1(actr->x - 2, actr->y - 2, actr))
+			break;
+		d = 1;
+		if (check_move1(actr->x - 2, actr->y + 2, actr))
+			break;
+		d = 2;
+		break;
+	case 1:
+		if (check_move1(actr->x - 2, actr->y + 2, actr))
+			break;
+		d = 0;
+		if (check_move1(actr->x - 2, actr->y - 2, actr))
+			break;
+		d = 3;
+		break;
+	case 2:
+		if (check_move1(actr->x + 2, actr->y - 2, actr))
+			break;
+		d = 3;
+		if (check_move1(actr->x + 2, actr->y + 2, actr))
+			break;
+		d = 0;
+		break;
+	case 3:
+		if (check_move1(actr->x + 2, actr->y + 2, actr))
+			break;
+		d = 2;
+		if (check_move1(actr->x + 2, actr->y - 2, actr))
+			break;
+		d = 1;
+		break;
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // No movement - frame cycle
 int movement_eighteen(ACTOR *actr) {
-    int d;
-
-    if (actr->temp5) {
-        actr->temp5--;
-        if (!actr->temp5) actr->num_moves = 1;
-    }
-    if (actr->temp1) {
-        d = movement_five(actr);
-        actr->rand--;
-        if (actr->hit_thor || !actr->rand) {
-            if (actr->hit_thor) {
-                actr->temp5 = 50;
-                actr->num_moves = 2;
-                actr->hit_thor = 0;
-                actr->dir = d;
-                d = reverse_direction(actr);
-            }
-            actr->temp1 = 0;
-            actr->rand = g_events->getRandomNumber(50, 149);
-        }
-    } else {
-        d = movement_three(actr);
-        actr->rand--;
-        if (!actr->rand) {
-            actr->temp5 = 0;
-            actr->temp1 = 1;
-            actr->rand = g_events->getRandomNumber(50, 149);
-        }
-        if (actr->hit_thor) {
-            actr->temp5 = 50;
-            actr->num_moves = 2;
-            actr->hit_thor = 0;
-            actr->dir = d;
-            d = reverse_direction(actr);
-        }
-    }
-    next_frame(actr);
-    return d;
+	int d;
+
+	if (actr->temp5) {
+		actr->temp5--;
+		if (!actr->temp5)
+			actr->num_moves = 1;
+	}
+	if (actr->temp1) {
+		d = movement_five(actr);
+		actr->rand--;
+		if (actr->hit_thor || !actr->rand) {
+			if (actr->hit_thor) {
+				actr->temp5 = 50;
+				actr->num_moves = 2;
+				actr->hit_thor = 0;
+				actr->dir = d;
+				d = reverse_direction(actr);
+			}
+			actr->temp1 = 0;
+			actr->rand = g_events->getRandomNumber(50, 149);
+		}
+	} else {
+		d = movement_three(actr);
+		actr->rand--;
+		if (!actr->rand) {
+			actr->temp5 = 0;
+			actr->temp1 = 1;
+			actr->rand = g_events->getRandomNumber(50, 149);
+		}
+		if (actr->hit_thor) {
+			actr->temp5 = 50;
+			actr->num_moves = 2;
+			actr->hit_thor = 0;
+			actr->dir = d;
+			d = reverse_direction(actr);
+		}
+	}
+	next_frame(actr);
+	return d;
 }
 
 // No movement - frame cycle
 int movement_nineteen(ACTOR *actr) {
-    return movement_seven(actr);
+	return movement_seven(actr);
 }
 
 int movement_twenty(ACTOR *actr) {
-    if (GAME1)
-        // Boss - snake
-        return boss1_movement(actr);
+	if (GAME1)
+		// Boss - snake
+		return boss1_movement(actr);
 
-    return movement_one(actr);
+	return movement_one(actr);
 }
 
 // No movement - frame cycle
 int movement_twentyone(ACTOR *actr) {
-    return movement_three(actr);
+	return movement_three(actr);
 }
 
 // Spear
 int movement_twentytwo(ACTOR *actr) {
-    int d;
+	int d;
 
-    d = actr->last_dir;
-    if (actr->directions == 1) d = 0;
+	d = actr->last_dir;
+	if (actr->directions == 1)
+		d = 0;
 
 redo:
 
-    switch (actr->temp2) {
-    case 0:
-        if (bgtile(actr->x, actr->y) >= TILE_SOLID) actr->next = 1;
-        else {
-            actr->temp2 = 6;
-            actr->temp1 = 1;
-            goto redo;
-        }
-        actr->temp2++;
-        break;
-    case 1:
-        actr->next = 2;
-        actr->temp2++;
-        break;
-    case 2:
-        actr->next = 3;
-        actr->strength = 255;
-        actr->temp2++;
-        actr->temp1 = 10;
-        break;
-    case 3:
-        check_move2(actr->x, actr->y, actr);
-        actr->temp1--;
-        if (actr->temp1) break;
-        actr->temp2++;
-        actr->next = 2;
-        break;
-    case 4:
-        actr->strength = 0;
-        actr->temp2++;
-        actr->next = 1;
-        break;
-    case 5:
-        actr->temp2++;
-        actr->next = 0;
-        actr->temp1 = 10;
-        break;
-    case 6:
-        actr->temp1--;
-        if (actr->temp1) break;
-        actr->temp2 = 0;
-        actr->next = 0;
-        switch (d) {
-        case 0:
-            actr->x += 16;
-            actr->y += 16;
-            d = 3;
-            if (bgtile(actr->x, actr->y) < TILE_SOLID) goto redo;
-            break;
-        case 1:
-            actr->x -= 16;
-            actr->y -= 16;
-            d = 2;
-            if (bgtile(actr->x, actr->y) < TILE_SOLID) goto redo;
-            break;
-        case 2:
-            actr->x += 16;
-            actr->y -= 16;
-            d = 0;
-            if (bgtile(actr->x, actr->y) < TILE_SOLID) goto redo;
-            break;
-        case 3:
-            actr->x -= 16;
-            actr->y += 16;
-            d = 1;
-            if (bgtile(actr->x, actr->y) < TILE_SOLID) goto redo;
-            break;
-        }
-        actr->dir = d;
-        actr->last_dir = d;
-        break;
-    }
-    return d;
+	switch (actr->temp2) {
+	case 0:
+		if (bgtile(actr->x, actr->y) >= TILE_SOLID)
+			actr->next = 1;
+		else {
+			actr->temp2 = 6;
+			actr->temp1 = 1;
+			goto redo;
+		}
+		actr->temp2++;
+		break;
+	case 1:
+		actr->next = 2;
+		actr->temp2++;
+		break;
+	case 2:
+		actr->next = 3;
+		actr->strength = 255;
+		actr->temp2++;
+		actr->temp1 = 10;
+		break;
+	case 3:
+		check_move2(actr->x, actr->y, actr);
+		actr->temp1--;
+		if (actr->temp1)
+			break;
+		actr->temp2++;
+		actr->next = 2;
+		break;
+	case 4:
+		actr->strength = 0;
+		actr->temp2++;
+		actr->next = 1;
+		break;
+	case 5:
+		actr->temp2++;
+		actr->next = 0;
+		actr->temp1 = 10;
+		break;
+	case 6:
+		actr->temp1--;
+		if (actr->temp1)
+			break;
+		actr->temp2 = 0;
+		actr->next = 0;
+		switch (d) {
+		case 0:
+			actr->x += 16;
+			actr->y += 16;
+			d = 3;
+			if (bgtile(actr->x, actr->y) < TILE_SOLID)
+				goto redo;
+			break;
+		case 1:
+			actr->x -= 16;
+			actr->y -= 16;
+			d = 2;
+			if (bgtile(actr->x, actr->y) < TILE_SOLID)
+				goto redo;
+			break;
+		case 2:
+			actr->x += 16;
+			actr->y -= 16;
+			d = 0;
+			if (bgtile(actr->x, actr->y) < TILE_SOLID)
+				goto redo;
+			break;
+		case 3:
+			actr->x -= 16;
+			actr->y += 16;
+			d = 1;
+			if (bgtile(actr->x, actr->y) < TILE_SOLID)
+				goto redo;
+			break;
+		}
+		actr->dir = d;
+		actr->last_dir = d;
+		break;
+	}
+	return d;
 }
 
 // Spinball counter-clockwise
 int movement_twentythree(ACTOR *actr) {
-    int d;
-
-    d = actr->last_dir;
-    next_frame(actr);
-    if (actr->pass_value & 2) actr->num_moves = 2;
-
-    switch (d) {
-    case 0:
-        if (bgtile(actr->x - 2, actr->y) >= TILE_FLY &&
-                bgtile(actr->x - 2, actr->y + actr->size_y - 1) >= TILE_FLY) {
-            d = 2;
-            actr->x -= 2;
-        } else {
-            if (bgtile(actr->x, actr->y - 2) < TILE_FLY ||
-                    bgtile(actr->x + actr->size_x - 1, actr->y - 2) < TILE_FLY) {
-                if (bgtile(actr->x + actr->size_x + 1, actr->y) >= TILE_FLY &&
-                        bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) >= TILE_FLY) {
-                    d = 3;
-                    actr->x += 2;
-                } else {
-                    d = 1;
-                    break;
-                }
-            } else actr->y -= 2;
-        }
-        break;
-    case 1:
-        if (bgtile(actr->x + actr->size_x + 1, actr->y) >= TILE_FLY &&
-                bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) >= TILE_FLY) {
-            d = 3;
-            actr->x += 2;
-        } else {
-            if (bgtile(actr->x, actr->y + actr->size_y + 1) < TILE_FLY ||
-                    bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) < TILE_FLY) {
-                if (bgtile(actr->x - 2, actr->y) >= TILE_FLY &&
-                        bgtile(actr->x - 2, actr->y + actr->size_y - 1) >= TILE_FLY) {
-                    d = 2;
-                    actr->x -= 2;
-                } else {
-                    d = 0;
-                    break;
-                }
-            } else actr->y += 2;
-        }
-        break;
-    case 2:
-        if (bgtile(actr->x, actr->y + actr->size_y + 1) >= TILE_FLY &&
-                bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) >= TILE_FLY) {
-            d = 1;
-            actr->y += 2;
-        } else {
-            if (bgtile(actr->x - 2, actr->y) < TILE_FLY ||
-                    bgtile(actr->x - 2, actr->y + actr->size_y - 1) < TILE_FLY) {
-                if (bgtile(actr->x, actr->y - 2) >= TILE_FLY &&
-                        bgtile(actr->x + actr->size_x - 1, actr->y - 2) >= TILE_FLY) {
-                    d = 0;
-                    actr->y -= 2;
-                } else {
-                    d = 3;
-                    break;
-                }
-            } else actr->x -= 2;
-        }
-        break;
-    case 3:
-        if (bgtile(actr->x, actr->y - 2) >= TILE_FLY &&
-                bgtile(actr->x + actr->size_x - 1, actr->y - 2) >= TILE_FLY) {
-            d = 0;
-            actr->y -= 2;
-        } else {
-            if (bgtile(actr->x + actr->size_x + 1, actr->y) < TILE_FLY ||
-                    bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) < TILE_FLY) {
-                if (bgtile(actr->x, actr->y + actr->size_y + 1) >= TILE_FLY &&
-                        bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) >= TILE_FLY) {
-                    d = 1;
-                    actr->y += 2;
-                } else {
-                    d = 2;
-                    break;
-                }
-            } else actr->x += 2;
-        }
-        break;
-    }
-    check_move2(actr->x, actr->y, actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	int d;
+
+	d = actr->last_dir;
+	next_frame(actr);
+	if (actr->pass_value & 2)
+		actr->num_moves = 2;
+
+	switch (d) {
+	case 0:
+		if (bgtile(actr->x - 2, actr->y) >= TILE_FLY &&
+			bgtile(actr->x - 2, actr->y + actr->size_y - 1) >= TILE_FLY) {
+			d = 2;
+			actr->x -= 2;
+		} else {
+			if (bgtile(actr->x, actr->y - 2) < TILE_FLY ||
+				bgtile(actr->x + actr->size_x - 1, actr->y - 2) < TILE_FLY) {
+				if (bgtile(actr->x + actr->size_x + 1, actr->y) >= TILE_FLY &&
+					bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) >= TILE_FLY) {
+					d = 3;
+					actr->x += 2;
+				} else {
+					d = 1;
+					break;
+				}
+			} else
+				actr->y -= 2;
+		}
+		break;
+	case 1:
+		if (bgtile(actr->x + actr->size_x + 1, actr->y) >= TILE_FLY &&
+			bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) >= TILE_FLY) {
+			d = 3;
+			actr->x += 2;
+		} else {
+			if (bgtile(actr->x, actr->y + actr->size_y + 1) < TILE_FLY ||
+				bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) < TILE_FLY) {
+				if (bgtile(actr->x - 2, actr->y) >= TILE_FLY &&
+					bgtile(actr->x - 2, actr->y + actr->size_y - 1) >= TILE_FLY) {
+					d = 2;
+					actr->x -= 2;
+				} else {
+					d = 0;
+					break;
+				}
+			} else
+				actr->y += 2;
+		}
+		break;
+	case 2:
+		if (bgtile(actr->x, actr->y + actr->size_y + 1) >= TILE_FLY &&
+			bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) >= TILE_FLY) {
+			d = 1;
+			actr->y += 2;
+		} else {
+			if (bgtile(actr->x - 2, actr->y) < TILE_FLY ||
+				bgtile(actr->x - 2, actr->y + actr->size_y - 1) < TILE_FLY) {
+				if (bgtile(actr->x, actr->y - 2) >= TILE_FLY &&
+					bgtile(actr->x + actr->size_x - 1, actr->y - 2) >= TILE_FLY) {
+					d = 0;
+					actr->y -= 2;
+				} else {
+					d = 3;
+					break;
+				}
+			} else
+				actr->x -= 2;
+		}
+		break;
+	case 3:
+		if (bgtile(actr->x, actr->y - 2) >= TILE_FLY &&
+			bgtile(actr->x + actr->size_x - 1, actr->y - 2) >= TILE_FLY) {
+			d = 0;
+			actr->y -= 2;
+		} else {
+			if (bgtile(actr->x + actr->size_x + 1, actr->y) < TILE_FLY ||
+				bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) < TILE_FLY) {
+				if (bgtile(actr->x, actr->y + actr->size_y + 1) >= TILE_FLY &&
+					bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) >= TILE_FLY) {
+					d = 1;
+					actr->y += 2;
+				} else {
+					d = 2;
+					break;
+				}
+			} else
+				actr->x += 2;
+		}
+		break;
+	}
+	check_move2(actr->x, actr->y, actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Spinball  clockwise
 int movement_twentyfour(ACTOR *actr) {
-    int d;
-
-    d = actr->last_dir;
-    next_frame(actr);
-    if (actr->pass_value & 2) actr->num_moves = 2;
-
-    switch (d) {
-    case 0:
-        if (bgtile(actr->x + actr->size_x + 1, actr->y) >= TILE_FLY &&
-                bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) >= TILE_FLY) {
-            d = 3;
-            actr->x += 2;
-        } else {
-            if (bgtile(actr->x, actr->y - 2) < TILE_FLY ||
-                    bgtile(actr->x + actr->size_x - 1, actr->y - 2) < TILE_FLY) {
-                if (bgtile(actr->x - 2, actr->y) >= TILE_FLY &&
-                        bgtile(actr->x - 2, actr->y + actr->size_y - 1) >= TILE_FLY) {
-                    d = 2;
-                    actr->x -= 2;
-                } else {
-                    d = 1;
-                    break;
-                }
-            } else actr->y -= 2;
-        }
-        break;
-    case 1:
-        if (bgtile(actr->x - 2, actr->y) >= TILE_FLY &&
-                bgtile(actr->x - 2, actr->y + actr->size_y - 1) >= TILE_FLY) {
-            d = 2;
-            actr->x -= 2;
-        } else {
-            if (bgtile(actr->x, actr->y + actr->size_y + 1) < TILE_FLY ||
-                    bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) < TILE_FLY) {
-                if (bgtile(actr->x + actr->size_x + 1, actr->y) >= TILE_FLY &&
-                        bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) >= TILE_FLY) {
-                    d = 3;
-                    actr->x += 2;
-                } else {
-                    d = 0;
-                    break;
-                }
-            } else actr->y += 2;
-        }
-        break;
-    case 2:
-        if (bgtile(actr->x, actr->y - 2) >= TILE_FLY &&
-                bgtile(actr->x + actr->size_x - 1, actr->y - 2) >= TILE_FLY) {
-            d = 0;
-            actr->y -= 2;
-        } else {
-            if (bgtile(actr->x - 2, actr->y) < TILE_FLY ||
-                    bgtile(actr->x - 2, actr->y + actr->size_y - 1) < TILE_FLY) {
-                if (bgtile(actr->x, actr->y + actr->size_y + 1) >= TILE_FLY &&
-                        bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) >= TILE_FLY) {
-                    d = 1;
-                    actr->y += 2;
-                } else {
-                    d = 3;
-                    break;
-                }
-            } else actr->x -= 2;
-        }
-        break;
-    case 3:
-        if (bgtile(actr->x, actr->y + actr->size_y + 1) >= TILE_FLY &&
-                bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) >= TILE_FLY) {
-            d = 1;
-            actr->y += 2;
-        } else {
-            if (bgtile(actr->x + actr->size_x + 1, actr->y) < TILE_FLY ||
-                    bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) < TILE_FLY) {
-                if (bgtile(actr->x, actr->y - 2) >= TILE_FLY &&
-                        bgtile(actr->x + actr->size_x - 1, actr->y - 2) >= TILE_FLY) {
-                    d = 0;
-                    actr->y -= 2;
-                } else {
-                    d = 2;
-                    break;
-                }
-            } else actr->x += 2;
-        }
-        break;
-    }
-    check_move2(actr->x, actr->y, actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	int d;
+
+	d = actr->last_dir;
+	next_frame(actr);
+	if (actr->pass_value & 2)
+		actr->num_moves = 2;
+
+	switch (d) {
+	case 0:
+		if (bgtile(actr->x + actr->size_x + 1, actr->y) >= TILE_FLY &&
+			bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) >= TILE_FLY) {
+			d = 3;
+			actr->x += 2;
+		} else {
+			if (bgtile(actr->x, actr->y - 2) < TILE_FLY ||
+				bgtile(actr->x + actr->size_x - 1, actr->y - 2) < TILE_FLY) {
+				if (bgtile(actr->x - 2, actr->y) >= TILE_FLY &&
+					bgtile(actr->x - 2, actr->y + actr->size_y - 1) >= TILE_FLY) {
+					d = 2;
+					actr->x -= 2;
+				} else {
+					d = 1;
+					break;
+				}
+			} else
+				actr->y -= 2;
+		}
+		break;
+	case 1:
+		if (bgtile(actr->x - 2, actr->y) >= TILE_FLY &&
+			bgtile(actr->x - 2, actr->y + actr->size_y - 1) >= TILE_FLY) {
+			d = 2;
+			actr->x -= 2;
+		} else {
+			if (bgtile(actr->x, actr->y + actr->size_y + 1) < TILE_FLY ||
+				bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) < TILE_FLY) {
+				if (bgtile(actr->x + actr->size_x + 1, actr->y) >= TILE_FLY &&
+					bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) >= TILE_FLY) {
+					d = 3;
+					actr->x += 2;
+				} else {
+					d = 0;
+					break;
+				}
+			} else
+				actr->y += 2;
+		}
+		break;
+	case 2:
+		if (bgtile(actr->x, actr->y - 2) >= TILE_FLY &&
+			bgtile(actr->x + actr->size_x - 1, actr->y - 2) >= TILE_FLY) {
+			d = 0;
+			actr->y -= 2;
+		} else {
+			if (bgtile(actr->x - 2, actr->y) < TILE_FLY ||
+				bgtile(actr->x - 2, actr->y + actr->size_y - 1) < TILE_FLY) {
+				if (bgtile(actr->x, actr->y + actr->size_y + 1) >= TILE_FLY &&
+					bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) >= TILE_FLY) {
+					d = 1;
+					actr->y += 2;
+				} else {
+					d = 3;
+					break;
+				}
+			} else
+				actr->x -= 2;
+		}
+		break;
+	case 3:
+		if (bgtile(actr->x, actr->y + actr->size_y + 1) >= TILE_FLY &&
+			bgtile(actr->x + actr->size_x - 1, actr->y + actr->size_y + 1) >= TILE_FLY) {
+			d = 1;
+			actr->y += 2;
+		} else {
+			if (bgtile(actr->x + actr->size_x + 1, actr->y) < TILE_FLY ||
+				bgtile(actr->x + actr->size_x + 1, actr->y + actr->size_y - 1) < TILE_FLY) {
+				if (bgtile(actr->x, actr->y - 2) >= TILE_FLY &&
+					bgtile(actr->x + actr->size_x - 1, actr->y - 2) >= TILE_FLY) {
+					d = 0;
+					actr->y -= 2;
+				} else {
+					d = 2;
+					break;
+				}
+			} else
+				actr->x += 2;
+		}
+		break;
+	}
+	check_move2(actr->x, actr->y, actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Acid puddle
 int movement_twentyfive(ACTOR *actr) {
-    int i, ret;
-
-    if (actr->temp2) {
-        actr->temp2--;
-        return movement_one(actr);
-    }
-    if (!actr->temp1) {
-        actr->last_dir = g_events->getRandomNumber(3);
-        i = 4;
-        while (i--) {
-            ret = movement_three(actr);
-            if (ret) return ret;
-            actr->last_dir++;
-            if (actr->last_dir > 3) actr->last_dir = 0;
-        }
-        actr->temp1 = 16;
-    }
-    actr->temp1--;
-    return movement_three(actr);
+	int i, ret;
+
+	if (actr->temp2) {
+		actr->temp2--;
+		return movement_one(actr);
+	}
+	if (!actr->temp1) {
+		actr->last_dir = g_events->getRandomNumber(3);
+		i = 4;
+		while (i--) {
+			ret = movement_three(actr);
+			if (ret)
+				return ret;
+			actr->last_dir++;
+			if (actr->last_dir > 3)
+				actr->last_dir = 0;
+		}
+		actr->temp1 = 16;
+	}
+	actr->temp1--;
+	return movement_three(actr);
 }
 
 int movement_twentysix(ACTOR *actr) {
-    if (GAME2)
-        return boss2_movement(actr);
-    if (GAME3)
-        return boss3_movement(actr);
+	if (GAME2)
+		return boss2_movement(actr);
+	if (GAME3)
+		return boss3_movement(actr);
 
-    return movement_one(actr);
+	return movement_one(actr);
 }
 
 int movement_twentyseven(ACTOR *actr) {
-    if (GAME2)
-        return boss2_movement(actr);
+	if (GAME2)
+		return boss2_movement(actr);
 
-    return movement_one(actr);
+	return movement_one(actr);
 }
 
 void set_thor_vars() {
-    _G(thor_x1) = _G(thor)->x + 1;
-    _G(thor_y1) = _G(thor)->y + 8;
-    _G(thor_real_y1) = _G(thor)->y;
-    if (_G(thor)->dir > 1)
-        _G(thor_x2) = (_G(thor)->x + 12);
-    else
-        _G(thor_x2) = (_G(thor)->x + 12);
-
-    _G(thor_y2) = _G(thor)->y + 15;
+	_G(thor_x1) = _G(thor)->x + 1;
+	_G(thor_y1) = _G(thor)->y + 8;
+	_G(thor_real_y1) = _G(thor)->y;
+	if (_G(thor)->dir > 1)
+		_G(thor_x2) = (_G(thor)->x + 12);
+	else
+		_G(thor_x2) = (_G(thor)->x + 12);
+
+	_G(thor_y2) = _G(thor)->y + 15;
 }
 
 // Fish
 int movement_twentyeight(ACTOR *actr) {
-    int d, x1, y1, ret;
-
-    d = actr->last_dir;
-    x1 = actr->x;
-    y1 = actr->y;
-
-    if (actr->i1) actr->i1--;
-    else {
-        if (!actr->temp3) {
-            if (!actr->next) {
-                actr->frame_count = 1;
-                actr->frame_speed = 4;
-            }
-
-            next_frame(actr);
-            if (actr->next == 3) {
-                if (actr->num_shots < actr->shots_allowed)
-                    actor_shoots(actr, 0);
-                actr->temp3 = 1;
-            }
-        } else {
-            actr->frame_count--;
-            if (actr->frame_count <= 0) {
-                actr->next--;
-                actr->frame_count = actr->frame_speed;
-                if (!actr->next) {
-                    actr->temp3 = 0;
-                    actr->frame_speed = 4;
-                    actr->i1 = g_events->getRandomNumber(60, 159);
-                }
-            }
-        }
-        goto done;
-    }
-    switch (actr->temp2) {
-    case 0:
-        y1 -= 2;
-        break;
-    case 1:
-        y1 += 2;
-        break;
-    case 2:
-        x1 -= 2;
-        break;
-    case 3:
-        x1 += 2;
-        break;
-    }
-    ret = bgtile(x1, y1);
-    if (ret != 100 && ret != 106 && ret != 110 && ret != 111 && ret != 113) goto chg_dir;
-    ret = bgtile((x1 + actr->size_x) - 1, y1);
-    if (ret != 100 && ret != 106 && ret != 110 && ret != 111 && ret != 113) goto chg_dir;
-    ret = bgtile(x1, (y1 + actr->size_y) - 1);
-    if (ret != 100 && ret != 106 && ret != 110 && ret != 111 && ret != 113) goto chg_dir;
-    ret = bgtile((x1 + actr->size_x) - 1, (y1 + actr->size_y) - 1);
-    if (ret != 100 && ret != 106 && ret != 110 && ret != 111 && ret != 113) goto chg_dir;
-
-    actr->x = x1;
-    actr->y = y1;
-
-    goto done;
+	int d, x1, y1, ret;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	if (actr->i1)
+		actr->i1--;
+	else {
+		if (!actr->temp3) {
+			if (!actr->next) {
+				actr->frame_count = 1;
+				actr->frame_speed = 4;
+			}
+
+			next_frame(actr);
+			if (actr->next == 3) {
+				if (actr->num_shots < actr->shots_allowed)
+					actor_shoots(actr, 0);
+				actr->temp3 = 1;
+			}
+		} else {
+			actr->frame_count--;
+			if (actr->frame_count <= 0) {
+				actr->next--;
+				actr->frame_count = actr->frame_speed;
+				if (!actr->next) {
+					actr->temp3 = 0;
+					actr->frame_speed = 4;
+					actr->i1 = g_events->getRandomNumber(60, 159);
+				}
+			}
+		}
+		goto done;
+	}
+	switch (actr->temp2) {
+	case 0:
+		y1 -= 2;
+		break;
+	case 1:
+		y1 += 2;
+		break;
+	case 2:
+		x1 -= 2;
+		break;
+	case 3:
+		x1 += 2;
+		break;
+	}
+	ret = bgtile(x1, y1);
+	if (ret != 100 && ret != 106 && ret != 110 && ret != 111 && ret != 113)
+		goto chg_dir;
+	ret = bgtile((x1 + actr->size_x) - 1, y1);
+	if (ret != 100 && ret != 106 && ret != 110 && ret != 111 && ret != 113)
+		goto chg_dir;
+	ret = bgtile(x1, (y1 + actr->size_y) - 1);
+	if (ret != 100 && ret != 106 && ret != 110 && ret != 111 && ret != 113)
+		goto chg_dir;
+	ret = bgtile((x1 + actr->size_x) - 1, (y1 + actr->size_y) - 1);
+	if (ret != 100 && ret != 106 && ret != 110 && ret != 111 && ret != 113)
+		goto chg_dir;
+
+	actr->x = x1;
+	actr->y = y1;
+
+	goto done;
 
 chg_dir:
-    actr->temp2 = _G(rand1) % 4;
+	actr->temp2 = _G(rand1) % 4;
 
 done:
-    if (actr->next) {
-        x1 = actr->x;
-        y1 = actr->y;
-        actr->solid = 1;
-        check_move2(x1, y1, actr);
-        actr->x = x1;
-        actr->y = y1;
-    } else actr->solid = 2;
-    if (actr->directions == 1) return 0;
-    return d;
+	if (actr->next) {
+		x1 = actr->x;
+		y1 = actr->y;
+		actr->solid = 1;
+		check_move2(x1, y1, actr);
+		actr->x = x1;
+		actr->y = y1;
+	} else
+		actr->solid = 2;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Horz or vert (pass_val)
 int movement_twentynine(ACTOR *actr) {
-    if (!actr->pass_value) return movement_thirty(actr);
-    else return movement_twelve(actr);
+	if (!actr->pass_value)
+		return movement_thirty(actr);
+	else
+		return movement_twelve(actr);
 }
 
 // Vert straight
 int movement_thirty(ACTOR *actr) {
-    int d, x1, y1;
-
-    d = actr->last_dir;
-    x1 = actr->x;
-    y1 = actr->y;
-
-    switch (d) {
-    case 0:
-        y1 -= 2;
-        break;
-    case 1:
-        y1 += 2;
-        break;
-    }
-    if (!check_move2(x1, y1, actr)) d ^= 1;
-
-    next_frame(actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	int d, x1, y1;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	switch (d) {
+	case 0:
+		y1 -= 2;
+		break;
+	case 1:
+		y1 += 2;
+		break;
+	}
+	if (!check_move2(x1, y1, actr))
+		d ^= 1;
+
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Drop (stalagtite)
 int movement_thirtyone(ACTOR *actr) {
-    int d, x1, y1, cx, cy, ty, i;
-
-    d = actr->last_dir;
-    x1 = actr->x;
-    y1 = actr->y;
-
-    if (actr->temp1) {
-        y1 += 2;
-        if (!check_move2(x1, y1, actr)) actor_destroyed(actr);
-    } else {
-        if (_G(thor_y1) > y1) {
-            if (ABS(x1 - _G(thor_x1)) < 16) {
-                cx = (actr->x + (actr->size_x / 2)) >> 4;
-                cy = ((actr->y + actr->size_y) - 2) >> 4;
-                ty = _G(thor)->center_y;
-                for (i = cy; i <= ty; i++) if (_G(scrn).icon[i][cx] < TILE_SOLID) goto done;
-                actr->num_moves = actr->pass_value + 1;
-                actr->temp1 = 1;
-            }
-        }
-    }
+	int d, x1, y1, cx, cy, ty, i;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	if (actr->temp1) {
+		y1 += 2;
+		if (!check_move2(x1, y1, actr))
+			actor_destroyed(actr);
+	} else {
+		if (_G(thor_y1) > y1) {
+			if (ABS(x1 - _G(thor_x1)) < 16) {
+				cx = (actr->x + (actr->size_x / 2)) >> 4;
+				cy = ((actr->y + actr->size_y) - 2) >> 4;
+				ty = _G(thor)->center_y;
+				for (i = cy; i <= ty; i++)
+					if (_G(scrn).icon[i][cx] < TILE_SOLID)
+						goto done;
+				actr->num_moves = actr->pass_value + 1;
+				actr->temp1 = 1;
+			}
+		}
+	}
 
 done:
-    next_frame(actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Unused
 int movement_thirtytwo(ACTOR *actr) {
-    return 0;
+	return 0;
 }
 
 // Unused
 int movement_thirtythree(ACTOR *actr) {
-    return 0;
+	return 0;
 }
 
 // Unused
 int movement_thirtyfour(ACTOR *actr) {
-    return 0;
+	return 0;
 }
 
 // Gun (single)
 int movement_thirtyfive(ACTOR *actr) {
-    actr->next = actr->last_dir;
-    return actr->dir;
+	actr->next = actr->last_dir;
+	return actr->dir;
 }
 
 // Acid drop
 int movement_thirtysix(ACTOR *actr) {
-    actr->speed = actr->pass_value;
-    next_frame(actr);
-    if (actr->next == 0 && actr->frame_count == actr->frame_speed) {
-        actor_always_shoots(actr, 1);
-        _G(actor[actr->shot_actor]).x -= 2;
-    }
-    return 0;
+	actr->speed = actr->pass_value;
+	next_frame(actr);
+	if (actr->next == 0 && actr->frame_count == actr->frame_speed) {
+		actor_always_shoots(actr, 1);
+		_G(actor[actr->shot_actor]).x -= 2;
+	}
+	return 0;
 }
 
 // 4-way straight (random length) change
 int movement_thirtyseven(ACTOR *actr) {
-    int d, x1, y1, f;
-
-    d = actr->last_dir;
-    x1 = actr->x;
-    y1 = actr->y;
-
-    f = 0;
-    if (actr->counter) {
-        actr->counter--;
-        switch (d) {
-        case 0:
-            y1 -= 2;
-            if (!check_move2(x1, y1, actr)) f = 1;
-            break;
-        case 1:
-            y1 += 2;
-            if (!check_move2(x1, y1, actr)) f = 1;
-            break;
-        case 2:
-            x1 -= 2;
-            if (!check_move2(x1, y1, actr)) f = 1;
-            break;
-        case 3:
-            x1 += 2;
-            if (!check_move2(x1, y1, actr)) f = 1;
-            break;
-        }
-    } else f = 1;
-
-    if (f == 1) {
-        actr->counter = g_events->getRandomNumber(10, 99);
-        d = g_events->getRandomNumber(3);
-    }
-    next_frame(actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	int d, x1, y1, f;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	f = 0;
+	if (actr->counter) {
+		actr->counter--;
+		switch (d) {
+		case 0:
+			y1 -= 2;
+			if (!check_move2(x1, y1, actr))
+				f = 1;
+			break;
+		case 1:
+			y1 += 2;
+			if (!check_move2(x1, y1, actr))
+				f = 1;
+			break;
+		case 2:
+			x1 -= 2;
+			if (!check_move2(x1, y1, actr))
+				f = 1;
+			break;
+		case 3:
+			x1 += 2;
+			if (!check_move2(x1, y1, actr))
+				f = 1;
+			break;
+		}
+	} else
+		f = 1;
+
+	if (f == 1) {
+		actr->counter = g_events->getRandomNumber(10, 99);
+		d = g_events->getRandomNumber(3);
+	}
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Timed darting
-#define TIMER     actr->i1
-#define INIT_DIR  actr->temp1
+#define TIMER actr->i1
+#define INIT_DIR actr->temp1
 #define OTHER_DIR actr->temp2
-#define FLAG      actr->temp3
-#define OX        actr->i2
-#define OY        actr->i3
-#define CNT       actr->i4
+#define FLAG actr->temp3
+#define OX actr->i2
+#define OY actr->i3
+#define CNT actr->i4
 int movement_thirtyeight(ACTOR *actr) {
-    int d, x1, y1;
-
-    d = actr->last_dir;
-    x1 = actr->x;
-    y1 = actr->y;
-
-    if (!FLAG) {
-        FLAG = 1;
-        if (actr->pass_value) TIMER = actr->pass_value * 15;
-        else TIMER = g_events->getRandomNumber(5, 364);
-        INIT_DIR = actr->last_dir;
-        OX = x1;
-        OY = y1;
-        CNT = 0;
-        switch (INIT_DIR) {
-        case 0:
-            OTHER_DIR = 1;
-            break;
-        case 1:
-            OTHER_DIR = 0;
-            break;
-        case 2:
-            OTHER_DIR = 3;
-            break;
-        case 3:
-            OTHER_DIR = 2;
-            break;
-        }
-    }
-    if (TIMER) {
-        TIMER--;
-        goto done;
-    }
-
-    switch (d) {
-    case 0:
-        y1 -= 2;
-        break;
-    case 1:
-        y1 += 2;
-        break;
-    case 2:
-        x1 -= 2;
-        break;
-    case 3:
-        x1 += 2;
-        break;
-    }
-
-    switch (FLAG) {
-    case 1:
-        if (!check_move2(x1, y1, actr)) {
-            if (CNT) {
-                d = OTHER_DIR;
-                actr->last_dir = d;
-                FLAG = 2;
-            } else {
-                actr->next = 0;
-                FLAG = 0;
-                goto done;
-            }
-        } else CNT++;
-        break;
-    case 2:
-        check_move2(x1, y1, actr);
-        if (x1 == OX && y1 == OY) {
-            FLAG = 0;
-            d = INIT_DIR;
-            actr->last_dir = d;
-            actr->next = 0;
-            goto done;
-        }
-    }
-    next_frame(actr);
+	int d, x1, y1;
+
+	d = actr->last_dir;
+	x1 = actr->x;
+	y1 = actr->y;
+
+	if (!FLAG) {
+		FLAG = 1;
+		if (actr->pass_value)
+			TIMER = actr->pass_value * 15;
+		else
+			TIMER = g_events->getRandomNumber(5, 364);
+		INIT_DIR = actr->last_dir;
+		OX = x1;
+		OY = y1;
+		CNT = 0;
+		switch (INIT_DIR) {
+		case 0:
+			OTHER_DIR = 1;
+			break;
+		case 1:
+			OTHER_DIR = 0;
+			break;
+		case 2:
+			OTHER_DIR = 3;
+			break;
+		case 3:
+			OTHER_DIR = 2;
+			break;
+		}
+	}
+	if (TIMER) {
+		TIMER--;
+		goto done;
+	}
+
+	switch (d) {
+	case 0:
+		y1 -= 2;
+		break;
+	case 1:
+		y1 += 2;
+		break;
+	case 2:
+		x1 -= 2;
+		break;
+	case 3:
+		x1 += 2;
+		break;
+	}
+
+	switch (FLAG) {
+	case 1:
+		if (!check_move2(x1, y1, actr)) {
+			if (CNT) {
+				d = OTHER_DIR;
+				actr->last_dir = d;
+				FLAG = 2;
+			} else {
+				actr->next = 0;
+				FLAG = 0;
+				goto done;
+			}
+		} else
+			CNT++;
+		break;
+	case 2:
+		check_move2(x1, y1, actr);
+		if (x1 == OX && y1 == OY) {
+			FLAG = 0;
+			d = INIT_DIR;
+			actr->last_dir = d;
+			actr->next = 0;
+			goto done;
+		}
+	}
+	next_frame(actr);
 
 done:
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Troll 1
 int movement_thirtynine(ACTOR *actr) {
-    if (_G(setup).skill == 0) {
-        actr->speed = 3;
-        actr->num_moves = 1;
-    } else if (_G(setup).skill == 1) {
-        actr->speed = 2;
-        actr->num_moves = 1;
-    } else if (_G(setup).skill == 2) {
-        actr->speed = 1;
-        actr->num_moves = 1;
-    }
-
-    if (actr->pass_value < 5) return movement_forty(actr);
-    if (actr->pass_value == 10) {
-        if (overlap(actr->x + 1, actr->y + 1, actr->x + actr->size_x - 1,
-                    actr->y + actr->size_y - 1, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
-            actr->strength = 255;
-            thor_damaged(actr);
-        }
-        return actr->dir;
-    }
-    if (actr->actor_num != 3) return actr->dir;
-
-    if (actr->i1) {
-        actr->i1--;
-        actr->x -= 2;
-        check_move2(actr->x, actr->y, actr);
-        _G(actor[4]).x -= 2;
-        _G(actor[5]).x -= 2;
-        _G(actor[6]).x -= 2;
-    }
-    next_frame(actr);
-    if (actr->next == 3) actr->next = 0;
-    _G(actor[4]).next = _G(actor[3]).next;
-    _G(actor[5]).next = 0;
-    _G(actor[6]).next = 0;
-    return actr->dir;
+	if (_G(setup).skill == 0) {
+		actr->speed = 3;
+		actr->num_moves = 1;
+	} else if (_G(setup).skill == 1) {
+		actr->speed = 2;
+		actr->num_moves = 1;
+	} else if (_G(setup).skill == 2) {
+		actr->speed = 1;
+		actr->num_moves = 1;
+	}
+
+	if (actr->pass_value < 5)
+		return movement_forty(actr);
+	if (actr->pass_value == 10) {
+		if (overlap(actr->x + 1, actr->y + 1, actr->x + actr->size_x - 1,
+					actr->y + actr->size_y - 1, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
+			actr->strength = 255;
+			thor_damaged(actr);
+		}
+		return actr->dir;
+	}
+	if (actr->actor_num != 3)
+		return actr->dir;
+
+	if (actr->i1) {
+		actr->i1--;
+		actr->x -= 2;
+		check_move2(actr->x, actr->y, actr);
+		_G(actor[4]).x -= 2;
+		_G(actor[5]).x -= 2;
+		_G(actor[6]).x -= 2;
+	}
+	next_frame(actr);
+	if (actr->next == 3)
+		actr->next = 0;
+	_G(actor[4]).next = _G(actor[3]).next;
+	_G(actor[5]).next = 0;
+	_G(actor[6]).next = 0;
+	return actr->dir;
 }
 
 // Troll 2
 int movement_forty(ACTOR *actr) {
-    int x1, x2, a, d, f;
-
-    if (overlap(actr->x + 1, actr->y + 1, actr->x + actr->size_x + 3,
-                actr->y + actr->size_y - 1, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
-        actr->strength = 150;
-        thor_damaged(actr);
-    }
-    a = 5 + (actr->pass_value * 4);
-    x1 = actr->x;
-    x2 = _G(actor[a + 1]).x;
-    d = actr->last_dir;
-
-    if (actr->last_dir == 2) {
-        f = 1;
-        if (bgtile(x1 - 2, actr->y) >= TILE_SOLID) {
-            _G(actor[a].x) -= 2;
-            _G(actor[a - 1]).x -= 2;
-            _G(actor[a - 2]).x -= 2;
-            _G(actor[a + 1]).x -= 2;
-        } else f = 0;
-        if (!f)
-            d = 3;
-    } else {
-        f = 1;
-        if (bgtile(_G(actor[a + 1]).x + 14, _G(actor[a + 1]).y) >= TILE_SOLID) {
-            _G(actor[a]).x += 2;
-            _G(actor[a - 1]).x += 2;
-            _G(actor[a - 2]).x += 2;
-            _G(actor[a + 1]).x += 2;
-        } else f = 0;
-        if (!f) d = 2;
-    }
-    if (!f) {
-        actr->x = x1;
-        _G(actor[a + 1]).x = x2;
-    }
-
-    if (actr->next == 3 && !actr->num_shots && actr->frame_count == actr->frame_speed) {
-        actor_always_shoots(actr, 1);
-        _G(actor[actr->shot_actor]).x += 6;
-    }
-
-    next_frame(actr);
-    _G(actor[a - 2]).next = actr->next;
-    _G(actor[a - 1]).next = actr->next;
-    _G(actor[a + 1]).next = actr->next;
-    _G(actor[a - 2]).last_dir = d;
-    _G(actor[a - 1]).last_dir = d;
-    _G(actor[a + 1]).last_dir = d;
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	int x1, x2, a, d, f;
+
+	if (overlap(actr->x + 1, actr->y + 1, actr->x + actr->size_x + 3,
+				actr->y + actr->size_y - 1, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
+		actr->strength = 150;
+		thor_damaged(actr);
+	}
+	a = 5 + (actr->pass_value * 4);
+	x1 = actr->x;
+	x2 = _G(actor[a + 1]).x;
+	d = actr->last_dir;
+
+	if (actr->last_dir == 2) {
+		f = 1;
+		if (bgtile(x1 - 2, actr->y) >= TILE_SOLID) {
+			_G(actor[a].x) -= 2;
+			_G(actor[a - 1]).x -= 2;
+			_G(actor[a - 2]).x -= 2;
+			_G(actor[a + 1]).x -= 2;
+		} else
+			f = 0;
+		if (!f)
+			d = 3;
+	} else {
+		f = 1;
+		if (bgtile(_G(actor[a + 1]).x + 14, _G(actor[a + 1]).y) >= TILE_SOLID) {
+			_G(actor[a]).x += 2;
+			_G(actor[a - 1]).x += 2;
+			_G(actor[a - 2]).x += 2;
+			_G(actor[a + 1]).x += 2;
+		} else
+			f = 0;
+		if (!f)
+			d = 2;
+	}
+	if (!f) {
+		actr->x = x1;
+		_G(actor[a + 1]).x = x2;
+	}
+
+	if (actr->next == 3 && !actr->num_shots && actr->frame_count == actr->frame_speed) {
+		actor_always_shoots(actr, 1);
+		_G(actor[actr->shot_actor]).x += 6;
+	}
+
+	next_frame(actr);
+	_G(actor[a - 2]).next = actr->next;
+	_G(actor[a - 1]).next = actr->next;
+	_G(actor[a + 1]).next = actr->next;
+	_G(actor[a - 2]).last_dir = d;
+	_G(actor[a - 1]).last_dir = d;
+	_G(actor[a + 1]).last_dir = d;
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 } // namespace Got


Commit: 807e103261accbe4aab27161192dbde3f4724bad
    https://github.com/scummvm/scummvm/commit/807e103261accbe4aab27161192dbde3f4724bad
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Some more cleanup in move and move_patterns

Changed paths:
    engines/got/data/actor.h
    engines/got/game/move.cpp
    engines/got/game/move_patterns.cpp


diff --git a/engines/got/data/actor.h b/engines/got/data/actor.h
index 7fab2cce78c..deea054e046 100644
--- a/engines/got/data/actor.h
+++ b/engines/got/data/actor.h
@@ -40,8 +40,8 @@ struct ACTOR {                      // Size=256
     byte frame_speed = 0;           // # cycles between frame changes
     byte frame_sequence[4] = {};    // Sequence
     byte speed = 0;                 // Move every Nth cycle
-    byte size_x = 0;                // Non-physical padding on X coor
-    byte size_y = 0;                // Non-phsyical padding on Y coor
+    byte size_x = 0;                // Non-physical padding on X coordinate
+    byte size_y = 0;                // Non-physical padding on Y coordinate
     byte strength = 0;              // Hit strength
     byte health = 0;                //
     byte num_moves = 0;             // # of moves every <speed> cycles
@@ -65,15 +65,15 @@ struct ACTOR {                      // Size=256
     byte frame_count = 0;           // Count to switch frames
     byte dir = 0;                   // Direction of travel
     byte last_dir = 0;              // Last direction of travel
-    int  x = 0;                     // Actual X coor
-    int  y = 0;                     // Actual Y coor
+    int  x = 0;                     // Actual X coordinate
+    int  y = 0;                     // Actual Y coordinate
     int  center = 0;                // Center of object
-    int  last_x[2] = {};            // Last X coor on each page
-    int  last_y[2] = {};            // Last Y coor on each page
+    int  last_x[2] = {};            // Last X coordinate on each page
+    int  last_y[2] = {};            // Last Y coordinate on each page
     byte used = 0;                  // 1=active, 0=not active
     byte next = 0;                  // Next frame to be shown
     byte speed_count = 0;           // Count down to movement
-    byte vunerable = 0;             // Count down to vunerability
+    byte vunerable = 0;             // Count down to vulnerability
     byte shot_cnt = 0;              // Count down to another shot
     byte num_shots = 0;             // # of shots currently on screen
     byte creator = 0;               // Which actor # created this actor
diff --git a/engines/got/game/move.cpp b/engines/got/game/move.cpp
index c65c10eafee..ebade012132 100644
--- a/engines/got/game/move.cpp
+++ b/engines/got/game/move.cpp
@@ -140,8 +140,6 @@ void actor_damaged(ACTOR *actr, int damage) {
 }
 
 void thor_damaged(ACTOR *actr) {
-	int damage;
-
 	actr->hit_thor = 1;
 
 	// If we're invincible, ignore any damage
@@ -162,7 +160,7 @@ void thor_damaged(ACTOR *actr) {
 		return;
 	}
 
-	damage = actr->strength;
+	int damage = actr->strength;
 	if (damage != 255) {
 		if (!_G(setup).skill)
 			damage /= 2;
@@ -222,14 +220,12 @@ void actor_destroyed(ACTOR *actr) {
 }
 
 int _actor_shoots(ACTOR *actr, int dir) {
-	int cx, cy;
-	ACTOR *act;
-
 	int t = actr->shot_type - 1;
 	for (int i = MAX_ENEMIES + 3; i < MAX_ACTORS; i++) {
 		if ((!_G(actor[i]).used) && (!_G(actor[i]).dead)) {
-			act = &_G(actor[i]);
+			ACTOR *act = &_G(actor[i]);
 			*act = _G(shot[t]);
+			int cx, cy;
 
 			if (actr->size_y < act->size_y)
 				cy = actr->y - ((act->size_y - actr->size_y) / 2);
@@ -328,8 +324,6 @@ int actor_shoots(ACTOR *actr, int dir) {
 }
 
 void move_actor(ACTOR *actr) {
-	int i;
-
 	if (actr->vunerable != 0)
 		actr->vunerable--;
 	if (actr->shot_cnt != 0)
@@ -351,12 +345,17 @@ void move_actor(ACTOR *actr) {
 			actr->speed_count = actr->speed;
 		else
 			actr->speed_count = (actr->speed << 1);
+		
+		int i;
+
 		if (actr->type == 3)
 			i = shot_movement_func[actr->move](actr);
 		else
 			i = movement_func[actr->move](actr);
+		
 		if (actr->directions == 2)
 			i &= 1;
+		
 		if (i != actr->dir)
 			actr->dir = i;
 
diff --git a/engines/got/game/move_patterns.cpp b/engines/got/game/move_patterns.cpp
index a200ce91031..904a4efb6f9 100644
--- a/engines/got/game/move_patterns.cpp
+++ b/engines/got/game/move_patterns.cpp
@@ -176,9 +176,11 @@ int check_move0(int x, int y, ACTOR *actr) {
 			actr->move_count = 0;
 			set_thor_vars();
 			return 1;
-		} else
-			return 0;
+		}
+
+		return 0;
 	}
+	
 	if (x > 306) {
 		if (_G(current_level) < 119) {
 			_G(new_level) = _G(current_level) + 1;
@@ -189,9 +191,11 @@ int check_move0(int x, int y, ACTOR *actr) {
 			actr->move_count = 0;
 			set_thor_vars();
 			return 1;
-		} else
-			return 0;
+		}
+
+		return 0;
 	}
+	
 	if (y < 0) {
 		if (_G(current_level) > 9) {
 			_G(new_level) = _G(current_level) - 10;
@@ -202,9 +206,11 @@ int check_move0(int x, int y, ACTOR *actr) {
 			actr->move_count = 0;
 			set_thor_vars();
 			return 1;
-		} else
-			return 0;
+		}
+
+		return 0;
 	}
+	
 	if (y > 175) {
 		if (_G(current_level) < 110) {
 			_G(new_level) = _G(current_level) + 10;
@@ -215,9 +221,11 @@ int check_move0(int x, int y, ACTOR *actr) {
 			actr->move_count = 0;
 			set_thor_vars();
 			return 1;
-		} else
-			return 0;
+		}
+
+		return 0;
 	}
+	
 	int x1 = (x + 1) >> 4;
 	int y1 = (y + 8) >> 4;
 	int x2 = (_G(thor)->dir > 1) ? (x + 12) >> 4 : (x + 10) >> 4;
@@ -237,18 +245,22 @@ int check_move0(int x, int y, ACTOR *actr) {
 			_G(thor_icon1) = 1;
 			ti = 1;
 		}
+		
 		if (icn2 < TILE_FLY) {
 			_G(thor_icon2) = 1;
 			ti = 1;
 		}
+		
 		if (icn3 < TILE_FLY) {
 			_G(thor_icon3) = 1;
 			ti = 1;
 		}
+		
 		if (icn4 < TILE_FLY) {
 			_G(thor_icon4) = 1;
 			ti = 1;
 		}
+		
 		if (ti)
 			return 0;
 
@@ -259,55 +271,59 @@ int check_move0(int x, int y, ACTOR *actr) {
 			icn3 = _G(scrn).icon[y1][x2];
 			icn4 = _G(scrn).icon[y2][x2];
 		}
+
 		if (icn2 > TILE_SPECIAL) {
 			if (!special_tile_thor(y2, x1, icn2))
 				return 0;
 			icn3 = _G(scrn).icon[y1][x2];
 			icn4 = _G(scrn).icon[y2][x2];
 		}
+
 		if (icn3 > TILE_SPECIAL) {
 			if (!special_tile_thor(y1, x2, icn3))
 				return 0;
 			icn4 = _G(scrn).icon[y2][x2];
 		}
-		if (icn4 > TILE_SPECIAL) {
-			if (!special_tile_thor(y2, x2, icn4))
-				return 0;
-		}
+
+		if (icn4 > TILE_SPECIAL && !special_tile_thor(y2, x2, icn4))
+			return 0;
 	}
 
 	if (!_G(slip_flag)) {
 		_G(slipping) = false;
 		_G(slip_cnt) = 0;
 	}
+	
 	if (_G(slip_flag) && !_G(slipping))
 		_G(slip_cnt++);
+	
 	if (_G(slip_cnt) > 8)
 		_G(slipping) = true;
+	
 	_G(slip_flag) = false;
 
 	x1 = x + 1;
 	y1 = y + 8;
+	
 	if (_G(thor)->dir > 1)
 		x2 = x + 12;
 	else
-		x2 = x + 12;
+		x2 = x + 12; // CHECKME : in check_move0() it's 10
+	
 	y2 = y + 15;
 
 	_G(thor_special_flag) = false;
 	for (int i = 3; i < MAX_ACTORS; i++) {
 		ACTOR *act = &_G(actor[i]);
-		if (act->solid & 128)
-			continue;
-		if (!act->used)
+		if ((act->solid & 128) || !act->used)
 			continue;
 
 		int x3 = act->x + 1;
-		if ((ABS(x3 - x1)) > 16)
-			continue;
 		int y3 = act->y + 1;
-		if ((ABS(y3 - y1)) > 16)
+		
+		if (ABS(x3 - x1) > 16 || ABS(y3 - y1) > 16)
 			continue;
+		
 		int x4 = act->x + act->size_x - 1;
 		int y4 = act->y + act->size_y - 1;
 		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
@@ -317,19 +333,20 @@ int check_move0(int x, int y, ACTOR *actr) {
 				act->temp1 = x;
 				act->temp2 = y;
 				_G(thor_special_flag) = true;
+				
 				return special_movement_func[act->func_num](act);
-			} else {
-				_G(thor_special_flag) = false;
-				thor_damaged(act);
-				if (act->solid < 2) {
-					if (!act->vunerable && (!(act->type & 1)))
-						play_sound(PUNCH1, false);
-
-					if (!_G(hammer)->used && _G(key_flag[key_fire]))
-						actor_damaged(act, _G(hammer)->strength);
-					else
-						actor_damaged(act, _G(thor)->strength);
-				}
+			}
+
+			_G(thor_special_flag) = false;
+			thor_damaged(act);
+			if (act->solid < 2) {
+				if (!act->vunerable && (!(act->type & 1)))
+					play_sound(PUNCH1, false);
+
+				if (!_G(hammer)->used && _G(key_flag[key_fire]))
+					actor_damaged(act, _G(hammer)->strength);
+				else
+					actor_damaged(act, _G(thor)->strength);
 			}
 			return 1;
 		}
@@ -341,30 +358,23 @@ int check_move0(int x, int y, ACTOR *actr) {
 
 // Check hammer move
 int check_move1(int x, int y, ACTOR *actr) {
-	int x1, x2, y1, y2, i;
-	int x3, y3, x4, y4;
-	int icn, f;
-	byte icn1, icn2, icn3, icn4;
-
-	ACTOR *act;
-
 	if (x < 0 || x > 306 || y < 0 || y > 177)
 		return 0;
 
-	x1 = (x + 1) >> 4;
-	y1 = (y + 6) >> 4;
-	x2 = (x + 10) >> 4;
-	y2 = (y + 10) >> 4;
+	int x1 = (x + 1) >> 4;
+	int y1 = (y + 6) >> 4;
+	int x2 = (x + 10) >> 4;
+	int y2 = (y + 10) >> 4;
 
 	// Check for solid or fly over
-	icn = TILE_FLY;
+	int icn = TILE_FLY;
 	if (actr->flying)
 		icn = TILE_SOLID;
 
-	icn1 = _G(scrn).icon[y1][x1];
-	icn2 = _G(scrn).icon[y2][x1];
-	icn3 = _G(scrn).icon[y1][x2];
-	icn4 = _G(scrn).icon[y2][x2];
+	byte icn1 = _G(scrn).icon[y1][x1];
+	byte icn2 = _G(scrn).icon[y2][x1];
+	byte icn3 = _G(scrn).icon[y1][x2];
+	byte icn4 = _G(scrn).icon[y2][x2];
 	if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn) {
 		if (actr->actor_num == 1 && actr->move == 2)
 			play_sound(CLANG, false);
@@ -372,39 +382,37 @@ int check_move1(int x, int y, ACTOR *actr) {
 		return 0;
 	}
 
-	if (icn1 > TILE_SPECIAL)
-		if (!special_tile(actr, y1, x1, icn1))
-			return 0;
-	if (icn2 > TILE_SPECIAL)
-		if (!special_tile(actr, y2, x1, icn2))
-			return 0;
-	if (icn3 > TILE_SPECIAL)
-		if (!special_tile(actr, y1, x2, icn3))
-			return 0;
-	if (icn4 > TILE_SPECIAL)
-		if (!special_tile(actr, y2, x2, icn4))
-			return 0;
+	if (icn1 > TILE_SPECIAL && !special_tile(actr, y1, x1, icn1))
+		return 0;
+
+	if (icn2 > TILE_SPECIAL && !special_tile(actr, y2, x1, icn2))
+		return 0;
+
+	if (icn3 > TILE_SPECIAL && !special_tile(actr, y1, x2, icn3))
+		return 0;
+
+	if (icn4 > TILE_SPECIAL && !special_tile(actr, y2, x2, icn4))
+		return 0;
 
 	x1 = x + 1;
 	y1 = y + 1;
 	x2 = x + 10;
 	y2 = y + 10;
 
-	f = 0;
-	for (i = 3; i < MAX_ACTORS; i++) {
-		act = &_G(actor[i]);
-		if (!act->used)
-			continue;
-		if (act->type == 3)
-			continue;
-		x3 = act->x;
-		if ((ABS(x3 - x1)) > 16)
+	int f = 0;
+	for (int i = 3; i < MAX_ACTORS; i++) {
+		ACTOR *act = &_G(actor[i]);
+		if (!act->used || act->type == 3)
 			continue;
-		y3 = act->y;
-		if ((ABS(y3 - y1)) > 16)
+		
+		int x3 = act->x;
+		int y3 = act->y;
+
+		if (ABS(x3 - x1) > 16 || ABS(y3 - y1) > 16)
 			continue;
-		x4 = act->x + act->size_x - 1;
-		y4 = act->y + act->size_y - 1;
+		
+		int x4 = act->x + act->size_x - 1;
+		int y4 = act->y + act->size_y - 1;
 
 		if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
 			if (_G(boss_active) && !GAME3) {
@@ -437,37 +445,32 @@ int check_move1(int x, int y, ACTOR *actr) {
 
 // Check enemy move
 int check_move2(int x, int y, ACTOR *actr) {
-	int x1, x2, y1, y2, i;
-	int x3, y3, x4, y4;
-	int icn;
-	byte icn1, icn2, icn3, icn4;
-
-	ACTOR *act;
-
 	if (actr->actor_num < 3)
 		return check_move1(x, y, actr);
 
 	if (x < 0 || x > (319 - actr->size_x) || y < 0 || y > 175)
 		return 0;
 
-	x1 = (x + 1) >> 4;
+	int x1 = (x + 1) >> 4;
+	int y1;
 	if (!actr->func_num)
 		y1 = (y + (actr->size_y / 2)) >> 4;
 	else
 		y1 = (y + 1) >> 4;
-	x2 = ((x + actr->size_x) - 1) >> 4;
-	y2 = ((y + actr->size_y) - 1) >> 4;
+
+	int x2 = ((x + actr->size_x) - 1) >> 4;
+	int y2 = ((y + actr->size_y) - 1) >> 4;
 
 	// Check for solid or fly over
 
-	icn = TILE_FLY;
+	int icn = TILE_FLY;
 	if (actr->flying)
 		icn = TILE_SOLID;
 
-	icn1 = _G(scrn).icon[y1][x1];
-	icn2 = _G(scrn).icon[y2][x1];
-	icn3 = _G(scrn).icon[y1][x2];
-	icn4 = _G(scrn).icon[y2][x2];
+	byte icn1 = _G(scrn).icon[y1][x1];
+	byte icn2 = _G(scrn).icon[y2][x1];
+	byte icn3 = _G(scrn).icon[y1][x2];
+	byte icn4 = _G(scrn).icon[y2][x2];
 	if (icn1 < icn || icn2 < icn || icn3 < icn || icn4 < icn)
 		return 0;
 
@@ -489,13 +492,9 @@ int check_move2(int x, int y, ACTOR *actr) {
 	x2 = (x + actr->size_x) - 1;
 	y2 = (y + actr->size_y) - 1;
 
-	for (i = 0; i < MAX_ACTORS; i++) {
-		act = &_G(actor[i]);
-		if (act->actor_num == actr->actor_num)
-			continue;
-		if (act->actor_num == 1)
-			continue;
-		if (!act->used)
+	for (int i = 0; i < MAX_ACTORS; i++) {
+		ACTOR *act = &_G(actor[i]);
+		if (act->actor_num == actr->actor_num || act->actor_num == 1 || !act->used)
 			continue;
 		if (act->type == 3)
 			continue; // Shot
@@ -506,16 +505,14 @@ int check_move2(int x, int y, ACTOR *actr) {
 				return 0;
 			}
 		} else {
-			x3 = act->x;
-			if ((ABS(x3 - x1)) > 16)
+			int x3 = act->x;
+			int y3 = act->y;
+			
+			if (ABS(x3 - x1) > 16 || ABS(y3 - y1) > 16)
 				continue;
 
-			y3 = act->y;
-			if ((ABS(y3 - y1)) > 16)
-				continue;
-
-			x4 = act->x + act->size_x;
-			y4 = act->y + act->size_y;
+			int x4 = act->x + act->size_x;
+			int y4 = act->y + act->size_y;
 			if (overlap(x1, y1, x2, y2, x3, y3, x4, y4)) {
 				if (actr->move == 38) {
 					if (act->func_num == 4)
@@ -590,11 +587,9 @@ int check_move3(int x, int y, ACTOR *actr) {
 			continue;
 
 		int x3 = act->x;
-		if ((ABS(x3 - x1)) > 16)
-			continue;
-
 		int y3 = act->y;
-		if ((ABS(y3 - y1)) > 16)
+
+		if (ABS(x3 - x1) > 16 || ABS(y3 - y1) > 16)
 			continue;
 
 		int x4 = x3 + 15;
@@ -631,7 +626,7 @@ int check_thor_move(int x, int y, ACTOR *actr) {
 	if (_G(diag_flag) || _G(thor_special_flag))
 		return 0;
 
-	if ((_G(thor_icon1) + _G(thor_icon2) + _G(thor_icon3) + _G(thor_icon4)) > 1)
+	if (_G(thor_icon1) + _G(thor_icon2) + _G(thor_icon3) + _G(thor_icon4) > 1)
 		return 0;
 
 	switch (actr->dir) {
@@ -692,20 +687,19 @@ int check_thor_move(int x, int y, ACTOR *actr) {
 
 // Player control
 int movement_zero(ACTOR *actr) {
-	int x, y;
 	int d = actr->dir;
 	int od = d;
 
 	set_thor_vars();
 
-	if ((_G(hammer)->used) && (_G(hammer)->move == 5)) {
+	if (_G(hammer)->used && _G(hammer)->move == 5) {
 		if (overlap(_G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2),
 					_G(hammer)->x, _G(hammer)->y, _G(hammer)->x + 13, _G(hammer)->y + 13)) {
 			actor_destroyed(_G(hammer));
 		}
 	}
-	x = actr->x;
-	y = actr->y;
+	int x = actr->x;
+	int y = actr->y;
 	_G(diag_flag) = false;
 	if (actr->move_counter)
 		actr->move_counter--;
@@ -987,7 +981,6 @@ int special_movement_two(ACTOR *actr) {
 
 // Yellow globe
 int special_movement_three(ACTOR *actr) {
-
 	if (_G(thunder_flag))
 		return 0;
 
@@ -1202,7 +1195,6 @@ int movement_three(ACTOR *actr) {
 
 // Simple tracking
 int movement_four(ACTOR *actr) {
-
 	int d = actr->last_dir;
 
 	int x1 = actr->x;
@@ -1421,13 +1413,11 @@ int movement_eight(ACTOR *actr) {
 
 // 4-way straight (random length) change
 int movement_nine(ACTOR *actr) {
-	int d, x1, y1, f;
-
-	d = actr->last_dir;
-	x1 = actr->x;
-	y1 = actr->y;
+	int d = actr->last_dir;
+	int x1 = actr->x;
+	int y1 = actr->y;
 
-	f = 0;
+	int f = 0;
 	if (actr->counter) {
 		actr->counter--;
 		switch (d) {
@@ -1468,13 +1458,11 @@ int movement_nine(ACTOR *actr) {
 
 // Vert straight (random length) change
 int movement_ten(ACTOR *actr) {
-	int d, x1, y1, f;
-
-	d = actr->last_dir;
-	x1 = actr->x;
-	y1 = actr->y;
+	int d = actr->last_dir;
+	int x1 = actr->x;
+	int y1 = actr->y;
 
-	f = 0;
+	int f = 0;
 	if (actr->counter) {
 		if (actr->pass_value != 1)
 			actr->counter--;
@@ -1520,9 +1508,7 @@ int movement_ten(ACTOR *actr) {
 
 // Horz only (bats)
 int movement_eleven(ACTOR *actr) {
-	int d;
-
-	d = actr->last_dir;
+	int d = actr->last_dir;
 
 	switch (d) {
 	case 0:
@@ -1568,9 +1554,7 @@ int movement_eleven(ACTOR *actr) {
 
 // Horz straight until bump
 int movement_twelve(ACTOR *actr) {
-	int d;
-
-	d = actr->last_dir;
+	int d = actr->last_dir;
 
 	switch (d) {
 	case 0:
@@ -1595,9 +1579,7 @@ int movement_twelve(ACTOR *actr) {
 
 // Pause-seek (mushroom)
 int movement_thirteen(ACTOR *actr) {
-	int d;
-
-	d = actr->last_dir;
+	int d = actr->last_dir;
 
 	if (actr->counter == 0 && actr->pause == 0) {
 		actr->pause = 60;
@@ -1623,12 +1605,10 @@ int movement_thirteen(ACTOR *actr) {
 
 // Move-bump-stop (boulder)
 int movement_fourteen(ACTOR *actr) {
-	int d, x1, y1;
-
-	d = actr->last_dir;
+	int d = actr->last_dir;
 	actr->dir = d;
-	x1 = actr->x;
-	y1 = actr->y;
+	int x1 = actr->x;
+	int y1 = actr->y;
 
 	switch (d) {
 	case 0:
@@ -1674,11 +1654,9 @@ int movement_fifteen(ACTOR *actr) {
 
 // Tornado 1
 int movement_sixteen(ACTOR *actr) {
-	int d, x1, y1;
-
-	d = actr->last_dir;
-	x1 = actr->x;
-	y1 = actr->y;
+	int d = actr->last_dir;
+	int x1 = actr->x;
+	int y1 = actr->y;
 
 	switch (d) {
 	case 0:
@@ -1708,9 +1686,7 @@ int movement_sixteen(ACTOR *actr) {
 
 // Tornado 2
 int movement_seventeen(ACTOR *actr) {
-	int d;
-
-	d = actr->last_dir;
+	int d = actr->last_dir;
 
 	switch (d) {
 	case 0:
@@ -1816,9 +1792,7 @@ int movement_twentyone(ACTOR *actr) {
 
 // Spear
 int movement_twentytwo(ACTOR *actr) {
-	int d;
-
-	d = actr->last_dir;
+	int d = actr->last_dir;
 	if (actr->directions == 1)
 		d = 0;
 
@@ -1908,9 +1882,7 @@ redo:
 
 // Spinball counter-clockwise
 int movement_twentythree(ACTOR *actr) {
-	int d;
-
-	d = actr->last_dir;
+	int d = actr->last_dir;
 	next_frame(actr);
 	if (actr->pass_value & 2)
 		actr->num_moves = 2;
@@ -2006,9 +1978,7 @@ int movement_twentythree(ACTOR *actr) {
 
 // Spinball  clockwise
 int movement_twentyfour(ACTOR *actr) {
-	int d;
-
-	d = actr->last_dir;
+	int d = actr->last_dir;
 	next_frame(actr);
 	if (actr->pass_value & 2)
 		actr->num_moves = 2;
@@ -2104,17 +2074,15 @@ int movement_twentyfour(ACTOR *actr) {
 
 // Acid puddle
 int movement_twentyfive(ACTOR *actr) {
-	int i, ret;
-
 	if (actr->temp2) {
 		actr->temp2--;
 		return movement_one(actr);
 	}
 	if (!actr->temp1) {
 		actr->last_dir = g_events->getRandomNumber(3);
-		i = 4;
+		int i = 4;
 		while (i--) {
-			ret = movement_three(actr);
+			int ret = movement_three(actr);
 			if (ret)
 				return ret;
 			actr->last_dir++;
@@ -2150,19 +2118,18 @@ void set_thor_vars() {
 	if (_G(thor)->dir > 1)
 		_G(thor_x2) = (_G(thor)->x + 12);
 	else
-		_G(thor_x2) = (_G(thor)->x + 12);
+		_G(thor_x2) = (_G(thor)->x + 12); // CHECKME : in check_move0() it's 10
 
 	_G(thor_y2) = _G(thor)->y + 15;
 }
 
 // Fish
 int movement_twentyeight(ACTOR *actr) {
-	int d, x1, y1, ret;
-
-	d = actr->last_dir;
-	x1 = actr->x;
-	y1 = actr->y;
-
+	int d = actr->last_dir;
+	int x1 = actr->x;
+	int y1 = actr->y;
+	int ret;
+	
 	if (actr->i1)
 		actr->i1--;
 	else {
@@ -2206,6 +2173,7 @@ int movement_twentyeight(ACTOR *actr) {
 		x1 += 2;
 		break;
 	}
+	
 	ret = bgtile(x1, y1);
 	if (ret != 100 && ret != 106 && ret != 110 && ret != 111 && ret != 113)
 		goto chg_dir;
@@ -2246,17 +2214,15 @@ done:
 int movement_twentynine(ACTOR *actr) {
 	if (!actr->pass_value)
 		return movement_thirty(actr);
-	else
-		return movement_twelve(actr);
+
+	return movement_twelve(actr);
 }
 
 // Vert straight
 int movement_thirty(ACTOR *actr) {
-	int d, x1, y1;
-
-	d = actr->last_dir;
-	x1 = actr->x;
-	y1 = actr->y;
+	int d = actr->last_dir;
+	int x1 = actr->x;
+	int y1 = actr->y;
 
 	switch (d) {
 	case 0:
@@ -2278,29 +2244,23 @@ int movement_thirty(ACTOR *actr) {
 
 // Drop (stalagtite)
 int movement_thirtyone(ACTOR *actr) {
-	int d, x1, y1, cx, cy, ty, i;
-
-	d = actr->last_dir;
-	x1 = actr->x;
-	y1 = actr->y;
+	int d = actr->last_dir;
+	int x1 = actr->x;
+	int y1 = actr->y;
 
 	if (actr->temp1) {
 		y1 += 2;
 		if (!check_move2(x1, y1, actr))
 			actor_destroyed(actr);
-	} else {
-		if (_G(thor_y1) > y1) {
-			if (ABS(x1 - _G(thor_x1)) < 16) {
-				cx = (actr->x + (actr->size_x / 2)) >> 4;
-				cy = ((actr->y + actr->size_y) - 2) >> 4;
-				ty = _G(thor)->center_y;
-				for (i = cy; i <= ty; i++)
-					if (_G(scrn).icon[i][cx] < TILE_SOLID)
-						goto done;
-				actr->num_moves = actr->pass_value + 1;
-				actr->temp1 = 1;
-			}
-		}
+	} else if (_G(thor_y1) > y1 && ABS(x1 - _G(thor_x1)) < 16) {
+		int cx = (actr->x + (actr->size_x / 2)) >> 4;
+		int cy = ((actr->y + actr->size_y) - 2) >> 4;
+		int ty = _G(thor)->center_y;
+		for (int i = cy; i <= ty; i++)
+			if (_G(scrn).icon[i][cx] < TILE_SOLID)
+				goto done;
+		actr->num_moves = actr->pass_value + 1;
+		actr->temp1 = 1;
 	}
 
 done:
@@ -2345,13 +2305,11 @@ int movement_thirtysix(ACTOR *actr) {
 
 // 4-way straight (random length) change
 int movement_thirtyseven(ACTOR *actr) {
-	int d, x1, y1, f;
-
-	d = actr->last_dir;
-	x1 = actr->x;
-	y1 = actr->y;
+	int d = actr->last_dir;
+	int x1 = actr->x;
+	int y1 = actr->y;
 
-	f = 0;
+	int f = 0;
 	if (actr->counter) {
 		actr->counter--;
 		switch (d) {
@@ -2399,11 +2357,9 @@ int movement_thirtyseven(ACTOR *actr) {
 #define OY actr->i3
 #define CNT actr->i4
 int movement_thirtyeight(ACTOR *actr) {
-	int d, x1, y1;
-
-	d = actr->last_dir;
-	x1 = actr->x;
-	y1 = actr->y;
+	int d = actr->last_dir;
+	int x1 = actr->x;
+	int y1 = actr->y;
 
 	if (!FLAG) {
 		FLAG = 1;
@@ -2529,20 +2485,18 @@ int movement_thirtynine(ACTOR *actr) {
 
 // Troll 2
 int movement_forty(ACTOR *actr) {
-	int x1, x2, a, d, f;
-
 	if (overlap(actr->x + 1, actr->y + 1, actr->x + actr->size_x + 3,
 				actr->y + actr->size_y - 1, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
 		actr->strength = 150;
 		thor_damaged(actr);
 	}
-	a = 5 + (actr->pass_value * 4);
-	x1 = actr->x;
-	x2 = _G(actor[a + 1]).x;
-	d = actr->last_dir;
+	int a = 5 + (actr->pass_value * 4);
+	int x1 = actr->x;
+	int x2 = _G(actor[a + 1]).x;
+	int d = actr->last_dir;
 
+	int f = 1;
 	if (actr->last_dir == 2) {
-		f = 1;
 		if (bgtile(x1 - 2, actr->y) >= TILE_SOLID) {
 			_G(actor[a].x) -= 2;
 			_G(actor[a - 1]).x -= 2;
@@ -2553,7 +2507,6 @@ int movement_forty(ACTOR *actr) {
 		if (!f)
 			d = 3;
 	} else {
-		f = 1;
 		if (bgtile(_G(actor[a + 1]).x + 14, _G(actor[a + 1]).y) >= TILE_SOLID) {
 			_G(actor[a]).x += 2;
 			_G(actor[a - 1]).x += 2;


Commit: 943918a02905327111e62206bd2c3f867ede58df
    https://github.com/scummvm/scummvm/commit/943918a02905327111e62206bd2c3f867ede58df
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Modify access to global arrays in back.cpp and boss1.cpp

Changed paths:
    engines/got/game/back.cpp
    engines/got/game/boss1.cpp


diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index aad8d25cc99..f0fc78fa8ed 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -51,7 +51,7 @@ static const char *odinEndMessage;
 void show_level(int new_level) {
 	_G(boss_active) = false;
     if (!_G(shield_on))
-        _G(actor)[2].used = 0;
+        _G(actor[2]).used = 0;
     _G(bomb_flag) = false;
     _G(slipping) = false;
 
@@ -253,20 +253,20 @@ void kill_enemies(int iy, int ix) {
     int i, x1, y1, x2, y2;
 
     for (i = 3; i < MAX_ACTORS; i++) {
-        if (_G(actor)[i].used) {
-            x1 = _G(actor)[i].x;
-            y1 = _G(actor)[i].y + _G(actor)[i].size_y - 2;
-            x2 = (_G(actor)[i].x + _G(actor)[i].size_x);
-            y2 = _G(actor)[i].y + _G(actor)[i].size_y - 1;
+        if (_G(actor[i]).used) {
+            x1 = _G(actor[i]).x;
+            y1 = _G(actor[i]).y + _G(actor[i]).size_y - 2;
+            x2 = (_G(actor[i]).x + _G(actor[i]).size_x);
+            y2 = _G(actor[i]).y + _G(actor[i]).size_y - 1;
 
             if (point_within(x1, y1, ix, iy, ix + 15, iy + 15))
-                actor_destroyed(&_G(actor)[i]);
+                actor_destroyed(&_G(actor[i]));
             else if (point_within(x2, y1, ix, iy, ix + 15, iy + 15))
-                actor_destroyed(&_G(actor)[i]);
+                actor_destroyed(&_G(actor[i]));
             else if (point_within(x1, y2, ix, iy, ix + 15, iy + 15))
-                actor_destroyed(&_G(actor)[i]);
+                actor_destroyed(&_G(actor[i]));
             else if (point_within(x2, y2, ix, iy, ix + 15, iy + 15))
-                actor_destroyed(&_G(actor)[i]);
+                actor_destroyed(&_G(actor[i]));
         }
     }
 
@@ -289,13 +289,11 @@ dead:
 }
 
 void remove_objects(int y, int x) {
-    int p;
+	int p = (y * 20) + x;
 
-    p = (y * 20) + x;
-
-    if (_G(object_map)[p] > 0) {
-        _G(object_map)[p] = 0;
-        _G(object_index)[p] = 0;
+    if (_G(object_map[p]) > 0) {
+        _G(object_map[p]) = 0;
+        _G(object_index[p]) = 0;
     }
 }
 
diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index 9371af9762a..6a3e61f7e5f 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -111,15 +111,15 @@ int boss1_movement(ACTOR *actr) {
         actr->counter--;
         switch (d) {
         case 1:
-            x1 = _G(actor)[5].x;
-            y1 = _G(actor)[5].y;
+            x1 = _G(actor[5]).x;
+            y1 = _G(actor[5]).y;
             y1 += 2;
 
-            if (!check_move2(x1, y1, &_G(actor)[5]))
+            if (!check_move2(x1, y1, &_G(actor[5])))
                 f = 1;
             else {
-                actr->x = _G(actor)[5].x;
-                actr->y = _G(actor)[5].y - 16;
+                actr->x = _G(actor[5]).x;
+                actr->y = _G(actor[5]).y - 16;
             }
             break;
         case 0:
@@ -127,14 +127,14 @@ int boss1_movement(ACTOR *actr) {
             if (!check_move2(x1, y1, actr)) f = 1;
             break;
         case 3:
-            x1 = _G(actor)[5].x;
-            y1 = _G(actor)[5].y;
+            x1 = _G(actor[5]).x;
+            y1 = _G(actor[5]).y;
             y1 += 2;
-            if (!check_move2(x1, y1, &_G(actor)[5]))
+            if (!check_move2(x1, y1, &_G(actor[5])))
 				f = 1;
             else {
-                actr->x = _G(actor)[5].x;
-                actr->y = _G(actor)[5].y - 16;
+                actr->x = _G(actor[5]).x;
+                actr->y = _G(actor[5]).y - 16;
             }
             break;
         case 2:
@@ -162,23 +162,23 @@ done0:
 done1:
     actr->last_dir = d;
 
-    _G(actor)[4].next = actr->next;
-    _G(actor)[5].next = actr->next;
-    _G(actor)[6].next = actr->next;
+    _G(actor[4]).next = actr->next;
+    _G(actor[5]).next = actr->next;
+    _G(actor[6]).next = actr->next;
 
-    _G(actor)[4].last_dir = d;
-    _G(actor)[5].last_dir = d;
-    _G(actor)[6].last_dir = d;
+    _G(actor[4]).last_dir = d;
+    _G(actor[5]).last_dir = d;
+    _G(actor[6]).last_dir = d;
 
-    _G(actor)[4].x = actr->x + 16;
-    _G(actor)[4].y = actr->y;
-    _G(actor)[5].x = actr->x;
-    _G(actor)[5].y = actr->y + 16;
-    _G(actor)[6].x = actr->x + 16;
-    _G(actor)[6].y = actr->y + 16;
-    _G(actor)[4].num_moves = actr->num_moves;
-    _G(actor)[5].num_moves = actr->num_moves;
-    _G(actor)[6].num_moves = actr->num_moves;
+    _G(actor[4]).x = actr->x + 16;
+    _G(actor[4]).y = actr->y;
+    _G(actor[5]).x = actr->x;
+    _G(actor[5]).y = actr->y + 16;
+    _G(actor[6]).x = actr->x + 16;
+    _G(actor[6]).y = actr->y + 16;
+    _G(actor[4]).num_moves = actr->num_moves;
+    _G(actor[5]).num_moves = actr->num_moves;
+    _G(actor[6]).num_moves = actr->num_moves;
 
     if (actr->directions == 1)
 		return 0;
@@ -187,26 +187,26 @@ done1:
 
 void check_boss1_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
 	if (actr->move == 15 && act_num == 4) {
-        if ((!_G(actor)[3].vunerable) && (_G(actor)[3].next != 3) &&
+        if ((!_G(actor[3]).vunerable) && (_G(actor[3]).next != 3) &&
                 overlap(x1, y1, x2, y2, actr->x + 6, actr->y + 4, actr->x + 14, actr->y + 20)) {
-            actor_damaged(&_G(actor)[3], _G(hammer)->strength);
-            if (_G(cheat) && _G(key_flag)[_Z])
-                _G(actor)[3].health = 0;
+            actor_damaged(&_G(actor[3]), _G(hammer)->strength);
+            if (_G(cheat) && _G(key_flag[_Z]))
+                _G(actor[3]).health = 0;
             else
-                _G(actor)[3].health -= 10;
+                _G(actor[3]).health -= 10;
 
-            _G(actor)[3].speed_count = 50;
-            boss_status(_G(actor)[3].health);
-            _G(actor)[3].vunerable = 100;
+            _G(actor[3]).speed_count = 50;
+            boss_status(_G(actor[3]).health);
+            _G(actor[3]).vunerable = 100;
             play_sound(BOSS13, true);
-            _G(actor)[3].next = 1;
+            _G(actor[3]).next = 1;
 
             for (int rep = 4; rep < 7; rep++) {
-                _G(actor)[rep].next = 1;
-                _G(actor)[rep].speed_count = 50;
+                _G(actor[rep]).next = 1;
+                _G(actor[rep]).speed_count = 50;
             }
 
-            if (_G(actor)[3].health == 0)
+            if (_G(actor[3]).health == 0)
                 _G(boss_dead) = true;
         }
     }
@@ -227,38 +227,38 @@ static int boss1_dead() {
 		int rep;
     	
 		for (rep = 0; rep < 4; rep++) {
-            int x1 = _G(actor)[3 + rep].last_x[_G(pge)];
-            int y1 = _G(actor)[3 + rep].last_y[_G(pge)];
-            int x = _G(actor)[3 + rep].x;
-            int y = _G(actor)[3 + rep].y;
-            int n = _G(actor)[3 + rep].actor_num;
-            int r = _G(actor)[3 + rep].rating;
-
-            _G(actor)[3 + rep] = _G(explosion);
-            _G(actor)[3 + rep].actor_num = n;
-            _G(actor)[3 + rep].rating = r;
-            _G(actor)[3 + rep].x = x;
-            _G(actor)[3 + rep].y = y;
-            _G(actor)[3 + rep].last_x[_G(pge)] = x1;
-            _G(actor)[3 + rep].last_x[_G(pge) ^ 1] = x;
-            _G(actor)[3 + rep].last_y[_G(pge)] = y1;
-            _G(actor)[3 + rep].last_y[_G(pge) ^ 1] = y;
-            _G(actor)[3 + rep].used = 1;
-            _G(actor)[3 + rep].vunerable = 255;
-            _G(actor)[3 + rep].move = 6;
-            _G(actor)[3 + rep].next = rep;
-            _G(actor)[3 + rep].speed = g_events->getRandomNumber(6, 8);
-            _G(actor)[3 + rep].num_shots = (10 - _G(actor)[3 + rep].speed) * 10;
-            _G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
+            int x1 = _G(actor[3 + rep]).last_x[_G(pge)];
+            int y1 = _G(actor[3 + rep]).last_y[_G(pge)];
+            int x = _G(actor[3 + rep]).x;
+            int y = _G(actor[3 + rep]).y;
+            int n = _G(actor[3 + rep]).actor_num;
+            int r = _G(actor[3 + rep]).rating;
+
+            _G(actor[3 + rep]) = _G(explosion);
+            _G(actor[3 + rep]).actor_num = n;
+            _G(actor[3 + rep]).rating = r;
+            _G(actor[3 + rep]).x = x;
+            _G(actor[3 + rep]).y = y;
+            _G(actor[3 + rep]).last_x[_G(pge)] = x1;
+            _G(actor[3 + rep]).last_x[_G(pge) ^ 1] = x;
+            _G(actor[3 + rep]).last_y[_G(pge)] = y1;
+            _G(actor[3 + rep]).last_y[_G(pge) ^ 1] = y;
+            _G(actor[3 + rep]).used = 1;
+            _G(actor[3 + rep]).vunerable = 255;
+            _G(actor[3 + rep]).move = 6;
+            _G(actor[3 + rep]).next = rep;
+            _G(actor[3 + rep]).speed = g_events->getRandomNumber(6, 8);
+            _G(actor[3 + rep]).num_shots = (10 - _G(actor[3 + rep]).speed) * 10;
+            _G(actor[3 + rep]).speed_count = _G(actor[3 + rep]).speed;
         }
         play_sound(EXPLODE, true);
         _G(boss_dead) = true;;
         for (rep = 7; rep < MAX_ACTORS; rep++)
-            if (_G(actor)[rep].used)
-                actor_destroyed(&_G(actor)[rep]);
+            if (_G(actor[rep]).used)
+                actor_destroyed(&_G(actor[rep]));
     }
 
-    return _G(actor)[3].last_dir;
+    return _G(actor[3]).last_dir;
 }
 
 void closing_sequence1() {


Commit: b94e80a1982c2e10cb6f91c52b4da6b0e36ddf68
    https://github.com/scummvm/scummvm/commit/b94e80a1982c2e10cb6f91c52b4da6b0e36ddf68
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: code formatting in back and boss1

Changed paths:
    engines/got/game/back.cpp
    engines/got/game/boss1.cpp


diff --git a/engines/got/game/back.cpp b/engines/got/game/back.cpp
index f0fc78fa8ed..6b1d7497820 100644
--- a/engines/got/game/back.cpp
+++ b/engines/got/game/back.cpp
@@ -19,8 +19,9 @@
  *
  */
 
-#include "common/file.h"
 #include "got/game/back.h"
+#include "common/file.h"
+#include "got/events.h"
 #include "got/game/boss1.h"
 #include "got/game/boss2.h"
 #include "got/game/boss3.h"
@@ -29,326 +30,327 @@
 #include "got/game/script.h"
 #include "got/gfx/image.h"
 #include "got/gfx/panel.h"
-#include "got/events.h"
 #include "got/vars.h"
 
 namespace Got {
 
 const char *OBJECT_NAMES[] = {
-    "Shrub","Child's Doll","UNUSED","FUTURE",
-    "FUTURE","FUTURE","FUTURE","FUTURE","FUTURE",
-    "FUTURE","FUTURE","FUTURE","FUTURE","FUTURE",
-    "FUTURE"
-};
+	"Shrub", "Child's Doll", "UNUSED", "FUTURE",
+	"FUTURE", "FUTURE", "FUTURE", "FUTURE", "FUTURE",
+	"FUTURE", "FUTURE", "FUTURE", "FUTURE", "FUTURE",
+	"FUTURE"};
 const char *ITEM_NAMES[] = {
-    "Enchanted Apple","Lightning Power",
-    "Winged Boots","Wind Power",
-    "Amulet of Protection","Thunder Power"
-};
+	"Enchanted Apple", "Lightning Power",
+	"Winged Boots", "Wind Power",
+	"Amulet of Protection", "Thunder Power"};
 
 static const char *odinEndMessage;
 
 void show_level(int new_level) {
 	_G(boss_active) = false;
-    if (!_G(shield_on))
-        _G(actor[2]).used = 0;
-    _G(bomb_flag) = false;
-    _G(slipping) = false;
-
-    int save_d = _G(thor)->dir;
-    if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154)
-        _G(thor)->dir = 0;
-
-    // The original copied 130 bytes from _G(scrn).static_object onwards into sd_data.
-    // This doesn't make sense, because that would put the ending in the middle of static_y.
-    // Plus, it follows with an entire copy of scrn into sd_data anyway, so the first
-    // move seems entirely redundant.
-    _G(scrn).save(_G(current_level));
-    _G(scrn).load(_G(new_level));
-
-    _G(level_type) = _G(scrn).type;
-
-    _G(thor)->next = 0;
-
-    show_objects();
-    show_enemies();
-
-    if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154) _G(thor)->dir = 0;
-    _G(thor)->dir = save_d;
-
-    if (_G(warp_flag))
-        _G(current_level) = new_level - 5;   // Force phase
-    _G(warp_flag) = false;
-
-    if (_G(warp_scroll)) {
-        _G(warp_scroll) = false;
-        if (_G(thor)->dir == 0)
-            _G(current_level) = new_level + 10;
-        else if (_G(thor)->dir == 1)
-            _G(current_level) = new_level - 10;
-        else if (_G(thor)->dir == 2)
-            _G(current_level) = new_level + 1;
-        else if (_G(thor)->dir == 3)
-            _G(current_level) = new_level - 1;
-    }
-
-    if (!_G(setup).scroll_flag)
-        _G(current_level) = new_level; // Force no scroll
-
-    if (_G(music_current) != _G(level_type))
-        _G(sound).music_pause();
-
-    switch (_G(new_level) - _G(current_level)) {
-    case 0:
-        // Nothing to do
-        show_level_done();
-        break;
-    case -1:
-        _G(gameMode) = MODE_AREA_CHANGE;
-        _G(transitionDir) = DIR_LEFT;
-        break;
-    case 1:
-        _G(gameMode) = MODE_AREA_CHANGE;
-        _G(transitionDir) = DIR_RIGHT;
-        break;
-    case -10:
-        _G(gameMode) = MODE_AREA_CHANGE;
-        _G(transitionDir) = DIR_UP;
-        break;
-    case 10:
-        _G(gameMode) = MODE_AREA_CHANGE;
-        _G(transitionDir) = DIR_DOWN;
-        break;
-    default:
-        _G(gameMode) = MODE_AREA_CHANGE;
-        _G(transitionDir) = DIR_PHASED;
-        break;
-    }
+	if (!_G(shield_on))
+		_G(actor[2]).used = 0;
+	_G(bomb_flag) = false;
+	_G(slipping) = false;
+
+	int save_d = _G(thor)->dir;
+	if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154)
+		_G(thor)->dir = 0;
+
+	// The original copied 130 bytes from _G(scrn).static_object onwards into sd_data.
+	// This doesn't make sense, because that would put the ending in the middle of static_y.
+	// Plus, it follows with an entire copy of scrn into sd_data anyway, so the first
+	// move seems entirely redundant.
+	_G(scrn).save(_G(current_level));
+	_G(scrn).load(_G(new_level));
+
+	_G(level_type) = _G(scrn).type;
+
+	_G(thor)->next = 0;
+
+	show_objects();
+	show_enemies();
+
+	if (_G(scrn).icon[_G(thor)->center_y][_G(thor)->center_x] == 154)
+		_G(thor)->dir = 0;
+	_G(thor)->dir = save_d;
+
+	if (_G(warp_flag))
+		_G(current_level) = new_level - 5; // Force phase
+	_G(warp_flag) = false;
+
+	if (_G(warp_scroll)) {
+		_G(warp_scroll) = false;
+		if (_G(thor)->dir == 0)
+			_G(current_level) = new_level + 10;
+		else if (_G(thor)->dir == 1)
+			_G(current_level) = new_level - 10;
+		else if (_G(thor)->dir == 2)
+			_G(current_level) = new_level + 1;
+		else if (_G(thor)->dir == 3)
+			_G(current_level) = new_level - 1;
+	}
+
+	if (!_G(setup).scroll_flag)
+		_G(current_level) = new_level; // Force no scroll
+
+	if (_G(music_current) != _G(level_type))
+		_G(sound).music_pause();
+
+	switch (_G(new_level) - _G(current_level)) {
+	case 0:
+		// Nothing to do
+		show_level_done();
+		break;
+	case -1:
+		_G(gameMode) = MODE_AREA_CHANGE;
+		_G(transitionDir) = DIR_LEFT;
+		break;
+	case 1:
+		_G(gameMode) = MODE_AREA_CHANGE;
+		_G(transitionDir) = DIR_RIGHT;
+		break;
+	case -10:
+		_G(gameMode) = MODE_AREA_CHANGE;
+		_G(transitionDir) = DIR_UP;
+		break;
+	case 10:
+		_G(gameMode) = MODE_AREA_CHANGE;
+		_G(transitionDir) = DIR_DOWN;
+		break;
+	default:
+		_G(gameMode) = MODE_AREA_CHANGE;
+		_G(transitionDir) = DIR_PHASED;
+		break;
+	}
 }
 
-
 void show_level_done() {
-    _G(current_level) = _G(new_level);
-
-    _G(thor_info).last_health = _G(thor)->health;
-    _G(thor_info).last_magic = _G(thor_info).magic;
-    _G(thor_info).last_jewels = _G(thor_info).jewels;
-    _G(thor_info).last_keys = _G(thor_info).keys;
-    _G(thor_info).last_score = _G(thor_info).score;
-    _G(thor_info).last_item = _G(thor_info).item;
-    _G(thor_info).last_screen = _G(current_level);
-    _G(thor_info).last_icon = ((_G(thor)->x + 8) / 16) + (((_G(thor)->y + 14) / 16) * 20);
-    _G(thor_info).last_dir = _G(thor)->dir;
-    _G(thor_info).last_inventory = _G(thor_info).inventory;
-    _G(thor_info).last_object = _G(thor_info).object;
-    _G(thor_info).last_object_name = _G(thor_info).object_name;
-
-    _G(last_setup) = _G(setup);
-
-    bool f = true;
-    if (GAME1 && _G(new_level) == BOSS_LEVEL1) {
-        if (!_G(setup).boss_dead[0]) {
-            if (!_G(auto_load))
-                boss_level1();
-            f = false;
-        }
-    }
-    if (GAME2 && _G(new_level) == BOSS_LEVEL2) {
-        if (!_G(setup).boss_dead[1]) {
-            if (!_G(auto_load))
-                boss_level2();
-            f = false;
-        }
-    }
-    if (GAME3) {
-        if (_G(new_level) == BOSS_LEVEL3) {
-            if (!_G(setup).boss_dead[2]) {
-                if (!_G(auto_load))
-                    boss_level3();
-                f = false;
-            }
-        }
-        if (_G(current_level) == ENDING_SCREEN) {
-            ending_screen();
-            f = false;
-        }
-    }
-
-    if (_G(startup))
-        f = false;
-    if (f)
-        music_play(_G(level_type), false);
+	_G(current_level) = _G(new_level);
+
+	_G(thor_info).last_health = _G(thor)->health;
+	_G(thor_info).last_magic = _G(thor_info).magic;
+	_G(thor_info).last_jewels = _G(thor_info).jewels;
+	_G(thor_info).last_keys = _G(thor_info).keys;
+	_G(thor_info).last_score = _G(thor_info).score;
+	_G(thor_info).last_item = _G(thor_info).item;
+	_G(thor_info).last_screen = _G(current_level);
+	_G(thor_info).last_icon = ((_G(thor)->x + 8) / 16) + (((_G(thor)->y + 14) / 16) * 20);
+	_G(thor_info).last_dir = _G(thor)->dir;
+	_G(thor_info).last_inventory = _G(thor_info).inventory;
+	_G(thor_info).last_object = _G(thor_info).object;
+	_G(thor_info).last_object_name = _G(thor_info).object_name;
+
+	_G(last_setup) = _G(setup);
+
+	bool f = true;
+	if (GAME1 && _G(new_level) == BOSS_LEVEL1) {
+		if (!_G(setup).boss_dead[0]) {
+			if (!_G(auto_load))
+				boss_level1();
+			f = false;
+		}
+	}
+	if (GAME2 && _G(new_level) == BOSS_LEVEL2) {
+		if (!_G(setup).boss_dead[1]) {
+			if (!_G(auto_load))
+				boss_level2();
+			f = false;
+		}
+	}
+	if (GAME3) {
+		if (_G(new_level) == BOSS_LEVEL3) {
+			if (!_G(setup).boss_dead[2]) {
+				if (!_G(auto_load))
+					boss_level3();
+				f = false;
+			}
+		}
+		if (_G(current_level) == ENDING_SCREEN) {
+			ending_screen();
+			f = false;
+		}
+	}
+
+	if (_G(startup))
+		f = false;
+	if (f)
+		music_play(_G(level_type), false);
 }
 
 static void odin_speaks_end() {
-    // In case Thor is now dead, flag as such
-    if (!_G(thor)->health) {
-        _G(thor)->show = 0;
-        _G(exit_flag) = 2;
-    }
-
-    // If there's an end message, pass it on to the view hierarchy.
-    // This is used in cases like the game end where multiple
-    // odin_speaks are done in sequence
-    if (odinEndMessage)
-        g_events->send(GameMessage(odinEndMessage));
+	// In case Thor is now dead, flag as such
+	if (!_G(thor)->health) {
+		_G(thor)->show = 0;
+		_G(exit_flag) = 2;
+	}
+
+	// If there's an end message, pass it on to the view hierarchy.
+	// This is used in cases like the game end where multiple
+	// odin_speaks are done in sequence
+	if (odinEndMessage)
+		g_events->send(GameMessage(odinEndMessage));
 }
 
 void odin_speaks(int index, int item, const char *endMessage) {
-    odinEndMessage = endMessage;
+	odinEndMessage = endMessage;
 
-    execute_script((long)index, _G(odin), odin_speaks_end);
+	execute_script((long)index, _G(odin), odin_speaks_end);
 }
 
-
 int switch_icons() {
-    int ix, iy;
-
-    play_sound(WOOP, false);
-
-    for (int y = 0; y < 12; y++) {
-        for (int x = 0; x < 20; x++) {
-            ix = x * 16;
-            iy = y * 16;
-            if (_G(scrn).icon[y][x] == 93) {
-                place_tile(x, y, 144);
-            } else if (_G(scrn).icon[y][x] == 144) {
-                place_tile(x, y, 93);
-                kill_enemies(iy, ix);
-            }
-            if (_G(scrn).icon[y][x] == 94) {
-                place_tile(x, y, 146);
-            } else if (_G(scrn).icon[y][x] == 146) {
-                place_tile(x, y, 94);
-                kill_enemies(iy, ix);
-            }
-        }
-    }
-
-    return 0;
+	int ix, iy;
+
+	play_sound(WOOP, false);
+
+	for (int y = 0; y < 12; y++) {
+		for (int x = 0; x < 20; x++) {
+			ix = x * 16;
+			iy = y * 16;
+			if (_G(scrn).icon[y][x] == 93) {
+				place_tile(x, y, 144);
+			} else if (_G(scrn).icon[y][x] == 144) {
+				place_tile(x, y, 93);
+				kill_enemies(iy, ix);
+			}
+			if (_G(scrn).icon[y][x] == 94) {
+				place_tile(x, y, 146);
+			} else if (_G(scrn).icon[y][x] == 146) {
+				place_tile(x, y, 94);
+				kill_enemies(iy, ix);
+			}
+		}
+	}
+
+	return 0;
 }
 
 int rotate_arrows() {
-    int x, y;
-
-    play_sound(WOOP, false);
-
-    for (y = 0; y < 12; y++) {
-        for (x = 0; x < 20; x++) {
-            if (_G(scrn).icon[y][x] == 205)
-                place_tile(x, y, 208);
-            else if (_G(scrn).icon[y][x] == 206)
-                place_tile(x, y, 207);
-            else if (_G(scrn).icon[y][x] == 207)
-                place_tile(x, y, 205);
-            else if (_G(scrn).icon[y][x] == 208)
-                place_tile(x, y, 206);
-        }
-    }
-
-    return 0;
+	int x, y;
+
+	play_sound(WOOP, false);
+
+	for (y = 0; y < 12; y++) {
+		for (x = 0; x < 20; x++) {
+			if (_G(scrn).icon[y][x] == 205)
+				place_tile(x, y, 208);
+			else if (_G(scrn).icon[y][x] == 206)
+				place_tile(x, y, 207);
+			else if (_G(scrn).icon[y][x] == 207)
+				place_tile(x, y, 205);
+			else if (_G(scrn).icon[y][x] == 208)
+				place_tile(x, y, 206);
+		}
+	}
+
+	return 0;
 }
 
 void kill_enemies(int iy, int ix) {
-    int i, x1, y1, x2, y2;
-
-    for (i = 3; i < MAX_ACTORS; i++) {
-        if (_G(actor[i]).used) {
-            x1 = _G(actor[i]).x;
-            y1 = _G(actor[i]).y + _G(actor[i]).size_y - 2;
-            x2 = (_G(actor[i]).x + _G(actor[i]).size_x);
-            y2 = _G(actor[i]).y + _G(actor[i]).size_y - 1;
-
-            if (point_within(x1, y1, ix, iy, ix + 15, iy + 15))
-                actor_destroyed(&_G(actor[i]));
-            else if (point_within(x2, y1, ix, iy, ix + 15, iy + 15))
-                actor_destroyed(&_G(actor[i]));
-            else if (point_within(x1, y2, ix, iy, ix + 15, iy + 15))
-                actor_destroyed(&_G(actor[i]));
-            else if (point_within(x2, y2, ix, iy, ix + 15, iy + 15))
-                actor_destroyed(&_G(actor[i]));
-        }
-    }
-
-    x1 = _G(thor)->x;
-    y1 = _G(thor)->y + 11;
-    x2 = x1 + 13;
-    y2 = y1 + 5;
-
-    if (point_within(x1, y1, ix, iy, ix + 15, iy + 15)) goto dead;
-    if (point_within(x2, y1, ix, iy, ix + 15, iy + 15)) goto dead;
-    if (point_within(x1, y2, ix, iy, ix + 15, iy + 15)) goto dead;
-    if (point_within(x2, y2, ix, iy, ix + 15, iy + 15)) goto dead;
-    return;
+	int i, x1, y1, x2, y2;
+
+	for (i = 3; i < MAX_ACTORS; i++) {
+		if (_G(actor[i]).used) {
+			x1 = _G(actor[i]).x;
+			y1 = _G(actor[i]).y + _G(actor[i]).size_y - 2;
+			x2 = (_G(actor[i]).x + _G(actor[i]).size_x);
+			y2 = _G(actor[i]).y + _G(actor[i]).size_y - 1;
+
+			if (point_within(x1, y1, ix, iy, ix + 15, iy + 15))
+				actor_destroyed(&_G(actor[i]));
+			else if (point_within(x2, y1, ix, iy, ix + 15, iy + 15))
+				actor_destroyed(&_G(actor[i]));
+			else if (point_within(x1, y2, ix, iy, ix + 15, iy + 15))
+				actor_destroyed(&_G(actor[i]));
+			else if (point_within(x2, y2, ix, iy, ix + 15, iy + 15))
+				actor_destroyed(&_G(actor[i]));
+		}
+	}
+
+	x1 = _G(thor)->x;
+	y1 = _G(thor)->y + 11;
+	x2 = x1 + 13;
+	y2 = y1 + 5;
+
+	if (point_within(x1, y1, ix, iy, ix + 15, iy + 15))
+		goto dead;
+	if (point_within(x2, y1, ix, iy, ix + 15, iy + 15))
+		goto dead;
+	if (point_within(x1, y2, ix, iy, ix + 15, iy + 15))
+		goto dead;
+	if (point_within(x2, y2, ix, iy, ix + 15, iy + 15))
+		goto dead;
+	return;
 
 dead:
-    if (!_G(cheats).freezeHealth) {
-        _G(thor)->health = 0;
-        g_events->send(GameMessage("THOR_DIES"));
-    }
+	if (!_G(cheats).freezeHealth) {
+		_G(thor)->health = 0;
+		g_events->send(GameMessage("THOR_DIES"));
+	}
 }
 
 void remove_objects(int y, int x) {
 	int p = (y * 20) + x;
 
-    if (_G(object_map[p]) > 0) {
-        _G(object_map[p]) = 0;
-        _G(object_index[p]) = 0;
-    }
+	if (_G(object_map[p]) > 0) {
+		_G(object_map[p]) = 0;
+		_G(object_index[p]) = 0;
+	}
 }
 
 void place_tile(int x, int y, int tile) {
-    _G(scrn).icon[y][x] = tile;
-    remove_objects(y, x);
+	_G(scrn).icon[y][x] = tile;
+	remove_objects(y, x);
 }
 
 int bgtile(int x, int y) {
-    if (x < 0 || x>319 || y < 0 || y>191) return 0;
+	if (x < 0 || x > 319 || y < 0 || y > 191)
+		return 0;
 
-    x = (x + 1) >> 4;
-    y = (y + 1) >> 4;
+	x = (x + 1) >> 4;
+	y = (y + 1) >> 4;
 
-    return _G(scrn).icon[y][x];
+	return _G(scrn).icon[y][x];
 }
 
 void select_item() {
-    // Only allow opening the dialog if something isn't currently going on
-    if (g_engine->canSaveAutosaveCurrently()) {
-        g_events->addView("SelectItem");
-    }
+	// Only allow opening the dialog if something isn't currently going on
+	if (g_engine->canSaveAutosaveCurrently()) {
+		g_events->addView("SelectItem");
+	}
 }
 
 int actor_speaks(ACTOR *actr, int index, int item) {
-    Common::String str;
-    int v;
-    long lind;
-
-    if (actr->type != 4)
-        return 0;
-    v = atoi(actr->name);
-    if (v < 1 || v>20)
-        return 0;
-
-    lind = (long)_G(current_level);
-    lind = lind * 1000;
-    lind += (long)actr->actor_num;
-
-    str = Common::String::format("FACE%d", v);
-    if (Common::File::exists(Common::Path(str))) {
-        Gfx::Pics pics(str, 262);
-        execute_script(lind, pics);
-    } else {
-        execute_script(lind, _G(odin));
-    }
-
-    if (!_G(thor)->health) {
-        _G(thor)->show = 0;
-        _G(exit_flag) = 2;
-    }
-
-    d_restore();
-
-    return 1;
+	Common::String str;
+	int v;
+	long lind;
+
+	if (actr->type != 4)
+		return 0;
+	v = atoi(actr->name);
+	if (v < 1 || v > 20)
+		return 0;
+
+	lind = (long)_G(current_level);
+	lind = lind * 1000;
+	lind += (long)actr->actor_num;
+
+	str = Common::String::format("FACE%d", v);
+	if (Common::File::exists(Common::Path(str))) {
+		Gfx::Pics pics(str, 262);
+		execute_script(lind, pics);
+	} else {
+		execute_script(lind, _G(odin));
+	}
+
+	if (!_G(thor)->health) {
+		_G(thor)->show = 0;
+		_G(exit_flag) = 2;
+	}
+
+	d_restore();
+
+	return 1;
 }
 
 } // namespace Got
diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index 6a3e61f7e5f..c4d531baac6 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "got/game/boss1.h"
+#include "got/events.h"
 #include "got/game/back.h"
 #include "got/game/init.h"
 #include "got/game/move.h"
@@ -27,281 +28,285 @@
 #include "got/game/status.h"
 #include "got/gfx/image.h"
 #include "got/gfx/panel.h"
-#include "got/vars.h"
-#include "got/events.h"
 #include "got/sound.h"
+#include "got/vars.h"
 
 namespace Got {
 
 static int boss1_dead();
 
 int boss1_movement(ACTOR *actr) {
-    int x1, y1, f;
-
-    if (_G(boss_dead))
-        return boss1_dead();
-
-    int d = actr->last_dir;
-    if (actr->edge_counter) {
-        actr->edge_counter--;
-        goto done;
-    }
-    x1 = actr->x;
-    y1 = actr->y;
-
-    if (overlap(actr->x + 2, actr->y + 8, actr->x + 30, actr->y + 30,
-                _G(thor)->x, _G(thor)->y + 8, _G(thor)->x + 15, _G(thor)->y + 15)) {
-        thor_damaged(actr);
-    }
-    if (actr->temp3) {  //start striking
-        actr->temp3--;
-        if (!actr->temp3)
+	int x1, y1, f;
+
+	if (_G(boss_dead))
+		return boss1_dead();
+
+	int d = actr->last_dir;
+	if (actr->edge_counter) {
+		actr->edge_counter--;
+		goto done;
+	}
+	x1 = actr->x;
+	y1 = actr->y;
+
+	if (overlap(actr->x + 2, actr->y + 8, actr->x + 30, actr->y + 30,
+				_G(thor)->x, _G(thor)->y + 8, _G(thor)->x + 15, _G(thor)->y + 15)) {
+		thor_damaged(actr);
+	}
+	if (actr->temp3) { //start striking
+		actr->temp3--;
+		if (!actr->temp3)
 			play_sound(BOSS11, false);
-    	
-        if (_G(hourglass_flag))
-            actr->num_moves = 3;
-        else
-            actr->num_moves = 6;
-
-        goto done0;
-    }
-
-    // Strike
-    if (actr->temp1) {
-        actr->temp1--;
-        if (actr->x < (_G(thor_x1) + 12))
-            actr->temp1 = 0;
-        actr->temp2 = 1;
-        d = 2;
-        actr->x -= 2;
-
-        if (overlap(actr->x + 2, actr->y + 8, actr->x + 32, actr->y + 30,
-                    _G(thor)->x, _G(thor)->y + 8, _G(thor)->x + 15, _G(thor)->y + 15)) {
-            actr->temp1 = 0;
-            goto done1;
-        }
-
-        actr->next = 3;
-        actr->num_moves = _G(setup).skill + 2;
-        goto done1;
-    }
-    if (actr->temp2) {          // Retreating
-        if (actr->x < 256) {
-            d = 3;
-            actr->x += 2;
-            if (overlap(actr->x + 2, actr->y + 8, actr->x + 32, actr->y + 30,
-                        _G(thor)->x, _G(thor)->y + 8, _G(thor)->x + 15, _G(thor)->y + 15)) {
-                goto done1;
-            }
-            actr->num_moves = _G(setup).skill + 1;
-            goto done0;
-        } else actr->temp2 = 0;
-    }
-    if (ABS((_G(thor_y1))-(actr->y + 20)) < 8) {
-        if (!actr->temp1) {
-            if (actr->x > _G(thor_x1)) {
-                actr->temp3 = 75;
-                actr->temp1 = 130;
-                actr->temp2 = 0;
-            }
-        }
-    }
-    f = 0;
-    if (actr->counter) {
-        actr->counter--;
-        switch (d) {
-        case 1:
-            x1 = _G(actor[5]).x;
-            y1 = _G(actor[5]).y;
-            y1 += 2;
-
-            if (!check_move2(x1, y1, &_G(actor[5])))
-                f = 1;
-            else {
-                actr->x = _G(actor[5]).x;
-                actr->y = _G(actor[5]).y - 16;
-            }
-            break;
-        case 0:
-            y1 -= 2;
-            if (!check_move2(x1, y1, actr)) f = 1;
-            break;
-        case 3:
-            x1 = _G(actor[5]).x;
-            y1 = _G(actor[5]).y;
-            y1 += 2;
-            if (!check_move2(x1, y1, &_G(actor[5])))
+
+		if (_G(hourglass_flag))
+			actr->num_moves = 3;
+		else
+			actr->num_moves = 6;
+
+		goto done0;
+	}
+
+	// Strike
+	if (actr->temp1) {
+		actr->temp1--;
+		if (actr->x < (_G(thor_x1) + 12))
+			actr->temp1 = 0;
+		actr->temp2 = 1;
+		d = 2;
+		actr->x -= 2;
+
+		if (overlap(actr->x + 2, actr->y + 8, actr->x + 32, actr->y + 30,
+					_G(thor)->x, _G(thor)->y + 8, _G(thor)->x + 15, _G(thor)->y + 15)) {
+			actr->temp1 = 0;
+			goto done1;
+		}
+
+		actr->next = 3;
+		actr->num_moves = _G(setup).skill + 2;
+		goto done1;
+	}
+	if (actr->temp2) { // Retreating
+		if (actr->x < 256) {
+			d = 3;
+			actr->x += 2;
+			if (overlap(actr->x + 2, actr->y + 8, actr->x + 32, actr->y + 30,
+						_G(thor)->x, _G(thor)->y + 8, _G(thor)->x + 15, _G(thor)->y + 15)) {
+				goto done1;
+			}
+			actr->num_moves = _G(setup).skill + 1;
+			goto done0;
+		} else
+			actr->temp2 = 0;
+	}
+	if (ABS((_G(thor_y1)) - (actr->y + 20)) < 8) {
+		if (!actr->temp1) {
+			if (actr->x > _G(thor_x1)) {
+				actr->temp3 = 75;
+				actr->temp1 = 130;
+				actr->temp2 = 0;
+			}
+		}
+	}
+	f = 0;
+	if (actr->counter) {
+		actr->counter--;
+		switch (d) {
+		case 1:
+			x1 = _G(actor[5]).x;
+			y1 = _G(actor[5]).y;
+			y1 += 2;
+
+			if (!check_move2(x1, y1, &_G(actor[5])))
+				f = 1;
+			else {
+				actr->x = _G(actor[5]).x;
+				actr->y = _G(actor[5]).y - 16;
+			}
+			break;
+		case 0:
+			y1 -= 2;
+			if (!check_move2(x1, y1, actr))
 				f = 1;
-            else {
-                actr->x = _G(actor[5]).x;
-                actr->y = _G(actor[5]).y - 16;
-            }
-            break;
-        case 2:
-            y1 -= 2;
-            if (!check_move2(x1, y1, actr)) f = 1;
-            break;
-        }
-    } else f = 1;
-
-    if (f == 1) {
-        actr->counter = g_events->getRandomNumber(10, 99);
-        d = g_events->getRandomNumber(1);
-        actr->edge_counter = 20;
-    }
+			break;
+		case 3:
+			x1 = _G(actor[5]).x;
+			y1 = _G(actor[5]).y;
+			y1 += 2;
+			if (!check_move2(x1, y1, &_G(actor[5])))
+				f = 1;
+			else {
+				actr->x = _G(actor[5]).x;
+				actr->y = _G(actor[5]).y - 16;
+			}
+			break;
+		case 2:
+			y1 -= 2;
+			if (!check_move2(x1, y1, actr))
+				f = 1;
+			break;
+		}
+	} else
+		f = 1;
+
+	if (f == 1) {
+		actr->counter = g_events->getRandomNumber(10, 99);
+		d = g_events->getRandomNumber(1);
+		actr->edge_counter = 20;
+	}
 
 done:
-    if (d > 1)
+	if (d > 1)
 		d -= 2;
 
 done0:
-    next_frame(actr);
-    if (actr->next == 3)
+	next_frame(actr);
+	if (actr->next == 3)
 		actr->next = 0;
 
 done1:
-    actr->last_dir = d;
-
-    _G(actor[4]).next = actr->next;
-    _G(actor[5]).next = actr->next;
-    _G(actor[6]).next = actr->next;
-
-    _G(actor[4]).last_dir = d;
-    _G(actor[5]).last_dir = d;
-    _G(actor[6]).last_dir = d;
-
-    _G(actor[4]).x = actr->x + 16;
-    _G(actor[4]).y = actr->y;
-    _G(actor[5]).x = actr->x;
-    _G(actor[5]).y = actr->y + 16;
-    _G(actor[6]).x = actr->x + 16;
-    _G(actor[6]).y = actr->y + 16;
-    _G(actor[4]).num_moves = actr->num_moves;
-    _G(actor[5]).num_moves = actr->num_moves;
-    _G(actor[6]).num_moves = actr->num_moves;
-
-    if (actr->directions == 1)
+	actr->last_dir = d;
+
+	_G(actor[4]).next = actr->next;
+	_G(actor[5]).next = actr->next;
+	_G(actor[6]).next = actr->next;
+
+	_G(actor[4]).last_dir = d;
+	_G(actor[5]).last_dir = d;
+	_G(actor[6]).last_dir = d;
+
+	_G(actor[4]).x = actr->x + 16;
+	_G(actor[4]).y = actr->y;
+	_G(actor[5]).x = actr->x;
+	_G(actor[5]).y = actr->y + 16;
+	_G(actor[6]).x = actr->x + 16;
+	_G(actor[6]).y = actr->y + 16;
+	_G(actor[4]).num_moves = actr->num_moves;
+	_G(actor[5]).num_moves = actr->num_moves;
+	_G(actor[6]).num_moves = actr->num_moves;
+
+	if (actr->directions == 1)
 		return 0;
-    return d;
+	return d;
 }
 
 void check_boss1_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
 	if (actr->move == 15 && act_num == 4) {
-        if ((!_G(actor[3]).vunerable) && (_G(actor[3]).next != 3) &&
-                overlap(x1, y1, x2, y2, actr->x + 6, actr->y + 4, actr->x + 14, actr->y + 20)) {
-            actor_damaged(&_G(actor[3]), _G(hammer)->strength);
-            if (_G(cheat) && _G(key_flag[_Z]))
-                _G(actor[3]).health = 0;
-            else
-                _G(actor[3]).health -= 10;
-
-            _G(actor[3]).speed_count = 50;
-            boss_status(_G(actor[3]).health);
-            _G(actor[3]).vunerable = 100;
-            play_sound(BOSS13, true);
-            _G(actor[3]).next = 1;
-
-            for (int rep = 4; rep < 7; rep++) {
-                _G(actor[rep]).next = 1;
-                _G(actor[rep]).speed_count = 50;
-            }
-
-            if (_G(actor[3]).health == 0)
-                _G(boss_dead) = true;
-        }
-    }
+		if ((!_G(actor[3]).vunerable) && (_G(actor[3]).next != 3) &&
+			overlap(x1, y1, x2, y2, actr->x + 6, actr->y + 4, actr->x + 14, actr->y + 20)) {
+			actor_damaged(&_G(actor[3]), _G(hammer)->strength);
+			if (_G(cheat) && _G(key_flag[_Z]))
+				_G(actor[3]).health = 0;
+			else
+				_G(actor[3]).health -= 10;
+
+			_G(actor[3]).speed_count = 50;
+			boss_status(_G(actor[3]).health);
+			_G(actor[3]).vunerable = 100;
+			play_sound(BOSS13, true);
+			_G(actor[3]).next = 1;
+
+			for (int rep = 4; rep < 7; rep++) {
+				_G(actor[rep]).next = 1;
+				_G(actor[rep]).speed_count = 50;
+			}
+
+			if (_G(actor[3]).health == 0)
+				_G(boss_dead) = true;
+		}
+	}
 }
 
 void boss_level1() {
-    setup_boss(1);
-    _G(boss_active) = true;
-    music_pause();
-    play_sound(BOSS11, true);
-    g_events->send("Game", GameMessage("PAUSE", 40));
-    music_play(5, true);
+	setup_boss(1);
+	_G(boss_active) = true;
+	music_pause();
+	play_sound(BOSS11, true);
+	g_events->send("Game", GameMessage("PAUSE", 40));
+	music_play(5, true);
 }
 
 static int boss1_dead() {
-    _G(hourglass_flag) = 0;
-    if (_G(boss_dead)) {
+	_G(hourglass_flag) = 0;
+	if (_G(boss_dead)) {
 		int rep;
-    	
+
 		for (rep = 0; rep < 4; rep++) {
-            int x1 = _G(actor[3 + rep]).last_x[_G(pge)];
-            int y1 = _G(actor[3 + rep]).last_y[_G(pge)];
-            int x = _G(actor[3 + rep]).x;
-            int y = _G(actor[3 + rep]).y;
-            int n = _G(actor[3 + rep]).actor_num;
-            int r = _G(actor[3 + rep]).rating;
-
-            _G(actor[3 + rep]) = _G(explosion);
-            _G(actor[3 + rep]).actor_num = n;
-            _G(actor[3 + rep]).rating = r;
-            _G(actor[3 + rep]).x = x;
-            _G(actor[3 + rep]).y = y;
-            _G(actor[3 + rep]).last_x[_G(pge)] = x1;
-            _G(actor[3 + rep]).last_x[_G(pge) ^ 1] = x;
-            _G(actor[3 + rep]).last_y[_G(pge)] = y1;
-            _G(actor[3 + rep]).last_y[_G(pge) ^ 1] = y;
-            _G(actor[3 + rep]).used = 1;
-            _G(actor[3 + rep]).vunerable = 255;
-            _G(actor[3 + rep]).move = 6;
-            _G(actor[3 + rep]).next = rep;
-            _G(actor[3 + rep]).speed = g_events->getRandomNumber(6, 8);
-            _G(actor[3 + rep]).num_shots = (10 - _G(actor[3 + rep]).speed) * 10;
-            _G(actor[3 + rep]).speed_count = _G(actor[3 + rep]).speed;
-        }
-        play_sound(EXPLODE, true);
-        _G(boss_dead) = true;;
-        for (rep = 7; rep < MAX_ACTORS; rep++)
-            if (_G(actor[rep]).used)
-                actor_destroyed(&_G(actor[rep]));
-    }
-
-    return _G(actor[3]).last_dir;
+			int x1 = _G(actor[3 + rep]).last_x[_G(pge)];
+			int y1 = _G(actor[3 + rep]).last_y[_G(pge)];
+			int x = _G(actor[3 + rep]).x;
+			int y = _G(actor[3 + rep]).y;
+			int n = _G(actor[3 + rep]).actor_num;
+			int r = _G(actor[3 + rep]).rating;
+
+			_G(actor[3 + rep]) = _G(explosion);
+			_G(actor[3 + rep]).actor_num = n;
+			_G(actor[3 + rep]).rating = r;
+			_G(actor[3 + rep]).x = x;
+			_G(actor[3 + rep]).y = y;
+			_G(actor[3 + rep]).last_x[_G(pge)] = x1;
+			_G(actor[3 + rep]).last_x[_G(pge) ^ 1] = x;
+			_G(actor[3 + rep]).last_y[_G(pge)] = y1;
+			_G(actor[3 + rep]).last_y[_G(pge) ^ 1] = y;
+			_G(actor[3 + rep]).used = 1;
+			_G(actor[3 + rep]).vunerable = 255;
+			_G(actor[3 + rep]).move = 6;
+			_G(actor[3 + rep]).next = rep;
+			_G(actor[3 + rep]).speed = g_events->getRandomNumber(6, 8);
+			_G(actor[3 + rep]).num_shots = (10 - _G(actor[3 + rep]).speed) * 10;
+			_G(actor[3 + rep]).speed_count = _G(actor[3 + rep]).speed;
+		}
+		play_sound(EXPLODE, true);
+		_G(boss_dead) = true;
+		;
+		for (rep = 7; rep < MAX_ACTORS; rep++)
+			if (_G(actor[rep]).used)
+				actor_destroyed(&_G(actor[rep]));
+	}
+
+	return _G(actor[3]).last_dir;
 }
 
 void closing_sequence1() {
-    _G(game_over) = true;
-    music_play(4, true);
-    odin_speaks(1001, 13, "CLOSING");
+	_G(game_over) = true;
+	music_play(4, true);
+	odin_speaks(1001, 13, "CLOSING");
 }
 
 void closing_sequence1_2() {
-    _G(thor_info).armor = 1;
-    load_new_thor();
-    _G(thor)->dir = 1;
-    _G(thor)->next = 0;
-    fill_score(20, "CLOSING");
+	_G(thor_info).armor = 1;
+	load_new_thor();
+	_G(thor)->dir = 1;
+	_G(thor)->next = 0;
+	fill_score(20, "CLOSING");
 }
 
 void closing_sequence1_3() {
-    fill_health();
-    fill_magic();
-    odin_speaks(1002, 0, "CLOSING");
+	fill_health();
+	fill_magic();
+	odin_speaks(1002, 0, "CLOSING");
 }
 
 void closing_sequence1_4() {
 	for (int rep = 0; rep < 16; rep++)
 		_G(scrn).actor_type[rep] = 0;
-	
-    _G(boss_dead) = false;
-    _G(setup).boss_dead[0] = 1;
-    _G(boss_active) = false;
-    _G(scrn).type = 4;
-    show_level(BOSS_LEVEL1);
-
-    play_sound(ANGEL, true);
-    place_tile(18, 6, 148);
-    place_tile(19, 6, 202);
-    actor_visible(1);
-    actor_visible(2);
-
-    LEVEL lvl;
-    lvl.load(59);
-    lvl.icon[6][18] = 148;
-    lvl.icon[6][19] = 202;
-    lvl.save(59);
+
+	_G(boss_dead) = false;
+	_G(setup).boss_dead[0] = 1;
+	_G(boss_active) = false;
+	_G(scrn).type = 4;
+	show_level(BOSS_LEVEL1);
+
+	play_sound(ANGEL, true);
+	place_tile(18, 6, 148);
+	place_tile(19, 6, 202);
+	actor_visible(1);
+	actor_visible(2);
+
+	LEVEL lvl;
+	lvl.load(59);
+	lvl.icon[6][18] = 148;
+	lvl.icon[6][19] = 202;
+	lvl.save(59);
 }
 
 } // namespace Got


Commit: b5299d123b7fd2a0b2db524d325c6bbab185b3ed
    https://github.com/scummvm/scummvm/commit/b5299d123b7fd2a0b2db524d325c6bbab185b3ed
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: remove extra semicolumn in boss1

Changed paths:
    engines/got/game/boss1.cpp


diff --git a/engines/got/game/boss1.cpp b/engines/got/game/boss1.cpp
index c4d531baac6..69ed8760b46 100644
--- a/engines/got/game/boss1.cpp
+++ b/engines/got/game/boss1.cpp
@@ -257,10 +257,11 @@ static int boss1_dead() {
 		}
 		play_sound(EXPLODE, true);
 		_G(boss_dead) = true;
-		;
-		for (rep = 7; rep < MAX_ACTORS; rep++)
+
+		for (rep = 7; rep < MAX_ACTORS; rep++) {
 			if (_G(actor[rep]).used)
 				actor_destroyed(&_G(actor[rep]));
+		}
 	}
 
 	return _G(actor[3]).last_dir;


Commit: 364789718ea409589f5fe2923567f64667dbfb48
    https://github.com/scummvm/scummvm/commit/364789718ea409589f5fe2923567f64667dbfb48
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Modify access to global arrays in boss2 and boss3

Changed paths:
    engines/got/game/boss2.cpp
    engines/got/game/boss3.cpp


diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index 0001efdd340..d1d84dd0840 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -124,15 +124,15 @@ int boss2_movement(ACTOR *actr) {
     if (actr->num_shots < num_skulls && !drop_flag) {
         if (x == 48 || x == 112 || x == 176 || x == 240) {
             drop_flag = true;
-            _G(actor)[3].temp6 = 40;
+            _G(actor[3]).temp6 = 40;
 
             actor_always_shoots(actr, 1);
             play_sound(FALL, false);
-            _G(actor)[actr->shot_actor].x = actr->x + 12;
-            _G(actor)[actr->shot_actor].y = actr->y + 32;
-            _G(actor)[actr->shot_actor].temp2 = 0;
-            _G(actor)[actr->shot_actor].temp3 = 4;
-            _G(actor)[actr->shot_actor].temp4 = 4;
+            _G(actor[actr->shot_actor]).x = actr->x + 12;
+            _G(actor[actr->shot_actor]).y = actr->y + 32;
+            _G(actor[actr->shot_actor]).temp2 = 0;
+            _G(actor[actr->shot_actor]).temp3 = 4;
+            _G(actor[actr->shot_actor]).temp4 = 4;
         }
     }
 
@@ -145,53 +145,53 @@ int boss2_movement(ACTOR *actr) {
 }
 
 static void boss_set(int d, int x, int y) {
-    _G(actor)[4].next = _G(actor)[3].next;
-    _G(actor)[5].next = _G(actor)[3].next;
-    _G(actor)[6].next = _G(actor)[3].next;
-    _G(actor)[3].last_dir = d;
-    _G(actor)[4].last_dir = d;
-    _G(actor)[5].last_dir = d;
-    _G(actor)[6].last_dir = d;
-    _G(actor)[4].x = x + 16;
-    _G(actor)[4].y = y;
-    _G(actor)[5].x = x;
-    _G(actor)[5].y = y + 16;
-    _G(actor)[6].x = x + 16;
-    _G(actor)[6].y = y + 16;
+    _G(actor[4]).next = _G(actor[3]).next;
+    _G(actor[5]).next = _G(actor[3]).next;
+    _G(actor[6]).next = _G(actor[3]).next;
+    _G(actor[3]).last_dir = d;
+    _G(actor[4]).last_dir = d;
+    _G(actor[5]).last_dir = d;
+    _G(actor[6]).last_dir = d;
+    _G(actor[4]).x = x + 16;
+    _G(actor[4]).y = y;
+    _G(actor[5]).x = x;
+    _G(actor[5]).y = y + 16;
+    _G(actor[6]).x = x + 16;
+    _G(actor[6]).y = y + 16;
 }
 
 void check_boss2_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
-    if ((!_G(actor)[3].vunerable)) {
+    if ((!_G(actor[3]).vunerable)) {
 		int rep;
 
-		actor_damaged(&_G(actor)[3], _G(hammer)->strength);
-        _G(actor)[3].health -= 10;
-        if (_G(actor)[3].health == 50) {
+		actor_damaged(&_G(actor[3]), _G(hammer)->strength);
+        _G(actor[3]).health -= 10;
+        if (_G(actor[3]).health == 50) {
             play_sound(BOSS12, 1);
 
             g_events->send("Game", GameMessage("PAUSE", 40));
 
-            _G(actor)[3].i1 = 1;
-            _G(actor)[3].i2 = 0;
+            _G(actor[3]).i1 = 1;
+            _G(actor[3]).i2 = 0;
             memset(expf, 0, 60);
             for (rep = 7; rep < MAX_ACTORS; rep++)
-                if (_G(actor)[rep].used)
-                    actor_destroyed(&_G(actor)[rep]);
-            _G(actor)[3].num_shots = 0;
+                if (_G(actor[rep]).used)
+                    actor_destroyed(&_G(actor[rep]));
+            _G(actor[3]).num_shots = 0;
         } else play_sound(BOSS13, true);
-        _G(actor)[3].speed_count = 75;
-        boss_status(_G(actor)[3].health);
-        _G(actor)[3].vunerable = 75;
-        _G(actor)[3].next = 1;
+        _G(actor[3]).speed_count = 75;
+        boss_status(_G(actor[3]).health);
+        _G(actor[3]).vunerable = 75;
+        _G(actor[3]).next = 1;
         for (rep = 4; rep < 7; rep++) {
-            _G(actor)[rep].next = 1;
-            _G(actor)[rep].speed_count = 50;
+            _G(actor[rep]).next = 1;
+            _G(actor[rep]).speed_count = 50;
         }
-        if (_G(actor)[3].health == 0) {
+        if (_G(actor[3]).health == 0) {
             _G(boss_dead) = true;
 			for (rep = 7; rep < MAX_ACTORS; rep++) {
-                if (_G(actor)[rep].used)
-                    actor_destroyed(&_G(actor)[rep]);
+                if (_G(actor[rep]).used)
+                    actor_destroyed(&_G(actor[rep]));
 			}
 		}
     }
@@ -217,55 +217,55 @@ static int boss2_die() {
     _G(thunder_flag) = 0;
     if (_G(boss_dead)) {
         for (int rep = 0; rep < 4; rep++) {
-            int x1 = _G(actor)[3 + rep].last_x[_G(pge)];
-            int y1 = _G(actor)[3 + rep].last_y[_G(pge)];
-            int x = _G(actor)[3 + rep].x;
-            int y = _G(actor)[3 + rep].y;
-            int n = _G(actor)[3 + rep].actor_num;
-            int r = _G(actor)[3 + rep].rating;
-
-            _G(actor)[3 + rep] = _G(explosion);
-
-            _G(actor)[3 + rep].actor_num = n;
-            _G(actor)[3 + rep].rating = r;
-            _G(actor)[3 + rep].x = x;
-            _G(actor)[3 + rep].y = y;
-            _G(actor)[3 + rep].last_x[_G(pge)] = x1;
-            _G(actor)[3 + rep].last_x[_G(pge) ^ 1] = x;
-            _G(actor)[3 + rep].last_y[_G(pge)] = y1;
-            _G(actor)[3 + rep].last_y[_G(pge) ^ 1] = y;
-            _G(actor)[3 + rep].used = 1;
-            _G(actor)[3 + rep].vunerable = 255;
-            _G(actor)[3 + rep].move = 6;
-            _G(actor)[3 + rep].next = rep;
-            _G(actor)[3 + rep].speed = g_events->getRandomNumber(6, 8);
-            _G(actor)[3 + rep].num_shots = (10 - _G(actor)[3 + rep].speed) * 10;
-            _G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
+            int x1 = _G(actor[3 + rep]).last_x[_G(pge)];
+            int y1 = _G(actor[3 + rep]).last_y[_G(pge)];
+            int x = _G(actor[3 + rep]).x;
+            int y = _G(actor[3 + rep]).y;
+            int n = _G(actor[3 + rep]).actor_num;
+            int r = _G(actor[3 + rep]).rating;
+
+            _G(actor[3 + rep]) = _G(explosion);
+
+            _G(actor[3 + rep]).actor_num = n;
+            _G(actor[3 + rep]).rating = r;
+            _G(actor[3 + rep]).x = x;
+            _G(actor[3 + rep]).y = y;
+            _G(actor[3 + rep]).last_x[_G(pge)] = x1;
+            _G(actor[3 + rep]).last_x[_G(pge) ^ 1] = x;
+            _G(actor[3 + rep]).last_y[_G(pge)] = y1;
+            _G(actor[3 + rep]).last_y[_G(pge) ^ 1] = y;
+            _G(actor[3 + rep]).used = 1;
+            _G(actor[3 + rep]).vunerable = 255;
+            _G(actor[3 + rep]).move = 6;
+            _G(actor[3 + rep]).next = rep;
+            _G(actor[3 + rep]).speed = g_events->getRandomNumber(6, 8);
+            _G(actor[3 + rep]).num_shots = (10 - _G(actor[3 + rep]).speed) * 10;
+            _G(actor[3 + rep]).speed_count = _G(actor[3 + rep]).speed;
         }
 
         play_sound(EXPLODE, true);
         _G(boss_dead) = true;;
     }
 
-    return _G(actor)[3].last_dir;
+    return _G(actor[3]).last_dir;
 }
 
 // Boss - skull (explode)
 static int boss2a_movement(ACTOR *actr) {
 	next_frame(actr);
-    _G(actor)[4].next = actr->next;
-    _G(actor)[5].next = actr->next;
-    _G(actor)[6].next = actr->next;
+    _G(actor[4]).next = actr->next;
+    _G(actor[5]).next = actr->next;
+    _G(actor[6]).next = actr->next;
     actr->vunerable = 20;
     if (actr->num_shots)
 		return 0;
-    if (_G(actor)[5].num_shots)
+    if (_G(actor[5]).num_shots)
 		return 0;
 
     play_sound(EXPLODE, true);
-    actor_always_shoots(&_G(actor)[5], 0);
-    int an = _G(actor)[5].shot_actor;
-    _G(actor)[an].move = 9;
+    actor_always_shoots(&_G(actor[5]), 0);
+    int an = _G(actor[5]).shot_actor;
+    _G(actor[an]).move = 9;
 
     int r = _G(rand1) % 60;
     while (expf[r]) {
@@ -275,16 +275,16 @@ static int boss2a_movement(ACTOR *actr) {
     expf[r] = 1;
     int x = (EXPLOSION[r] % 20) * 16;
     int y = (EXPLOSION[r] / 20) * 16;
-    _G(actor)[an].x = x;
-    _G(actor)[an].y = y;
+    _G(actor[an]).x = x;
+    _G(actor[an]).y = y;
 
     _G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
 
-    _G(actor)[3].i2++;
-    if (_G(actor)[3].i2 > 59) {
-        _G(actor)[3].i1 = 2;
-        _G(actor)[3].i2 = 0;
-        _G(actor)[3].num_moves = 3;
+    _G(actor[3]).i2++;
+    if (_G(actor[3]).i2 > 59) {
+        _G(actor[3]).i1 = 2;
+        _G(actor[3]).i2 = 0;
+        _G(actor[3]).num_moves = 3;
     }
 
     return 0;
@@ -298,9 +298,9 @@ static int boss2b_movement(ACTOR *actr) {
         hx = _G(hammer)->x;
         int hy = _G(hammer)->y;
         for (rep = 7; rep < 15; rep++) {
-            if (!_G(actor)[rep].used) continue;
-            if (overlap(hx + 1, hy + 1, hx + 10, hy + 10, _G(actor)[rep].x, _G(actor)[rep].y,
-                        _G(actor)[rep].x + _G(actor)[rep].size_x - 1, _G(actor)[rep].y + _G(actor)[rep].size_y - 1)) {
+            if (!_G(actor[rep]).used) continue;
+            if (overlap(hx + 1, hy + 1, hx + 10, hy + 10, _G(actor[rep]).x, _G(actor[rep]).y,
+                        _G(actor[rep]).x + _G(actor[rep]).size_x - 1, _G(actor[rep]).y + _G(actor[rep]).size_y - 1)) {
                 _G(hammer)->move = 5;
                 int d = reverse_direction(_G(hammer));
                 _G(hammer)->dir = d;
@@ -321,7 +321,7 @@ static int boss2b_movement(ACTOR *actr) {
         }
         goto done;
     }
-    if (_G(actor)[4].num_shots) goto done;
+    if (_G(actor[4]).num_shots) goto done;
 
     if (!actr->i3) {
         actr->i3 = g_events->getRandomNumber(2, 3);
@@ -337,25 +337,25 @@ static int boss2b_movement(ACTOR *actr) {
         actr->i2 = 0;
 
         Common::fill(su, su + 18, 0);
-        actor_always_shoots(&_G(actor)[4], 1);
-        an = _G(actor)[4].shot_actor;
+        actor_always_shoots(&_G(actor[4]), 1);
+        an = _G(actor[4]).shot_actor;
         hx = (_G(thor)->x / 16);
-        _G(actor)[an].x = _G(thor)->x;  //hx*16;
-        _G(actor)[an].y = g_events->getRandomNumber(15);
+        _G(actor[an]).x = _G(thor)->x;  //hx*16;
+        _G(actor[an]).y = g_events->getRandomNumber(15);
 
         su[hx] = 1;
-        _G(actor)[an].next = g_events->getRandomNumber(3);
+        _G(actor[an]).next = g_events->getRandomNumber(3);
         for(rep = 0; rep < num_spikes; rep++) {
             while (1) {
                 hx = g_events->getRandomNumber(17);
                 if (!su[hx]) break;
             }
             su[hx] = 1;
-            actor_always_shoots(&_G(actor)[4], 1);
-            an = _G(actor)[4].shot_actor;
-            _G(actor)[an].next = g_events->getRandomNumber(3);
-            _G(actor)[an].x = 16 + hx * 16;
-            _G(actor)[an].y = g_events->getRandomNumber(15);
+            actor_always_shoots(&_G(actor[4]), 1);
+            an = _G(actor[4]).shot_actor;
+            _G(actor[an]).next = g_events->getRandomNumber(3);
+            _G(actor[an]).x = 16 + hx * 16;
+            _G(actor[an]).y = g_events->getRandomNumber(15);
         }
     }
 
@@ -404,10 +404,10 @@ void closing_sequence2_4() {
     place_tile(19, 10, 202);
     actor_visible(1);
     actor_visible(2);
-    _G(actor)[7].x = 288;
-    _G(actor)[7].y = 160;
-    _G(actor)[8].x = 304;
-    _G(actor)[8].y = 160;
+    _G(actor[7]).x = 288;
+    _G(actor[7]).y = 160;
+    _G(actor[8]).x = 304;
+    _G(actor[8]).y = 160;
 
     lvl.load(BOSS_LEVEL2);
     lvl.icon[6][18] = 152;
diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index d22849edbd2..20ea71ec853 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -53,23 +53,23 @@ static void check_boss_hit();
 static void boss_change_mode();
 
 static void set_boss(ACTOR *actr) {
-    _G(actor)[4].next = actr->next;
-    _G(actor)[5].next = actr->next;
-    _G(actor)[6].next = actr->next;
-
-    _G(actor)[4].last_dir = actr->dir;
-    _G(actor)[5].last_dir = actr->dir;
-    _G(actor)[6].last_dir = actr->dir;
-    _G(actor)[4].dir = actr->dir;
-    _G(actor)[5].dir = actr->dir;
-    _G(actor)[6].dir = actr->dir;
-
-    _G(actor)[4].x = actr->x + 16;
-    _G(actor)[4].y = actr->y;
-    _G(actor)[5].x = actr->x;
-    _G(actor)[5].y = actr->y + 16;
-    _G(actor)[6].x = actr->x + 16;
-    _G(actor)[6].y = actr->y + 16;
+    _G(actor[4]).next = actr->next;
+    _G(actor[5]).next = actr->next;
+    _G(actor[6]).next = actr->next;
+
+    _G(actor[4]).last_dir = actr->dir;
+    _G(actor[5]).last_dir = actr->dir;
+    _G(actor[6]).last_dir = actr->dir;
+    _G(actor[4]).dir = actr->dir;
+    _G(actor[5]).dir = actr->dir;
+    _G(actor[6]).dir = actr->dir;
+
+    _G(actor[4]).x = actr->x + 16;
+    _G(actor[4]).y = actr->y;
+    _G(actor[5]).x = actr->x;
+    _G(actor[5]).y = actr->y + 16;
+    _G(actor[6]).x = actr->x + 16;
+    _G(actor[6]).y = actr->y + 16;
 }
 
 // Boss - Loki-2
@@ -99,9 +99,9 @@ static int boss_movement_one(ACTOR *actr) {
         actr->temp1 = 1;
         actr->i6 = 1;
         actr->solid |= 128;
-        _G(actor)[4].solid |= 128;
-        _G(actor)[5].solid |= 128;
-        _G(actor)[6].solid |= 128;
+        _G(actor[4]).solid |= 128;
+        _G(actor[5]).solid |= 128;
+        _G(actor[6]).solid |= 128;
         play_sound(EXPLODE, true);
         goto done;
     }
@@ -123,7 +123,7 @@ static int boss_movement_one(ACTOR *actr) {
         goto done1;
     } else if (actr->temp3) {
         for (i = 0; i < num_pods1; i++)
-            if (_G(actor)[19 + i].used)
+            if (_G(actor[19 + i]).used)
                 goto done1;
 
         while (1) {
@@ -154,9 +154,9 @@ static int boss_movement_one(ACTOR *actr) {
                 actr->temp4 = 0;
                 actr->temp5 = 80;
                 actr->solid &= 0x7f;
-                _G(actor)[4].solid &= 0x7f;
-                _G(actor)[5].solid &= 0x7f;
-                _G(actor)[6].solid &= 0x7f;
+                _G(actor[4]).solid &= 0x7f;
+                _G(actor[5]).solid &= 0x7f;
+                _G(actor[6]).solid &= 0x7f;
             }
 
             actr->frame_count = 3;
@@ -172,14 +172,15 @@ static int boss_movement_one(ACTOR *actr) {
             goto done1;
         }
         if (!actr->temp5) {
-            if (_G(actor)[4].num_shots < _G(actor)[4].shots_allowed) {
-                actor_always_shoots(&_G(actor)[4], 0);
-                _G(actor)[_G(actor)[4].shot_actor].num_moves = pod_speed;
-                _G(actor)[_G(actor)[4].shot_actor].x = actr->x + 8;
-                _G(actor)[_G(actor)[4].shot_actor].y = actr->y + 16;
-                _G(actor)[_G(actor)[4].shot_actor].temp5 = 0;
+            if (_G(actor[4]).num_shots < _G(actor[4]).shots_allowed) {
+                actor_always_shoots(&_G(actor[4]), 0);
+                const byte shot_actor = _G(actor[4]).shot_actor;
+				_G(actor[shot_actor]).num_moves = pod_speed;
+				_G(actor[shot_actor]).x = actr->x + 8;
+				_G(actor[shot_actor]).y = actr->y + 16;
+				_G(actor[shot_actor]).temp5 = 0;
                 for (i = 0; i < numPods; i++)
-                    _G(actor)[20 + i] = _G(actor)[19];
+                    _G(actor[20 + i]) = _G(actor[19]);
 
                 num_pods1 = numPods;
                 actr->temp1 = 0;
@@ -238,13 +239,13 @@ int boss3_movement(ACTOR *actr) {
         actr->temp4--;
         if (!actr->temp4) {
             actr->temp3 = 0;
-            _G(actor)[3].frame_speed = 4;
-            _G(actor)[3].dir = 0;
-            _G(actor)[3].last_dir = 0;
-            _G(actor)[3].next = 3;
-            _G(actor)[4].dir = 0;
-            _G(actor)[4].last_dir = 0;
-            _G(actor)[4].next = 3;
+            _G(actor[3]).frame_speed = 4;
+            _G(actor[3]).dir = 0;
+            _G(actor[3]).last_dir = 0;
+            _G(actor[3]).next = 3;
+            _G(actor[4]).dir = 0;
+            _G(actor[4]).last_dir = 0;
+            _G(actor[4]).next = 3;
         }
         goto skip_move;
     }
@@ -252,57 +253,56 @@ int boss3_movement(ACTOR *actr) {
     if (actr->edge_counter) actr->edge_counter--;
     else goto new_dir;
 
-    if (overlap(actr->x + 2, actr->y + 8, actr->x + 30, actr->y + 30,
-                _G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15))
+    if (overlap(actr->x + 2, actr->y + 8, actr->x + 30, actr->y + 30, _G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15))
         thor_damaged(actr);
 
     ox = actr->x;
     oy = actr->y;
     switch (actr->temp5) {
     case 0:
-        x1 = _G(actor)[3].x;
-        y1 = _G(actor)[3].y - 2;
-        if (!check_move2(x1, y1, &_G(actor)[3])) {
+        x1 = _G(actor[3]).x;
+        y1 = _G(actor[3]).y - 2;
+        if (!check_move2(x1, y1, &_G(actor[3]))) {
             f = 1;
             break;
         }
-        if (!check_move2(x1 + 16, y1, &_G(actor)[4])) f = 1;
+        if (!check_move2(x1 + 16, y1, &_G(actor[4]))) f = 1;
         actr->y = oy - 2;
         break;
     case 1:
-        x1 = _G(actor)[5].x;
-        y1 = _G(actor)[5].y + 2;
-        if (!check_move2(x1, y1, &_G(actor)[5])) {
+        x1 = _G(actor[5]).x;
+        y1 = _G(actor[5]).y + 2;
+        if (!check_move2(x1, y1, &_G(actor[5]))) {
             f = 1;
             break;
         }
-        if (!check_move2(x1 + 16, y1, &_G(actor)[6])) f = 1;
+        if (!check_move2(x1 + 16, y1, &_G(actor[6]))) f = 1;
         actr->y = oy + 2;
         break;
     case 2:
-        x1 = _G(actor)[3].x - 2;
-        y1 = _G(actor)[3].y;
-        if (!check_move2(x1, y1, &_G(actor)[3])) {
+        x1 = _G(actor[3]).x - 2;
+        y1 = _G(actor[3]).y;
+        if (!check_move2(x1, y1, &_G(actor[3]))) {
             f = 1;
             break;
         }
-        if (!check_move2(x1, y1 + 16, &_G(actor)[5])) f = 1;
+        if (!check_move2(x1, y1 + 16, &_G(actor[5]))) f = 1;
         actr->x = ox - 2;
         break;
     case 3:
-        x1 = _G(actor)[4].x + 2;
-        y1 = _G(actor)[4].y;
-        if (!check_move2(x1, y1, &_G(actor)[4])) {
+        x1 = _G(actor[4]).x + 2;
+        y1 = _G(actor[4]).y;
+        if (!check_move2(x1, y1, &_G(actor[4]))) {
             f = 1;
             break;
         }
-        if (!check_move2(x1, y1 + 16, &_G(actor)[6])) f = 1;
+        if (!check_move2(x1, y1 + 16, &_G(actor[6]))) f = 1;
         actr->x = ox + 2;
         break;
     case 4:               //ul
-        x1 = _G(actor)[3].x - 2;
-        y1 = _G(actor)[3].y - 2;
-        if (!check_move2(x1, y1, &_G(actor)[3])) {
+        x1 = _G(actor[3]).x - 2;
+        y1 = _G(actor[3]).y - 2;
+        if (!check_move2(x1, y1, &_G(actor[3]))) {
             f = 1;
             break;
         }
@@ -310,9 +310,9 @@ int boss3_movement(ACTOR *actr) {
         actr->y = oy - 2;
         break;
     case 5:
-        x1 = _G(actor)[4].x + 2;
-        y1 = _G(actor)[4].y - 2;
-        if (!check_move2(x1, y1, &_G(actor)[4])) {
+        x1 = _G(actor[4]).x + 2;
+        y1 = _G(actor[4]).y - 2;
+        if (!check_move2(x1, y1, &_G(actor[4]))) {
             f = 1;
             break;
         }
@@ -320,9 +320,9 @@ int boss3_movement(ACTOR *actr) {
         actr->y = oy - 2;
         break;
     case 6:
-        x1 = _G(actor)[6].x + 2;
-        y1 = _G(actor)[6].y + 2;
-        if (!check_move2(x1, y1, &_G(actor)[6])) {
+        x1 = _G(actor[6]).x + 2;
+        y1 = _G(actor[6]).y + 2;
+        if (!check_move2(x1, y1, &_G(actor[6]))) {
             f = 1;
             break;
         }
@@ -330,9 +330,9 @@ int boss3_movement(ACTOR *actr) {
         actr->y = oy + 2;
         break;
     case 7:
-        x1 = _G(actor)[5].x - 2;
-        y1 = _G(actor)[5].y + 2;
-        if (!check_move2(x1, y1, &_G(actor)[5])) {
+        x1 = _G(actor[5]).x - 2;
+        y1 = _G(actor[5]).y + 2;
+        if (!check_move2(x1, y1, &_G(actor[5]))) {
             f = 1;
             break;
         }
@@ -354,16 +354,16 @@ skip_move:
 
 new_dir:
     if (actr->temp3 < 120) goto new_dir1;
-    _G(actor)[3].frame_speed = 8;
-    _G(actor)[3].next = 3;
-    _G(actor)[4].next = 3;
+    _G(actor[3]).frame_speed = 8;
+    _G(actor[3]).next = 3;
+    _G(actor[4]).next = 3;
     actr->temp4 = 120;
     actor_always_shoots(actr, 0);
-    _G(actor)[actr->shot_actor].x = actr->x + 8;
-    _G(actor)[actr->shot_actor].y = actr->y - 8;
-    _G(actor)[actr->shot_actor].temp1 = g_events->getRandomNumber(90, 189);
-    _G(actor)[actr->shot_actor].temp5 = 30;
-    _G(actor)[actr->shot_actor].speed = 2;
+    _G(actor[actr->shot_actor]).x = actr->x + 8;
+    _G(actor[actr->shot_actor]).y = actr->y - 8;
+    _G(actor[actr->shot_actor]).temp1 = g_events->getRandomNumber(90, 189);
+    _G(actor[actr->shot_actor]).temp5 = 30;
+    _G(actor[actr->shot_actor]).speed = 2;
     play_sound(BOSS12, true);
 
 new_dir1:
@@ -378,56 +378,56 @@ done:
 static void check_boss_hit() {
     int rep;
 
-    if (_G(actor)[3].solid & 128) {
+    if (_G(actor[3]).solid & 128) {
         for (rep = 3; rep < 7; rep++)
-			_G(actor)[rep].magic_hit = 0;
+			_G(actor[rep]).magic_hit = 0;
 
     	return;
     }
-    if (_G(actor)[3].magic_hit || _G(actor)[4].magic_hit ||
-            _G(actor)[5].magic_hit || _G(actor)[6].magic_hit) {
-        if (!_G(actor)[3].temp2) {
-            actor_damaged(&_G(actor)[3], 10);
+    if (_G(actor[3]).magic_hit || _G(actor[4]).magic_hit ||
+            _G(actor[5]).magic_hit || _G(actor[6]).magic_hit) {
+        if (!_G(actor[3]).temp2) {
+            actor_damaged(&_G(actor[3]), 10);
 
-            if (_G(cheat) && _G(key_flag)[_Z])
-                _G(actor)[3].health -= 50;
+            if (_G(cheat) && _G(key_flag[_Z]))
+                _G(actor[3]).health -= 50;
             else
-                _G(actor)[3].health -= 10;
-            _G(actor)[3].speed_count = 50;
+                _G(actor[3]).health -= 10;
+            _G(actor[3]).speed_count = 50;
 
-            boss_status(_G(actor)[3].health);
-            _G(actor)[3].vunerable = 50;
+            boss_status(_G(actor[3]).health);
+            _G(actor[3]).vunerable = 50;
             play_sound(BOSS13, true);
 
             for (rep = 4; rep < 7; rep++) {
-                _G(actor)[rep].magic_hit = 0;
-                _G(actor)[rep].next = 1;
-                _G(actor)[rep].speed_count = 50;
+                _G(actor[rep]).magic_hit = 0;
+                _G(actor[rep]).next = 1;
+                _G(actor[rep]).speed_count = 50;
             }
 
-            if (_G(actor)[3].health == 0) {
+            if (_G(actor[3]).health == 0) {
                 _G(boss_dead) = true;
 				for (rep = 7; rep < MAX_ACTORS; rep++) {
-                    if (_G(actor)[rep].used)
-                        actor_destroyed(&_G(actor)[rep]);
+                    if (_G(actor[rep]).used)
+                        actor_destroyed(&_G(actor[rep]));
 				}
 			}
 
-            if (_G(actor)[3].health == 50) {
+            if (_G(actor[3]).health == 50) {
                 boss_change_mode();
-                _G(actor)[3].temp1 = 0;
-                _G(actor)[3].temp2 = 0;
-                _G(actor)[3].temp3 = 0;
-                _G(actor)[3].temp4 = 0;
-                _G(actor)[3].temp5 = 0;
-                _G(actor)[3].i6 = 0;
-                _G(actor)[3].speed_count = 2;
+                _G(actor[3]).temp1 = 0;
+                _G(actor[3]).temp2 = 0;
+                _G(actor[3]).temp3 = 0;
+                _G(actor[3]).temp4 = 0;
+                _G(actor[3]).temp5 = 0;
+                _G(actor[3]).i6 = 0;
+                _G(actor[3]).speed_count = 2;
             } else {
-                _G(actor)[3].temp2 = 40;
+                _G(actor[3]).temp2 = 40;
             }
         }
         for (rep = 3; rep < 7; rep++)
-            _G(actor)[rep].magic_hit = 0;
+            _G(actor[rep]).magic_hit = 0;
     }
 }
 
@@ -466,37 +466,37 @@ void boss_level3() {
 static int boss_die() {
 	if (_G(boss_dead)) {
         for(int rep = 0; rep < 4; rep++) {
-            int x1 = _G(actor)[3 + rep].last_x[_G(pge)];
-            int y1 = _G(actor)[3 + rep].last_y[_G(pge)];
-            int x = _G(actor)[3 + rep].x;
-            int y = _G(actor)[3 + rep].y;
-            int n = _G(actor)[3 + rep].actor_num;
-            int r = _G(actor)[3 + rep].rating;
-
-            _G(actor)[3 + rep] = _G(explosion);
-
-            _G(actor)[3 + rep].actor_num = n;
-            _G(actor)[3 + rep].rating = r;
-            _G(actor)[3 + rep].x = x;
-            _G(actor)[3 + rep].y = y;
-            _G(actor)[3 + rep].last_x[_G(pge)] = x1;
-            _G(actor)[3 + rep].last_x[_G(pge) ^ 1] = x;
-            _G(actor)[3 + rep].last_y[_G(pge)] = y1;
-            _G(actor)[3 + rep].last_y[_G(pge) ^ 1] = y;
-            _G(actor)[3 + rep].used = 1;
-            _G(actor)[3 + rep].vunerable = 255;
-            _G(actor)[3 + rep].move = 6;
-            _G(actor)[3 + rep].next = rep;
-            _G(actor)[3 + rep].speed = g_events->getRandomNumber(6, 8);
-            _G(actor)[3 + rep].num_shots = (10 - _G(actor)[3 + rep].speed) * 10;
-            _G(actor)[3 + rep].speed_count = _G(actor)[3 + rep].speed;
+            int x1 = _G(actor[3 + rep]).last_x[_G(pge)];
+            int y1 = _G(actor[3 + rep]).last_y[_G(pge)];
+            int x = _G(actor[3 + rep]).x;
+            int y = _G(actor[3 + rep]).y;
+            int n = _G(actor[3 + rep]).actor_num;
+            int r = _G(actor[3 + rep]).rating;
+
+            _G(actor[3 + rep]) = _G(explosion);
+
+            _G(actor[3 + rep]).actor_num = n;
+            _G(actor[3 + rep]).rating = r;
+            _G(actor[3 + rep]).x = x;
+            _G(actor[3 + rep]).y = y;
+            _G(actor[3 + rep]).last_x[_G(pge)] = x1;
+            _G(actor[3 + rep]).last_x[_G(pge) ^ 1] = x;
+            _G(actor[3 + rep]).last_y[_G(pge)] = y1;
+            _G(actor[3 + rep]).last_y[_G(pge) ^ 1] = y;
+            _G(actor[3 + rep]).used = 1;
+            _G(actor[3 + rep]).vunerable = 255;
+            _G(actor[3 + rep]).move = 6;
+            _G(actor[3 + rep]).next = rep;
+            _G(actor[3 + rep]).speed = g_events->getRandomNumber(6, 8);
+            _G(actor[3 + rep]).num_shots = (10 - _G(actor[3 + rep]).speed) * 10;
+            _G(actor[3 + rep]).speed_count = _G(actor[3 + rep]).speed;
         }
 
         play_sound(EXPLODE, true);
         _G(boss_dead) = true;;
     }
 
-    return _G(actor)[3].last_dir;
+    return _G(actor[3]).last_dir;
 }
 
 void closing_sequence3() {
@@ -533,7 +533,7 @@ void closing_sequence3_3() {
 
 void ending_screen() {
 	for (int i = 3; i < MAX_ACTORS; i++)
-        _G(actor)[i].move = 1;
+        _G(actor[i]).move = 1;
     music_play(6, true);
     _G(timer_cnt) = 0;
 
@@ -543,23 +543,23 @@ void ending_screen() {
     _G(exprow) = 0;
     expcnt = 0;
 
-    _G(actor)[34] = _G(explosion);
-    _G(actor)[34].used = 0;
-    _G(actor)[34].speed = 2;
-    _G(actor)[34].speed_count = _G(actor)[34].speed;
-    _G(actor)[34].num_shots = 3;  // Used to reverse explosion
-    _G(actor)[34].vunerable = 255;
-    _G(actor)[34].i2 = 6;
+    _G(actor[34]) = _G(explosion);
+    _G(actor[34]).used = 0;
+    _G(actor[34]).speed = 2;
+    _G(actor[34]).speed_count = _G(actor[34]).speed;
+    _G(actor[34]).num_shots = 3;  // Used to reverse explosion
+    _G(actor[34]).vunerable = 255;
+    _G(actor[34]).i2 = 6;
 }
 
 // Explode
 int endgame_one() {
-	if (_G(actor)[34].i2) {
-        _G(actor)[34].i2--;
+	if (_G(actor[34]).i2) {
+        _G(actor[34]).i2--;
         return 0;
     }
 
-    _G(actor)[34].i2 = 6;
+    _G(actor[34]).i2 = 6;
     play_sound(EXPLODE, true);
 
     int r = _G(rand1) % 32;
@@ -570,17 +570,17 @@ int endgame_one() {
     expf[r / 8][r % 8] = 1;
     int x = (EXPLOSION[r / 8][r % 8] % 20) * 16;
     int y = (EXPLOSION[r / 8][r % 8] / 20) * 16;
-    _G(actor)[34].x = x;
-    _G(actor)[34].y = y;
-    _G(actor)[34].used = 1;
-    _G(actor)[34].next = 0;
-    _G(actor)[34].num_shots = 3;
+    _G(actor[34]).x = x;
+    _G(actor[34]).y = y;
+    _G(actor[34]).used = 1;
+    _G(actor[34]).next = 0;
+    _G(actor[34]).num_shots = 3;
 
     _G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
 
-    _G(endgame)++;
+    _G(endgame++);
     if (_G(endgame) > 32) {
-        _G(actor)[34].used = 0;
+        _G(actor[34]).used = 0;
         _G(endgame) = 0;
     }
     return 1;
@@ -594,11 +594,11 @@ int endgame_movement() {
         endgame_one();
         return 0;
     }
-    if (_G(actor)[34].i2) {
-        _G(actor)[34].i2--;
+    if (_G(actor[34]).i2) {
+        _G(actor[34]).i2--;
         return 0;
     }
-    _G(actor)[34].i2 = 6;
+    _G(actor[34]).i2 = 6;
     play_sound(EXPLODE, true);
 
     int r = _G(rand1) % 8;
@@ -609,19 +609,19 @@ int endgame_movement() {
     expf[_G(exprow)][r] = 1;
     int x = (EXPLOSION[_G(exprow)][r] % 20) * 16;
     int y = (EXPLOSION[_G(exprow)][r] / 20) * 16;
-    _G(actor)[34].x = x;
-    _G(actor)[34].y = y;
-    _G(actor)[34].used = 1;
-    _G(actor)[34].next = 0;
-    _G(actor)[34].num_shots = 3;
+    _G(actor[34]).x = x;
+    _G(actor[34]).y = y;
+    _G(actor[34]).used = 1;
+    _G(actor[34]).next = 0;
+    _G(actor[34]).num_shots = 3;
 
     _G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
     _G(scrn).icon[(y / 16) - 4][x / 16] = _G(scrn).bg_color;
 
-    _G(endgame)++;
+    _G(endgame++);
     if (_G(endgame) > 8) {
         _G(endgame) = 1;
-        _G(exprow)++;
+        _G(exprow++);
         expcnt++;
         if (expcnt > 3) {
             memset(expf, 0, 32);


Commit: 556d84cc8de395ea7bf15c5123b8a09503664138
    https://github.com/scummvm/scummvm/commit/556d84cc8de395ea7bf15c5123b8a09503664138
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Code formatting in boss2 and boss3

Changed paths:
    engines/got/game/boss2.cpp
    engines/got/game/boss3.cpp


diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index d1d84dd0840..150282442e2 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -20,31 +20,30 @@
  */
 
 #include "got/game/boss2.h"
+#include "got/events.h"
 #include "got/game/back.h"
 #include "got/game/init.h"
 #include "got/game/move.h"
 #include "got/game/status.h"
 #include "got/gfx/image.h"
 #include "got/gfx/panel.h"
-#include "got/vars.h"
-#include "got/events.h"
 #include "got/sound.h"
+#include "got/vars.h"
 
 namespace Got {
 
 static const byte EXPLOSION[] = {
-    61, 62, 65, 66, 69, 70, 73, 74, 77, 78,
-    81, 82, 85, 86, 89, 90, 93, 94, 97, 98,
-    101,102,105,106,109,110,113,114,117,118,
-    121,122,125,126,129,130,133,134,137,138,
-    141,142,145,146,149,150,153,154,157,158,
-    161,162,165,166,169,170,173,174,177,178
-};
+	61, 62, 65, 66, 69, 70, 73, 74, 77, 78,
+	81, 82, 85, 86, 89, 90, 93, 94, 97, 98,
+	101, 102, 105, 106, 109, 110, 113, 114, 117, 118,
+	121, 122, 125, 126, 129, 130, 133, 134, 137, 138,
+	141, 142, 145, 146, 149, 150, 153, 154, 157, 158,
+	161, 162, 165, 166, 169, 170, 173, 174, 177, 178};
 static byte expf[60];
-static byte num_skulls;  // Hehe
+static byte num_skulls; // Hehe
 static byte num_spikes;
 static bool drop_flag;
-static byte su[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
+static byte su[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
 static int boss2a_movement(ACTOR *actr);
 static int boss2b_movement(ACTOR *actr);
@@ -53,366 +52,377 @@ static void boss_set(int d, int x, int y);
 
 int boss2_movement(ACTOR *actr) {
 	switch (_G(setup).skill) {
-    case 0:
-        num_skulls = 3;
-        num_spikes = 5;
-        break;
-    case 1:
-        num_skulls = 6;
-        num_spikes = 8;
-        break;
-    case 2:
-        num_skulls = 9;
-        num_spikes = 11;
-        break;
-    }
-    if (_G(boss_dead))
-        return boss2_die();
-
-    if (actr->i1) {
-        if (actr->i1 == 1)
+	case 0:
+		num_skulls = 3;
+		num_spikes = 5;
+		break;
+	case 1:
+		num_skulls = 6;
+		num_spikes = 8;
+		break;
+	case 2:
+		num_skulls = 9;
+		num_spikes = 11;
+		break;
+	}
+	if (_G(boss_dead))
+		return boss2_die();
+
+	if (actr->i1) {
+		if (actr->i1 == 1)
 			return boss2a_movement(actr);
 
 		return boss2b_movement(actr);
-    }
-	
-    int d = actr->last_dir;
-    int x = actr->x;
-	
-    if (actr->temp6)
+	}
+
+	int d = actr->last_dir;
+	int x = actr->x;
+
+	if (actr->temp6)
 		actr->temp6--;
 
 	if (!actr->temp6) {
 		bool f = false;
 		drop_flag = false;
-		
-        if (actr->temp5)
+
+		if (actr->temp5)
 			actr->temp5--;
 
 		if (!actr->temp5)
 			f = true;
 		else {
-            if (d == 2) {
-                if (x > 18)
+			if (d == 2) {
+				if (x > 18)
 					actr->x -= 2;
-                else
+				else
 					f = true;
-            } else if (d == 3) {
-                if (x < 272)
+			} else if (d == 3) {
+				if (x < 272)
 					actr->x += 2;
-                else
+				else
 					f = true;
-            }
-        }
-        if (f) {
-            actr->temp5 = _G(rand1) + 60;
-            if (d == 2)
+			}
+		}
+		if (f) {
+			actr->temp5 = _G(rand1) + 60;
+			if (d == 2)
 				d = 3;
-            else
+			else
 				d = 2;
-        }
-    }
+		}
+	}
 
-    actr->frame_count--;
-    if (actr->frame_count <= 0) {
-        actr->next++;
-        if (actr->next > 2)
+	actr->frame_count--;
+	if (actr->frame_count <= 0) {
+		actr->next++;
+		if (actr->next > 2)
 			actr->next = 0;
-        actr->frame_count = actr->frame_speed;
-    }
-    x = actr->x;
-    if (actr->num_shots < num_skulls && !drop_flag) {
-        if (x == 48 || x == 112 || x == 176 || x == 240) {
-            drop_flag = true;
-            _G(actor[3]).temp6 = 40;
-
-            actor_always_shoots(actr, 1);
-            play_sound(FALL, false);
-            _G(actor[actr->shot_actor]).x = actr->x + 12;
-            _G(actor[actr->shot_actor]).y = actr->y + 32;
-            _G(actor[actr->shot_actor]).temp2 = 0;
-            _G(actor[actr->shot_actor]).temp3 = 4;
-            _G(actor[actr->shot_actor]).temp4 = 4;
-        }
-    }
-
-    boss_set(d, x, actr->y);
-
-    if (actr->directions == 1)
+		actr->frame_count = actr->frame_speed;
+	}
+	x = actr->x;
+	if (actr->num_shots < num_skulls && !drop_flag) {
+		if (x == 48 || x == 112 || x == 176 || x == 240) {
+			drop_flag = true;
+			_G(actor[3]).temp6 = 40;
+
+			actor_always_shoots(actr, 1);
+			play_sound(FALL, false);
+			_G(actor[actr->shot_actor]).x = actr->x + 12;
+			_G(actor[actr->shot_actor]).y = actr->y + 32;
+			_G(actor[actr->shot_actor]).temp2 = 0;
+			_G(actor[actr->shot_actor]).temp3 = 4;
+			_G(actor[actr->shot_actor]).temp4 = 4;
+		}
+	}
+
+	boss_set(d, x, actr->y);
+
+	if (actr->directions == 1)
 		return 0;
 
-    return d;
+	return d;
 }
 
 static void boss_set(int d, int x, int y) {
-    _G(actor[4]).next = _G(actor[3]).next;
-    _G(actor[5]).next = _G(actor[3]).next;
-    _G(actor[6]).next = _G(actor[3]).next;
-    _G(actor[3]).last_dir = d;
-    _G(actor[4]).last_dir = d;
-    _G(actor[5]).last_dir = d;
-    _G(actor[6]).last_dir = d;
-    _G(actor[4]).x = x + 16;
-    _G(actor[4]).y = y;
-    _G(actor[5]).x = x;
-    _G(actor[5]).y = y + 16;
-    _G(actor[6]).x = x + 16;
-    _G(actor[6]).y = y + 16;
+	_G(actor[4]).next = _G(actor[3]).next;
+	_G(actor[5]).next = _G(actor[3]).next;
+	_G(actor[6]).next = _G(actor[3]).next;
+	_G(actor[3]).last_dir = d;
+	_G(actor[4]).last_dir = d;
+	_G(actor[5]).last_dir = d;
+	_G(actor[6]).last_dir = d;
+	_G(actor[4]).x = x + 16;
+	_G(actor[4]).y = y;
+	_G(actor[5]).x = x;
+	_G(actor[5]).y = y + 16;
+	_G(actor[6]).x = x + 16;
+	_G(actor[6]).y = y + 16;
 }
 
 void check_boss2_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
-    if ((!_G(actor[3]).vunerable)) {
+	if ((!_G(actor[3]).vunerable)) {
 		int rep;
 
 		actor_damaged(&_G(actor[3]), _G(hammer)->strength);
-        _G(actor[3]).health -= 10;
-        if (_G(actor[3]).health == 50) {
-            play_sound(BOSS12, 1);
-
-            g_events->send("Game", GameMessage("PAUSE", 40));
-
-            _G(actor[3]).i1 = 1;
-            _G(actor[3]).i2 = 0;
-            memset(expf, 0, 60);
-            for (rep = 7; rep < MAX_ACTORS; rep++)
-                if (_G(actor[rep]).used)
-                    actor_destroyed(&_G(actor[rep]));
-            _G(actor[3]).num_shots = 0;
-        } else play_sound(BOSS13, true);
-        _G(actor[3]).speed_count = 75;
-        boss_status(_G(actor[3]).health);
-        _G(actor[3]).vunerable = 75;
-        _G(actor[3]).next = 1;
-        for (rep = 4; rep < 7; rep++) {
-            _G(actor[rep]).next = 1;
-            _G(actor[rep]).speed_count = 50;
-        }
-        if (_G(actor[3]).health == 0) {
-            _G(boss_dead) = true;
+		_G(actor[3]).health -= 10;
+		if (_G(actor[3]).health == 50) {
+			play_sound(BOSS12, 1);
+
+			g_events->send("Game", GameMessage("PAUSE", 40));
+
+			_G(actor[3]).i1 = 1;
+			_G(actor[3]).i2 = 0;
+			memset(expf, 0, 60);
+			for (rep = 7; rep < MAX_ACTORS; rep++)
+				if (_G(actor[rep]).used)
+					actor_destroyed(&_G(actor[rep]));
+			_G(actor[3]).num_shots = 0;
+		} else
+			play_sound(BOSS13, true);
+		_G(actor[3]).speed_count = 75;
+		boss_status(_G(actor[3]).health);
+		_G(actor[3]).vunerable = 75;
+		_G(actor[3]).next = 1;
+		for (rep = 4; rep < 7; rep++) {
+			_G(actor[rep]).next = 1;
+			_G(actor[rep]).speed_count = 50;
+		}
+		if (_G(actor[3]).health == 0) {
+			_G(boss_dead) = true;
 			for (rep = 7; rep < MAX_ACTORS; rep++) {
-                if (_G(actor[rep]).used)
-                    actor_destroyed(&_G(actor[rep]));
+				if (_G(actor[rep]).used)
+					actor_destroyed(&_G(actor[rep]));
 			}
 		}
-    }
+	}
 }
 
 void boss_level2() {
-    setup_boss(2);
-    _G(boss_active) = true;
-    boss_status(-1);
-    music_pause();
-    play_sound(BOSS11, true);
-    _G(timer_cnt) = 0;
-
-    drop_flag = false;
-    Common::fill(su, su + 18, 0);
-
-    g_events->send("Game", GameMessage("PAUSE", 40));
-    music_play(7, true);
+	setup_boss(2);
+	_G(boss_active) = true;
+	boss_status(-1);
+	music_pause();
+	play_sound(BOSS11, true);
+	_G(timer_cnt) = 0;
+
+	drop_flag = false;
+	Common::fill(su, su + 18, 0);
+
+	g_events->send("Game", GameMessage("PAUSE", 40));
+	music_play(7, true);
 }
 
 static int boss2_die() {
 	_G(hourglass_flag) = 0;
-    _G(thunder_flag) = 0;
-    if (_G(boss_dead)) {
-        for (int rep = 0; rep < 4; rep++) {
-            int x1 = _G(actor[3 + rep]).last_x[_G(pge)];
-            int y1 = _G(actor[3 + rep]).last_y[_G(pge)];
-            int x = _G(actor[3 + rep]).x;
-            int y = _G(actor[3 + rep]).y;
-            int n = _G(actor[3 + rep]).actor_num;
-            int r = _G(actor[3 + rep]).rating;
-
-            _G(actor[3 + rep]) = _G(explosion);
-
-            _G(actor[3 + rep]).actor_num = n;
-            _G(actor[3 + rep]).rating = r;
-            _G(actor[3 + rep]).x = x;
-            _G(actor[3 + rep]).y = y;
-            _G(actor[3 + rep]).last_x[_G(pge)] = x1;
-            _G(actor[3 + rep]).last_x[_G(pge) ^ 1] = x;
-            _G(actor[3 + rep]).last_y[_G(pge)] = y1;
-            _G(actor[3 + rep]).last_y[_G(pge) ^ 1] = y;
-            _G(actor[3 + rep]).used = 1;
-            _G(actor[3 + rep]).vunerable = 255;
-            _G(actor[3 + rep]).move = 6;
-            _G(actor[3 + rep]).next = rep;
-            _G(actor[3 + rep]).speed = g_events->getRandomNumber(6, 8);
-            _G(actor[3 + rep]).num_shots = (10 - _G(actor[3 + rep]).speed) * 10;
-            _G(actor[3 + rep]).speed_count = _G(actor[3 + rep]).speed;
-        }
-
-        play_sound(EXPLODE, true);
-        _G(boss_dead) = true;;
-    }
-
-    return _G(actor[3]).last_dir;
+	_G(thunder_flag) = 0;
+	if (_G(boss_dead)) {
+		for (int rep = 0; rep < 4; rep++) {
+			int x1 = _G(actor[3 + rep]).last_x[_G(pge)];
+			int y1 = _G(actor[3 + rep]).last_y[_G(pge)];
+			int x = _G(actor[3 + rep]).x;
+			int y = _G(actor[3 + rep]).y;
+			int n = _G(actor[3 + rep]).actor_num;
+			int r = _G(actor[3 + rep]).rating;
+
+			_G(actor[3 + rep]) = _G(explosion);
+
+			_G(actor[3 + rep]).actor_num = n;
+			_G(actor[3 + rep]).rating = r;
+			_G(actor[3 + rep]).x = x;
+			_G(actor[3 + rep]).y = y;
+			_G(actor[3 + rep]).last_x[_G(pge)] = x1;
+			_G(actor[3 + rep]).last_x[_G(pge) ^ 1] = x;
+			_G(actor[3 + rep]).last_y[_G(pge)] = y1;
+			_G(actor[3 + rep]).last_y[_G(pge) ^ 1] = y;
+			_G(actor[3 + rep]).used = 1;
+			_G(actor[3 + rep]).vunerable = 255;
+			_G(actor[3 + rep]).move = 6;
+			_G(actor[3 + rep]).next = rep;
+			_G(actor[3 + rep]).speed = g_events->getRandomNumber(6, 8);
+			_G(actor[3 + rep]).num_shots = (10 - _G(actor[3 + rep]).speed) * 10;
+			_G(actor[3 + rep]).speed_count = _G(actor[3 + rep]).speed;
+		}
+
+		play_sound(EXPLODE, true);
+		_G(boss_dead) = true;
+		;
+	}
+
+	return _G(actor[3]).last_dir;
 }
 
 // Boss - skull (explode)
 static int boss2a_movement(ACTOR *actr) {
 	next_frame(actr);
-    _G(actor[4]).next = actr->next;
-    _G(actor[5]).next = actr->next;
-    _G(actor[6]).next = actr->next;
-    actr->vunerable = 20;
-    if (actr->num_shots)
+	_G(actor[4]).next = actr->next;
+	_G(actor[5]).next = actr->next;
+	_G(actor[6]).next = actr->next;
+	actr->vunerable = 20;
+	if (actr->num_shots)
 		return 0;
-    if (_G(actor[5]).num_shots)
+	if (_G(actor[5]).num_shots)
 		return 0;
 
-    play_sound(EXPLODE, true);
-    actor_always_shoots(&_G(actor[5]), 0);
-    int an = _G(actor[5]).shot_actor;
-    _G(actor[an]).move = 9;
-
-    int r = _G(rand1) % 60;
-    while (expf[r]) {
-        r++;
-        if (r > 59) r = 0;
-    }
-    expf[r] = 1;
-    int x = (EXPLOSION[r] % 20) * 16;
-    int y = (EXPLOSION[r] / 20) * 16;
-    _G(actor[an]).x = x;
-    _G(actor[an]).y = y;
-
-    _G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
-
-    _G(actor[3]).i2++;
-    if (_G(actor[3]).i2 > 59) {
-        _G(actor[3]).i1 = 2;
-        _G(actor[3]).i2 = 0;
-        _G(actor[3]).num_moves = 3;
-    }
-
-    return 0;
+	play_sound(EXPLODE, true);
+	actor_always_shoots(&_G(actor[5]), 0);
+	int an = _G(actor[5]).shot_actor;
+	_G(actor[an]).move = 9;
+
+	int r = _G(rand1) % 60;
+	while (expf[r]) {
+		r++;
+		if (r > 59)
+			r = 0;
+	}
+	expf[r] = 1;
+	int x = (EXPLOSION[r] % 20) * 16;
+	int y = (EXPLOSION[r] / 20) * 16;
+	_G(actor[an]).x = x;
+	_G(actor[an]).y = y;
+
+	_G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
+
+	_G(actor[3]).i2++;
+	if (_G(actor[3]).i2 > 59) {
+		_G(actor[3]).i1 = 2;
+		_G(actor[3]).i2 = 0;
+		_G(actor[3]).num_moves = 3;
+	}
+
+	return 0;
 }
 
 // Boss - skull - shake
 static int boss2b_movement(ACTOR *actr) {
-    int rep, an, hx;
-
-    if (_G(hammer)->used && _G(hammer)->move != 5) {
-        hx = _G(hammer)->x;
-        int hy = _G(hammer)->y;
-        for (rep = 7; rep < 15; rep++) {
-            if (!_G(actor[rep]).used) continue;
-            if (overlap(hx + 1, hy + 1, hx + 10, hy + 10, _G(actor[rep]).x, _G(actor[rep]).y,
-                        _G(actor[rep]).x + _G(actor[rep]).size_x - 1, _G(actor[rep]).y + _G(actor[rep]).size_y - 1)) {
-                _G(hammer)->move = 5;
-                int d = reverse_direction(_G(hammer));
-                _G(hammer)->dir = d;
-                break;
-            }
-        }
-    }
-    if (actr->i4) {
-        actr->i4--;
-        if (!actr->i4) _G(thunder_flag) = 0;
-    }
-    if (!actr->i2) {
-        if (actr->x < 144) actr->x += 2;
-        else if (actr->x > 144) actr->x -= 2;
-        else {
-            actr->i2 = 1;
-            actr->i3 = 0;
-        }
-        goto done;
-    }
-    if (_G(actor[4]).num_shots) goto done;
-
-    if (!actr->i3) {
-        actr->i3 = g_events->getRandomNumber(2, 3);
-    }
-
-    if (actr->i3 == 2) actr->x -= 2;
-    else actr->x += 2;
-
-    if (actr->x < 20 || actr->x>270) {
-        _G(thunder_flag) = 100;
-        actr->i4 = 50;
-        play_sound(EXPLODE, true);
-        actr->i2 = 0;
-
-        Common::fill(su, su + 18, 0);
-        actor_always_shoots(&_G(actor[4]), 1);
-        an = _G(actor[4]).shot_actor;
-        hx = (_G(thor)->x / 16);
-        _G(actor[an]).x = _G(thor)->x;  //hx*16;
-        _G(actor[an]).y = g_events->getRandomNumber(15);
-
-        su[hx] = 1;
-        _G(actor[an]).next = g_events->getRandomNumber(3);
-        for(rep = 0; rep < num_spikes; rep++) {
-            while (1) {
-                hx = g_events->getRandomNumber(17);
-                if (!su[hx]) break;
-            }
-            su[hx] = 1;
-            actor_always_shoots(&_G(actor[4]), 1);
-            an = _G(actor[4]).shot_actor;
-            _G(actor[an]).next = g_events->getRandomNumber(3);
-            _G(actor[an]).x = 16 + hx * 16;
-            _G(actor[an]).y = g_events->getRandomNumber(15);
-        }
-    }
+	int rep, an, hx;
+
+	if (_G(hammer)->used && _G(hammer)->move != 5) {
+		hx = _G(hammer)->x;
+		int hy = _G(hammer)->y;
+		for (rep = 7; rep < 15; rep++) {
+			if (!_G(actor[rep]).used)
+				continue;
+			if (overlap(hx + 1, hy + 1, hx + 10, hy + 10, _G(actor[rep]).x, _G(actor[rep]).y,
+						_G(actor[rep]).x + _G(actor[rep]).size_x - 1, _G(actor[rep]).y + _G(actor[rep]).size_y - 1)) {
+				_G(hammer)->move = 5;
+				int d = reverse_direction(_G(hammer));
+				_G(hammer)->dir = d;
+				break;
+			}
+		}
+	}
+	if (actr->i4) {
+		actr->i4--;
+		if (!actr->i4)
+			_G(thunder_flag) = 0;
+	}
+	if (!actr->i2) {
+		if (actr->x < 144)
+			actr->x += 2;
+		else if (actr->x > 144)
+			actr->x -= 2;
+		else {
+			actr->i2 = 1;
+			actr->i3 = 0;
+		}
+		goto done;
+	}
+	if (_G(actor[4]).num_shots)
+		goto done;
+
+	if (!actr->i3) {
+		actr->i3 = g_events->getRandomNumber(2, 3);
+	}
+
+	if (actr->i3 == 2)
+		actr->x -= 2;
+	else
+		actr->x += 2;
+
+	if (actr->x < 20 || actr->x > 270) {
+		_G(thunder_flag) = 100;
+		actr->i4 = 50;
+		play_sound(EXPLODE, true);
+		actr->i2 = 0;
+
+		Common::fill(su, su + 18, 0);
+		actor_always_shoots(&_G(actor[4]), 1);
+		an = _G(actor[4]).shot_actor;
+		hx = (_G(thor)->x / 16);
+		_G(actor[an]).x = _G(thor)->x; //hx*16;
+		_G(actor[an]).y = g_events->getRandomNumber(15);
+
+		su[hx] = 1;
+		_G(actor[an]).next = g_events->getRandomNumber(3);
+		for (rep = 0; rep < num_spikes; rep++) {
+			while (1) {
+				hx = g_events->getRandomNumber(17);
+				if (!su[hx])
+					break;
+			}
+			su[hx] = 1;
+			actor_always_shoots(&_G(actor[4]), 1);
+			an = _G(actor[4]).shot_actor;
+			_G(actor[an]).next = g_events->getRandomNumber(3);
+			_G(actor[an]).x = 16 + hx * 16;
+			_G(actor[an]).y = g_events->getRandomNumber(15);
+		}
+	}
 
 done:
-    next_frame(actr);
-    boss_set(actr->dir, actr->x, actr->y);
-    return 0;
+	next_frame(actr);
+	boss_set(actr->dir, actr->x, actr->y);
+	return 0;
 }
 
 void closing_sequence2() {
-    music_play(6, true);
-    odin_speaks(1001, 0, "CLOSING");
+	music_play(6, true);
+	odin_speaks(1001, 0, "CLOSING");
 }
 
 void closing_sequence2_2() {
-    _G(thor_info).armor = 10;
-    load_new_thor();
-    _G(thor)->dir = 1;
-    _G(thor)->next = 0;
+	_G(thor_info).armor = 10;
+	load_new_thor();
+	_G(thor)->dir = 1;
+	_G(thor)->next = 0;
 
-    fill_score(20, "CLOSING");
+	fill_score(20, "CLOSING");
 }
 
 void closing_sequence2_3() {
-    fill_health();
-    fill_magic();
-    odin_speaks(1002, 0, "CLOSING");
+	fill_health();
+	fill_magic();
+	odin_speaks(1002, 0, "CLOSING");
 }
 
 void closing_sequence2_4() {
-    LEVEL lvl;
+	LEVEL lvl;
 
-    for (int rep = 0; rep < 16; rep++)
+	for (int rep = 0; rep < 16; rep++)
 		_G(scrn).actor_type[rep] = 0;
-	
-    _G(boss_dead) = false;
-    _G(setup).boss_dead[1] = 1;
-    _G(game_over) = true;
-    _G(boss_active) = false;
-    _G(scrn).type = 6;
+
+	_G(boss_dead) = false;
+	_G(setup).boss_dead[1] = 1;
+	_G(game_over) = true;
+	_G(boss_active) = false;
+	_G(scrn).type = 6;
 
 	show_level(BOSS_LEVEL2);
 
-    play_sound(ANGEL, true);
-    place_tile(18, 10, 152);
-    place_tile(19, 10, 202);
-    actor_visible(1);
-    actor_visible(2);
-    _G(actor[7]).x = 288;
-    _G(actor[7]).y = 160;
-    _G(actor[8]).x = 304;
-    _G(actor[8]).y = 160;
-
-    lvl.load(BOSS_LEVEL2);
-    lvl.icon[6][18] = 152;
-    lvl.icon[6][19] = 202;
-    lvl.save(BOSS_LEVEL2);
+	play_sound(ANGEL, true);
+	place_tile(18, 10, 152);
+	place_tile(19, 10, 202);
+	actor_visible(1);
+	actor_visible(2);
+	_G(actor[7]).x = 288;
+	_G(actor[7]).y = 160;
+	_G(actor[8]).x = 304;
+	_G(actor[8]).y = 160;
+
+	lvl.load(BOSS_LEVEL2);
+	lvl.icon[6][18] = 152;
+	lvl.icon[6][19] = 202;
+	lvl.save(BOSS_LEVEL2);
 }
 
 } // namespace Got
diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index 20ea71ec853..5035247b0d9 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "got/game/boss3.h"
+#include "got/events.h"
 #include "got/game/back.h"
 #include "got/game/init.h"
 #include "got/game/move.h"
@@ -27,23 +28,21 @@
 #include "got/game/status.h"
 #include "got/gfx/image.h"
 #include "got/gfx/panel.h"
-#include "got/vars.h"
-#include "got/events.h"
 #include "got/sound.h"
+#include "got/vars.h"
 
 namespace Got {
 
 #define LFC 10
 
-static int  boss_mode;
-static int  num_pods1;
+static int boss_mode;
+static int num_pods1;
 static byte pod_speed;
 static const byte EXPLOSION[4][8] = {
-    {126,127,128,129,130,131,132,133},
-    {146,147,148,149,150,151,152,153},
-    {166,167,168,169,170,171,172,173},
-    {186,187,188,189,190,191,192,193}
-};
+	{126, 127, 128, 129, 130, 131, 132, 133},
+	{146, 147, 148, 149, 150, 151, 152, 153},
+	{166, 167, 168, 169, 170, 171, 172, 173},
+	{186, 187, 188, 189, 190, 191, 192, 193}};
 
 static bool expf[4][8];
 static byte expcnt;
@@ -53,582 +52,596 @@ static void check_boss_hit();
 static void boss_change_mode();
 
 static void set_boss(ACTOR *actr) {
-    _G(actor[4]).next = actr->next;
-    _G(actor[5]).next = actr->next;
-    _G(actor[6]).next = actr->next;
-
-    _G(actor[4]).last_dir = actr->dir;
-    _G(actor[5]).last_dir = actr->dir;
-    _G(actor[6]).last_dir = actr->dir;
-    _G(actor[4]).dir = actr->dir;
-    _G(actor[5]).dir = actr->dir;
-    _G(actor[6]).dir = actr->dir;
-
-    _G(actor[4]).x = actr->x + 16;
-    _G(actor[4]).y = actr->y;
-    _G(actor[5]).x = actr->x;
-    _G(actor[5]).y = actr->y + 16;
-    _G(actor[6]).x = actr->x + 16;
-    _G(actor[6]).y = actr->y + 16;
+	_G(actor[4]).next = actr->next;
+	_G(actor[5]).next = actr->next;
+	_G(actor[6]).next = actr->next;
+
+	_G(actor[4]).last_dir = actr->dir;
+	_G(actor[5]).last_dir = actr->dir;
+	_G(actor[6]).last_dir = actr->dir;
+	_G(actor[4]).dir = actr->dir;
+	_G(actor[5]).dir = actr->dir;
+	_G(actor[6]).dir = actr->dir;
+
+	_G(actor[4]).x = actr->x + 16;
+	_G(actor[4]).y = actr->y;
+	_G(actor[5]).x = actr->x;
+	_G(actor[5]).y = actr->y + 16;
+	_G(actor[6]).x = actr->x + 16;
+	_G(actor[6]).y = actr->y + 16;
 }
 
 // Boss - Loki-2
 static int boss_movement_one(ACTOR *actr) {
-    int rx, ry, i, numPods = 0;
-
-    actr->num_moves = 2;
-    pod_speed = 2;
-
-    switch (_G(setup).skill) {
-    case 0:
-        numPods = 3;
-        break;
-    case 1:
-        numPods = 5;
-        break;
-    case 2:
-        numPods = 8;
-        break;
-    }
-
-    if (!actr->temp1) {
-        // Disappear
-        actr->dir = 1;
-        actr->frame_count = LFC;
-        actr->next = 0;
-        actr->temp1 = 1;
-        actr->i6 = 1;
-        actr->solid |= 128;
-        _G(actor[4]).solid |= 128;
-        _G(actor[5]).solid |= 128;
-        _G(actor[6]).solid |= 128;
-        play_sound(EXPLODE, true);
-        goto done;
-    }
-    if (actr->i6) {
-        // Fade out
-        actr->frame_count--;
-        if (actr->frame_count <= 0) {
-            actr->next++;
-            if (actr->next > 2) {
-                actr->i6 = 0;
-                actr->temp3 = 160;
-            }
-            actr->frame_count = 3;
-        }
-        goto done1;
-    }
-    if (actr->temp3 > 1) {
-        actr->temp3--;
-        goto done1;
-    } else if (actr->temp3) {
-        for (i = 0; i < num_pods1; i++)
-            if (_G(actor[19 + i]).used)
-                goto done1;
-
-        while (1) {
-            rx = g_events->getRandomNumber(255) + 16;
-            ry = g_events->getRandomNumber(143);
-            if (!overlap(rx, ry, rx + 32, ry + 32, _G(thor_x1), _G(thor_y1),
-                         _G(thor_x2), _G(thor_y2)))
-                break;
-        }
-
-        actr->x = rx;
-        actr->y = ry;
-        actr->frame_count = LFC;
-        actr->temp4 = 40;
-        actr->temp3 = 0;
-        play_sound(EXPLODE, true);
-        goto done1;
-    }
-
-    if (actr->temp4) {
-        // Fade in
-        actr->frame_count--;
-        if (actr->frame_count <= 0) {
-            actr->next--;
-            if (actr->next > 254) {
-                actr->next = 0;
-                actr->dir = 0;
-                actr->temp4 = 0;
-                actr->temp5 = 80;
-                actr->solid &= 0x7f;
-                _G(actor[4]).solid &= 0x7f;
-                _G(actor[5]).solid &= 0x7f;
-                _G(actor[6]).solid &= 0x7f;
-            }
-
-            actr->frame_count = 3;
-        }
-        goto done1;
-    }
-
-    if (actr->temp5) {
-        // Shoot
-        actr->temp5--;
-        if (actr->temp5 == 20) {
-            actr->next = 3;
-            goto done1;
-        }
-        if (!actr->temp5) {
-            if (_G(actor[4]).num_shots < _G(actor[4]).shots_allowed) {
-                actor_always_shoots(&_G(actor[4]), 0);
-                const byte shot_actor = _G(actor[4]).shot_actor;
+	int rx, ry, i, numPods = 0;
+
+	actr->num_moves = 2;
+	pod_speed = 2;
+
+	switch (_G(setup).skill) {
+	case 0:
+		numPods = 3;
+		break;
+	case 1:
+		numPods = 5;
+		break;
+	case 2:
+		numPods = 8;
+		break;
+	}
+
+	if (!actr->temp1) {
+		// Disappear
+		actr->dir = 1;
+		actr->frame_count = LFC;
+		actr->next = 0;
+		actr->temp1 = 1;
+		actr->i6 = 1;
+		actr->solid |= 128;
+		_G(actor[4]).solid |= 128;
+		_G(actor[5]).solid |= 128;
+		_G(actor[6]).solid |= 128;
+		play_sound(EXPLODE, true);
+		goto done;
+	}
+	if (actr->i6) {
+		// Fade out
+		actr->frame_count--;
+		if (actr->frame_count <= 0) {
+			actr->next++;
+			if (actr->next > 2) {
+				actr->i6 = 0;
+				actr->temp3 = 160;
+			}
+			actr->frame_count = 3;
+		}
+		goto done1;
+	}
+	if (actr->temp3 > 1) {
+		actr->temp3--;
+		goto done1;
+	} else if (actr->temp3) {
+		for (i = 0; i < num_pods1; i++)
+			if (_G(actor[19 + i]).used)
+				goto done1;
+
+		while (1) {
+			rx = g_events->getRandomNumber(255) + 16;
+			ry = g_events->getRandomNumber(143);
+			if (!overlap(rx, ry, rx + 32, ry + 32, _G(thor_x1), _G(thor_y1),
+						 _G(thor_x2), _G(thor_y2)))
+				break;
+		}
+
+		actr->x = rx;
+		actr->y = ry;
+		actr->frame_count = LFC;
+		actr->temp4 = 40;
+		actr->temp3 = 0;
+		play_sound(EXPLODE, true);
+		goto done1;
+	}
+
+	if (actr->temp4) {
+		// Fade in
+		actr->frame_count--;
+		if (actr->frame_count <= 0) {
+			actr->next--;
+			if (actr->next > 254) {
+				actr->next = 0;
+				actr->dir = 0;
+				actr->temp4 = 0;
+				actr->temp5 = 80;
+				actr->solid &= 0x7f;
+				_G(actor[4]).solid &= 0x7f;
+				_G(actor[5]).solid &= 0x7f;
+				_G(actor[6]).solid &= 0x7f;
+			}
+
+			actr->frame_count = 3;
+		}
+		goto done1;
+	}
+
+	if (actr->temp5) {
+		// Shoot
+		actr->temp5--;
+		if (actr->temp5 == 20) {
+			actr->next = 3;
+			goto done1;
+		}
+		if (!actr->temp5) {
+			if (_G(actor[4]).num_shots < _G(actor[4]).shots_allowed) {
+				actor_always_shoots(&_G(actor[4]), 0);
+				const byte shot_actor = _G(actor[4]).shot_actor;
 				_G(actor[shot_actor]).num_moves = pod_speed;
 				_G(actor[shot_actor]).x = actr->x + 8;
 				_G(actor[shot_actor]).y = actr->y + 16;
 				_G(actor[shot_actor]).temp5 = 0;
-                for (i = 0; i < numPods; i++)
-                    _G(actor[20 + i]) = _G(actor[19]);
+				for (i = 0; i < numPods; i++)
+					_G(actor[20 + i]) = _G(actor[19]);
 
-                num_pods1 = numPods;
-                actr->temp1 = 0;
-            }
-        }
+				num_pods1 = numPods;
+				actr->temp1 = 0;
+			}
+		}
 
-        if (actr->temp5 < 31)
-            goto done1;
-    }
+		if (actr->temp5 < 31)
+			goto done1;
+	}
 
 done:
-    actr->frame_count--;
-    if (actr->frame_count <= 0) {
-        actr->next++;
-        if (actr->next > 2)
-            actr->next = 0;
-        actr->frame_count = LFC;
-    }
+	actr->frame_count--;
+	if (actr->frame_count <= 0) {
+		actr->next++;
+		if (actr->next > 2)
+			actr->next = 0;
+		actr->frame_count = LFC;
+	}
 done1:
-    set_boss(actr);
-    return actr->dir;
+	set_boss(actr);
+	return actr->dir;
 }
 
 // Boss - Loki-1
 int boss3_movement(ACTOR *actr) {
-    int d, x1, y1, f, ox, oy;
-
-    if (actr->temp2)
-        actr->temp2--;
-    if (_G(boss_dead))
-        return boss_die();
-    check_boss_hit();
-
-    if (!boss_mode) return boss_movement_one(actr);
-    num_pods1 = 10;
-    switch (_G(setup).skill) {
-    case 0:
-        actr->num_moves = 3;
-        actr->speed = 2;
-        break;
-    case 1:
-        actr->num_moves = 2;
-        actr->speed = 1;
-        break;
-    case 2:
-        actr->num_moves = 5;
-        actr->speed = 2;
-        break;
-    }
-
-    d = actr->last_dir;
-    actr->temp3++;
-
-    f = 0;
-    if (actr->temp4) {
-        actr->temp4--;
-        if (!actr->temp4) {
-            actr->temp3 = 0;
-            _G(actor[3]).frame_speed = 4;
-            _G(actor[3]).dir = 0;
-            _G(actor[3]).last_dir = 0;
-            _G(actor[3]).next = 3;
-            _G(actor[4]).dir = 0;
-            _G(actor[4]).last_dir = 0;
-            _G(actor[4]).next = 3;
-        }
-        goto skip_move;
-    }
-
-    if (actr->edge_counter) actr->edge_counter--;
-    else goto new_dir;
-
-    if (overlap(actr->x + 2, actr->y + 8, actr->x + 30, actr->y + 30, _G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15))
-        thor_damaged(actr);
-
-    ox = actr->x;
-    oy = actr->y;
-    switch (actr->temp5) {
-    case 0:
-        x1 = _G(actor[3]).x;
-        y1 = _G(actor[3]).y - 2;
-        if (!check_move2(x1, y1, &_G(actor[3]))) {
-            f = 1;
-            break;
-        }
-        if (!check_move2(x1 + 16, y1, &_G(actor[4]))) f = 1;
-        actr->y = oy - 2;
-        break;
-    case 1:
-        x1 = _G(actor[5]).x;
-        y1 = _G(actor[5]).y + 2;
-        if (!check_move2(x1, y1, &_G(actor[5]))) {
-            f = 1;
-            break;
-        }
-        if (!check_move2(x1 + 16, y1, &_G(actor[6]))) f = 1;
-        actr->y = oy + 2;
-        break;
-    case 2:
-        x1 = _G(actor[3]).x - 2;
-        y1 = _G(actor[3]).y;
-        if (!check_move2(x1, y1, &_G(actor[3]))) {
-            f = 1;
-            break;
-        }
-        if (!check_move2(x1, y1 + 16, &_G(actor[5]))) f = 1;
-        actr->x = ox - 2;
-        break;
-    case 3:
-        x1 = _G(actor[4]).x + 2;
-        y1 = _G(actor[4]).y;
-        if (!check_move2(x1, y1, &_G(actor[4]))) {
-            f = 1;
-            break;
-        }
-        if (!check_move2(x1, y1 + 16, &_G(actor[6]))) f = 1;
-        actr->x = ox + 2;
-        break;
-    case 4:               //ul
-        x1 = _G(actor[3]).x - 2;
-        y1 = _G(actor[3]).y - 2;
-        if (!check_move2(x1, y1, &_G(actor[3]))) {
-            f = 1;
-            break;
-        }
-        actr->x = ox - 2;
-        actr->y = oy - 2;
-        break;
-    case 5:
-        x1 = _G(actor[4]).x + 2;
-        y1 = _G(actor[4]).y - 2;
-        if (!check_move2(x1, y1, &_G(actor[4]))) {
-            f = 1;
-            break;
-        }
-        actr->x = ox + 2;
-        actr->y = oy - 2;
-        break;
-    case 6:
-        x1 = _G(actor[6]).x + 2;
-        y1 = _G(actor[6]).y + 2;
-        if (!check_move2(x1, y1, &_G(actor[6]))) {
-            f = 1;
-            break;
-        }
-        actr->x = ox + 2;
-        actr->y = oy + 2;
-        break;
-    case 7:
-        x1 = _G(actor[5]).x - 2;
-        y1 = _G(actor[5]).y + 2;
-        if (!check_move2(x1, y1, &_G(actor[5]))) {
-            f = 1;
-            break;
-        }
-        actr->x = ox - 2;
-        actr->y = oy + 2;
-        break;
-    }
-    actr->frame_count--;
-    if (actr->frame_count <= 0) {
-        actr->next++;
-        if (actr->next > 2) actr->next = 0;
-        actr->frame_count = 30;
-    }
+	int d, x1, y1, f, ox, oy;
+
+	if (actr->temp2)
+		actr->temp2--;
+	if (_G(boss_dead))
+		return boss_die();
+	check_boss_hit();
+
+	if (!boss_mode)
+		return boss_movement_one(actr);
+	num_pods1 = 10;
+	switch (_G(setup).skill) {
+	case 0:
+		actr->num_moves = 3;
+		actr->speed = 2;
+		break;
+	case 1:
+		actr->num_moves = 2;
+		actr->speed = 1;
+		break;
+	case 2:
+		actr->num_moves = 5;
+		actr->speed = 2;
+		break;
+	}
+
+	d = actr->last_dir;
+	actr->temp3++;
+
+	f = 0;
+	if (actr->temp4) {
+		actr->temp4--;
+		if (!actr->temp4) {
+			actr->temp3 = 0;
+			_G(actor[3]).frame_speed = 4;
+			_G(actor[3]).dir = 0;
+			_G(actor[3]).last_dir = 0;
+			_G(actor[3]).next = 3;
+			_G(actor[4]).dir = 0;
+			_G(actor[4]).last_dir = 0;
+			_G(actor[4]).next = 3;
+		}
+		goto skip_move;
+	}
+
+	if (actr->edge_counter)
+		actr->edge_counter--;
+	else
+		goto new_dir;
+
+	if (overlap(actr->x + 2, actr->y + 8, actr->x + 30, actr->y + 30, _G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15))
+		thor_damaged(actr);
+
+	ox = actr->x;
+	oy = actr->y;
+	switch (actr->temp5) {
+	case 0:
+		x1 = _G(actor[3]).x;
+		y1 = _G(actor[3]).y - 2;
+		if (!check_move2(x1, y1, &_G(actor[3]))) {
+			f = 1;
+			break;
+		}
+		if (!check_move2(x1 + 16, y1, &_G(actor[4])))
+			f = 1;
+		actr->y = oy - 2;
+		break;
+	case 1:
+		x1 = _G(actor[5]).x;
+		y1 = _G(actor[5]).y + 2;
+		if (!check_move2(x1, y1, &_G(actor[5]))) {
+			f = 1;
+			break;
+		}
+		if (!check_move2(x1 + 16, y1, &_G(actor[6])))
+			f = 1;
+		actr->y = oy + 2;
+		break;
+	case 2:
+		x1 = _G(actor[3]).x - 2;
+		y1 = _G(actor[3]).y;
+		if (!check_move2(x1, y1, &_G(actor[3]))) {
+			f = 1;
+			break;
+		}
+		if (!check_move2(x1, y1 + 16, &_G(actor[5])))
+			f = 1;
+		actr->x = ox - 2;
+		break;
+	case 3:
+		x1 = _G(actor[4]).x + 2;
+		y1 = _G(actor[4]).y;
+		if (!check_move2(x1, y1, &_G(actor[4]))) {
+			f = 1;
+			break;
+		}
+		if (!check_move2(x1, y1 + 16, &_G(actor[6])))
+			f = 1;
+		actr->x = ox + 2;
+		break;
+	case 4: //ul
+		x1 = _G(actor[3]).x - 2;
+		y1 = _G(actor[3]).y - 2;
+		if (!check_move2(x1, y1, &_G(actor[3]))) {
+			f = 1;
+			break;
+		}
+		actr->x = ox - 2;
+		actr->y = oy - 2;
+		break;
+	case 5:
+		x1 = _G(actor[4]).x + 2;
+		y1 = _G(actor[4]).y - 2;
+		if (!check_move2(x1, y1, &_G(actor[4]))) {
+			f = 1;
+			break;
+		}
+		actr->x = ox + 2;
+		actr->y = oy - 2;
+		break;
+	case 6:
+		x1 = _G(actor[6]).x + 2;
+		y1 = _G(actor[6]).y + 2;
+		if (!check_move2(x1, y1, &_G(actor[6]))) {
+			f = 1;
+			break;
+		}
+		actr->x = ox + 2;
+		actr->y = oy + 2;
+		break;
+	case 7:
+		x1 = _G(actor[5]).x - 2;
+		y1 = _G(actor[5]).y + 2;
+		if (!check_move2(x1, y1, &_G(actor[5]))) {
+			f = 1;
+			break;
+		}
+		actr->x = ox - 2;
+		actr->y = oy + 2;
+		break;
+	}
+	actr->frame_count--;
+	if (actr->frame_count <= 0) {
+		actr->next++;
+		if (actr->next > 2)
+			actr->next = 0;
+		actr->frame_count = 30;
+	}
 
 skip_move:
 
-    set_boss(actr);
-    if (!f) goto done;
+	set_boss(actr);
+	if (!f)
+		goto done;
 
 new_dir:
-    if (actr->temp3 < 120) goto new_dir1;
-    _G(actor[3]).frame_speed = 8;
-    _G(actor[3]).next = 3;
-    _G(actor[4]).next = 3;
-    actr->temp4 = 120;
-    actor_always_shoots(actr, 0);
-    _G(actor[actr->shot_actor]).x = actr->x + 8;
-    _G(actor[actr->shot_actor]).y = actr->y - 8;
-    _G(actor[actr->shot_actor]).temp1 = g_events->getRandomNumber(90, 189);
-    _G(actor[actr->shot_actor]).temp5 = 30;
-    _G(actor[actr->shot_actor]).speed = 2;
-    play_sound(BOSS12, true);
+	if (actr->temp3 < 120)
+		goto new_dir1;
+	_G(actor[3]).frame_speed = 8;
+	_G(actor[3]).next = 3;
+	_G(actor[4]).next = 3;
+	actr->temp4 = 120;
+	actor_always_shoots(actr, 0);
+	_G(actor[actr->shot_actor]).x = actr->x + 8;
+	_G(actor[actr->shot_actor]).y = actr->y - 8;
+	_G(actor[actr->shot_actor]).temp1 = g_events->getRandomNumber(90, 189);
+	_G(actor[actr->shot_actor]).temp5 = 30;
+	_G(actor[actr->shot_actor]).speed = 2;
+	play_sound(BOSS12, true);
 
 new_dir1:
-    actr->temp5 = _G(rand1) % 8;
-    actr->edge_counter = _G(rand2) + 60;
+	actr->temp5 = _G(rand1) % 8;
+	actr->edge_counter = _G(rand2) + 60;
 
 done:
-    if (actr->directions == 1) return 0;
-    return d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 static void check_boss_hit() {
-    int rep;
+	int rep;
 
-    if (_G(actor[3]).solid & 128) {
-        for (rep = 3; rep < 7; rep++)
+	if (_G(actor[3]).solid & 128) {
+		for (rep = 3; rep < 7; rep++)
 			_G(actor[rep]).magic_hit = 0;
 
-    	return;
-    }
-    if (_G(actor[3]).magic_hit || _G(actor[4]).magic_hit ||
-            _G(actor[5]).magic_hit || _G(actor[6]).magic_hit) {
-        if (!_G(actor[3]).temp2) {
-            actor_damaged(&_G(actor[3]), 10);
-
-            if (_G(cheat) && _G(key_flag[_Z]))
-                _G(actor[3]).health -= 50;
-            else
-                _G(actor[3]).health -= 10;
-            _G(actor[3]).speed_count = 50;
-
-            boss_status(_G(actor[3]).health);
-            _G(actor[3]).vunerable = 50;
-            play_sound(BOSS13, true);
-
-            for (rep = 4; rep < 7; rep++) {
-                _G(actor[rep]).magic_hit = 0;
-                _G(actor[rep]).next = 1;
-                _G(actor[rep]).speed_count = 50;
-            }
-
-            if (_G(actor[3]).health == 0) {
-                _G(boss_dead) = true;
+		return;
+	}
+	if (_G(actor[3]).magic_hit || _G(actor[4]).magic_hit ||
+		_G(actor[5]).magic_hit || _G(actor[6]).magic_hit) {
+		if (!_G(actor[3]).temp2) {
+			actor_damaged(&_G(actor[3]), 10);
+
+			if (_G(cheat) && _G(key_flag[_Z]))
+				_G(actor[3]).health -= 50;
+			else
+				_G(actor[3]).health -= 10;
+			_G(actor[3]).speed_count = 50;
+
+			boss_status(_G(actor[3]).health);
+			_G(actor[3]).vunerable = 50;
+			play_sound(BOSS13, true);
+
+			for (rep = 4; rep < 7; rep++) {
+				_G(actor[rep]).magic_hit = 0;
+				_G(actor[rep]).next = 1;
+				_G(actor[rep]).speed_count = 50;
+			}
+
+			if (_G(actor[3]).health == 0) {
+				_G(boss_dead) = true;
 				for (rep = 7; rep < MAX_ACTORS; rep++) {
-                    if (_G(actor[rep]).used)
-                        actor_destroyed(&_G(actor[rep]));
+					if (_G(actor[rep]).used)
+						actor_destroyed(&_G(actor[rep]));
 				}
 			}
 
-            if (_G(actor[3]).health == 50) {
-                boss_change_mode();
-                _G(actor[3]).temp1 = 0;
-                _G(actor[3]).temp2 = 0;
-                _G(actor[3]).temp3 = 0;
-                _G(actor[3]).temp4 = 0;
-                _G(actor[3]).temp5 = 0;
-                _G(actor[3]).i6 = 0;
-                _G(actor[3]).speed_count = 2;
-            } else {
-                _G(actor[3]).temp2 = 40;
-            }
-        }
-        for (rep = 3; rep < 7; rep++)
-            _G(actor[rep]).magic_hit = 0;
-    }
+			if (_G(actor[3]).health == 50) {
+				boss_change_mode();
+				_G(actor[3]).temp1 = 0;
+				_G(actor[3]).temp2 = 0;
+				_G(actor[3]).temp3 = 0;
+				_G(actor[3]).temp4 = 0;
+				_G(actor[3]).temp5 = 0;
+				_G(actor[3]).i6 = 0;
+				_G(actor[3]).speed_count = 2;
+			} else {
+				_G(actor[3]).temp2 = 40;
+			}
+		}
+		for (rep = 3; rep < 7; rep++)
+			_G(actor[rep]).magic_hit = 0;
+	}
 }
 
 static void boss_change_mode() {
-    if (!_G(boss_intro2)) {
-        Gfx::Pics loki("FACE18", 262);
-        execute_script(1003, loki);
-        d_restore();
-        _G(boss_intro2) = true;
-    }
-    boss_mode = 0;
+	if (!_G(boss_intro2)) {
+		Gfx::Pics loki("FACE18", 262);
+		execute_script(1003, loki);
+		d_restore();
+		_G(boss_intro2) = true;
+	}
+	boss_mode = 0;
 }
 
 void boss_level3() {
-    setup_boss(3);
-    _G(boss_active) = true;
-    boss_status(-1);
-    music_pause();
-    play_sound(BOSS11, true);
-    _G(timer_cnt) = 0;
-
-    g_events->send("Game", GameMessage("PAUSE", 40));
-
-    if (!_G(boss_intro1)) {
-        Gfx::Pics loki("FACE18", 262);
-        execute_script(1002, loki);
-        d_restore();
-        _G(boss_intro1) = true;
-    }
-
-    music_play(7, true);
-    _G(apple_drop) = 0;
-    boss_mode = 1;
+	setup_boss(3);
+	_G(boss_active) = true;
+	boss_status(-1);
+	music_pause();
+	play_sound(BOSS11, true);
+	_G(timer_cnt) = 0;
+
+	g_events->send("Game", GameMessage("PAUSE", 40));
+
+	if (!_G(boss_intro1)) {
+		Gfx::Pics loki("FACE18", 262);
+		execute_script(1002, loki);
+		d_restore();
+		_G(boss_intro1) = true;
+	}
+
+	music_play(7, true);
+	_G(apple_drop) = 0;
+	boss_mode = 1;
 }
 
 static int boss_die() {
 	if (_G(boss_dead)) {
-        for(int rep = 0; rep < 4; rep++) {
-            int x1 = _G(actor[3 + rep]).last_x[_G(pge)];
-            int y1 = _G(actor[3 + rep]).last_y[_G(pge)];
-            int x = _G(actor[3 + rep]).x;
-            int y = _G(actor[3 + rep]).y;
-            int n = _G(actor[3 + rep]).actor_num;
-            int r = _G(actor[3 + rep]).rating;
-
-            _G(actor[3 + rep]) = _G(explosion);
-
-            _G(actor[3 + rep]).actor_num = n;
-            _G(actor[3 + rep]).rating = r;
-            _G(actor[3 + rep]).x = x;
-            _G(actor[3 + rep]).y = y;
-            _G(actor[3 + rep]).last_x[_G(pge)] = x1;
-            _G(actor[3 + rep]).last_x[_G(pge) ^ 1] = x;
-            _G(actor[3 + rep]).last_y[_G(pge)] = y1;
-            _G(actor[3 + rep]).last_y[_G(pge) ^ 1] = y;
-            _G(actor[3 + rep]).used = 1;
-            _G(actor[3 + rep]).vunerable = 255;
-            _G(actor[3 + rep]).move = 6;
-            _G(actor[3 + rep]).next = rep;
-            _G(actor[3 + rep]).speed = g_events->getRandomNumber(6, 8);
-            _G(actor[3 + rep]).num_shots = (10 - _G(actor[3 + rep]).speed) * 10;
-            _G(actor[3 + rep]).speed_count = _G(actor[3 + rep]).speed;
-        }
-
-        play_sound(EXPLODE, true);
-        _G(boss_dead) = true;;
-    }
-
-    return _G(actor[3]).last_dir;
+		for (int rep = 0; rep < 4; rep++) {
+			int x1 = _G(actor[3 + rep]).last_x[_G(pge)];
+			int y1 = _G(actor[3 + rep]).last_y[_G(pge)];
+			int x = _G(actor[3 + rep]).x;
+			int y = _G(actor[3 + rep]).y;
+			int n = _G(actor[3 + rep]).actor_num;
+			int r = _G(actor[3 + rep]).rating;
+
+			_G(actor[3 + rep]) = _G(explosion);
+
+			_G(actor[3 + rep]).actor_num = n;
+			_G(actor[3 + rep]).rating = r;
+			_G(actor[3 + rep]).x = x;
+			_G(actor[3 + rep]).y = y;
+			_G(actor[3 + rep]).last_x[_G(pge)] = x1;
+			_G(actor[3 + rep]).last_x[_G(pge) ^ 1] = x;
+			_G(actor[3 + rep]).last_y[_G(pge)] = y1;
+			_G(actor[3 + rep]).last_y[_G(pge) ^ 1] = y;
+			_G(actor[3 + rep]).used = 1;
+			_G(actor[3 + rep]).vunerable = 255;
+			_G(actor[3 + rep]).move = 6;
+			_G(actor[3 + rep]).next = rep;
+			_G(actor[3 + rep]).speed = g_events->getRandomNumber(6, 8);
+			_G(actor[3 + rep]).num_shots = (10 - _G(actor[3 + rep]).speed) * 10;
+			_G(actor[3 + rep]).speed_count = _G(actor[3 + rep]).speed;
+		}
+
+		play_sound(EXPLODE, true);
+		_G(boss_dead) = true;
+		;
+	}
+
+	return _G(actor[3]).last_dir;
 }
 
 void closing_sequence3() {
-    music_play(6, true);
-    odin_speaks(1001, 0, "CLOSING");
+	music_play(6, true);
+	odin_speaks(1001, 0, "CLOSING");
 }
 
 void closing_sequence3_2() {
-    fill_score(20, "CLOSING");
+	fill_score(20, "CLOSING");
 }
 
 void closing_sequence3_3() {
 	fill_health();
-    fill_magic();
+	fill_magic();
 
-    for (int rep = 0; rep < 16; rep++)
+	for (int rep = 0; rep < 16; rep++)
 		_G(scrn).actor_type[rep] = 0;
-	
-    _G(boss_dead) = false;
-    _G(setup).boss_dead[2] = 1;
-    _G(game_over) = true;
-    _G(boss_active) = false;
-    _G(scrn).type = 6;
-    show_level(BOSS_LEVEL3);
-
-    _G(exit_flag) = 0;
-    music_pause();
-
-    _G(new_level) = ENDING_SCREEN;
-    _G(thor)->x = 152;
-    _G(thor)->y = 160;
-    _G(thor)->dir = 1;
+
+	_G(boss_dead) = false;
+	_G(setup).boss_dead[2] = 1;
+	_G(game_over) = true;
+	_G(boss_active) = false;
+	_G(scrn).type = 6;
+	show_level(BOSS_LEVEL3);
+
+	_G(exit_flag) = 0;
+	music_pause();
+
+	_G(new_level) = ENDING_SCREEN;
+	_G(thor)->x = 152;
+	_G(thor)->y = 160;
+	_G(thor)->dir = 1;
 }
 
 void ending_screen() {
 	for (int i = 3; i < MAX_ACTORS; i++)
-        _G(actor[i]).move = 1;
-    music_play(6, true);
-    _G(timer_cnt) = 0;
-
-    memset(expf, 0, 4 * 8);
-    _G(endgame) = 1;
-
-    _G(exprow) = 0;
-    expcnt = 0;
-
-    _G(actor[34]) = _G(explosion);
-    _G(actor[34]).used = 0;
-    _G(actor[34]).speed = 2;
-    _G(actor[34]).speed_count = _G(actor[34]).speed;
-    _G(actor[34]).num_shots = 3;  // Used to reverse explosion
-    _G(actor[34]).vunerable = 255;
-    _G(actor[34]).i2 = 6;
+		_G(actor[i]).move = 1;
+	music_play(6, true);
+	_G(timer_cnt) = 0;
+
+	memset(expf, 0, 4 * 8);
+	_G(endgame) = 1;
+
+	_G(exprow) = 0;
+	expcnt = 0;
+
+	_G(actor[34]) = _G(explosion);
+	_G(actor[34]).used = 0;
+	_G(actor[34]).speed = 2;
+	_G(actor[34]).speed_count = _G(actor[34]).speed;
+	_G(actor[34]).num_shots = 3; // Used to reverse explosion
+	_G(actor[34]).vunerable = 255;
+	_G(actor[34]).i2 = 6;
 }
 
 // Explode
 int endgame_one() {
 	if (_G(actor[34]).i2) {
-        _G(actor[34]).i2--;
-        return 0;
-    }
-
-    _G(actor[34]).i2 = 6;
-    play_sound(EXPLODE, true);
-
-    int r = _G(rand1) % 32;
-    while (expf[r / 8][r % 8]) {
-        r++;
-        if (r > 31) r = 0;
-    }
-    expf[r / 8][r % 8] = 1;
-    int x = (EXPLOSION[r / 8][r % 8] % 20) * 16;
-    int y = (EXPLOSION[r / 8][r % 8] / 20) * 16;
-    _G(actor[34]).x = x;
-    _G(actor[34]).y = y;
-    _G(actor[34]).used = 1;
-    _G(actor[34]).next = 0;
-    _G(actor[34]).num_shots = 3;
-
-    _G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
-
-    _G(endgame++);
-    if (_G(endgame) > 32) {
-        _G(actor[34]).used = 0;
-        _G(endgame) = 0;
-    }
-    return 1;
+		_G(actor[34]).i2--;
+		return 0;
+	}
+
+	_G(actor[34]).i2 = 6;
+	play_sound(EXPLODE, true);
+
+	int r = _G(rand1) % 32;
+	while (expf[r / 8][r % 8]) {
+		r++;
+		if (r > 31)
+			r = 0;
+	}
+	expf[r / 8][r % 8] = 1;
+	int x = (EXPLOSION[r / 8][r % 8] % 20) * 16;
+	int y = (EXPLOSION[r / 8][r % 8] / 20) * 16;
+	_G(actor[34]).x = x;
+	_G(actor[34]).y = y;
+	_G(actor[34]).used = 1;
+	_G(actor[34]).next = 0;
+	_G(actor[34]).num_shots = 3;
+
+	_G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
+
+	_G(endgame++);
+	if (_G(endgame) > 32) {
+		_G(actor[34]).used = 0;
+		_G(endgame) = 0;
+	}
+	return 1;
 }
 
 // Explode
 int endgame_movement() {
 	if (!_G(endgame))
-        return 0;
-    if (expcnt > 3) {
-        endgame_one();
-        return 0;
-    }
-    if (_G(actor[34]).i2) {
-        _G(actor[34]).i2--;
-        return 0;
-    }
-    _G(actor[34]).i2 = 6;
-    play_sound(EXPLODE, true);
-
-    int r = _G(rand1) % 8;
-    while (expf[_G(exprow)][r]) {
-        r++;
-        if (r > 7) r = 0;
-    }
-    expf[_G(exprow)][r] = 1;
-    int x = (EXPLOSION[_G(exprow)][r] % 20) * 16;
-    int y = (EXPLOSION[_G(exprow)][r] / 20) * 16;
-    _G(actor[34]).x = x;
-    _G(actor[34]).y = y;
-    _G(actor[34]).used = 1;
-    _G(actor[34]).next = 0;
-    _G(actor[34]).num_shots = 3;
-
-    _G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
-    _G(scrn).icon[(y / 16) - 4][x / 16] = _G(scrn).bg_color;
-
-    _G(endgame++);
-    if (_G(endgame) > 8) {
-        _G(endgame) = 1;
-        _G(exprow++);
-        expcnt++;
-        if (expcnt > 3) {
-            memset(expf, 0, 32);
-        }
-    }
-
-    return 1;
+		return 0;
+	if (expcnt > 3) {
+		endgame_one();
+		return 0;
+	}
+	if (_G(actor[34]).i2) {
+		_G(actor[34]).i2--;
+		return 0;
+	}
+	_G(actor[34]).i2 = 6;
+	play_sound(EXPLODE, true);
+
+	int r = _G(rand1) % 8;
+	while (expf[_G(exprow)][r]) {
+		r++;
+		if (r > 7)
+			r = 0;
+	}
+	expf[_G(exprow)][r] = 1;
+	int x = (EXPLOSION[_G(exprow)][r] % 20) * 16;
+	int y = (EXPLOSION[_G(exprow)][r] / 20) * 16;
+	_G(actor[34]).x = x;
+	_G(actor[34]).y = y;
+	_G(actor[34]).used = 1;
+	_G(actor[34]).next = 0;
+	_G(actor[34]).num_shots = 3;
+
+	_G(scrn).icon[y / 16][x / 16] = _G(scrn).bg_color;
+	_G(scrn).icon[(y / 16) - 4][x / 16] = _G(scrn).bg_color;
+
+	_G(endgame++);
+	if (_G(endgame) > 8) {
+		_G(endgame) = 1;
+		_G(exprow++);
+		expcnt++;
+		if (expcnt > 3) {
+			memset(expf, 0, 32);
+		}
+	}
+
+	return 1;
 }
 
 } // namespace Got


Commit: 8f8269eb5fe61d892acad9dcea3696230e07a471
    https://github.com/scummvm/scummvm/commit/8f8269eb5fe61d892acad9dcea3696230e07a471
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: janitorial - remove extra semi-column in boss2 and boss3

Changed paths:
    engines/got/game/boss2.cpp
    engines/got/game/boss3.cpp


diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index 150282442e2..70ef9d49b60 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -245,7 +245,6 @@ static int boss2_die() {
 
 		play_sound(EXPLODE, true);
 		_G(boss_dead) = true;
-		;
 	}
 
 	return _G(actor[3]).last_dir;
diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index 5035247b0d9..61594202b0e 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -504,7 +504,6 @@ static int boss_die() {
 
 		play_sound(EXPLODE, true);
 		_G(boss_dead) = true;
-		;
 	}
 
 	return _G(actor[3]).last_dir;


Commit: 844b41c577f4957bf8e09904df3d7f5f34080fce
    https://github.com/scummvm/scummvm/commit/844b41c577f4957bf8e09904df3d7f5f34080fce
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: some more small cleanups in boss 2 and boss3

Changed paths:
    engines/got/game/boss2.cpp
    engines/got/game/boss3.cpp


diff --git a/engines/got/game/boss2.cpp b/engines/got/game/boss2.cpp
index 70ef9d49b60..276323db932 100644
--- a/engines/got/game/boss2.cpp
+++ b/engines/got/game/boss2.cpp
@@ -179,14 +179,17 @@ void check_boss2_hit(ACTOR *actr, int x1, int y1, int x2, int y2, int act_num) {
 			_G(actor[3]).num_shots = 0;
 		} else
 			play_sound(BOSS13, true);
+		
 		_G(actor[3]).speed_count = 75;
 		boss_status(_G(actor[3]).health);
 		_G(actor[3]).vunerable = 75;
 		_G(actor[3]).next = 1;
+		
 		for (rep = 4; rep < 7; rep++) {
 			_G(actor[rep]).next = 1;
 			_G(actor[rep]).speed_count = 50;
 		}
+		
 		if (_G(actor[3]).health == 0) {
 			_G(boss_dead) = true;
 			for (rep = 7; rep < MAX_ACTORS; rep++) {
@@ -257,9 +260,8 @@ static int boss2a_movement(ACTOR *actr) {
 	_G(actor[5]).next = actr->next;
 	_G(actor[6]).next = actr->next;
 	actr->vunerable = 20;
-	if (actr->num_shots)
-		return 0;
-	if (_G(actor[5]).num_shots)
+	
+	if (actr->num_shots || _G(actor[5]).num_shots)
 		return 0;
 
 	play_sound(EXPLODE, true);
@@ -301,6 +303,7 @@ static int boss2b_movement(ACTOR *actr) {
 		for (rep = 7; rep < 15; rep++) {
 			if (!_G(actor[rep]).used)
 				continue;
+			
 			if (overlap(hx + 1, hy + 1, hx + 10, hy + 10, _G(actor[rep]).x, _G(actor[rep]).y,
 						_G(actor[rep]).x + _G(actor[rep]).size_x - 1, _G(actor[rep]).y + _G(actor[rep]).size_y - 1)) {
 				_G(hammer)->move = 5;
@@ -395,8 +398,6 @@ void closing_sequence2_3() {
 }
 
 void closing_sequence2_4() {
-	LEVEL lvl;
-
 	for (int rep = 0; rep < 16; rep++)
 		_G(scrn).actor_type[rep] = 0;
 
@@ -418,6 +419,7 @@ void closing_sequence2_4() {
 	_G(actor[8]).x = 304;
 	_G(actor[8]).y = 160;
 
+	LEVEL lvl;
 	lvl.load(BOSS_LEVEL2);
 	lvl.icon[6][18] = 152;
 	lvl.icon[6][19] = 202;
diff --git a/engines/got/game/boss3.cpp b/engines/got/game/boss3.cpp
index 61594202b0e..243c470c643 100644
--- a/engines/got/game/boss3.cpp
+++ b/engines/got/game/boss3.cpp
@@ -26,7 +26,6 @@
 #include "got/game/move.h"
 #include "got/game/move_patterns.h"
 #include "got/game/status.h"
-#include "got/gfx/image.h"
 #include "got/gfx/panel.h"
 #include "got/sound.h"
 #include "got/vars.h"
@@ -120,7 +119,9 @@ static int boss_movement_one(ACTOR *actr) {
 	if (actr->temp3 > 1) {
 		actr->temp3--;
 		goto done1;
-	} else if (actr->temp3) {
+	}
+
+	if (actr->temp3) {
 		for (i = 0; i < num_pods1; i++)
 			if (_G(actor[19 + i]).used)
 				goto done1;
@@ -170,6 +171,7 @@ static int boss_movement_one(ACTOR *actr) {
 			actr->next = 3;
 			goto done1;
 		}
+		
 		if (!actr->temp5) {
 			if (_G(actor[4]).num_shots < _G(actor[4]).shots_allowed) {
 				actor_always_shoots(&_G(actor[4]), 0);
@@ -205,7 +207,7 @@ done1:
 
 // Boss - Loki-1
 int boss3_movement(ACTOR *actr) {
-	int d, x1, y1, f, ox, oy;
+	int x1, y1, ox, oy;
 
 	if (actr->temp2)
 		actr->temp2--;
@@ -231,10 +233,10 @@ int boss3_movement(ACTOR *actr) {
 		break;
 	}
 
-	d = actr->last_dir;
+	int d = actr->last_dir;
 	actr->temp3++;
 
-	f = 0;
+	int f = 0;
 	if (actr->temp4) {
 		actr->temp4--;
 		if (!actr->temp4) {
@@ -363,6 +365,7 @@ skip_move:
 new_dir:
 	if (actr->temp3 < 120)
 		goto new_dir1;
+	
 	_G(actor[3]).frame_speed = 8;
 	_G(actor[3]).next = 3;
 	_G(actor[4]).next = 3;
@@ -403,6 +406,7 @@ static void check_boss_hit() {
 				_G(actor[3]).health -= 50;
 			else
 				_G(actor[3]).health -= 10;
+			
 			_G(actor[3]).speed_count = 50;
 
 			boss_status(_G(actor[3]).health);
@@ -544,6 +548,7 @@ void closing_sequence3_3() {
 void ending_screen() {
 	for (int i = 3; i < MAX_ACTORS; i++)
 		_G(actor[i]).move = 1;
+	
 	music_play(6, true);
 	_G(timer_cnt) = 0;
 


Commit: 07e3aaa20ad4563151d1cf2ecf356d2e99cefc73
    https://github.com/scummvm/scummvm/commit/07e3aaa20ad4563151d1cf2ecf356d2e99cefc73
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Modify access to global arrays in init, main and object

Changed paths:
    engines/got/game/init.cpp
    engines/got/game/main.cpp
    engines/got/game/main.h
    engines/got/game/object.cpp


diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index 7350531a2d8..66aea6a4a00 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -122,66 +122,66 @@ int setup_boss(int num) {
 
     if (_G(boss_loaded)) {
         for(int rep = 0; rep < 3; rep++) {
-            if (_G(boss_sound)[rep])
-                free(_G(boss_sound)[rep]);
-            if (_G(boss_pcsound)[rep])
-                free(_G(boss_pcsound)[rep]);
+            if (_G(boss_sound[rep]))
+                free(_G(boss_sound[rep]));
+            if (_G(boss_pcsound[rep]))
+                free(_G(boss_pcsound[rep]));
         }
     }
 
     Common::String ress = Common::String::format("BOSSV%d1", num);
-    _G(boss_sound)[0] = (byte *)res_falloc_read(ress);
-    if (!_G(boss_sound)[0]) return 0;
-    _G(dig_sound)[NUM_SOUNDS - 3] = _G(boss_sound)[0];
+    _G(boss_sound[0]) = (byte *)res_falloc_read(ress);
+    if (!_G(boss_sound[0])) return 0;
+    _G(dig_sound[NUM_SOUNDS - 3]) = _G(boss_sound[0]);
 
     ress = Common::String::format("BOSSV%d2", num);
-    _G(boss_sound)[1] = (byte *)res_falloc_read(ress);
-    if (!_G(boss_sound)[1]) return 0;
-    _G(dig_sound)[NUM_SOUNDS - 2] = _G(boss_sound)[1];
+    _G(boss_sound[1]) = (byte *)res_falloc_read(ress);
+    if (!_G(boss_sound[1])) return 0;
+    _G(dig_sound[NUM_SOUNDS - 2]) = _G(boss_sound[1]);
 
     ress = Common::String::format("BOSSV%d3", num);
-    _G(boss_sound)[2] = (byte *)res_falloc_read(ress);
-    if (!_G(boss_sound)[2]) return 0;
-    _G(dig_sound)[NUM_SOUNDS - 1] = _G(boss_sound)[2];
+    _G(boss_sound[2]) = (byte *)res_falloc_read(ress);
+    if (!_G(boss_sound[2])) return 0;
+    _G(dig_sound[NUM_SOUNDS - 1]) = _G(boss_sound[2]);
 
     Common::String prefix = (num == 2) ? "BOSSP1" : Common::String::format("BOSSP%d", num);
     ress = prefix + "1";
-    _G(boss_pcsound)[0] = (byte *)res_falloc_read(ress);
-    if (!_G(boss_pcsound)[0]) return 0;
+    _G(boss_pcsound[0]) = (byte *)res_falloc_read(ress);
+    if (!_G(boss_pcsound[0])) return 0;
 
-    _G(pc_sound)[NUM_SOUNDS - 3] = _G(boss_pcsound)[0];
-    _G(pc_sound)[NUM_SOUNDS - 3][0] = 0;
-    _G(pc_sound)[NUM_SOUNDS - 3][1] = 0;
+    _G(pc_sound[NUM_SOUNDS - 3]) = _G(boss_pcsound[0]);
+    _G(pc_sound[NUM_SOUNDS - 3][0]) = 0;
+    _G(pc_sound[NUM_SOUNDS - 3][1]) = 0;
 
 	Common::File f;
 	if (!f.open(Common::Path(ress)))
         return 0;
-    _G(pcsound_length)[NUM_SOUNDS - 3] = f.size();
+    _G(pcsound_length[NUM_SOUNDS - 3]) = f.size();
     f.close();
 
     ress = prefix + "2";
-    _G(boss_pcsound)[1] = (byte *)res_falloc_read(ress);
-    if (!_G(boss_pcsound)[1]) return 0;
+    _G(boss_pcsound[1]) = (byte *)res_falloc_read(ress);
+    if (!_G(boss_pcsound[1])) return 0;
 
-    _G(pc_sound)[NUM_SOUNDS - 2] = _G(boss_pcsound)[1];
-    _G(pc_sound)[NUM_SOUNDS - 2][0] = 0;
-    _G(pc_sound)[NUM_SOUNDS - 2][1] = 0;
+    _G(pc_sound[NUM_SOUNDS - 2]) = _G(boss_pcsound[1]);
+    _G(pc_sound[NUM_SOUNDS - 2][0]) = 0;
+    _G(pc_sound[NUM_SOUNDS - 2][1]) = 0;
 
     if (!f.open(Common::Path(ress)))
         return 0;
-    _G(pcsound_length)[NUM_SOUNDS - 2] = f.size();
+    _G(pcsound_length[NUM_SOUNDS - 2]) = f.size();
     f.close();
 
     ress = prefix + "3";
-    _G(boss_pcsound)[2] = (byte *)res_falloc_read(ress);
-    if (!_G(boss_pcsound)[2]) return 0;
-    _G(pc_sound)[NUM_SOUNDS - 1] = _G(boss_pcsound)[2];
-    _G(pc_sound)[NUM_SOUNDS - 1][0] = 0;
-    _G(pc_sound)[NUM_SOUNDS - 1][1] = 0;
+    _G(boss_pcsound[2]) = (byte *)res_falloc_read(ress);
+    if (!_G(boss_pcsound[2])) return 0;
+    _G(pc_sound[NUM_SOUNDS - 1]) = _G(boss_pcsound[2]);
+    _G(pc_sound[NUM_SOUNDS - 1][0]) = 0;
+    _G(pc_sound[NUM_SOUNDS - 1][1]) = 0;
 
     if (!f.open(Common::Path(ress)))
         return 0;
-    _G(pcsound_length)[NUM_SOUNDS - 1] = f.size();
+    _G(pcsound_length[NUM_SOUNDS - 1]) = f.size();
     f.close();
 
     _G(boss_loaded) = num;
diff --git a/engines/got/game/main.cpp b/engines/got/game/main.cpp
index 65c79a17c9c..00baa84d28c 100644
--- a/engines/got/game/main.cpp
+++ b/engines/got/game/main.cpp
@@ -57,8 +57,8 @@ void setup_load() {
     _G(lightning_used) = false;
     _G(tornado_used) = false;
     _G(shield_on) = false;
-    _G(actor)[1].used = 0;
-    _G(actor)[2].used = 0;
+    _G(actor[1]).used = 0;
+    _G(actor[2]).used = 0;
     _G(thor)->speed_count = 6;
 
     _G(scrn).load(_G(new_level));
diff --git a/engines/got/game/main.h b/engines/got/game/main.h
index e49017143f5..210d829879d 100644
--- a/engines/got/game/main.h
+++ b/engines/got/game/main.h
@@ -22,8 +22,6 @@
 #ifndef GOT_GAME_MAIN_H
 #define GOT_GAME_MAIN_H
 
-#include "got/data/defines.h"
-
 namespace Got {
 
 extern void setup_load();
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index 536a9dc3433..d4b3bf18e7f 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -41,8 +41,8 @@ void show_objects() {
     for (int i = 0; i < OBJECTS_COUNT; i++) {
         if (_G(scrn).static_obj[i]) {
             int p = _G(scrn).static_x[i] + (_G(scrn).static_y[i] * TILES_X);
-            _G(object_index)[p] = i;
-            _G(object_map)[p] = _G(scrn).static_obj[i];
+            _G(object_index[p]) = i;
+            _G(object_map[p]) = _G(scrn).static_obj[i];
         }
     }
 }
@@ -50,7 +50,7 @@ void show_objects() {
 void pick_up_object(int p) {
     int r, x, y, s;
 
-    switch (_G(object_map)[p]) {
+    switch (_G(object_map[p])) {
     case 1:           // Red jewel
         if (_G(thor_info).jewels >= 999) {
             cannot_carry_more();
@@ -124,18 +124,18 @@ void pick_up_object(int p) {
     case 24:
     case 25:
     case 26:
-        if (_G(object_map)[p] == 13 && HERMIT_HAS_DOLL) return;
+        if (_G(object_map[p]) == 13 && HERMIT_HAS_DOLL) return;
         _G(thor)->num_moves = 1;
         _G(hammer)->num_moves = 2;
-        _G(actor)[2].used = 0;
+        _G(actor[2]).used = 0;
         _G(shield_on) = false;
         _G(tornado_used) = false;
         _G(thor_info).inventory |= 64;
         _G(thor_info).item = 7;
-        _G(thor_info).object = _G(object_map)[p] - 11;
+        _G(thor_info).object = _G(object_map[p]) - 11;
         display_item();
         _G(thor_info).object_name = OBJECT_NAMES[_G(thor_info).object - 1];
-        odin_speaks((_G(object_map)[p] - 12) + 501, _G(object_map)[p] - 1);
+        odin_speaks((_G(object_map[p]) - 12) + 501, _G(object_map[p]) - 1);
         break;
     case 27:
     case 28:
@@ -150,12 +150,12 @@ void pick_up_object(int p) {
         _G(tornado_used) = false;
         _G(hammer)->num_moves = 2;
         _G(thor)->num_moves = 1;
-        _G(actor)[2].used = 0;
-        s = 1 << (_G(object_map)[p] - 27);
+        _G(actor[2]).used = 0;
+        s = 1 << (_G(object_map[p]) - 27);
         _G(thor_info).inventory |= s;
-        odin_speaks((_G(object_map)[p] - 27) + 516, _G(object_map)[p] - 1);
+        odin_speaks((_G(object_map[p]) - 27) + 516, _G(object_map[p]) - 1);
         s = 1;
-        _G(thor_info).item = _G(object_map)[p] - 26;
+        _G(thor_info).item = _G(object_map[p]) - 26;
         display_item();
         add_magic(150);
         fill_score(5);
@@ -172,13 +172,13 @@ void pick_up_object(int p) {
     s = 0;
     if (!s)
         play_sound(YAH, false);
-    _G(object_map)[p] = 0;
+    _G(object_map[p]) = 0;
 
     if (r) {
         // Reset so it doesn't reappear on reentry to screen
-        if (_G(object_index)[p] < 30)
-            _G(scrn).static_obj[_G(object_index)[p]] = 0;
-        _G(object_index)[p] = 0;
+        if (_G(object_index[p]) < 30)
+            _G(scrn).static_obj[_G(object_index[p])] = 0;
+        _G(object_index[p]) = 0;
     }
 }
 
@@ -210,9 +210,9 @@ int drop_object(ACTOR *actr) {
 
 int _drop_obj(ACTOR *actr, int o) {
 	int p = (actr->x + (actr->size_x / 2)) / 16 + (((actr->y + (actr->size_y / 2)) / 16) * 20);
-    if (!_G(object_map)[p] && _G(scrn).icon[p / 20][p % 20] >= 140) {  //nothing there and solid
-        _G(object_map)[p] = o;
-        _G(object_index)[p] = 27 + actr->actor_num;  //actor is 3-15
+    if (!_G(object_map[p]) && _G(scrn).icon[p / 20][p % 20] >= 140) {  //nothing there and solid
+        _G(object_map[p]) = o;
+        _G(object_index[p]) = 27 + actr->actor_num;  //actor is 3-15
 
         return 1;
     }
@@ -275,7 +275,7 @@ int use_hourglass(int flag) {
 
     if (_G(hourglass_flag)) {
         if ((int)_G(magic_cnt) > hour_time[_G(hourglass_flag)]) {
-            _G(hourglass_flag)++;
+            _G(hourglass_flag++);
             if (_G(hourglass_flag) == 16) {
                 _G(hourglass_flag) = 0;
                 music_resume();
@@ -337,10 +337,10 @@ int use_shield(int flag) {
                 add_magic(-1);
                 setup_magic_item(1);
 
-                _G(actor)[2] = _G(magic_item)[1];
-                setup_actor(&_G(actor)[2], 2, 0, _G(thor)->x, _G(thor)->y);
-                _G(actor)[2].speed_count = 1;
-                _G(actor)[2].speed = 1;
+                _G(actor[2]) = _G(magic_item[1]);
+                setup_actor(&_G(actor[2]), 2, 0, _G(thor)->x, _G(thor)->y);
+                _G(actor[2]).speed_count = 1;
+                _G(actor[2]).speed = 1;
                 _G(shield_on) = true;
             } else if (_G(magic_cnt) > 8) {
                 _G(magic_cnt) = 0;
@@ -359,8 +359,8 @@ int use_shield(int flag) {
 
     if (f) {
         if (_G(shield_on)) {
-            _G(actor)[2].dead = 2;
-            _G(actor)[2].used = 0;
+            _G(actor[2]).dead = 2;
+            _G(actor[2]).used = 0;
             _G(shield_on) = false;
         }
     }
@@ -384,15 +384,15 @@ int use_lightning(int flag) {
 int use_tornado(int flag) {
     if (flag) {
         if (_G(thor_info).magic > 10) {
-            if (!_G(tornado_used) && !_G(actor)[2].dead && _G(magic_cnt) > 20) {
+            if (!_G(tornado_used) && !_G(actor[2]).dead && _G(magic_cnt) > 20) {
                 _G(magic_cnt) = 0;
                 add_magic(-10);
                 setup_magic_item(0);
-                _G(actor)[2] = _G(magic_item)[0];
+                _G(actor[2]) = _G(magic_item[0]);
 
-                setup_actor(&_G(actor)[2], 2, 0, _G(thor)->x, _G(thor)->y);
-                _G(actor)[2].last_dir = _G(thor)->dir;
-                _G(actor)[2].move = 16;
+                setup_actor(&_G(actor[2]), 2, 0, _G(thor)->x, _G(thor)->y);
+                _G(actor[2]).last_dir = _G(thor)->dir;
+                _G(actor[2]).move = 16;
                 _G(tornado_used) = true;
                 play_sound(WIND, false);
             }
@@ -407,7 +407,7 @@ int use_tornado(int flag) {
             }
         }
         if (_G(thor_info).magic < 1) {
-            actor_destroyed(&_G(actor)[2]);
+            actor_destroyed(&_G(actor[2]));
             _G(tornado_used) = false;
             not_enough_magic();
             return 0;
@@ -429,10 +429,10 @@ int use_object(int flag) {
 void use_item() {
     int ret = 0;
 
-    int kf = _G(key_flag)[key_magic];
+    int kf = _G(key_flag[key_magic]);
 
     if (!kf && _G(tornado_used)) {
-        actor_destroyed(&_G(actor)[2]);
+        actor_destroyed(&_G(actor[2]));
         _G(tornado_used) = false;
     }
 


Commit: 9cd3af680a8fed48b62b15d8eff6e7abad325f9f
    https://github.com/scummvm/scummvm/commit/9cd3af680a8fed48b62b15d8eff6e7abad325f9f
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Code formatting in init, main and object

Changed paths:
    engines/got/game/init.cpp
    engines/got/game/main.cpp
    engines/got/game/object.cpp


diff --git a/engines/got/game/init.cpp b/engines/got/game/init.cpp
index 66aea6a4a00..429db4bc84e 100644
--- a/engines/got/game/init.cpp
+++ b/engines/got/game/init.cpp
@@ -19,173 +19,178 @@
  *
  */
 
+#include "got/game/init.h"
 #include "common/memstream.h"
 #include "common/textconsole.h"
-#include "got/game/init.h"
+#include "got/events.h"
 #include "got/game/back.h"
-#include "got/game/main.h"
 #include "got/gfx/image.h"
-#include "got/utils/file.h"
-#include "got/events.h"
 #include "got/sound.h"
+#include "got/utils/file.h"
 #include "got/vars.h"
 
 namespace Got {
 
 void setup_player() {
 	_G(thor_info).clear();
-    _G(thor_info).inventory = 0;
-    if (_G(area) > 1)
-        _G(thor_info).inventory |= APPLE_MAGIC + LIGHTNING_MAGIC;
-    if (_G(area) > 2)
-        _G(thor_info).inventory |= BOOTS_MAGIC + WIND_MAGIC;
-
-    _G(thor)->health = 150;
-    _G(thor_info).magic = _G(area) > 1 ? 150 : 0;
-    _G(thor_info).jewels = 0;
-    _G(thor_info).score = 0;
-    _G(thor_info).keys = 0;
-    _G(thor_info).last_item = 0;
-    _G(thor_info).object = 0;
-    _G(thor_info).object_name = nullptr;
-    _G(thor)->last_x[0] = _G(thor)->x;
-    _G(thor)->last_x[1] = _G(thor)->x;
-    _G(thor)->last_y[0] = _G(thor)->y;
-    _G(thor)->last_y[1] = _G(thor)->y;
-    _G(thor_info).last_icon = (6 * 20) + 8;
-    _G(thor_info).last_screen = 23;
-    _G(thor)->dir = 1;
-
-    switch (_G(area)) {
-    case 1:
-        _G(thor)->x = 152;
-        _G(thor)->y = 96;
-        break;
-    case 2:
-        _G(thor)->x = 32;
-        _G(thor)->y = 32;
-        break;
-    case 3:
-        _G(thor)->x = 272;
-        _G(thor)->y = 80;
-        break;
-    default:
-        break;
-    }
+	_G(thor_info).inventory = 0;
+	if (_G(area) > 1)
+		_G(thor_info).inventory |= APPLE_MAGIC + LIGHTNING_MAGIC;
+	if (_G(area) > 2)
+		_G(thor_info).inventory |= BOOTS_MAGIC + WIND_MAGIC;
+
+	_G(thor)->health = 150;
+	_G(thor_info).magic = _G(area) > 1 ? 150 : 0;
+	_G(thor_info).jewels = 0;
+	_G(thor_info).score = 0;
+	_G(thor_info).keys = 0;
+	_G(thor_info).last_item = 0;
+	_G(thor_info).object = 0;
+	_G(thor_info).object_name = nullptr;
+	_G(thor)->last_x[0] = _G(thor)->x;
+	_G(thor)->last_x[1] = _G(thor)->x;
+	_G(thor)->last_y[0] = _G(thor)->y;
+	_G(thor)->last_y[1] = _G(thor)->y;
+	_G(thor_info).last_icon = (6 * 20) + 8;
+	_G(thor_info).last_screen = 23;
+	_G(thor)->dir = 1;
+
+	switch (_G(area)) {
+	case 1:
+		_G(thor)->x = 152;
+		_G(thor)->y = 96;
+		break;
+	case 2:
+		_G(thor)->x = 32;
+		_G(thor)->y = 32;
+		break;
+	case 3:
+		_G(thor)->x = 272;
+		_G(thor)->y = 80;
+		break;
+	default:
+		break;
+	}
 }
 
 void initialize_game() {
-    load_standard_actors();
-    setup_player();
-
-    if (_G(demo)) {
-        g_vars->setArea(1);
-        _G(thor)->health = 100;
-        _G(thor_info).magic = 100;
-        _G(thor_info).jewels = 463;
-        _G(thor_info).score = 12455;
-        _G(setup).skill = 0;
-        _G(thor_info).inventory = 1 + 2;
-        _G(current_level) = 54;
-        _G(thor_info).item = 2;
-
-        File f("DEMO");
-        _G(demoKeys).clear();
-        for (int i = 0; i < DEMO_LEN; ++i)
-            _G(demoKeys).push(f.readByte());
+	load_standard_actors();
+	setup_player();
+
+	if (_G(demo)) {
+		g_vars->setArea(1);
+		_G(thor)->health = 100;
+		_G(thor_info).magic = 100;
+		_G(thor_info).jewels = 463;
+		_G(thor_info).score = 12455;
+		_G(setup).skill = 0;
+		_G(thor_info).inventory = 1 + 2;
+		_G(current_level) = 54;
+		_G(thor_info).item = 2;
+
+		File f("DEMO");
+		_G(demoKeys).clear();
+		for (int i = 0; i < DEMO_LEN; ++i)
+			_G(demoKeys).push(f.readByte());
 
 		// Drop the first six bytes off. This comprises of
 		// the "part I" display in the original, and ScummVM
 		// doesn't do demo key processing until the game view
 		for (int i = 0; i < 6; ++i)
 			_G(demoKeys).pop();
-    }
+	}
 
-    _G(thor)->speed_count = 6;
+	_G(thor)->speed_count = 6;
 
-    // Load level data
-    _G(new_level) = _G(current_level);
-    _G(scrn).load(_G(current_level));
-    show_level(_G(current_level));
+	// Load level data
+	_G(new_level) = _G(current_level);
+	_G(scrn).load(_G(current_level));
+	show_level(_G(current_level));
 
-    if (!_G(auto_load)) {
-        _G(sound).music_play(_G(level_type), 1);
-    }
+	if (!_G(auto_load)) {
+		_G(sound).music_play(_G(level_type), 1);
+	}
 
-    g_vars->resetEndgameFlags();
-    _G(startup) = false;
+	g_vars->resetEndgameFlags();
+	_G(startup) = false;
 }
 
 int setup_boss(int num) {
-    if (_G(boss_loaded) == num)
-        return 1;
-
-    if (_G(boss_loaded)) {
-        for(int rep = 0; rep < 3; rep++) {
-            if (_G(boss_sound[rep]))
-                free(_G(boss_sound[rep]));
-            if (_G(boss_pcsound[rep]))
-                free(_G(boss_pcsound[rep]));
-        }
-    }
-
-    Common::String ress = Common::String::format("BOSSV%d1", num);
-    _G(boss_sound[0]) = (byte *)res_falloc_read(ress);
-    if (!_G(boss_sound[0])) return 0;
-    _G(dig_sound[NUM_SOUNDS - 3]) = _G(boss_sound[0]);
-
-    ress = Common::String::format("BOSSV%d2", num);
-    _G(boss_sound[1]) = (byte *)res_falloc_read(ress);
-    if (!_G(boss_sound[1])) return 0;
-    _G(dig_sound[NUM_SOUNDS - 2]) = _G(boss_sound[1]);
-
-    ress = Common::String::format("BOSSV%d3", num);
-    _G(boss_sound[2]) = (byte *)res_falloc_read(ress);
-    if (!_G(boss_sound[2])) return 0;
-    _G(dig_sound[NUM_SOUNDS - 1]) = _G(boss_sound[2]);
-
-    Common::String prefix = (num == 2) ? "BOSSP1" : Common::String::format("BOSSP%d", num);
-    ress = prefix + "1";
-    _G(boss_pcsound[0]) = (byte *)res_falloc_read(ress);
-    if (!_G(boss_pcsound[0])) return 0;
-
-    _G(pc_sound[NUM_SOUNDS - 3]) = _G(boss_pcsound[0]);
-    _G(pc_sound[NUM_SOUNDS - 3][0]) = 0;
-    _G(pc_sound[NUM_SOUNDS - 3][1]) = 0;
+	if (_G(boss_loaded) == num)
+		return 1;
+
+	if (_G(boss_loaded)) {
+		for (int rep = 0; rep < 3; rep++) {
+			if (_G(boss_sound[rep]))
+				free(_G(boss_sound[rep]));
+			if (_G(boss_pcsound[rep]))
+				free(_G(boss_pcsound[rep]));
+		}
+	}
+
+	Common::String ress = Common::String::format("BOSSV%d1", num);
+	_G(boss_sound[0]) = (byte *)res_falloc_read(ress);
+	if (!_G(boss_sound[0]))
+		return 0;
+	_G(dig_sound[NUM_SOUNDS - 3]) = _G(boss_sound[0]);
+
+	ress = Common::String::format("BOSSV%d2", num);
+	_G(boss_sound[1]) = (byte *)res_falloc_read(ress);
+	if (!_G(boss_sound[1]))
+		return 0;
+	_G(dig_sound[NUM_SOUNDS - 2]) = _G(boss_sound[1]);
+
+	ress = Common::String::format("BOSSV%d3", num);
+	_G(boss_sound[2]) = (byte *)res_falloc_read(ress);
+	if (!_G(boss_sound[2]))
+		return 0;
+	_G(dig_sound[NUM_SOUNDS - 1]) = _G(boss_sound[2]);
+
+	Common::String prefix = (num == 2) ? "BOSSP1" : Common::String::format("BOSSP%d", num);
+	ress = prefix + "1";
+	_G(boss_pcsound[0]) = (byte *)res_falloc_read(ress);
+	if (!_G(boss_pcsound[0]))
+		return 0;
+
+	_G(pc_sound[NUM_SOUNDS - 3]) = _G(boss_pcsound[0]);
+	_G(pc_sound[NUM_SOUNDS - 3][0]) = 0;
+	_G(pc_sound[NUM_SOUNDS - 3][1]) = 0;
 
 	Common::File f;
 	if (!f.open(Common::Path(ress)))
-        return 0;
-    _G(pcsound_length[NUM_SOUNDS - 3]) = f.size();
-    f.close();
-
-    ress = prefix + "2";
-    _G(boss_pcsound[1]) = (byte *)res_falloc_read(ress);
-    if (!_G(boss_pcsound[1])) return 0;
-
-    _G(pc_sound[NUM_SOUNDS - 2]) = _G(boss_pcsound[1]);
-    _G(pc_sound[NUM_SOUNDS - 2][0]) = 0;
-    _G(pc_sound[NUM_SOUNDS - 2][1]) = 0;
-
-    if (!f.open(Common::Path(ress)))
-        return 0;
-    _G(pcsound_length[NUM_SOUNDS - 2]) = f.size();
-    f.close();
-
-    ress = prefix + "3";
-    _G(boss_pcsound[2]) = (byte *)res_falloc_read(ress);
-    if (!_G(boss_pcsound[2])) return 0;
-    _G(pc_sound[NUM_SOUNDS - 1]) = _G(boss_pcsound[2]);
-    _G(pc_sound[NUM_SOUNDS - 1][0]) = 0;
-    _G(pc_sound[NUM_SOUNDS - 1][1]) = 0;
-
-    if (!f.open(Common::Path(ress)))
-        return 0;
-    _G(pcsound_length[NUM_SOUNDS - 1]) = f.size();
-    f.close();
-
-    _G(boss_loaded) = num;
-    return 1;
+		return 0;
+	_G(pcsound_length[NUM_SOUNDS - 3]) = f.size();
+	f.close();
+
+	ress = prefix + "2";
+	_G(boss_pcsound[1]) = (byte *)res_falloc_read(ress);
+	if (!_G(boss_pcsound[1]))
+		return 0;
+
+	_G(pc_sound[NUM_SOUNDS - 2]) = _G(boss_pcsound[1]);
+	_G(pc_sound[NUM_SOUNDS - 2][0]) = 0;
+	_G(pc_sound[NUM_SOUNDS - 2][1]) = 0;
+
+	if (!f.open(Common::Path(ress)))
+		return 0;
+	_G(pcsound_length[NUM_SOUNDS - 2]) = f.size();
+	f.close();
+
+	ress = prefix + "3";
+	_G(boss_pcsound[2]) = (byte *)res_falloc_read(ress);
+	if (!_G(boss_pcsound[2]))
+		return 0;
+	_G(pc_sound[NUM_SOUNDS - 1]) = _G(boss_pcsound[2]);
+	_G(pc_sound[NUM_SOUNDS - 1][0]) = 0;
+	_G(pc_sound[NUM_SOUNDS - 1][1]) = 0;
+
+	if (!f.open(Common::Path(ress)))
+		return 0;
+	_G(pcsound_length[NUM_SOUNDS - 1]) = f.size();
+	f.close();
+
+	_G(boss_loaded) = num;
+	return 1;
 }
 
 } // namespace Got
diff --git a/engines/got/game/main.cpp b/engines/got/game/main.cpp
index 00baa84d28c..0972a7412ee 100644
--- a/engines/got/game/main.cpp
+++ b/engines/got/game/main.cpp
@@ -26,49 +26,51 @@
 namespace Got {
 
 void setup_load() {
-    _G(thor)->used = 1;
-    _G(new_level) = _G(thor_info).last_screen;
-    _G(thor)->x = (_G(thor_info).last_icon % 20) * 16;
-    _G(thor)->y = ((_G(thor_info).last_icon / 20) * 16) - 1;
-    if (_G(thor)->x < 1) _G(thor)->x = 1;
-    if (_G(thor)->y < 0) _G(thor)->y = 0;
-    _G(thor)->last_x[0] = _G(thor)->x;
-    _G(thor)->last_x[1] = _G(thor)->x;
-    _G(thor)->last_y[0] = _G(thor)->y;
-    _G(thor)->last_y[1] = _G(thor)->y;
-    _G(thor)->dir = _G(thor_info).last_dir;
-    _G(thor)->last_dir = _G(thor_info).last_dir;
-    _G(thor)->health = _G(thor_info).last_health;
-    _G(thor_info).magic = _G(thor_info).last_magic;
-    _G(thor_info).jewels = _G(thor_info).last_jewels;
-    _G(thor_info).keys = _G(thor_info).last_keys;
-    _G(thor_info).score = _G(thor_info).last_score;
-    _G(thor_info).item = _G(thor_info).last_item;
-    _G(thor_info).inventory = _G(thor_info).last_inventory;
-    _G(thor_info).object = _G(thor_info).last_object;
-    _G(thor_info).object_name = _G(thor_info).last_object_name;
-    _G(thor)->num_moves = 1;
-    _G(thor)->vunerable = 60;
-    _G(thor)->show = 60;
-    _G(hourglass_flag) = 0;
-    _G(apple_flag) = false;
-    _G(bomb_flag) = false;
-    _G(thunder_flag) = 0;
-    _G(lightning_used) = false;
-    _G(tornado_used) = false;
-    _G(shield_on) = false;
-    _G(actor[1]).used = 0;
-    _G(actor[2]).used = 0;
-    _G(thor)->speed_count = 6;
+	_G(thor)->used = 1;
+	_G(new_level) = _G(thor_info).last_screen;
+	_G(thor)->x = (_G(thor_info).last_icon % 20) * 16;
+	_G(thor)->y = ((_G(thor_info).last_icon / 20) * 16) - 1;
+	if (_G(thor)->x < 1)
+		_G(thor)->x = 1;
+	if (_G(thor)->y < 0)
+		_G(thor)->y = 0;
+	_G(thor)->last_x[0] = _G(thor)->x;
+	_G(thor)->last_x[1] = _G(thor)->x;
+	_G(thor)->last_y[0] = _G(thor)->y;
+	_G(thor)->last_y[1] = _G(thor)->y;
+	_G(thor)->dir = _G(thor_info).last_dir;
+	_G(thor)->last_dir = _G(thor_info).last_dir;
+	_G(thor)->health = _G(thor_info).last_health;
+	_G(thor_info).magic = _G(thor_info).last_magic;
+	_G(thor_info).jewels = _G(thor_info).last_jewels;
+	_G(thor_info).keys = _G(thor_info).last_keys;
+	_G(thor_info).score = _G(thor_info).last_score;
+	_G(thor_info).item = _G(thor_info).last_item;
+	_G(thor_info).inventory = _G(thor_info).last_inventory;
+	_G(thor_info).object = _G(thor_info).last_object;
+	_G(thor_info).object_name = _G(thor_info).last_object_name;
+	_G(thor)->num_moves = 1;
+	_G(thor)->vunerable = 60;
+	_G(thor)->show = 60;
+	_G(hourglass_flag) = 0;
+	_G(apple_flag) = false;
+	_G(bomb_flag) = false;
+	_G(thunder_flag) = 0;
+	_G(lightning_used) = false;
+	_G(tornado_used) = false;
+	_G(shield_on) = false;
+	_G(actor[1]).used = 0;
+	_G(actor[2]).used = 0;
+	_G(thor)->speed_count = 6;
 
-    _G(scrn).load(_G(new_level));
+	_G(scrn).load(_G(new_level));
 
-    _G(current_level) = _G(new_level);
-    show_level(_G(new_level));
+	_G(current_level) = _G(new_level);
+	show_level(_G(new_level));
 }
 
 void pause(int delay) {
-    g_system->delayMillis(delay);
+	g_system->delayMillis(delay);
 }
 
 } // namespace Got
diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index d4b3bf18e7f..321ee1d3349 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -20,13 +20,13 @@
  */
 
 #include "got/game/object.h"
+#include "got/data/flags.h"
+#include "got/events.h"
 #include "got/game/back.h"
 #include "got/game/move.h"
-#include "got/gfx/panel.h"
 #include "got/game/status.h"
-#include "got/data/flags.h"
 #include "got/gfx/image.h"
-#include "got/events.h"
+#include "got/gfx/panel.h"
 #include "got/vars.h"
 
 namespace Got {
@@ -36,211 +36,211 @@ void cannot_carry_more();
 
 void show_objects() {
 	Common::fill(_G(object_map), _G(object_map) + TILES_COUNT, 0);
-    Common::fill(_G(object_index), _G(object_index) + TILES_COUNT, 0);
-
-    for (int i = 0; i < OBJECTS_COUNT; i++) {
-        if (_G(scrn).static_obj[i]) {
-            int p = _G(scrn).static_x[i] + (_G(scrn).static_y[i] * TILES_X);
-            _G(object_index[p]) = i;
-            _G(object_map[p]) = _G(scrn).static_obj[i];
-        }
-    }
+	Common::fill(_G(object_index), _G(object_index) + TILES_COUNT, 0);
+
+	for (int i = 0; i < OBJECTS_COUNT; i++) {
+		if (_G(scrn).static_obj[i]) {
+			int p = _G(scrn).static_x[i] + (_G(scrn).static_y[i] * TILES_X);
+			_G(object_index[p]) = i;
+			_G(object_map[p]) = _G(scrn).static_obj[i];
+		}
+	}
 }
 
 void pick_up_object(int p) {
-    int r, x, y, s;
-
-    switch (_G(object_map[p])) {
-    case 1:           // Red jewel
-        if (_G(thor_info).jewels >= 999) {
-            cannot_carry_more();
-            return;
-        }
-        add_jewels(10);
-        break;
-    case 2:           // Blue jewel
-        if (_G(thor_info).jewels >= 999) {
-            cannot_carry_more();
-            return;
-        }
-        add_jewels(1);
-        break;
-    case 3:           // Red potion
-        if (_G(thor_info).magic >= 150) {
-            cannot_carry_more();
-            return;
-        }
-        add_magic(10);
-        break;
-    case 4:           // Blue potion
-        if (_G(thor_info).magic >= 150) {
-            cannot_carry_more();
-            return;
-        }
-        add_magic(3);
-        break;
-    case 5:          // Good apple
-        if (_G(thor)->health >= 150) {
-            cannot_carry_more();
-            return;
-        }
-        play_sound(GULP, false);
-        s = 1;
-        add_health(5);
-        break;
-    case 6:           // Bad apple
-        play_sound(OW, false);
-        s = 1;
-        add_health(-10);
-        break;
-    case 7:           // Key (reset on exit)
-        add_keys(1);
-        break;
-    case 8:           // Treasure
-        if (_G(thor_info).jewels >= 999) {
-            cannot_carry_more();
-            return;
-        }
-        add_jewels(50);
-        break;
-    case 9:          // Trophy
-        add_score(100);
-        break;
-    case 10:         // Crown
-        add_score(1000);
-        break;
-    case 12:
-    case 13:
-    case 14:
-    case 15:
-    case 16:
-    case 17:
-    case 18:
-    case 19:
-    case 20:
-    case 21:
-    case 22:
-    case 23:
-    case 24:
-    case 25:
-    case 26:
-        if (_G(object_map[p]) == 13 && HERMIT_HAS_DOLL) return;
-        _G(thor)->num_moves = 1;
-        _G(hammer)->num_moves = 2;
-        _G(actor[2]).used = 0;
-        _G(shield_on) = false;
-        _G(tornado_used) = false;
-        _G(thor_info).inventory |= 64;
-        _G(thor_info).item = 7;
-        _G(thor_info).object = _G(object_map[p]) - 11;
-        display_item();
-        _G(thor_info).object_name = OBJECT_NAMES[_G(thor_info).object - 1];
-        odin_speaks((_G(object_map[p]) - 12) + 501, _G(object_map[p]) - 1);
-        break;
-    case 27:
-    case 28:
-    case 29:
-    case 30:
-    case 31:
-    case 32:
-        _G(hourglass_flag) = 0;
-        _G(thunder_flag) = 0;
-        _G(shield_on) = false;
-        _G(lightning_used) = false;
-        _G(tornado_used) = false;
-        _G(hammer)->num_moves = 2;
-        _G(thor)->num_moves = 1;
-        _G(actor[2]).used = 0;
-        s = 1 << (_G(object_map[p]) - 27);
-        _G(thor_info).inventory |= s;
-        odin_speaks((_G(object_map[p]) - 27) + 516, _G(object_map[p]) - 1);
-        s = 1;
-        _G(thor_info).item = _G(object_map[p]) - 26;
-        display_item();
-        add_magic(150);
-        fill_score(5);
-        break;
-    }
-    x = p % 20;
-    y = p / 20;
-
-    _G(ox) = x * 16;
-    _G(oy) = y * 16;
-    _G(of) = 1;
-
-    r = 1;
-    s = 0;
-    if (!s)
-        play_sound(YAH, false);
-    _G(object_map[p]) = 0;
-
-    if (r) {
-        // Reset so it doesn't reappear on reentry to screen
-        if (_G(object_index[p]) < 30)
-            _G(scrn).static_obj[_G(object_index[p])] = 0;
-        _G(object_index[p]) = 0;
-    }
+	int r, x, y, s;
+
+	switch (_G(object_map[p])) {
+	case 1: // Red jewel
+		if (_G(thor_info).jewels >= 999) {
+			cannot_carry_more();
+			return;
+		}
+		add_jewels(10);
+		break;
+	case 2: // Blue jewel
+		if (_G(thor_info).jewels >= 999) {
+			cannot_carry_more();
+			return;
+		}
+		add_jewels(1);
+		break;
+	case 3: // Red potion
+		if (_G(thor_info).magic >= 150) {
+			cannot_carry_more();
+			return;
+		}
+		add_magic(10);
+		break;
+	case 4: // Blue potion
+		if (_G(thor_info).magic >= 150) {
+			cannot_carry_more();
+			return;
+		}
+		add_magic(3);
+		break;
+	case 5: // Good apple
+		if (_G(thor)->health >= 150) {
+			cannot_carry_more();
+			return;
+		}
+		play_sound(GULP, false);
+		s = 1;
+		add_health(5);
+		break;
+	case 6: // Bad apple
+		play_sound(OW, false);
+		s = 1;
+		add_health(-10);
+		break;
+	case 7: // Key (reset on exit)
+		add_keys(1);
+		break;
+	case 8: // Treasure
+		if (_G(thor_info).jewels >= 999) {
+			cannot_carry_more();
+			return;
+		}
+		add_jewels(50);
+		break;
+	case 9: // Trophy
+		add_score(100);
+		break;
+	case 10: // Crown
+		add_score(1000);
+		break;
+	case 12:
+	case 13:
+	case 14:
+	case 15:
+	case 16:
+	case 17:
+	case 18:
+	case 19:
+	case 20:
+	case 21:
+	case 22:
+	case 23:
+	case 24:
+	case 25:
+	case 26:
+		if (_G(object_map[p]) == 13 && HERMIT_HAS_DOLL)
+			return;
+		_G(thor)->num_moves = 1;
+		_G(hammer)->num_moves = 2;
+		_G(actor[2]).used = 0;
+		_G(shield_on) = false;
+		_G(tornado_used) = false;
+		_G(thor_info).inventory |= 64;
+		_G(thor_info).item = 7;
+		_G(thor_info).object = _G(object_map[p]) - 11;
+		display_item();
+		_G(thor_info).object_name = OBJECT_NAMES[_G(thor_info).object - 1];
+		odin_speaks((_G(object_map[p]) - 12) + 501, _G(object_map[p]) - 1);
+		break;
+	case 27:
+	case 28:
+	case 29:
+	case 30:
+	case 31:
+	case 32:
+		_G(hourglass_flag) = 0;
+		_G(thunder_flag) = 0;
+		_G(shield_on) = false;
+		_G(lightning_used) = false;
+		_G(tornado_used) = false;
+		_G(hammer)->num_moves = 2;
+		_G(thor)->num_moves = 1;
+		_G(actor[2]).used = 0;
+		s = 1 << (_G(object_map[p]) - 27);
+		_G(thor_info).inventory |= s;
+		odin_speaks((_G(object_map[p]) - 27) + 516, _G(object_map[p]) - 1);
+		s = 1;
+		_G(thor_info).item = _G(object_map[p]) - 26;
+		display_item();
+		add_magic(150);
+		fill_score(5);
+		break;
+	}
+	x = p % 20;
+	y = p / 20;
+
+	_G(ox) = x * 16;
+	_G(oy) = y * 16;
+	_G(of) = 1;
+
+	r = 1;
+	s = 0;
+	if (!s)
+		play_sound(YAH, false);
+	_G(object_map[p]) = 0;
+
+	if (r) {
+		// Reset so it doesn't reappear on reentry to screen
+		if (_G(object_index[p]) < 30)
+			_G(scrn).static_obj[_G(object_index[p])] = 0;
+		_G(object_index[p]) = 0;
+	}
 }
 
 int drop_object(ACTOR *actr) {
-    int o;
-
-    int rnd1 = g_events->getRandomNumber(99);
-    int rnd2 = g_events->getRandomNumber(99);
-
-    if (rnd1 < 25)
-        o = 5;      // Apple
-    else if (rnd1 & 1) {
-        // Jewels
-        if (rnd2 < 10)
-            o = 1;      // Red
-        else
-            o = 2;      // Blue
-    } else {
-        // Potion
-        if (rnd2 < 10)
-            o = 3;      // Red
-        else
-            o = 4;      // Blue
-    }
-
-    _drop_obj(actr, o);
-    return 1;
+	int o;
+
+	int rnd1 = g_events->getRandomNumber(99);
+	int rnd2 = g_events->getRandomNumber(99);
+
+	if (rnd1 < 25)
+		o = 5; // Apple
+	else if (rnd1 & 1) {
+		// Jewels
+		if (rnd2 < 10)
+			o = 1; // Red
+		else
+			o = 2; // Blue
+	} else {
+		// Potion
+		if (rnd2 < 10)
+			o = 3; // Red
+		else
+			o = 4; // Blue
+	}
+
+	_drop_obj(actr, o);
+	return 1;
 }
 
 int _drop_obj(ACTOR *actr, int o) {
 	int p = (actr->x + (actr->size_x / 2)) / 16 + (((actr->y + (actr->size_y / 2)) / 16) * 20);
-    if (!_G(object_map[p]) && _G(scrn).icon[p / 20][p % 20] >= 140) {  //nothing there and solid
-        _G(object_map[p]) = o;
-        _G(object_index[p]) = 27 + actr->actor_num;  //actor is 3-15
+	if (!_G(object_map[p]) && _G(scrn).icon[p / 20][p % 20] >= 140) { //nothing there and solid
+		_G(object_map[p]) = o;
+		_G(object_index[p]) = 27 + actr->actor_num; //actor is 3-15
 
-        return 1;
-    }
+		return 1;
+	}
 
-    return 0;
+	return 0;
 }
 
 int use_apple(int flag) {
-    if (_G(thor)->health == 150)
-        return 0;
-
-    if (flag && _G(thor_info).magic > 0) {
-        if (!_G(apple_flag)) {
-            _G(magic_cnt) = 0;
-            add_magic(-2);
-            add_health(1);
-            play_sound(ANGEL, false);
-        } else if (_G(magic_cnt) > 8) {
-            _G(magic_cnt) = 0;
-            add_magic(-2);
-            add_health(1);
-            if (!sound_playing())
-                play_sound(ANGEL, false);
-        }
+	if (_G(thor)->health == 150)
+		return 0;
+
+	if (flag && _G(thor_info).magic > 0) {
+		if (!_G(apple_flag)) {
+			_G(magic_cnt) = 0;
+			add_magic(-2);
+			add_health(1);
+			play_sound(ANGEL, false);
+		} else if (_G(magic_cnt) > 8) {
+			_G(magic_cnt) = 0;
+			add_magic(-2);
+			add_health(1);
+			if (!sound_playing())
+				play_sound(ANGEL, false);
+		}
 		_G(apple_flag) = true;
 		return 1;
-
-    }
+	}
 
 	_G(apple_flag) = false;
 	if (flag)
@@ -251,245 +251,245 @@ int use_apple(int flag) {
 
 int use_thunder(int flag) {
 
-    if (flag && _G(thor_info).magic > 29) {
-        if (!_G(thunder_flag)) {
-            add_magic(-30);
-            play_sound(THUNDER, false);
-            _G(thunder_flag) = 60;
-        }
-        return 1;
-    }
+	if (flag && _G(thor_info).magic > 29) {
+		if (!_G(thunder_flag)) {
+			add_magic(-30);
+			play_sound(THUNDER, false);
+			_G(thunder_flag) = 60;
+		}
+		return 1;
+	}
 
 	if (flag && !_G(thunder_flag))
 		not_enough_magic();
 
-    if (_G(thunder_flag))
+	if (_G(thunder_flag))
 		return 1;
-    return 0;
+	return 0;
 }
 
 int use_hourglass(int flag) {
-    int hour_time[] = { 0,60,120,180,240,300,360,420,480,
-                        510,540,570,600,630,660,690
-                      };
-
-    if (_G(hourglass_flag)) {
-        if ((int)_G(magic_cnt) > hour_time[_G(hourglass_flag)]) {
-            _G(hourglass_flag++);
-            if (_G(hourglass_flag) == 16) {
-                _G(hourglass_flag) = 0;
-                music_resume();
-            }
-            play_sound(WOOP, true);
-        }
-        return 1;
-    }
-
-    if (flag && _G(thor_info).magic > 29) {
-        if (!_G(hourglass_flag)) {
-            _G(magic_cnt) = 0;
-            add_magic(-30);
-            music_pause();
-            play_sound(WOOP, true);
-            _G(hourglass_flag) = 1;
-            return 1;
-        }
-    } else {
-        _G(hourglass_flag) = 0;
-        if (flag) not_enough_magic();
-    }
-    return 0;
+	int hour_time[] = {0, 60, 120, 180, 240, 300, 360, 420, 480,
+					   510, 540, 570, 600, 630, 660, 690};
+
+	if (_G(hourglass_flag)) {
+		if ((int)_G(magic_cnt) > hour_time[_G(hourglass_flag)]) {
+			_G(hourglass_flag++);
+			if (_G(hourglass_flag) == 16) {
+				_G(hourglass_flag) = 0;
+				music_resume();
+			}
+			play_sound(WOOP, true);
+		}
+		return 1;
+	}
+
+	if (flag && _G(thor_info).magic > 29) {
+		if (!_G(hourglass_flag)) {
+			_G(magic_cnt) = 0;
+			add_magic(-30);
+			music_pause();
+			play_sound(WOOP, true);
+			_G(hourglass_flag) = 1;
+			return 1;
+		}
+	} else {
+		_G(hourglass_flag) = 0;
+		if (flag)
+			not_enough_magic();
+	}
+	return 0;
 }
 
 int use_boots(int flag) {
 
-    if (flag) {
-        if (_G(thor_info).magic > 0) {
-            if (_G(thor)->num_moves == 1) {
-                _G(magic_cnt) = 0;
-                add_magic(-1);
-            } else if (_G(magic_cnt) > 8) {
-                _G(magic_cnt) = 0;
-                add_magic(-1);
-            }
-            _G(thor)->num_moves = 2;
-            _G(hammer)->num_moves = 3;
-            return 1;
-        } else {
-            not_enough_magic();
-            _G(thor)->num_moves = 1;
-            _G(hammer)->num_moves = 2;
-        }
-    } else {
-        _G(thor)->num_moves = 1;
-        _G(hammer)->num_moves = 2;
-    }
-    return 0;
+	if (flag) {
+		if (_G(thor_info).magic > 0) {
+			if (_G(thor)->num_moves == 1) {
+				_G(magic_cnt) = 0;
+				add_magic(-1);
+			} else if (_G(magic_cnt) > 8) {
+				_G(magic_cnt) = 0;
+				add_magic(-1);
+			}
+			_G(thor)->num_moves = 2;
+			_G(hammer)->num_moves = 3;
+			return 1;
+		} else {
+			not_enough_magic();
+			_G(thor)->num_moves = 1;
+			_G(hammer)->num_moves = 2;
+		}
+	} else {
+		_G(thor)->num_moves = 1;
+		_G(hammer)->num_moves = 2;
+	}
+	return 0;
 }
 
 int use_shield(int flag) {
-    bool f = false;
-
-    if (flag) {
-        if (_G(thor_info).magic) {
-            if (!_G(shield_on)) {
-                _G(magic_cnt) = 0;
-                add_magic(-1);
-                setup_magic_item(1);
-
-                _G(actor[2]) = _G(magic_item[1]);
-                setup_actor(&_G(actor[2]), 2, 0, _G(thor)->x, _G(thor)->y);
-                _G(actor[2]).speed_count = 1;
-                _G(actor[2]).speed = 1;
-                _G(shield_on) = true;
-            } else if (_G(magic_cnt) > 8) {
-                _G(magic_cnt) = 0;
-                add_magic(-1);
-            }
-
-            return 1;
-
-        } else {
-            f = true;
-            not_enough_magic();
-        }
-    } else {
-        f = true;
-    }
-
-    if (f) {
-        if (_G(shield_on)) {
-            _G(actor[2]).dead = 2;
-            _G(actor[2]).used = 0;
-            _G(shield_on) = false;
-        }
-    }
-
-    return 0;
+	bool f = false;
+
+	if (flag) {
+		if (_G(thor_info).magic) {
+			if (!_G(shield_on)) {
+				_G(magic_cnt) = 0;
+				add_magic(-1);
+				setup_magic_item(1);
+
+				_G(actor[2]) = _G(magic_item[1]);
+				setup_actor(&_G(actor[2]), 2, 0, _G(thor)->x, _G(thor)->y);
+				_G(actor[2]).speed_count = 1;
+				_G(actor[2]).speed = 1;
+				_G(shield_on) = true;
+			} else if (_G(magic_cnt) > 8) {
+				_G(magic_cnt) = 0;
+				add_magic(-1);
+			}
+
+			return 1;
+
+		} else {
+			f = true;
+			not_enough_magic();
+		}
+	} else {
+		f = true;
+	}
+
+	if (f) {
+		if (_G(shield_on)) {
+			_G(actor[2]).dead = 2;
+			_G(actor[2]).used = 0;
+			_G(shield_on) = false;
+		}
+	}
+
+	return 0;
 }
 
 int use_lightning(int flag) {
-    if (flag) {
-        if (_G(thor_info).magic > 14) {
-            add_magic(-15);
-            g_events->send("Game", GameMessage("THROW_LIGHTNING"));
-        } else {
-            not_enough_magic();
-            return 0;
-        }
-    }
-    return 1;
+	if (flag) {
+		if (_G(thor_info).magic > 14) {
+			add_magic(-15);
+			g_events->send("Game", GameMessage("THROW_LIGHTNING"));
+		} else {
+			not_enough_magic();
+			return 0;
+		}
+	}
+	return 1;
 }
 
 int use_tornado(int flag) {
-    if (flag) {
-        if (_G(thor_info).magic > 10) {
-            if (!_G(tornado_used) && !_G(actor[2]).dead && _G(magic_cnt) > 20) {
-                _G(magic_cnt) = 0;
-                add_magic(-10);
-                setup_magic_item(0);
-                _G(actor[2]) = _G(magic_item[0]);
-
-                setup_actor(&_G(actor[2]), 2, 0, _G(thor)->x, _G(thor)->y);
-                _G(actor[2]).last_dir = _G(thor)->dir;
-                _G(actor[2]).move = 16;
-                _G(tornado_used) = true;
-                play_sound(WIND, false);
-            }
-        } else if (!_G(tornado_used)) {
-            not_enough_magic();
-            return 0;
-        }
-        if (_G(magic_cnt) > 8) {
-            if (_G(tornado_used)) {
-                _G(magic_cnt) = 0;
-                add_magic(-1);
-            }
-        }
-        if (_G(thor_info).magic < 1) {
-            actor_destroyed(&_G(actor[2]));
-            _G(tornado_used) = false;
-            not_enough_magic();
-            return 0;
-        }
-        return 1;
-    }
-    return 0;
+	if (flag) {
+		if (_G(thor_info).magic > 10) {
+			if (!_G(tornado_used) && !_G(actor[2]).dead && _G(magic_cnt) > 20) {
+				_G(magic_cnt) = 0;
+				add_magic(-10);
+				setup_magic_item(0);
+				_G(actor[2]) = _G(magic_item[0]);
+
+				setup_actor(&_G(actor[2]), 2, 0, _G(thor)->x, _G(thor)->y);
+				_G(actor[2]).last_dir = _G(thor)->dir;
+				_G(actor[2]).move = 16;
+				_G(tornado_used) = true;
+				play_sound(WIND, false);
+			}
+		} else if (!_G(tornado_used)) {
+			not_enough_magic();
+			return 0;
+		}
+		if (_G(magic_cnt) > 8) {
+			if (_G(tornado_used)) {
+				_G(magic_cnt) = 0;
+				add_magic(-1);
+			}
+		}
+		if (_G(thor_info).magic < 1) {
+			actor_destroyed(&_G(actor[2]));
+			_G(tornado_used) = false;
+			not_enough_magic();
+			return 0;
+		}
+		return 1;
+	}
+	return 0;
 }
 
 int use_object(int flag) {
-    if (!flag) return 0;
-    if (!(_G(thor_info).inventory & 64))
-        return 0;
+	if (!flag)
+		return 0;
+	if (!(_G(thor_info).inventory & 64))
+		return 0;
 
-    odin_speaks((_G(thor_info).object - 1) + 5501, _G(thor_info).object - 1);
-    return 1;
+	odin_speaks((_G(thor_info).object - 1) + 5501, _G(thor_info).object - 1);
+	return 1;
 }
 
 void use_item() {
-    int ret = 0;
-
-    int kf = _G(key_flag[key_magic]);
-
-    if (!kf && _G(tornado_used)) {
-        actor_destroyed(&_G(actor[2]));
-        _G(tornado_used) = false;
-    }
-
-    bool mf = _G(magic_inform);
-    switch (_G(thor_info).item) {
-    case 1:
-        ret = use_apple(kf);
-        break;
-    case 2:
-        ret = use_lightning(kf);
-        break;
-    case 3:
-        ret = use_boots(kf);
-        break;
-    case 4:
-        ret = use_tornado(kf);
-        break;
-    case 5:
-        ret = use_shield(kf);
-        break;
-    case 6:
-        ret = use_thunder(kf);
-        break;
-    case 7:
-        ret = use_object(kf);
-        break;
-
-    }
-    if (kf) {
-        if ((!ret) && (!_G(useItemFlag))) {
-            if (mf)
-                play_sound(BRAAPP, false);
-            _G(useItemFlag) = true;
-        }
-    } else {
-        _G(useItemFlag) = false;
-    }
+	int ret = 0;
+
+	int kf = _G(key_flag[key_magic]);
+
+	if (!kf && _G(tornado_used)) {
+		actor_destroyed(&_G(actor[2]));
+		_G(tornado_used) = false;
+	}
+
+	bool mf = _G(magic_inform);
+	switch (_G(thor_info).item) {
+	case 1:
+		ret = use_apple(kf);
+		break;
+	case 2:
+		ret = use_lightning(kf);
+		break;
+	case 3:
+		ret = use_boots(kf);
+		break;
+	case 4:
+		ret = use_tornado(kf);
+		break;
+	case 5:
+		ret = use_shield(kf);
+		break;
+	case 6:
+		ret = use_thunder(kf);
+		break;
+	case 7:
+		ret = use_object(kf);
+		break;
+	}
+	if (kf) {
+		if ((!ret) && (!_G(useItemFlag))) {
+			if (mf)
+				play_sound(BRAAPP, false);
+			_G(useItemFlag) = true;
+		}
+	} else {
+		_G(useItemFlag) = false;
+	}
 }
 
 void not_enough_magic() {
-    if (!_G(magic_inform))
-        odin_speaks(2006, 0);
+	if (!_G(magic_inform))
+		odin_speaks(2006, 0);
 
-    _G(magic_inform) = true;
+	_G(magic_inform) = true;
 }
 
 void cannot_carry_more() {
-    if (!_G(carry_inform))
-        odin_speaks(2007, 0);
-    _G(carry_inform) = true;
+	if (!_G(carry_inform))
+		odin_speaks(2007, 0);
+	_G(carry_inform) = true;
 }
 
 void delete_object() {
 
-    _G(thor_info).inventory &= 0xbf;
-    _G(thor_info).item = 1;
-    display_item();
+	_G(thor_info).inventory &= 0xbf;
+	_G(thor_info).item = 1;
+	display_item();
 }
 
 } // namespace Got


Commit: e334ef6c76806619d85e5e470f341cec3edacda7
    https://github.com/scummvm/scummvm/commit/e334ef6c76806619d85e5e470f341cec3edacda7
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: add a comment in object, small cleanup

Changed paths:
    engines/got/game/object.cpp


diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index 321ee1d3349..590e0a2fa0b 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -48,7 +48,7 @@ void show_objects() {
 }
 
 void pick_up_object(int p) {
-	int r, x, y, s;
+	int s; // CHECKME : Maybe it should be initialized to 0, and the assignment before the check should be remove
 
 	switch (_G(object_map[p])) {
 	case 1: // Red jewel
@@ -162,14 +162,14 @@ void pick_up_object(int p) {
 		fill_score(5);
 		break;
 	}
-	x = p % 20;
-	y = p / 20;
+	int x = p % 20;
+	int y = p / 20;
 
 	_G(ox) = x * 16;
 	_G(oy) = y * 16;
 	_G(of) = 1;
 
-	r = 1;
+	int r = 1;
 	s = 0;
 	if (!s)
 		play_sound(YAH, false);
@@ -302,7 +302,6 @@ int use_hourglass(int flag) {
 }
 
 int use_boots(int flag) {
-
 	if (flag) {
 		if (_G(thor_info).magic > 0) {
 			if (_G(thor)->num_moves == 1) {


Commit: 8ee0a057b1bb513a451a0e34746e9e70d57d29ae
    https://github.com/scummvm/scummvm/commit/8ee0a057b1bb513a451a0e34746e9e70d57d29ae
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: remove useless "else" checks in object

Changed paths:
    engines/got/game/object.cpp


diff --git a/engines/got/game/object.cpp b/engines/got/game/object.cpp
index 590e0a2fa0b..72781743447 100644
--- a/engines/got/game/object.cpp
+++ b/engines/got/game/object.cpp
@@ -314,11 +314,12 @@ int use_boots(int flag) {
 			_G(thor)->num_moves = 2;
 			_G(hammer)->num_moves = 3;
 			return 1;
-		} else {
-			not_enough_magic();
-			_G(thor)->num_moves = 1;
-			_G(hammer)->num_moves = 2;
 		}
+
+		not_enough_magic();
+		_G(thor)->num_moves = 1;
+		_G(hammer)->num_moves = 2;
+
 	} else {
 		_G(thor)->num_moves = 1;
 		_G(hammer)->num_moves = 2;
@@ -348,10 +349,10 @@ int use_shield(int flag) {
 
 			return 1;
 
-		} else {
-			f = true;
-			not_enough_magic();
 		}
+
+		f = true;
+		not_enough_magic();
 	} else {
 		f = true;
 	}


Commit: 9bbfd746df5161bb7f38b12de0d5c71c543b8d9a
    https://github.com/scummvm/scummvm/commit/9bbfd746df5161bb7f38b12de0d5c71c543b8d9a
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: modify access to global arrays in 3 more source files

Changed paths:
    engines/got/game/script.cpp
    engines/got/game/script.h
    engines/got/game/shot_movement.cpp
    engines/got/game/shot_pattern.cpp


diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 3b2cdb2e93e..808020b9d7a 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -26,7 +26,6 @@
 #include "got/game/object.h"
 #include "got/game/status.h"
 #include "got/gfx/image.h"
-#include "got/gfx/panel.h"
 #include "got/utils/file.h"
 #include "got/views/dialogs/ask.h"
 #include "got/views/dialogs/say.h"
@@ -45,7 +44,7 @@ static const char *SCR_COMMAND[] = {
     "ADDSCORE", "SAY", "ASK", "SOUND", "PLACETILE",
     "ITEMGIVE", "ITEMTAKE", "ITEMSAY", "SETFLAG", "LTOA",
     "PAUSE", "TEXT", "EXEC", "VISIBLE", "RANDOM",
-    NULL
+    nullptr
 };
 
 static const char *INTERNAL_VARIABLE[] = {
@@ -56,7 +55,7 @@ static const char *INTERNAL_VARIABLE[] = {
     "@DEAD", "@BRAAPP", "@WIND", "@PUNCH", "@CLANG",
     "@EXPLODE", "@FLAG", "@ITEM", "@THORTILE",
     "@THORPOS",
-    NULL
+    nullptr
 };
 
 static const char *SCR_ERROR[] = {
@@ -65,7 +64,7 @@ static const char *SCR_ERROR[] = {
     "Syntax", "Out of Range", "Undefined Label",
     "RETURN Without GOSUB", "Nesting",
     "NEXT Without FOR",
-    NULL
+    nullptr
 };
 
 static const char *OFFENSE[] = {
@@ -106,11 +105,10 @@ Scripts::~Scripts() {
     g_scripts = nullptr;
 }
 
-void Scripts::execute_script(long index, const Gfx::Pics &speakerIcon,
-                             ScriptEndFn endFn) {
+void Scripts::execute_script(long index, const Gfx::Pics &speakerIcon, ScriptEndFn endFn) {
     // Firstly disable any on-screen actors
     for (int i = 0; i < MAX_ACTORS; i++)
-        _G(actor)[i].show = 0;
+        _G(actor[i]).show = 0;
 
     _endFn = endFn;
     _scrIndex = index;
@@ -122,9 +120,7 @@ void Scripts::execute_script(long index, const Gfx::Pics &speakerIcon,
 }
 
 void Scripts::runScript(bool firstTime) {
-    int i;
-
-    // Clear line label buffer, line ptrs, and the gosub stack
+	// Clear line label buffer, line ptrs, and the gosub stack
     Common::fill((char *)_lineLabel, (char *)_lineLabel + 32 * 9, 0);
     Common::fill(_linePtr, _linePtr + 32, (char *)nullptr);
     Common::fill(_gosubStack, _gosubStack + 32, (char *)nullptr);
@@ -135,7 +131,7 @@ void Scripts::runScript(bool firstTime) {
     Common::fill(_forStack, _forStack + 11, (char *)nullptr);
     _forPtr = 0;
 
-    i = read_script_file();
+    int i = read_script_file();
     if (i != 0) {
         script_error(i);
         script_exit();
@@ -150,19 +146,20 @@ void Scripts::runScript(bool firstTime) {
 }
 
 void Scripts::scriptLoop() {
-    int ret;
-
-    while (!_paused) {
-        if (_G(cheat) && _G(key_flag)[_B])
+	while (!_paused) {
+        if (_G(cheat) && _G(key_flag[_B]))
 			break;
     	
-        ret = get_command();
+        int ret = get_command();
         if (ret == -1)
             break;       // Ignore NO END error
-        else if (ret == -2) {
+
+		if (ret == -2) {
             script_error(5);       // Syntax error
             break;
-        } else if (ret > 0) {
+        }
+
+    	if (ret > 0) {
             ret = exec_command(ret);
             if (ret == -100) {         // RUN command
                 if (_buffer)
@@ -200,16 +197,14 @@ int Scripts::skip_colon() {
 }
 
 int Scripts::get_command() {
-    int ret, i, len;
-
     if (!skip_colon()) return -1;
 
-    i = 0;
+    int i = 0;
     while (1) {
         if (!SCR_COMMAND[i])
             break;           // Lookup command
 
-        len = strlen(SCR_COMMAND[i]);
+        int len = strlen(SCR_COMMAND[i]);
         if (!strncmp(_buffPtr, SCR_COMMAND[i], len)) {
             _buffPtr += len;
             return i;
@@ -219,22 +214,28 @@ int Scripts::get_command() {
     }
 
     if (Common::isAlpha(*_buffPtr)) {
-        if (*(_buffPtr + 1) == '=') {           // Num var assignment
+		int ret;
+		if (*(_buffPtr + 1) == '=') { // Num var assignment
             i = (*_buffPtr) - 65;
             _buffPtr += 2;
             ret = calc_value();
-            if (!ret) return -2;
-            else {
-                _numVar[i] = _lValue;
-                return 0;
-            }
-        } else if (*(_buffPtr + 1) == '$' && *(_buffPtr + 2) == '=') {
+            if (!ret)
+				return -2;
+
+			_numVar[i] = _lValue;
+            return 0;
+        }
+
+    	if (*(_buffPtr + 1) == '$' && *(_buffPtr + 2) == '=') {
             i = (*_buffPtr) - 65;
             _buffPtr += 3;
             ret = calc_string(0);                 // String var assignment
             if (ret == 0) return -2;
-            else if (ret == -1) return -3;
+
+			if (ret == -1) return -3;
+    		
             if (strlen(_tempS) > 80) return -3;
+    		
             Common::strcpy_s(_strVar[i], _tempS);
             return 0;
         }
@@ -290,10 +291,8 @@ strdone:
 }
 
 void Scripts::get_str() {
-    int t;
-
-    _buffPtr++;
-    t = 0;
+	_buffPtr++;
+    int t = 0;
 
     while (1) {
         if (*_buffPtr == '"' || *_buffPtr == 0) {
@@ -308,12 +307,9 @@ void Scripts::get_str() {
 }
 
 int Scripts::calc_value() {
-    long tmpval2;
-    char exptype;
-    char ch;
 
-    tmpval2 = 0;
-    exptype = 1;
+	long tmpval2 = 0;
+    char exptype = 1;
 
     while (1) {
         if (!get_next_val()) return 0;
@@ -332,7 +328,7 @@ int Scripts::calc_value() {
             break;
         }
 
-        ch = *_buffPtr;
+        char ch = *_buffPtr;
         switch (ch) {
         case 42:
             exptype = 0;                       /* multiply */
@@ -356,11 +352,9 @@ int Scripts::calc_value() {
 }
 
 int Scripts::get_next_val() {
-    char ch;
-    char tmpstr[25];
-    int t;
+	char tmpstr[25];
 
-    ch = *_buffPtr;
+	char ch = *_buffPtr;
     if (ch == 0 || ch == ':')
 		return 0;
     if (ch == 64)
@@ -372,7 +366,7 @@ int Scripts::get_next_val() {
         return 1;
     }
 
-    t = 0;
+    int t = 0;
     if (strchr("0123456789-", ch)) {
         tmpstr[0] = ch;
         t++;
@@ -392,12 +386,10 @@ int Scripts::get_next_val() {
 }
 
 int Scripts::get_internal_variable() {
-    int i, len;
-
-    i = 0;
+	int i = 0;
     while (1) {
         if (!INTERNAL_VARIABLE[i]) return 0;         // Lookup internal variable
-        len = strlen(INTERNAL_VARIABLE[i]);
+        int len = strlen(INTERNAL_VARIABLE[i]);
         if (!strncmp(_buffPtr, INTERNAL_VARIABLE[i], len)) {
             _buffPtr += len;
             break;
@@ -468,9 +460,7 @@ int Scripts::get_internal_variable() {
 }
 
 int Scripts::get_line(char *src, char *dst) {
-    int cnt;
-
-    cnt = 0;
+	int cnt = 0;
     while (*src != 13) {
         if (*src != 10) {
             *dst = *src;
@@ -1024,12 +1014,12 @@ void Scripts::scr_func3() {
 
     if (y < 0 || x < 0 || y>11 || x>19) {
         play_sound(BRAAPP, true);
-        _G(key_flag)[key_magic] = false;
+        _G(key_flag[key_magic]) = false;
         return;
     }
     if (_G(scrn).icon[y][x] < 174 || _G(scrn).icon[y][x]>178) {
         play_sound(BRAAPP, true);
-        _G(key_flag)[key_magic] = false;
+        _G(key_flag[key_magic]) = false;
         return;
     }
 
@@ -1037,22 +1027,22 @@ void Scripts::scr_func3() {
     play_sound(WOOP, true);
     if (_G(current_level) == 106 && p == 69) {
         place_tile(x, y, 220);
-        _G(key_flag)[key_magic] = false;
+        _G(key_flag[key_magic]) = false;
         return;
     }
 
-    _G(key_flag)[key_magic] = false;
+    _G(key_flag[key_magic]) = false;
     place_tile(x, y, 191);
 
     if ((g_events->getRandomNumber(99)) < 25 ||
             (_G(current_level) == 13 && p == 150 && !_G(setup).f26 && _G(setup).f28)) {
-        if (!_G(object_map)[p] && _G(scrn).icon[y][x] >= 140) {  // nothing there and solid
+        if (!_G(object_map[p]) && _G(scrn).icon[y][x] >= 140) {  // nothing there and solid
             o = g_events->getRandomNumber(1, 5);
             if (_G(current_level) == 13 && p == 150 && !_G(setup).f26 && _G(setup).f28)
                 o = 20;
 
-            _G(object_map)[p] = o;
-            _G(object_index)[p] = 31;  // actor is 3-15
+            _G(object_map[p]) = o;
+            _G(object_index[p]) = 31;  // actor is 3-15
         }
     }
 }
@@ -1066,7 +1056,7 @@ void Scripts::scr_func5() {
     _G(scrn).actor_loc[1] -= 2;
     _G(scrn).actor_loc[2] -= 2;
     _G(scrn).actor_loc[3] -= 2;
-    _G(actor)[3].i1 = 16;
+    _G(actor[3]).i1 = 16;
 }
 
 int Scripts::cmd_exec() {
diff --git a/engines/got/game/script.h b/engines/got/game/script.h
index de61f880057..5d72fa6b04d 100644
--- a/engines/got/game/script.h
+++ b/engines/got/game/script.h
@@ -34,6 +34,28 @@ enum ScriptPause {
 };
 
 class Scripts {
+public:
+	Scripts();
+	~Scripts();
+
+	void execute_script(long index, const Gfx::Pics &speakerIcon,
+						ScriptEndFn endFn = nullptr);
+
+	void pause() {
+		_paused = SCRIPT_PAUSED;
+	}
+	void resume() {
+		_paused = SCRIPT_RESUMING;
+	}
+
+	void setAskResponse(int option);
+	void runIfResuming() {
+		if (_paused == SCRIPT_RESUMING) {
+			_paused = SCRIPT_READY;
+			scriptLoop();
+		}
+	}
+
 private:
     ScriptEndFn _endFn = nullptr;
     long  _numVar[26] = {};        // numeric variables
@@ -107,27 +129,6 @@ private:
     void runScript(bool firstTime = true);
     void scriptLoop();
 
-public:
-    Scripts();
-    ~Scripts();
-
-    void execute_script(long index, const Gfx::Pics &speakerIcon,
-                        ScriptEndFn endFn = nullptr);
-
-    void pause() {
-        _paused = SCRIPT_PAUSED;
-    }
-    void resume() {
-        _paused = SCRIPT_RESUMING;
-    }
-
-    void setAskResponse(int option);
-    void runIfResuming() {
-        if (_paused == SCRIPT_RESUMING) {
-            _paused = SCRIPT_READY;
-            scriptLoop();
-        }
-    }
 };
 
 extern void execute_script(long index, const Gfx::Pics &speakerIcon,
diff --git a/engines/got/game/shot_movement.cpp b/engines/got/game/shot_movement.cpp
index d3149ffe20d..8ea61fd602d 100644
--- a/engines/got/game/shot_movement.cpp
+++ b/engines/got/game/shot_movement.cpp
@@ -82,8 +82,8 @@ int shot_movement_none(ACTOR *actr) {
     actr->temp3--;
     if (!actr->temp3) {
         actor_destroyed(actr);
-        if (_G(actor)[actr->creator].num_shots)
-            _G(actor)[actr->creator].num_shots--;
+        if (_G(actor[actr->creator]).num_shots)
+            _G(actor[actr->creator]).num_shots--;
     }
 
     next_shot_frame(actr);
@@ -94,9 +94,9 @@ int shot_movement_none(ACTOR *actr) {
 }
 
 int shot_movement_one(ACTOR *actr) {
-    int d, x1 = 0, y1 = 0;
+    int x1 = 0, y1 = 0;
 
-    d = actr->last_dir;
+    int d = actr->last_dir;
 
     switch (d) {
     case 0:
@@ -119,7 +119,7 @@ int shot_movement_one(ACTOR *actr) {
 
     if (!check_move3(x1, y1, actr)) {
         actor_destroyed(actr);
-        if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+        if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
     } else {
         next_shot_frame(actr);
         actr->last_dir = d;
@@ -134,9 +134,9 @@ int shot_movement_one(ACTOR *actr) {
 }
 
 int shot_movement_two(ACTOR *actr) {
-    int d, x1 = 0, y1 = 0;
+    int x1 = 0, y1 = 0;
 
-    d = actr->last_dir;
+    int d = actr->last_dir;
 
     switch (d) {
     case 0:
@@ -158,7 +158,7 @@ int shot_movement_two(ACTOR *actr) {
     }
     if (!check_move4(x1, y1, actr)) {
         actor_destroyed(actr);
-        if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+        if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
     } else {
         next_shot_frame(actr);
         actr->last_dir = d;
@@ -170,11 +170,9 @@ int shot_movement_two(ACTOR *actr) {
 
 // Serpent fire
 int shot_movement_three(ACTOR *actr) {
-    int d;
-
-    d = actr->last_dir;
+	int d = actr->last_dir;
+	
     actr->x -= 2;
-
     actr->temp3--;
     actr->temp4--;
 
@@ -192,7 +190,7 @@ int shot_movement_three(ACTOR *actr) {
     }
     if (!actr->temp3) {
         actor_destroyed(actr);
-        if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+        if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
     } else {
         next_shot_frame(actr);
         actr->last_dir = d;
@@ -209,7 +207,7 @@ int shot_movement_four(ACTOR *actr) {
         actr->temp1--;
         if (!actr->temp1) {
             actor_destroyed(actr);
-            _G(apple_drop)++;
+            _G(apple_drop++);
             if (_G(apple_drop) == 4) {
                 if (_drop_obj(actr, 5)) _G(apple_drop) = 0;
                 else _G(apple_drop) = 3;
@@ -332,7 +330,7 @@ int shot_movement_six(ACTOR *actr) {
     actr->temp1--;
     if (!actr->temp1) {
         actor_destroyed(actr);
-        if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+        if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
     } else next_shot_frame(actr);
     if (actr->directions == 1) return 0;
     return actr->last_dir;
@@ -425,7 +423,7 @@ int shot_movement_eight(ACTOR *actr) {
     if (y > 164) y = 164;
     //   8       311
     if (x<1 || x>(319 - actr->size_x)) {
-        if (!actr->dead) if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+        if (!actr->dead) if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
         actor_destroyed(actr);
     }
     if (overlap(actr->x, actr->y, actr->x + actr->size_x, actr->y + actr->size_y,
@@ -444,7 +442,7 @@ int shot_movement_eight(ACTOR *actr) {
 int shot_movement_nine(ACTOR *actr) {
     actr->next++;
     if (actr->next == 3) {
-        _G(actor)[actr->creator].num_shots--;
+        _G(actor[actr->creator]).num_shots--;
         actor_destroyed(actr);
         return 0;
     }
@@ -465,7 +463,7 @@ int shot_movement_ten(ACTOR *actr) {
         f = 1;
     }
     if ((actr->y > 160) || f) {
-        if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+        if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
         actor_destroyed(actr);
     }
 
@@ -538,7 +536,7 @@ int shot_movement_eleven(ACTOR *actr) {
     }
 
     if (!check_move3(x1, y1, actr)) {
-        if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+        if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
         actor_destroyed(actr);
     } else next_frame(actr);
 
@@ -626,9 +624,9 @@ int shot_movement_thirteen(ACTOR *actr) {
     }
     if (actr->temp4) actr->temp4--;
     if (!actr->temp4) {
-        if (_G(actor)[actr->creator].num_shots) _G(actor)[actr->creator].num_shots--;
+        if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
         actor_destroyed(actr);
-        _G(apple_drop)++;
+        _G(apple_drop++);
         if (_G(apple_drop) > 4) {
             if (_drop_obj(actr, 5)) _G(apple_drop) = 0;
             else _G(apple_drop) = 4;
diff --git a/engines/got/game/shot_pattern.cpp b/engines/got/game/shot_pattern.cpp
index 9e17bdc7000..fa158d92dac 100644
--- a/engines/got/game/shot_pattern.cpp
+++ b/engines/got/game/shot_pattern.cpp
@@ -157,9 +157,9 @@ int shot_pattern_five(ACTOR *actr) {
 
             int num = actr->shot_actor;
             actr->shot_cnt = 50;
-            _G(actor)[num].temp3 = 120;
-            _G(actor)[num].temp4 = 5 + (_G(rand2) % 17);
-            _G(actor)[num].temp5 = _G(actor)[num].temp4;
+            _G(actor[num]).temp3 = 120;
+            _G(actor[num]).temp4 = 5 + (_G(rand2) % 17);
+            _G(actor[num]).temp5 = _G(actor[num]).temp4;
             actr->y -= 16;
             return 1;
         }


Commit: c9c9f22705bac6050f912f345aee2cb8675136c6
    https://github.com/scummvm/scummvm/commit/c9c9f22705bac6050f912f345aee2cb8675136c6
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Code formatting in script, shot_movement, shot_pattern and special_tile

Changed paths:
    engines/got/game/script.cpp
    engines/got/game/shot_movement.cpp
    engines/got/game/shot_pattern.cpp
    engines/got/game/special_tile.cpp


diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 808020b9d7a..1ef70e5f41a 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -19,18 +19,18 @@
  *
  */
 
-#include "common/textconsole.h"
 #include "got/game/script.h"
+#include "common/textconsole.h"
+#include "got/events.h"
 #include "got/game/back.h"
 #include "got/game/main.h"
 #include "got/game/object.h"
 #include "got/game/status.h"
 #include "got/gfx/image.h"
 #include "got/utils/file.h"
+#include "got/vars.h"
 #include "got/views/dialogs/ask.h"
 #include "got/views/dialogs/say.h"
-#include "got/events.h"
-#include "got/vars.h"
 
 namespace Got {
 
@@ -38,866 +38,891 @@ namespace Got {
 #define SCR_BUFF_SIZE 5000
 
 static const char *SCR_COMMAND[] = {
-    "!@#$%", "END", "GOTO", "GOSUB", "RETURN", "FOR", "NEXT",
-    "IF", "ELSE", "RUN",
-    "ADDJEWELS", "ADDHEALTH", "ADDMAGIC", "ADDKEYS",
-    "ADDSCORE", "SAY", "ASK", "SOUND", "PLACETILE",
-    "ITEMGIVE", "ITEMTAKE", "ITEMSAY", "SETFLAG", "LTOA",
-    "PAUSE", "TEXT", "EXEC", "VISIBLE", "RANDOM",
-    nullptr
-};
+	"!@#$%", "END", "GOTO", "GOSUB", "RETURN", "FOR", "NEXT",
+	"IF", "ELSE", "RUN",
+	"ADDJEWELS", "ADDHEALTH", "ADDMAGIC", "ADDKEYS",
+	"ADDSCORE", "SAY", "ASK", "SOUND", "PLACETILE",
+	"ITEMGIVE", "ITEMTAKE", "ITEMSAY", "SETFLAG", "LTOA",
+	"PAUSE", "TEXT", "EXEC", "VISIBLE", "RANDOM",
+	nullptr};
 
 static const char *INTERNAL_VARIABLE[] = {
-    "@JEWELS", "@HEALTH", "@MAGIC", "@SCORE",
-    "@SCREEN", "@KEYS",
-    "@OW", "@GULP", "@SWISH", "@YAH", "@ELECTRIC",
-    "@THUNDER", "@DOOR", "@FALL", "@ANGEL", "@WOOP",
-    "@DEAD", "@BRAAPP", "@WIND", "@PUNCH", "@CLANG",
-    "@EXPLODE", "@FLAG", "@ITEM", "@THORTILE",
-    "@THORPOS",
-    nullptr
-};
+	"@JEWELS", "@HEALTH", "@MAGIC", "@SCORE",
+	"@SCREEN", "@KEYS",
+	"@OW", "@GULP", "@SWISH", "@YAH", "@ELECTRIC",
+	"@THUNDER", "@DOOR", "@FALL", "@ANGEL", "@WOOP",
+	"@DEAD", "@BRAAPP", "@WIND", "@PUNCH", "@CLANG",
+	"@EXPLODE", "@FLAG", "@ITEM", "@THORTILE",
+	"@THORPOS",
+	nullptr};
 
 static const char *SCR_ERROR[] = {
-    "!@#$%", "Out of Memory", "Can't Read Script",
-    "Too Many Labels", "No END",
-    "Syntax", "Out of Range", "Undefined Label",
-    "RETURN Without GOSUB", "Nesting",
-    "NEXT Without FOR",
-    nullptr
-};
+	"!@#$%", "Out of Memory", "Can't Read Script",
+	"Too Many Labels", "No END",
+	"Syntax", "Out of Range", "Undefined Label",
+	"RETURN Without GOSUB", "Nesting",
+	"NEXT Without FOR",
+	nullptr};
 
 static const char *OFFENSE[] = {
-    "Cussing", "Rebellion", "Kissing Your Mother Goodbye",
-    "Being a Thunder God", "Door-to-Door Sales",
-    "Carrying a Concealed Hammer"
-};
+	"Cussing", "Rebellion", "Kissing Your Mother Goodbye",
+	"Being a Thunder God", "Door-to-Door Sales",
+	"Carrying a Concealed Hammer"};
 
 static const char *REASON[] = {
-    "We heard you say 'Booger'.",
-    "You look kind of rebellious.",
-    "Your mother turned you in.",
-    "We don't want you here.",
-    "Nobody wants your sweepers.",
-    "That's a dangerous weapon."
-};
+	"We heard you say 'Booger'.",
+	"You look kind of rebellious.",
+	"Your mother turned you in.",
+	"We don't want you here.",
+	"Nobody wants your sweepers.",
+	"That's a dangerous weapon."};
 
 Scripts::ScrFunction Scripts::scr_func[5] = {
-    &Scripts::scr_func1,
-    &Scripts::scr_func2,
-    &Scripts::scr_func3,
-    &Scripts::scr_func4,
-    &Scripts::scr_func5,
+	&Scripts::scr_func1,
+	&Scripts::scr_func2,
+	&Scripts::scr_func3,
+	&Scripts::scr_func4,
+	&Scripts::scr_func5,
 };
 
 Scripts *g_scripts;
 
-void execute_script(long index, const Gfx::Pics &speakerIcon,
-                    ScriptEndFn endFn) {
-    g_scripts->execute_script(index, speakerIcon, endFn);
+void execute_script(long index, const Gfx::Pics &speakerIcon, ScriptEndFn endFn) {
+	g_scripts->execute_script(index, speakerIcon, endFn);
 }
 
 Scripts::Scripts() {
-    g_scripts = this;
+	g_scripts = this;
 }
 
 Scripts::~Scripts() {
-    g_scripts = nullptr;
+	g_scripts = nullptr;
 }
 
 void Scripts::execute_script(long index, const Gfx::Pics &speakerIcon, ScriptEndFn endFn) {
-    // Firstly disable any on-screen actors
-    for (int i = 0; i < MAX_ACTORS; i++)
-        _G(actor[i]).show = 0;
+	// Firstly disable any on-screen actors
+	for (int i = 0; i < MAX_ACTORS; i++)
+		_G(actor[i]).show = 0;
 
-    _endFn = endFn;
-    _scrIndex = index;
-    _scrPic = speakerIcon;
+	_endFn = endFn;
+	_scrIndex = index;
+	_scrPic = speakerIcon;
 
-    Common::fill(_numVar, _numVar + 26, 0);
-    Common::fill((char *)_strVar, (char *)_strVar + 81 * 26, 0);
-    runScript();
+	Common::fill(_numVar, _numVar + 26, 0);
+	Common::fill((char *)_strVar, (char *)_strVar + 81 * 26, 0);
+	runScript();
 }
 
 void Scripts::runScript(bool firstTime) {
 	// Clear line label buffer, line ptrs, and the gosub stack
-    Common::fill((char *)_lineLabel, (char *)_lineLabel + 32 * 9, 0);
-    Common::fill(_linePtr, _linePtr + 32, (char *)nullptr);
-    Common::fill(_gosubStack, _gosubStack + 32, (char *)nullptr);
-    _gosubPtr = 0;
-
-    Common::fill(_forVar, _forVar + 11, 0);
-    Common::fill(_forVal, _forVal + 11, 0);
-    Common::fill(_forStack, _forStack + 11, (char *)nullptr);
-    _forPtr = 0;
-
-    int i = read_script_file();
-    if (i != 0) {
-        script_error(i);
-        script_exit();
-        return;
-    }
-
-    if (firstTime)
-        script_entry();
-
-    _buffPtr = _buffer;
-    scriptLoop();
+	Common::fill((char *)_lineLabel, (char *)_lineLabel + 32 * 9, 0);
+	Common::fill(_linePtr, _linePtr + 32, (char *)nullptr);
+	Common::fill(_gosubStack, _gosubStack + 32, (char *)nullptr);
+	_gosubPtr = 0;
+
+	Common::fill(_forVar, _forVar + 11, 0);
+	Common::fill(_forVal, _forVal + 11, 0);
+	Common::fill(_forStack, _forStack + 11, (char *)nullptr);
+	_forPtr = 0;
+
+	int i = read_script_file();
+	if (i != 0) {
+		script_error(i);
+		script_exit();
+		return;
+	}
+
+	if (firstTime)
+		script_entry();
+
+	_buffPtr = _buffer;
+	scriptLoop();
 }
 
 void Scripts::scriptLoop() {
 	while (!_paused) {
-        if (_G(cheat) && _G(key_flag[_B]))
+		if (_G(cheat) && _G(key_flag[_B]))
 			break;
-    	
-        int ret = get_command();
-        if (ret == -1)
-            break;       // Ignore NO END error
+
+		int ret = get_command();
+		if (ret == -1)
+			break; // Ignore NO END error
 
 		if (ret == -2) {
-            script_error(5);       // Syntax error
-            break;
-        }
-
-    	if (ret > 0) {
-            ret = exec_command(ret);
-            if (ret == -100) {         // RUN command
-                if (_buffer)
-                    free(_buffer);
-
-                runScript(false);
-                return;
-            }
-            if (!ret)
-                break;
-        }
-    }
-
-    if (!_paused)
-        script_exit();
+			script_error(5); // Syntax error
+			break;
+		}
+
+		if (ret > 0) {
+			ret = exec_command(ret);
+			if (ret == -100) { // RUN command
+				if (_buffer)
+					free(_buffer);
+
+				runScript(false);
+				return;
+			}
+			if (!ret)
+				break;
+		}
+	}
+
+	if (!_paused)
+		script_exit();
 }
 
 void Scripts::script_exit() {
-    if (_buffer) {
-        free(_buffer);
-        _buffer = nullptr;
-    }
+	if (_buffer) {
+		free(_buffer);
+		_buffer = nullptr;
+	}
 
-    if (_endFn)
-        _endFn();
+	if (_endFn)
+		_endFn();
 }
 
 int Scripts::skip_colon() {
-    while (*_buffPtr == 0 || *_buffPtr == ':') {
-        _buffPtr++;
-        if (_buffPtr > _buffEnd) return 0;
-    }
+	while (*_buffPtr == 0 || *_buffPtr == ':') {
+		_buffPtr++;
+		if (_buffPtr > _buffEnd)
+			return 0;
+	}
 
-    return 1;
+	return 1;
 }
 
 int Scripts::get_command() {
-    if (!skip_colon()) return -1;
+	if (!skip_colon())
+		return -1;
 
-    int i = 0;
-    while (1) {
-        if (!SCR_COMMAND[i])
-            break;           // Lookup command
-
-        int len = strlen(SCR_COMMAND[i]);
-        if (!strncmp(_buffPtr, SCR_COMMAND[i], len)) {
-            _buffPtr += len;
-            return i;
-        }
+	int i = 0;
+	while (1) {
+		if (!SCR_COMMAND[i])
+			break; // Lookup command
+
+		int len = strlen(SCR_COMMAND[i]);
+		if (!strncmp(_buffPtr, SCR_COMMAND[i], len)) {
+			_buffPtr += len;
+			return i;
+		}
 
-        i++;
-    }
+		i++;
+	}
 
-    if (Common::isAlpha(*_buffPtr)) {
+	if (Common::isAlpha(*_buffPtr)) {
 		int ret;
 		if (*(_buffPtr + 1) == '=') { // Num var assignment
-            i = (*_buffPtr) - 65;
-            _buffPtr += 2;
-            ret = calc_value();
-            if (!ret)
+			i = (*_buffPtr) - 65;
+			_buffPtr += 2;
+			ret = calc_value();
+			if (!ret)
 				return -2;
 
 			_numVar[i] = _lValue;
-            return 0;
-        }
-
-    	if (*(_buffPtr + 1) == '$' && *(_buffPtr + 2) == '=') {
-            i = (*_buffPtr) - 65;
-            _buffPtr += 3;
-            ret = calc_string(0);                 // String var assignment
-            if (ret == 0) return -2;
-
-			if (ret == -1) return -3;
-    		
-            if (strlen(_tempS) > 80) return -3;
-    		
-            Common::strcpy_s(_strVar[i], _tempS);
-            return 0;
-        }
-    }
-
-    return -2;
+			return 0;
+		}
+
+		if (*(_buffPtr + 1) == '$' && *(_buffPtr + 2) == '=') {
+			i = (*_buffPtr) - 65;
+			_buffPtr += 3;
+			ret = calc_string(0); // String var assignment
+			if (ret == 0)
+				return -2;
+
+			if (ret == -1)
+				return -3;
+
+			if (strlen(_tempS) > 80)
+				return -3;
+
+			Common::strcpy_s(_strVar[i], _tempS);
+			return 0;
+		}
+	}
+
+	return -2;
 }
 
 int Scripts::calc_string(int mode) {
-    // if mode==1 stop at comma
-    char varstr[255];
-    uint varnum;
+	// if mode==1 stop at comma
+	char varstr[255];
+	uint varnum;
 
-    Common::strcpy_s(varstr, "");
+	Common::strcpy_s(varstr, "");
 
-    if (!skip_colon()) return 0;
+	if (!skip_colon())
+		return 0;
 
 strloop:
-    if (*_buffPtr == '"') {
-        get_str();
-        if (strlen(varstr) + strlen(_tempS) < 255)
-            Common::strcat_s(varstr, _tempS);
-        goto nextstr;
-    }
-    if (Common::isAlpha(*_buffPtr)) {
-        if (*(_buffPtr + 1) == '$') {
-            varnum = (*_buffPtr) - 65;
-            if (strlen(varstr) + strlen(_strVar[varnum]) < 255)
-                Common::strcat_s(varstr, _strVar[varnum]);
-            _buffPtr += 2;
-            goto nextstr;
-        }
-    }
-    return 0;
+	if (*_buffPtr == '"') {
+		get_str();
+		if (strlen(varstr) + strlen(_tempS) < 255)
+			Common::strcat_s(varstr, _tempS);
+		goto nextstr;
+	}
+	if (Common::isAlpha(*_buffPtr)) {
+		if (*(_buffPtr + 1) == '$') {
+			varnum = (*_buffPtr) - 65;
+			if (strlen(varstr) + strlen(_strVar[varnum]) < 255)
+				Common::strcat_s(varstr, _strVar[varnum]);
+			_buffPtr += 2;
+			goto nextstr;
+		}
+	}
+	return 0;
 
 nextstr:
-    if (*_buffPtr == 0 || *_buffPtr == 58) {
-        _buffPtr++;
-        goto strdone;
-    }
-    if (*_buffPtr == ',' && mode == 1) goto strdone;
-
-    if (*_buffPtr == '+') {
-        _buffPtr++;
-        goto strloop;
-    }
-    return 0;
+	if (*_buffPtr == 0 || *_buffPtr == 58) {
+		_buffPtr++;
+		goto strdone;
+	}
+	if (*_buffPtr == ',' && mode == 1)
+		goto strdone;
+
+	if (*_buffPtr == '+') {
+		_buffPtr++;
+		goto strloop;
+	}
+	return 0;
 
 strdone:
-    if (strlen(varstr) > 255) return -1;
-    Common::strcpy_s(_tempS, (char *) varstr);
-    return 1;
+	if (strlen(varstr) > 255)
+		return -1;
+	Common::strcpy_s(_tempS, (char *)varstr);
+	return 1;
 }
 
 void Scripts::get_str() {
 	_buffPtr++;
-    int t = 0;
-
-    while (1) {
-        if (*_buffPtr == '"' || *_buffPtr == 0) {
-            _tempS[t] = 0;
-            if (*_buffPtr == '"') _buffPtr++;
-            return;
-        }
-
-        _tempS[t++] = *_buffPtr;
-        _buffPtr++;
-    }
+	int t = 0;
+
+	while (1) {
+		if (*_buffPtr == '"' || *_buffPtr == 0) {
+			_tempS[t] = 0;
+			if (*_buffPtr == '"')
+				_buffPtr++;
+			return;
+		}
+
+		_tempS[t++] = *_buffPtr;
+		_buffPtr++;
+	}
 }
 
 int Scripts::calc_value() {
 
 	long tmpval2 = 0;
-    char exptype = 1;
-
-    while (1) {
-        if (!get_next_val()) return 0;
-        switch (exptype) {
-        case 0:
-            tmpval2 = tmpval2 * _lTemp;
-            break;
-        case 1:
-            tmpval2 = tmpval2 + _lTemp;
-            break;
-        case 2:
-            tmpval2 = tmpval2 - _lTemp;
-            break;
-        case 3:
-            if (_lTemp != 0) tmpval2 = tmpval2 / _lTemp;
-            break;
-        }
-
-        char ch = *_buffPtr;
-        switch (ch) {
-        case 42:
-            exptype = 0;                       /* multiply */
-            break;
-        case 43:
-            exptype = 1;                       /* add */
-            break;
-        case 45:
-            exptype = 2;                       /* minus */
-            break;
-        case 47:
-            exptype = 3;                       /* divide */
-            break;
-        default:
-            _lValue = tmpval2;
-            return 1;
-        }
-
-        _buffPtr++;
-    }
+	char exptype = 1;
+
+	while (1) {
+		if (!get_next_val())
+			return 0;
+		switch (exptype) {
+		case 0:
+			tmpval2 = tmpval2 * _lTemp;
+			break;
+		case 1:
+			tmpval2 = tmpval2 + _lTemp;
+			break;
+		case 2:
+			tmpval2 = tmpval2 - _lTemp;
+			break;
+		case 3:
+			if (_lTemp != 0)
+				tmpval2 = tmpval2 / _lTemp;
+			break;
+		}
+
+		char ch = *_buffPtr;
+		switch (ch) {
+		case 42:
+			exptype = 0; /* multiply */
+			break;
+		case 43:
+			exptype = 1; /* add */
+			break;
+		case 45:
+			exptype = 2; /* minus */
+			break;
+		case 47:
+			exptype = 3; /* divide */
+			break;
+		default:
+			_lValue = tmpval2;
+			return 1;
+		}
+
+		_buffPtr++;
+	}
 }
 
 int Scripts::get_next_val() {
 	char tmpstr[25];
 
 	char ch = *_buffPtr;
-    if (ch == 0 || ch == ':')
+	if (ch == 0 || ch == ':')
 		return 0;
-    if (ch == 64)
+	if (ch == 64)
 		return get_internal_variable();
 
-    if (Common::isAlpha(ch)) {
-        _buffPtr++;
-        _lTemp = _numVar[ch - 65];
-        return 1;
-    }
-
-    int t = 0;
-    if (strchr("0123456789-", ch)) {
-        tmpstr[0] = ch;
-        t++;
-        _buffPtr++;
-        while (strchr("0123456789", *_buffPtr) && *_buffPtr != 0) {
-            tmpstr[t] = *_buffPtr;
-            _buffPtr++;
-            t++;
-        }
-        tmpstr[t] = 0;
-        if (t > 10) return 0;
-        _lTemp = atol(tmpstr);
-        return 1;
-    }
-
-    return 0;
+	if (Common::isAlpha(ch)) {
+		_buffPtr++;
+		_lTemp = _numVar[ch - 65];
+		return 1;
+	}
+
+	int t = 0;
+	if (strchr("0123456789-", ch)) {
+		tmpstr[0] = ch;
+		t++;
+		_buffPtr++;
+		while (strchr("0123456789", *_buffPtr) && *_buffPtr != 0) {
+			tmpstr[t] = *_buffPtr;
+			_buffPtr++;
+			t++;
+		}
+		tmpstr[t] = 0;
+		if (t > 10)
+			return 0;
+		_lTemp = atol(tmpstr);
+		return 1;
+	}
+
+	return 0;
 }
 
 int Scripts::get_internal_variable() {
 	int i = 0;
-    while (1) {
-        if (!INTERNAL_VARIABLE[i]) return 0;         // Lookup internal variable
-        int len = strlen(INTERNAL_VARIABLE[i]);
-        if (!strncmp(_buffPtr, INTERNAL_VARIABLE[i], len)) {
-            _buffPtr += len;
-            break;
-        }
-        i++;
-    }
-    switch (i) {
-    case 0:
-        _lTemp = _G(thor_info).jewels;
-        break;
-    case 1:
-        _lTemp = _G(thor)->health;
-        break;
-    case 2:
-        _lTemp = _G(thor_info).magic;
-        break;
-    case 3:
-        _lTemp = _G(thor_info).score;
-        break;
-    case 4:
-        _lTemp = _G(current_level);
-        break;
-    case 5:
-        _lTemp = _G(thor_info).keys;
-        break;
-    case 6:
-    case 7:
-    case 8:
-    case 9:
-    case 10:
-    case 11:
-    case 12:
-    case 13:
-    case 14:
-    case 15:
-    case 16:
-    case 17:
-    case 18:
-    case 19:
-    case 20:
-    case 21:
-        _lTemp = (long)(i - 5l);
-        break;
-    case 22:
-        if (!calc_value())
-            return 0;
-        i = (int)_lValue;
-        if (i < 1 || i>64)
-            return 0;
+	while (1) {
+		if (!INTERNAL_VARIABLE[i])
+			return 0; // Lookup internal variable
+		int len = strlen(INTERNAL_VARIABLE[i]);
+		if (!strncmp(_buffPtr, INTERNAL_VARIABLE[i], len)) {
+			_buffPtr += len;
+			break;
+		}
+		i++;
+	}
+	switch (i) {
+	case 0:
+		_lTemp = _G(thor_info).jewels;
+		break;
+	case 1:
+		_lTemp = _G(thor)->health;
+		break;
+	case 2:
+		_lTemp = _G(thor_info).magic;
+		break;
+	case 3:
+		_lTemp = _G(thor_info).score;
+		break;
+	case 4:
+		_lTemp = _G(current_level);
+		break;
+	case 5:
+		_lTemp = _G(thor_info).keys;
+		break;
+	case 6:
+	case 7:
+	case 8:
+	case 9:
+	case 10:
+	case 11:
+	case 12:
+	case 13:
+	case 14:
+	case 15:
+	case 16:
+	case 17:
+	case 18:
+	case 19:
+	case 20:
+	case 21:
+		_lTemp = (long)(i - 5l);
+		break;
+	case 22:
+		if (!calc_value())
+			return 0;
+		i = (int)_lValue;
+		if (i < 1 || i > 64)
+			return 0;
 
 		_lTemp = _G(setup)._flags[i - 1] ? 1 : 0;
-        break;
-    case 23:
-        if (_G(thor_info).inventory & 64) _lTemp = _G(thor_info).object;
-        else _lTemp = 0;
-        break;
-    case 24:
-        _lTemp = _G(scrn).icon[(_G(thor)->y + 8) / 16][(_G(thor)->x + 7) / 16];
-        break;
-    case 25:
-        _lTemp = (((_G(thor)->y + 8) / 16) * 20) + ((_G(thor)->x + 7) / 16);
-        break;
-    default:
-        return 0;
-    }
-
-    return 1;
+		break;
+	case 23:
+		if (_G(thor_info).inventory & 64)
+			_lTemp = _G(thor_info).object;
+		else
+			_lTemp = 0;
+		break;
+	case 24:
+		_lTemp = _G(scrn).icon[(_G(thor)->y + 8) / 16][(_G(thor)->x + 7) / 16];
+		break;
+	case 25:
+		_lTemp = (((_G(thor)->y + 8) / 16) * 20) + ((_G(thor)->x + 7) / 16);
+		break;
+	default:
+		return 0;
+	}
+
+	return 1;
 }
 
 int Scripts::get_line(char *src, char *dst) {
 	int cnt = 0;
-    while (*src != 13) {
-        if (*src != 10) {
-            *dst = *src;
-            dst++;
-        }
-        cnt++;
-        src++;
-    }
-
-    *dst = 0;
-    cnt++;
-    src++;
-
-    return cnt;
+	while (*src != 13) {
+		if (*src != 10) {
+			*dst = *src;
+			dst++;
+		}
+		cnt++;
+		src++;
+	}
+
+	*dst = 0;
+	cnt++;
+	src++;
+
+	return cnt;
 }
 
 int Scripts::read_script_file() {
-    char temp_buff[255];
-    char quote_flag;
-    int  i, len, p, ret, cnt;
-    char ch;
-    char *sb;
-    char *sbuff = nullptr;
-    Common::String str;
-    char tmps[255];
-
-    _buffer = (char *)malloc(SCR_BUFF_SIZE);
-    if (!_buffer) {
-        ret = 1;
-        goto done;
-    };
-    _buffPtr = _buffer;
-    Common::fill(_buffer, _buffer + SCR_BUFF_SIZE, 0);
-
-    sbuff = (char *)malloc(25000l);
-    if (!sbuff) {
-        ret = 1;
-        goto done;
-    };
-    sb = sbuff;
-
-    str = Common::String::format("SPEAK%d", _G(area));
-    if (res_read(str.c_str(), sb) < 0) {
-        ret = 6;
-        goto done;
-    }
-
-    str = Common::String::format("|%ld", _scrIndex);
-    Common::strcpy_s(temp_buff, str.c_str());
-
-    while (1) {
-        cnt = get_line(sb, (char *)tmps);
-        sb += cnt;
-        if (!strcmp(tmps, "|EOF")) {
-            ret = 2;
-            goto done;
-        }
-        if (!strcmp(tmps, temp_buff))
+	char temp_buff[255];
+	char quote_flag;
+	int i, len, p, ret, cnt;
+	char ch;
+	char *sb;
+	char *sbuff = nullptr;
+	Common::String str;
+	char tmps[255];
+
+	_buffer = (char *)malloc(SCR_BUFF_SIZE);
+	if (!_buffer) {
+		ret = 1;
+		goto done;
+	};
+	_buffPtr = _buffer;
+	Common::fill(_buffer, _buffer + SCR_BUFF_SIZE, 0);
+
+	sbuff = (char *)malloc(25000l);
+	if (!sbuff) {
+		ret = 1;
+		goto done;
+	};
+	sb = sbuff;
+
+	str = Common::String::format("SPEAK%d", _G(area));
+	if (res_read(str.c_str(), sb) < 0) {
+		ret = 6;
+		goto done;
+	}
+
+	str = Common::String::format("|%ld", _scrIndex);
+	Common::strcpy_s(temp_buff, str.c_str());
+
+	while (1) {
+		cnt = get_line(sb, (char *)tmps);
+		sb += cnt;
+		if (!strcmp(tmps, "|EOF")) {
+			ret = 2;
+			goto done;
+		}
+		if (!strcmp(tmps, temp_buff))
 			break;
-    }
-    _numLabels = 0;
-    while (1) {
-        cnt = get_line(sb, (char *)tmps);
-        if (!strcmp(tmps, "|STOP")) {
-            if (_buffPtr != _buffer) {
-                _buffEnd = _buffPtr;
-                ret = 0;
-                goto done;
-            }
-            ret = 2;
-            goto done;
-        }
-        sb += cnt;
-        len = strlen(tmps);
-        if (len < 2) {
-            *_buffPtr = 0;
-            _buffPtr++;
-            continue;
-        }
-        quote_flag = 0;
-        p = 0;
-        for (i = 0; i < len; i++) {
-            ch = tmps[i];
-            if (ch == 34) quote_flag ^= 1;
-            else if (ch == 13 || ch == 10) {  // Check for CR
-                temp_buff[p] = 0;
-                break;
-            } else if ((ch == 39 || ch == 96) && !quote_flag) {
-                temp_buff[p] = 0;
-                break;
-            }
-            if (!quote_flag) ch = toupper(ch);
-            if (quote_flag || ch > 32) {
-                temp_buff[p++] = ch;
-            }
-        }
-        temp_buff[p] = 0;
-
-        len = strlen(temp_buff);
-        if (len > 0 && len < 10 && temp_buff[len - 1] == ':') {       //line label
-            temp_buff[len - 1] = 0;
-            _linePtr[_numLabels] = _buffPtr;
-            Common::strcpy_s(_lineLabel[_numLabels++], (char *) temp_buff);
-            if (_numLabels > 31) {
-                ret = 3;
-                goto done;
-            }
-            *_buffPtr = 0;
-            _buffPtr++;
-            continue;
-        }
-
-        Common::strcpy_s(_buffPtr, SCR_BUFF_SIZE, temp_buff);
-        _buffPtr += strlen(temp_buff);
-        *_buffPtr = 0;
-        _buffPtr++;
-    }
+	}
+	_numLabels = 0;
+	while (1) {
+		cnt = get_line(sb, (char *)tmps);
+		if (!strcmp(tmps, "|STOP")) {
+			if (_buffPtr != _buffer) {
+				_buffEnd = _buffPtr;
+				ret = 0;
+				goto done;
+			}
+			ret = 2;
+			goto done;
+		}
+		sb += cnt;
+		len = strlen(tmps);
+		if (len < 2) {
+			*_buffPtr = 0;
+			_buffPtr++;
+			continue;
+		}
+		quote_flag = 0;
+		p = 0;
+		for (i = 0; i < len; i++) {
+			ch = tmps[i];
+			if (ch == 34)
+				quote_flag ^= 1;
+			else if (ch == 13 || ch == 10) { // Check for CR
+				temp_buff[p] = 0;
+				break;
+			} else if ((ch == 39 || ch == 96) && !quote_flag) {
+				temp_buff[p] = 0;
+				break;
+			}
+			if (!quote_flag)
+				ch = toupper(ch);
+			if (quote_flag || ch > 32) {
+				temp_buff[p++] = ch;
+			}
+		}
+		temp_buff[p] = 0;
+
+		len = strlen(temp_buff);
+		if (len > 0 && len < 10 && temp_buff[len - 1] == ':') { //line label
+			temp_buff[len - 1] = 0;
+			_linePtr[_numLabels] = _buffPtr;
+			Common::strcpy_s(_lineLabel[_numLabels++], (char *)temp_buff);
+			if (_numLabels > 31) {
+				ret = 3;
+				goto done;
+			}
+			*_buffPtr = 0;
+			_buffPtr++;
+			continue;
+		}
+
+		Common::strcpy_s(_buffPtr, SCR_BUFF_SIZE, temp_buff);
+		_buffPtr += strlen(temp_buff);
+		*_buffPtr = 0;
+		_buffPtr++;
+	}
 
 done:
-    if (sbuff)
-        free(sbuff);
+	if (sbuff)
+		free(sbuff);
 
-    return ret;
+	return ret;
 }
 
 void Scripts::script_error(int err_num) {
-    int line_num;
-    char *tb;
+	int line_num;
+	char *tb;
 
-    line_num = 1;
-    tb = _buffer;
+	line_num = 1;
+	tb = _buffer;
 
-    while (1) {
-        if (*tb == 0) line_num++;
-        if (tb >= _buffPtr)
+	while (1) {
+		if (*tb == 0)
+			line_num++;
+		if (tb >= _buffPtr)
 			break;
-        tb++;
-    }
+		tb++;
+	}
 
-    if (err_num > ERROR_MAX)
-        err_num = 5;       // Unknown=syntax
+	if (err_num > ERROR_MAX)
+		err_num = 5; // Unknown=syntax
 
-    warning("%s in Line #%d", SCR_ERROR[err_num], line_num);
+	warning("%s in Line #%d", SCR_ERROR[err_num], line_num);
 }
 
 int Scripts::cmd_goto() {
-    int i, len;
-    char s[255];
-    char *p;
-
-    Common::strcpy_s(s, _buffPtr);
-    p = strchr(s, ':');
-    if (p) *p = 0;
-
-    for (i = 0; i < _numLabels; i++) {
-        len = strlen(s);
-        if (len == 0)
+	int i, len;
+	char s[255];
+	char *p;
+
+	Common::strcpy_s(s, _buffPtr);
+	p = strchr(s, ':');
+	if (p)
+		*p = 0;
+
+	for (i = 0; i < _numLabels; i++) {
+		len = strlen(s);
+		if (len == 0)
 			break;
-        if (!strcmp(s, _lineLabel[i])) {
-            _newPtr = _linePtr[i];
-            _buffPtr += len;
-            return 0;
-        }
-    }
-    return 8;
+		if (!strcmp(s, _lineLabel[i])) {
+			_newPtr = _linePtr[i];
+			_buffPtr += len;
+			return 0;
+		}
+	}
+	return 8;
 }
 
 int Scripts::cmd_if() {
-    long tmpval1, tmpval2;
-    char exptype, ch;
+	long tmpval1, tmpval2;
+	char exptype, ch;
 
-    if (!calc_value())
+	if (!calc_value())
 		return 5;
-    tmpval1 = _lValue;
-    exptype = *_buffPtr;
-    _buffPtr++;
+	tmpval1 = _lValue;
+	exptype = *_buffPtr;
+	_buffPtr++;
 
-    ch = *_buffPtr;
-    if (ch == 60 || ch == 61 || ch == 62) {
-        if (exptype == *_buffPtr)
+	ch = *_buffPtr;
+	if (ch == 60 || ch == 61 || ch == 62) {
+		if (exptype == *_buffPtr)
 			return 5;
-        exptype += *_buffPtr;
-        _buffPtr++;
-    }
-    if (!calc_value())
+		exptype += *_buffPtr;
+		_buffPtr++;
+	}
+	if (!calc_value())
 		return 5;
 
 	tmpval2 = _lValue;
-    _buffPtr += 4;
+	_buffPtr += 4;
 
 	switch (exptype) {
-    case 60:                              /* less than */
-        if (tmpval1 < tmpval2) goto iftrue;
-        goto iffalse;
-    case 61:                              /* equal */
-        if (tmpval1 == tmpval2) goto iftrue;
-        goto iffalse;
-    case 62:                              /* greater than */
-        if (tmpval1 > tmpval2) goto iftrue;
-        goto iffalse;
-    case 121:                              /* less than or equal */
-        if (tmpval1 <= tmpval2) goto iftrue;
-        goto iffalse;
-    case 122:                              /* less or greater (not equal) */
-        if (tmpval1 != tmpval2) goto iftrue;
-        goto iffalse;
-    case 123:                              /* greater than or equal */
-        if (tmpval1 >= tmpval2) goto iftrue;
-        goto iffalse;
-    default:
-        return 5;
-    }
+	case 60: /* less than */
+		if (tmpval1 < tmpval2)
+			goto iftrue;
+		goto iffalse;
+	case 61: /* equal */
+		if (tmpval1 == tmpval2)
+			goto iftrue;
+		goto iffalse;
+	case 62: /* greater than */
+		if (tmpval1 > tmpval2)
+			goto iftrue;
+		goto iffalse;
+	case 121: /* less than or equal */
+		if (tmpval1 <= tmpval2)
+			goto iftrue;
+		goto iffalse;
+	case 122: /* less or greater (not equal) */
+		if (tmpval1 != tmpval2)
+			goto iftrue;
+		goto iffalse;
+	case 123: /* greater than or equal */
+		if (tmpval1 >= tmpval2)
+			goto iftrue;
+		goto iffalse;
+	default:
+		return 5;
+	}
 
 iffalse:
-    while (*_buffPtr != 0) _buffPtr++;
-    while (*_buffPtr == 0) _buffPtr++;
+	while (*_buffPtr != 0)
+		_buffPtr++;
+	while (*_buffPtr == 0)
+		_buffPtr++;
 
-    if (!strncmp(_buffPtr, "ELSE", 4))
+	if (!strncmp(_buffPtr, "ELSE", 4))
 		_buffPtr += 4;
 
 iftrue:
-    return 0;
+	return 0;
 }
 
 int Scripts::cmd_run() {
-    if (!calc_value())
+	if (!calc_value())
 		return 5;
 
-    _buffPtr++;
-    _scrIndex = _lValue;
-    return -100;
+	_buffPtr++;
+	_scrIndex = _lValue;
+	return -100;
 }
 
 int Scripts::cmd_addjewels() {
-    if (!calc_value())
-        return 5;
+	if (!calc_value())
+		return 5;
 
-    _buffPtr++;
+	_buffPtr++;
 
-    add_jewels(_lValue);
-    return 0;
+	add_jewels(_lValue);
+	return 0;
 }
 
 int Scripts::cmd_addhealth() {
-    if (!calc_value())
+	if (!calc_value())
 		return 5;
 
-    _buffPtr++;
-    add_health((int)_lValue);
-    return 0;
+	_buffPtr++;
+	add_health((int)_lValue);
+	return 0;
 }
 
 int Scripts::cmd_addmagic() {
-    if (!calc_value())
+	if (!calc_value())
 		return 5;
 
-    _buffPtr++;
-    add_magic((int)_lValue);
-    return 0;
+	_buffPtr++;
+	add_magic((int)_lValue);
+	return 0;
 }
 
 int Scripts::cmd_addkeys() {
-    if (!calc_value())
+	if (!calc_value())
 		return 5;
 
-    _buffPtr++;
-    add_keys((int)_lValue);
-    return 0;
+	_buffPtr++;
+	add_keys((int)_lValue);
+	return 0;
 }
 
 int Scripts::cmd_addscore() {
-    if (!calc_value())
+	if (!calc_value())
 		return 5;
 
-    _buffPtr++;
-    add_score((int)_lValue);
-    return 0;
+	_buffPtr++;
+	add_score((int)_lValue);
+	return 0;
 }
 
 int Scripts::cmd_say(int mode, int type) {
-    char *p;
-    int obj;
+	char *p;
+	int obj;
 
-    if (mode) {
-        if (!calc_value())
+	if (mode) {
+		if (!calc_value())
 			return 5;
-        _buffPtr++;
-        obj = (int)_lValue;
-        if (obj < 0 || obj>32)
+		_buffPtr++;
+		obj = (int)_lValue;
+		if (obj < 0 || obj > 32)
 			return 6;
-        if (obj) obj += 10;
-    } else obj = 0;
-
-    Common::fill(_G(tmp_buff), _G(tmp_buff) + TMP_SIZE, 0);
-    p = (char *)_G(tmp_buff);
-
-    while (calc_string(0)) {
-        Common::strcpy_s(p, TMP_SIZE, _tempS);
-        p += strlen(_tempS);
-        *(p) = 10;
-        p++;
-    }
-    *(p - 1) = 0;
+		if (obj)
+			obj += 10;
+	} else
+		obj = 0;
+
+	Common::fill(_G(tmp_buff), _G(tmp_buff) + TMP_SIZE, 0);
+	p = (char *)_G(tmp_buff);
+
+	while (calc_string(0)) {
+		Common::strcpy_s(p, TMP_SIZE, _tempS);
+		p += strlen(_tempS);
+		*(p) = 10;
+		p++;
+	}
+	*(p - 1) = 0;
 
-    pause();
-    Views::Dialogs::Say::show(obj, _scrPic, type);
+	pause();
+	Views::Dialogs::Say::show(obj, _scrPic, type);
 
-    return 0;
+	return 0;
 }
 
 int Scripts::cmd_ask() {
-    int v = 0;
-    uint p;
-    char title[41], opt[41];
-    Common::StringArray opts;
-
-    memset(_G(tmp_buff), 0, TMP_SIZE);
-
-    if (!skip_colon())
-        return 5;
-
-    if (Common::isAlpha(*_buffPtr)) {
-        v = *_buffPtr - 65;
-        _buffPtr++;
-        if (*_buffPtr != ',') return 5;
-        _buffPtr++;
-    } else {
-        return 5;
-    }
-
-    if (!calc_string(1))
-        return 5;
-
-    strncpy(title, _tempS, 41);
-    title[40] = 0;
-
-    if (*_buffPtr == ',') {
-        _buffPtr++;
-        if (!calc_value())
-            return 5;
-
-        _buffPtr++;
-        p = _lValue;
-    } else {
-        return 5;
-    }
-
-    _askVar = v;
-
-    while (calc_string(0)) {
-        Common::strcpy_s(opt, _tempS);
-        opts.push_back(opt);
-
-        if (opts.size() > 9)
-            return 3;
-    }
-
-    if (p > opts.size())
-        p = 0;
-
-    // Pause the script execution, and open up an ask window.
-    // Execution of the script will resume after a selection.
-    pause();
-    Views::Dialogs::Ask::show(title, opts);
-    return 0;
+	int v = 0;
+	uint p;
+	char title[41], opt[41];
+	Common::StringArray opts;
+
+	memset(_G(tmp_buff), 0, TMP_SIZE);
+
+	if (!skip_colon())
+		return 5;
+
+	if (Common::isAlpha(*_buffPtr)) {
+		v = *_buffPtr - 65;
+		_buffPtr++;
+		if (*_buffPtr != ',')
+			return 5;
+		_buffPtr++;
+	} else {
+		return 5;
+	}
+
+	if (!calc_string(1))
+		return 5;
+
+	strncpy(title, _tempS, 41);
+	title[40] = 0;
+
+	if (*_buffPtr == ',') {
+		_buffPtr++;
+		if (!calc_value())
+			return 5;
+
+		_buffPtr++;
+		p = _lValue;
+	} else {
+		return 5;
+	}
+
+	_askVar = v;
+
+	while (calc_string(0)) {
+		Common::strcpy_s(opt, _tempS);
+		opts.push_back(opt);
+
+		if (opts.size() > 9)
+			return 3;
+	}
+
+	if (p > opts.size())
+		p = 0;
+
+	// Pause the script execution, and open up an ask window.
+	// Execution of the script will resume after a selection.
+	pause();
+	Views::Dialogs::Ask::show(title, opts);
+	return 0;
 }
 
 void Scripts::setAskResponse(int option) {
-    _numVar[_askVar] = option;
-    resume();
+	_numVar[_askVar] = option;
+	resume();
 }
 
 int Scripts::cmd_sound() {
-    if (!calc_value())
+	if (!calc_value())
 		return 5;
 
-    _buffPtr++;
-    if (_lValue < 1 || _lValue>16) return 6;
-    play_sound((int)_lValue - 1, true);
-    return 0;
+	_buffPtr++;
+	if (_lValue < 1 || _lValue > 16)
+		return 6;
+	play_sound((int)_lValue - 1, true);
+	return 0;
 }
 
 int Scripts::cmd_settile() {
-    int screen, pos, tile;
+	int screen, pos, tile;
 
-    if (!calc_value())
+	if (!calc_value())
 		return 5;
-    _buffPtr++;
-    screen = (int)_lValue;
-    if (!calc_value())
+	_buffPtr++;
+	screen = (int)_lValue;
+	if (!calc_value())
 		return 5;
-    _buffPtr++;
-    pos = (int)_lValue;
-    if (!calc_value())
+	_buffPtr++;
+	pos = (int)_lValue;
+	if (!calc_value())
 		return 5;
-    tile = (int)_lValue;
+	tile = (int)_lValue;
 
 	if (screen < 0 || screen > 119)
 		return 6;
-    if (pos < 0 || pos > 239)
+	if (pos < 0 || pos > 239)
 		return 6;
-    if (tile < 0 || tile > 230)
+	if (tile < 0 || tile > 230)
 		return 6;
 
 	if (screen == _G(current_level)) {
-        place_tile(pos % 20, pos / 20, tile);
-    } else {
-        LEVEL tmp;
-        tmp.load(screen);
-        tmp.icon[pos / 20][pos % 20] = tile;
-        tmp.save(screen);
-    }
-    return 0;
+		place_tile(pos % 20, pos / 20, tile);
+	} else {
+		LEVEL tmp;
+		tmp.load(screen);
+		tmp.icon[pos / 20][pos % 20] = tile;
+		tmp.save(screen);
+	}
+	return 0;
 }
 
 int Scripts::cmd_itemgive() {
-    int i;
+	int i;
 
-    if (!calc_value())
-        return 5;
+	if (!calc_value())
+		return 5;
 
-    _buffPtr++;
-    i = (int)_lValue;
-    if (i < 1 || i > 15)
+	_buffPtr++;
+	i = (int)_lValue;
+	if (i < 1 || i > 15)
 		return 6;
 
-    _G(thor_info).inventory |= 64;
-    _G(thor_info).item = 7;
-    _G(thor_info).object = i;
-    _G(thor_info).object_name = OBJECT_NAMES[_G(thor_info).object - 1];
+	_G(thor_info).inventory |= 64;
+	_G(thor_info).item = 7;
+	_G(thor_info).object = i;
+	_G(thor_info).object_name = OBJECT_NAMES[_G(thor_info).object - 1];
 
-    return 0;
+	return 0;
 }
 
 int Scripts::cmd_itemtake() {
-    delete_object();
-    return 0;
+	delete_object();
+	return 0;
 }
 
 int Scripts::cmd_setflag() {
@@ -907,7 +932,7 @@ int Scripts::cmd_setflag() {
 		return 5;
 
 	i = (int)_lValue;
-	if (i < 1 || i>64)
+	if (i < 1 || i > 64)
 		return 6;
 
 	_G(setup)._flags[i - 1] = true;
@@ -939,282 +964,288 @@ int Scripts::cmd_ltoa() {
 }
 
 int Scripts::cmd_pause() {
-    if (!calc_value())
-        return 5;
-    _buffPtr++;
-    if (_lValue < 1 || _lValue>65535l)
-        return 6;
-
-    Got::pause((int)_lValue);
-    return 0;
+	if (!calc_value())
+		return 5;
+	_buffPtr++;
+	if (_lValue < 1 || _lValue > 65535l)
+		return 6;
+
+	Got::pause((int)_lValue);
+	return 0;
 }
 
 int Scripts::cmd_visible() {
-    if (!calc_value()) return 5;
-    _buffPtr++;
-    if (_lValue < 1 || _lValue>16) return 6;
+	if (!calc_value())
+		return 5;
+	_buffPtr++;
+	if (_lValue < 1 || _lValue > 16)
+		return 6;
 
-    actor_visible((int)_lValue);
-    return 0;
+	actor_visible((int)_lValue);
+	return 0;
 }
 
 int Scripts::cmd_random() {
-    int v, r;
+	int v, r;
 
-    if (Common::isAlpha(*_buffPtr)) {
-        v = *_buffPtr - 65;
-        _buffPtr++;
-        if (*_buffPtr != ',')
+	if (Common::isAlpha(*_buffPtr)) {
+		v = *_buffPtr - 65;
+		_buffPtr++;
+		if (*_buffPtr != ',')
 			return 5;
-        _buffPtr++;
+		_buffPtr++;
 	} else {
 		return 5;
 	}
 
-    if (!calc_value())
+	if (!calc_value())
 		return 5;
-    _buffPtr++;
-    r = (int)_lValue;
-    if (r < 1 || r>1000)
+	_buffPtr++;
+	r = (int)_lValue;
+	if (r < 1 || r > 1000)
 		return 6;
 
-    _numVar[v] = g_events->getRandomNumber(r - 1);
-    return 0;
+	_numVar[v] = g_events->getRandomNumber(r - 1);
+	return 0;
 }
 
 void Scripts::scr_func1() {
-    play_sound(FALL, true);
-
-    _G(new_level) = 109;
-    _G(new_level_tile) = 215;
-    _G(thor)->x = (_G(new_level_tile) % 20) * 16;
-    _G(thor)->y = ((_G(new_level_tile) / 20) * 16) - 2;
-
-    _G(thor)->last_x[0] = _G(thor)->x;
-    _G(thor)->last_x[1] = _G(thor)->x;
-    _G(thor)->last_y[0] = _G(thor)->y;
-    _G(thor)->last_y[1] = _G(thor)->y;
-    _G(thor)->show = 2;
+	play_sound(FALL, true);
+
+	_G(new_level) = 109;
+	_G(new_level_tile) = 215;
+	_G(thor)->x = (_G(new_level_tile) % 20) * 16;
+	_G(thor)->y = ((_G(new_level_tile) / 20) * 16) - 2;
+
+	_G(thor)->last_x[0] = _G(thor)->x;
+	_G(thor)->last_x[1] = _G(thor)->x;
+	_G(thor)->last_y[0] = _G(thor)->y;
+	_G(thor)->last_y[1] = _G(thor)->y;
+	_G(thor)->show = 2;
 }
 
 void Scripts::scr_func2() {
-    int r;
+	int r;
 
-    r = g_events->getRandomNumber(5);
-    Common::strcpy_s(_strVar[0], 81, OFFENSE[r]);
-    Common::strcpy_s(_strVar[1], 81, REASON[r]);
+	r = g_events->getRandomNumber(5);
+	Common::strcpy_s(_strVar[0], 81, OFFENSE[r]);
+	Common::strcpy_s(_strVar[1], 81, REASON[r]);
 }
 
 void Scripts::scr_func3() {
-    int p, x, y, o;
-
-    p = (((_G(thor)->y + 8) / 16) * 20) + ((_G(thor)->x + 7) / 16);
-    y = p / 20;
-    x = p % 20;
-
-    if (y < 0 || x < 0 || y>11 || x>19) {
-        play_sound(BRAAPP, true);
-        _G(key_flag[key_magic]) = false;
-        return;
-    }
-    if (_G(scrn).icon[y][x] < 174 || _G(scrn).icon[y][x]>178) {
-        play_sound(BRAAPP, true);
-        _G(key_flag[key_magic]) = false;
-        return;
-    }
-
-    _numVar[0] = 1;
-    play_sound(WOOP, true);
-    if (_G(current_level) == 106 && p == 69) {
-        place_tile(x, y, 220);
-        _G(key_flag[key_magic]) = false;
-        return;
-    }
-
-    _G(key_flag[key_magic]) = false;
-    place_tile(x, y, 191);
-
-    if ((g_events->getRandomNumber(99)) < 25 ||
-            (_G(current_level) == 13 && p == 150 && !_G(setup).f26 && _G(setup).f28)) {
-        if (!_G(object_map[p]) && _G(scrn).icon[y][x] >= 140) {  // nothing there and solid
-            o = g_events->getRandomNumber(1, 5);
-            if (_G(current_level) == 13 && p == 150 && !_G(setup).f26 && _G(setup).f28)
-                o = 20;
-
-            _G(object_map[p]) = o;
-            _G(object_index[p]) = 31;  // actor is 3-15
-        }
-    }
+	int p, x, y, o;
+
+	p = (((_G(thor)->y + 8) / 16) * 20) + ((_G(thor)->x + 7) / 16);
+	y = p / 20;
+	x = p % 20;
+
+	if (y < 0 || x < 0 || y > 11 || x > 19) {
+		play_sound(BRAAPP, true);
+		_G(key_flag[key_magic]) = false;
+		return;
+	}
+	if (_G(scrn).icon[y][x] < 174 || _G(scrn).icon[y][x] > 178) {
+		play_sound(BRAAPP, true);
+		_G(key_flag[key_magic]) = false;
+		return;
+	}
+
+	_numVar[0] = 1;
+	play_sound(WOOP, true);
+	if (_G(current_level) == 106 && p == 69) {
+		place_tile(x, y, 220);
+		_G(key_flag[key_magic]) = false;
+		return;
+	}
+
+	_G(key_flag[key_magic]) = false;
+	place_tile(x, y, 191);
+
+	if ((g_events->getRandomNumber(99)) < 25 ||
+		(_G(current_level) == 13 && p == 150 && !_G(setup).f26 && _G(setup).f28)) {
+		if (!_G(object_map[p]) && _G(scrn).icon[y][x] >= 140) { // nothing there and solid
+			o = g_events->getRandomNumber(1, 5);
+			if (_G(current_level) == 13 && p == 150 && !_G(setup).f26 && _G(setup).f28)
+				o = 20;
+
+			_G(object_map[p]) = o;
+			_G(object_index[p]) = 31; // actor is 3-15
+		}
+	}
 }
 
 void Scripts::scr_func4() {
-    _G(thunder_flag) = 60;
+	_G(thunder_flag) = 60;
 }
 
 void Scripts::scr_func5() {
-    _G(scrn).actor_loc[0] -= 2;
-    _G(scrn).actor_loc[1] -= 2;
-    _G(scrn).actor_loc[2] -= 2;
-    _G(scrn).actor_loc[3] -= 2;
-    _G(actor[3]).i1 = 16;
+	_G(scrn).actor_loc[0] -= 2;
+	_G(scrn).actor_loc[1] -= 2;
+	_G(scrn).actor_loc[2] -= 2;
+	_G(scrn).actor_loc[3] -= 2;
+	_G(actor[3]).i1 = 16;
 }
 
 int Scripts::cmd_exec() {
-    if (!calc_value())
+	if (!calc_value())
 		return 5;
-    _buffPtr++;
-    if (_lValue < 1 || _lValue>10)
-        return 6;
+	_buffPtr++;
+	if (_lValue < 1 || _lValue > 10)
+		return 6;
 
-    (this->*scr_func[_lValue - 1])();
-    return 0;
+	(this->*scr_func[_lValue - 1])();
+	return 0;
 }
 
 int Scripts::exec_command(int num) {
-    int ret;
-    char ch;
-
-    ret = 0;
-    switch (num) {
-    case 1:                          // end
-        return 0;
-    case 2:                          // goto
-        ret = cmd_goto();
-        if (!ret) _buffPtr = _newPtr;
-        break;
-    case 3:                          // gosub
-        ret = cmd_goto();
-        if (!ret) {
-            _gosubPtr++;
-            if (_gosubPtr > 31) {
-                ret = 10;
-                break;
-            }
-            _gosubStack[_gosubPtr] = _buffPtr;
-            _buffPtr = _newPtr;
-        }
-        break;
-    case 4:                         // return
-        if (!_gosubPtr) {
-            ret = 9;
-            break;
-        }
-        _buffPtr = _gosubStack[_gosubPtr--];
-        break;
-    case 5:                         // for
-        _forPtr++;
-        if (_forPtr > 10) {
-            ret = 10;
-            break;
-        }
-        ch = *_buffPtr;
-        if (!Common::isAlpha(ch)) {
-            ret = 5;
-            break;
-        }
-        ch -= 65;
-        _forVar[_forPtr] = ch;
-        _buffPtr += 2;
-        if (!calc_value()) {
-            ret = 5;
-            break;
-        }
-        _numVar[_forVar[_forPtr]] = _lValue;
-        _buffPtr += 2;
-        if (!calc_value()) {
-            ret = 5;
-            break;
-        }
-        _forVal[_forPtr] = _lValue;
-        _forStack[_forPtr] = _buffPtr;
-        break;
-    case 6:                         // next
-        if (!_forPtr) {
-            ret = 11;
-            break;
-        }
-        _numVar[_forVar[_forPtr]] = _numVar[_forVar[_forPtr]] + 1;
-        if (_numVar[_forVar[_forPtr]] <= _forVal[_forPtr])
-            _buffPtr = _forStack[_forPtr];
-        else _forPtr--;
-        break;
-    case 7:                         // if
-        ret = cmd_if();
-        break;
-    case 8:                         // else
-        while (*_buffPtr != 0) _buffPtr++;
-        break;
-    case 9:                         // run
-        ret = cmd_run();
-        if (ret < 0) return -100;
-        break;
-    case 10:                        // addjewels
-        ret = cmd_addjewels();
-        break;
-    case 11:                        // addhealth
-        ret = cmd_addhealth();
-        break;
-    case 12:                        // addmagic
-        ret = cmd_addmagic();
-        break;
-    case 13:                        // addkeys
-        ret = cmd_addkeys();
-        break;
-    case 14:                        // addscore
-        ret = cmd_addscore();
-        break;
-    case 15:                        // say
-        ret = cmd_say(0, 1);
-        break;
-    case 16:                        // ask
-        ret = cmd_ask();
-        break;
-    case 17:                        // sound
-        ret = cmd_sound();
-        break;
-    case 18:                        // settile
-        ret = cmd_settile();
-        break;
-    case 19:                        // itemgive
-        ret = cmd_itemgive();
-        break;
-    case 20:                        // itemtake
-        ret = cmd_itemtake();
-        break;
-    case 21:                        // itemsay
-        ret = cmd_say(1, 1);
-        break;
-    case 22:                        // setflag
-        ret = cmd_setflag();
-        break;
-    case 23:                        // ltoa
-        ret = cmd_ltoa();
-        break;
-    case 24:                        // pause
-        ret = cmd_pause();
-        break;
-    case 25:                        // text
-        ret = cmd_say(0, 0);
-        break;
-    case 26:                        // exec
-        ret = cmd_exec();
-        break;
-    case 27:                        // visible
-        ret = cmd_visible();
-        break;
-    case 28:                        // random
-        ret = cmd_random();
-        break;
-    default:
-        ret = 5;
-    }
+	int ret;
+	char ch;
+
+	ret = 0;
+	switch (num) {
+	case 1: // end
+		return 0;
+	case 2: // goto
+		ret = cmd_goto();
+		if (!ret)
+			_buffPtr = _newPtr;
+		break;
+	case 3: // gosub
+		ret = cmd_goto();
+		if (!ret) {
+			_gosubPtr++;
+			if (_gosubPtr > 31) {
+				ret = 10;
+				break;
+			}
+			_gosubStack[_gosubPtr] = _buffPtr;
+			_buffPtr = _newPtr;
+		}
+		break;
+	case 4: // return
+		if (!_gosubPtr) {
+			ret = 9;
+			break;
+		}
+		_buffPtr = _gosubStack[_gosubPtr--];
+		break;
+	case 5: // for
+		_forPtr++;
+		if (_forPtr > 10) {
+			ret = 10;
+			break;
+		}
+		ch = *_buffPtr;
+		if (!Common::isAlpha(ch)) {
+			ret = 5;
+			break;
+		}
+		ch -= 65;
+		_forVar[_forPtr] = ch;
+		_buffPtr += 2;
+		if (!calc_value()) {
+			ret = 5;
+			break;
+		}
+		_numVar[_forVar[_forPtr]] = _lValue;
+		_buffPtr += 2;
+		if (!calc_value()) {
+			ret = 5;
+			break;
+		}
+		_forVal[_forPtr] = _lValue;
+		_forStack[_forPtr] = _buffPtr;
+		break;
+	case 6: // next
+		if (!_forPtr) {
+			ret = 11;
+			break;
+		}
+		_numVar[_forVar[_forPtr]] = _numVar[_forVar[_forPtr]] + 1;
+		if (_numVar[_forVar[_forPtr]] <= _forVal[_forPtr])
+			_buffPtr = _forStack[_forPtr];
+		else
+			_forPtr--;
+		break;
+	case 7: // if
+		ret = cmd_if();
+		break;
+	case 8: // else
+		while (*_buffPtr != 0)
+			_buffPtr++;
+		break;
+	case 9: // run
+		ret = cmd_run();
+		if (ret < 0)
+			return -100;
+		break;
+	case 10: // addjewels
+		ret = cmd_addjewels();
+		break;
+	case 11: // addhealth
+		ret = cmd_addhealth();
+		break;
+	case 12: // addmagic
+		ret = cmd_addmagic();
+		break;
+	case 13: // addkeys
+		ret = cmd_addkeys();
+		break;
+	case 14: // addscore
+		ret = cmd_addscore();
+		break;
+	case 15: // say
+		ret = cmd_say(0, 1);
+		break;
+	case 16: // ask
+		ret = cmd_ask();
+		break;
+	case 17: // sound
+		ret = cmd_sound();
+		break;
+	case 18: // settile
+		ret = cmd_settile();
+		break;
+	case 19: // itemgive
+		ret = cmd_itemgive();
+		break;
+	case 20: // itemtake
+		ret = cmd_itemtake();
+		break;
+	case 21: // itemsay
+		ret = cmd_say(1, 1);
+		break;
+	case 22: // setflag
+		ret = cmd_setflag();
+		break;
+	case 23: // ltoa
+		ret = cmd_ltoa();
+		break;
+	case 24: // pause
+		ret = cmd_pause();
+		break;
+	case 25: // text
+		ret = cmd_say(0, 0);
+		break;
+	case 26: // exec
+		ret = cmd_exec();
+		break;
+	case 27: // visible
+		ret = cmd_visible();
+		break;
+	case 28: // random
+		ret = cmd_random();
+		break;
+	default:
+		ret = 5;
+	}
 
 	if (ret > 0) {
-        script_error(ret);
-        return 0;
-    }
+		script_error(ret);
+		return 0;
+	}
 
-    return 1;
+	return 1;
 }
 
 } // namespace Got
diff --git a/engines/got/game/shot_movement.cpp b/engines/got/game/shot_movement.cpp
index 8ea61fd602d..b5a75a7d758 100644
--- a/engines/got/game/shot_movement.cpp
+++ b/engines/got/game/shot_movement.cpp
@@ -20,10 +20,10 @@
  */
 
 #include "got/game/shot_movement.h"
+#include "got/events.h"
 #include "got/game/move.h"
 #include "got/game/move_patterns.h"
 #include "got/game/object.h"
-#include "got/events.h"
 #include "got/vars.h"
 
 namespace Got {
@@ -43,297 +43,338 @@ int shot_movement_eleven(ACTOR *actr);
 int shot_movement_twelve(ACTOR *actr);
 int shot_movement_thirteen(ACTOR *actr);
 
-int (*const shot_movement_func[]) (ACTOR *actr) = {
-    shot_movement_none,
-    shot_movement_one,
-    shot_movement_two,
-    shot_movement_three,
-    shot_movement_four,
-    shot_movement_five,
-    shot_movement_six,
-    shot_movement_seven,
-    shot_movement_eight,
-    shot_movement_nine,
-    shot_movement_ten,
-    shot_movement_eleven,
-    shot_movement_twelve,
-    shot_movement_thirteen
-};
+int (*const shot_movement_func[])(ACTOR *actr) = {
+	shot_movement_none,
+	shot_movement_one,
+	shot_movement_two,
+	shot_movement_three,
+	shot_movement_four,
+	shot_movement_five,
+	shot_movement_six,
+	shot_movement_seven,
+	shot_movement_eight,
+	shot_movement_nine,
+	shot_movement_ten,
+	shot_movement_eleven,
+	shot_movement_twelve,
+	shot_movement_thirteen};
 
 void next_shot_frame(ACTOR *actr) {
-    if (actr->directions == 4 && actr->frames == 1) {
-        actr->next = actr->last_dir;
-        actr->dir = 0;
-    } else {
-        actr->frame_count--;
-
-        if (actr->frame_count <= 0) {
-            actr->next++;
-            if (actr->next > 3)
-                actr->next = 0;
-
-            actr->frame_count = actr->frame_speed;
-        }
-    }
+	if (actr->directions == 4 && actr->frames == 1) {
+		actr->next = actr->last_dir;
+		actr->dir = 0;
+	} else {
+		actr->frame_count--;
+
+		if (actr->frame_count <= 0) {
+			actr->next++;
+			if (actr->next > 3)
+				actr->next = 0;
+
+			actr->frame_count = actr->frame_speed;
+		}
+	}
 }
 
 // Boss - snake
 int shot_movement_none(ACTOR *actr) {
-    actr->temp3--;
-    if (!actr->temp3) {
-        actor_destroyed(actr);
-        if (_G(actor[actr->creator]).num_shots)
-            _G(actor[actr->creator]).num_shots--;
-    }
-
-    next_shot_frame(actr);
-    if (actr->directions == 1)
-        return 0;
-
-    return actr->last_dir;
+	actr->temp3--;
+	if (!actr->temp3) {
+		actor_destroyed(actr);
+		if (_G(actor[actr->creator]).num_shots)
+			_G(actor[actr->creator]).num_shots--;
+	}
+
+	next_shot_frame(actr);
+	if (actr->directions == 1)
+		return 0;
+
+	return actr->last_dir;
 }
 
 int shot_movement_one(ACTOR *actr) {
-    int x1 = 0, y1 = 0;
-
-    int d = actr->last_dir;
-
-    switch (d) {
-    case 0:
-        x1 = actr->x;
-        y1 = actr->y - 2;
-        break;
-    case 1:
-        x1 = actr->x;
-        y1 = actr->y + 2;
-        break;
-    case 2:
-        x1 = actr->x - 2;
-        y1 = actr->y;
-        break;
-    case 3:
-        x1 = actr->x + 2;
-        y1 = actr->y;
-        break;
-    }
-
-    if (!check_move3(x1, y1, actr)) {
-        actor_destroyed(actr);
-        if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
-    } else {
-        next_shot_frame(actr);
-        actr->last_dir = d;
-    }
-
-    if (actr->directions == 1)
-        return 0;
-    if (actr->directions == 4 && actr->frames == 1)
-        return 0;
-
-    return d;
+	int x1 = 0, y1 = 0;
+
+	int d = actr->last_dir;
+
+	switch (d) {
+	case 0:
+		x1 = actr->x;
+		y1 = actr->y - 2;
+		break;
+	case 1:
+		x1 = actr->x;
+		y1 = actr->y + 2;
+		break;
+	case 2:
+		x1 = actr->x - 2;
+		y1 = actr->y;
+		break;
+	case 3:
+		x1 = actr->x + 2;
+		y1 = actr->y;
+		break;
+	}
+
+	if (!check_move3(x1, y1, actr)) {
+		actor_destroyed(actr);
+		if (_G(actor[actr->creator]).num_shots)
+			_G(actor[actr->creator]).num_shots--;
+	} else {
+		next_shot_frame(actr);
+		actr->last_dir = d;
+	}
+
+	if (actr->directions == 1)
+		return 0;
+	if (actr->directions == 4 && actr->frames == 1)
+		return 0;
+
+	return d;
 }
 
 int shot_movement_two(ACTOR *actr) {
-    int x1 = 0, y1 = 0;
-
-    int d = actr->last_dir;
-
-    switch (d) {
-    case 0:
-        x1 = actr->x;
-        y1 = actr->y - 2;
-        break;
-    case 1:
-        x1 = actr->x;
-        y1 = actr->y + 2;
-        break;
-    case 2:
-        x1 = actr->x - 2;
-        y1 = actr->y;
-        break;
-    case 3:
-        x1 = actr->x + 2;
-        y1 = actr->y;
-        break;
-    }
-    if (!check_move4(x1, y1, actr)) {
-        actor_destroyed(actr);
-        if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
-    } else {
-        next_shot_frame(actr);
-        actr->last_dir = d;
-    }
-    if (actr->directions == 1) return 0;
-    if (actr->directions == 4 && actr->frames == 1) return 0;
-    return d;
+	int x1 = 0, y1 = 0;
+
+	int d = actr->last_dir;
+
+	switch (d) {
+	case 0:
+		x1 = actr->x;
+		y1 = actr->y - 2;
+		break;
+	case 1:
+		x1 = actr->x;
+		y1 = actr->y + 2;
+		break;
+	case 2:
+		x1 = actr->x - 2;
+		y1 = actr->y;
+		break;
+	case 3:
+		x1 = actr->x + 2;
+		y1 = actr->y;
+		break;
+	}
+	if (!check_move4(x1, y1, actr)) {
+		actor_destroyed(actr);
+		if (_G(actor[actr->creator]).num_shots)
+			_G(actor[actr->creator]).num_shots--;
+	} else {
+		next_shot_frame(actr);
+		actr->last_dir = d;
+	}
+	if (actr->directions == 1)
+		return 0;
+	if (actr->directions == 4 && actr->frames == 1)
+		return 0;
+	return d;
 }
 
 // Serpent fire
 int shot_movement_three(ACTOR *actr) {
 	int d = actr->last_dir;
-	
-    actr->x -= 2;
-    actr->temp3--;
-    actr->temp4--;
-
-    if (overlap(_G(thor_x1) - 1, _G(thor_y1) - 1, _G(thor_x2) + 1, _G(thor_y2) + 1,
-                actr->x, actr->y, actr->x + 15, actr->y + 15)) {
-        actr->move = 0;
-        actr->speed = 6;
-        thor_damaged(actr);
-        actr->x += 2;
-    }
-    if (!actr->temp4) {
-        actr->temp4 = actr->temp5;
-        actr->speed++;
-        if (actr->speed > 6) actr->move = 0;
-    }
-    if (!actr->temp3) {
-        actor_destroyed(actr);
-        if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
-    } else {
-        next_shot_frame(actr);
-        actr->last_dir = d;
-    }
-    if (actr->directions == 1) return 0;
-    return d;
+
+	actr->x -= 2;
+	actr->temp3--;
+	actr->temp4--;
+
+	if (overlap(_G(thor_x1) - 1, _G(thor_y1) - 1, _G(thor_x2) + 1, _G(thor_y2) + 1,
+				actr->x, actr->y, actr->x + 15, actr->y + 15)) {
+		actr->move = 0;
+		actr->speed = 6;
+		thor_damaged(actr);
+		actr->x += 2;
+	}
+	if (!actr->temp4) {
+		actr->temp4 = actr->temp5;
+		actr->speed++;
+		if (actr->speed > 6)
+			actr->move = 0;
+	}
+	if (!actr->temp3) {
+		actor_destroyed(actr);
+		if (_G(actor[actr->creator]).num_shots)
+			_G(actor[actr->creator]).num_shots--;
+	} else {
+		next_shot_frame(actr);
+		actr->last_dir = d;
+	}
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // Wraith balls
 int shot_movement_four(ACTOR *actr) {
-    int x1, y1, xd, yd, d;
-
-    if (actr->temp1) {
-        actr->temp1--;
-        if (!actr->temp1) {
-            actor_destroyed(actr);
-            _G(apple_drop++);
-            if (_G(apple_drop) == 4) {
-                if (_drop_obj(actr, 5)) _G(apple_drop) = 0;
-                else _G(apple_drop) = 3;
-            } else _drop_obj(actr, 3);
-            return 0;
-        }
-    }
-    if (overlap(_G(thor)->x - 1, _G(thor)->y - 1, _G(thor_x2) + 1, _G(thor_y2) + 1,
-                actr->x, actr->y, actr->x + 15, actr->y + 15)) {
-        thor_damaged(actr);
-        actor_destroyed(actr);
-        return 0;
-    }
-
-    x1 = actr->x;
-    y1 = actr->y;
-    xd = yd = 0;
-    d = actr->last_dir;
-
-    if ((x1 > (_G(thor_x1))+1)) xd = -2;
-    else if ((x1 < (_G(thor_x1))-1)) xd = 2;
-
-    if (actr->actor_num == 1) {
-        if (y1 < (_G(thor_y1) - 6)) yd = 2;
-        else if (y1 > (_G(thor_y1) - 6)) yd = -2;
-    } else {
-        if (y1 < (_G(thor_real_y1) - 1)) yd = 2;
-        else if (y1 > (_G(thor_real_y1) + 1)) yd = -2;
-    }
-
-    if (xd && yd) {
-        if (xd == -2 && yd == -2) d = 2;
-        else if (xd == -2 && yd == 2) d = 2;
-        else if (xd == 2 && yd == -2) d = 3;
-        else if (xd == 2 && yd == 2) d = 3;
-        x1 += xd;
-        y1 += yd;
-        if (check_move3(x1, y1, actr)) {
-            next_frame(actr);
-            actr->last_dir = d;
-            if (actr->directions == 1) return 0;
-            return d;
-        }
-    } else {
-        if (xd == 0 && yd == 2) d = 1;
-        else if (xd == 0 && yd == -2) d = 0;
-        else if (xd == 2 && yd == 0) d = 3;
-        else if (xd == -2 && yd == 0) d = 2;
-    }
-    x1 = actr->x;
-    y1 = actr->y;
-    actr->toggle ^= 1;
-
-    if (actr->toggle) {
-        if (xd) {
-            x1 += xd;
-            if (check_move3(x1, y1, actr)) {
-                if (xd > 0) d = 3;
-                else d = 2;
-                next_frame(actr);
-                actr->last_dir = d;
-                if (actr->directions == 1) return 0;
-                return d;
-            }
-            x1 = actr->x;
-        }
-        if (yd) {
-            y1 += yd;
-            if (check_move3(x1, y1, actr)) {
-                if (yd > 0) d = 1;
-                else d = 0;
-                next_frame(actr);
-                actr->last_dir = d;
-                if (actr->directions == 1) return 0;
-                return d;
-            }
-        }
-        y1 = actr->y;
-    } else {
-        if (yd) {
-            y1 += yd;
-            if (check_move3(x1, y1, actr)) {
-                if (yd > 0) d = 1;
-                else d = 0;
-                next_frame(actr);
-                actr->last_dir = d;
-                if (actr->directions == 1) return 0;
-                return d;
-            }
-            y1 = actr->y;
-        }
-        if (xd) {
-            x1 += xd;
-            if (check_move3(x1, y1, actr)) {
-                if (xd > 0) d = 3;
-                else d = 2;
-                next_frame(actr);
-                actr->last_dir = d;
-                if (actr->directions == 1) return 0;
-                return d;
-            }
-        }
-    }
-    check_move3(actr->x, actr->y, actr);
-    next_frame(actr);
-    actr->last_dir = d;
-    if (actr->directions == 1) return 0;
-    return d;
+	int x1, y1, xd, yd, d;
+
+	if (actr->temp1) {
+		actr->temp1--;
+		if (!actr->temp1) {
+			actor_destroyed(actr);
+			_G(apple_drop++);
+			if (_G(apple_drop) == 4) {
+				if (_drop_obj(actr, 5))
+					_G(apple_drop) = 0;
+				else
+					_G(apple_drop) = 3;
+			} else
+				_drop_obj(actr, 3);
+			return 0;
+		}
+	}
+	if (overlap(_G(thor)->x - 1, _G(thor)->y - 1, _G(thor_x2) + 1, _G(thor_y2) + 1,
+				actr->x, actr->y, actr->x + 15, actr->y + 15)) {
+		thor_damaged(actr);
+		actor_destroyed(actr);
+		return 0;
+	}
+
+	x1 = actr->x;
+	y1 = actr->y;
+	xd = yd = 0;
+	d = actr->last_dir;
+
+	if ((x1 > (_G(thor_x1)) + 1))
+		xd = -2;
+	else if ((x1 < (_G(thor_x1)) - 1))
+		xd = 2;
+
+	if (actr->actor_num == 1) {
+		if (y1 < (_G(thor_y1) - 6))
+			yd = 2;
+		else if (y1 > (_G(thor_y1) - 6))
+			yd = -2;
+	} else {
+		if (y1 < (_G(thor_real_y1) - 1))
+			yd = 2;
+		else if (y1 > (_G(thor_real_y1) + 1))
+			yd = -2;
+	}
+
+	if (xd && yd) {
+		if (xd == -2 && yd == -2)
+			d = 2;
+		else if (xd == -2 && yd == 2)
+			d = 2;
+		else if (xd == 2 && yd == -2)
+			d = 3;
+		else if (xd == 2 && yd == 2)
+			d = 3;
+		x1 += xd;
+		y1 += yd;
+		if (check_move3(x1, y1, actr)) {
+			next_frame(actr);
+			actr->last_dir = d;
+			if (actr->directions == 1)
+				return 0;
+			return d;
+		}
+	} else {
+		if (xd == 0 && yd == 2)
+			d = 1;
+		else if (xd == 0 && yd == -2)
+			d = 0;
+		else if (xd == 2 && yd == 0)
+			d = 3;
+		else if (xd == -2 && yd == 0)
+			d = 2;
+	}
+	x1 = actr->x;
+	y1 = actr->y;
+	actr->toggle ^= 1;
+
+	if (actr->toggle) {
+		if (xd) {
+			x1 += xd;
+			if (check_move3(x1, y1, actr)) {
+				if (xd > 0)
+					d = 3;
+				else
+					d = 2;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1)
+					return 0;
+				return d;
+			}
+			x1 = actr->x;
+		}
+		if (yd) {
+			y1 += yd;
+			if (check_move3(x1, y1, actr)) {
+				if (yd > 0)
+					d = 1;
+				else
+					d = 0;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1)
+					return 0;
+				return d;
+			}
+		}
+		y1 = actr->y;
+	} else {
+		if (yd) {
+			y1 += yd;
+			if (check_move3(x1, y1, actr)) {
+				if (yd > 0)
+					d = 1;
+				else
+					d = 0;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1)
+					return 0;
+				return d;
+			}
+			y1 = actr->y;
+		}
+		if (xd) {
+			x1 += xd;
+			if (check_move3(x1, y1, actr)) {
+				if (xd > 0)
+					d = 3;
+				else
+					d = 2;
+				next_frame(actr);
+				actr->last_dir = d;
+				if (actr->directions == 1)
+					return 0;
+				return d;
+			}
+		}
+	}
+	check_move3(actr->x, actr->y, actr);
+	next_frame(actr);
+	actr->last_dir = d;
+	if (actr->directions == 1)
+		return 0;
+	return d;
 }
 
 // No move, frame cycle
 int shot_movement_five(ACTOR *actr) {
-    next_shot_frame(actr);
-    if (actr->directions == 1) return 0;
-    return actr->last_dir;
+	next_shot_frame(actr);
+	if (actr->directions == 1)
+		return 0;
+	return actr->last_dir;
 }
 
 // Wraith spots
 int shot_movement_six(ACTOR *actr) {
-    actr->temp1--;
-    if (!actr->temp1) {
-        actor_destroyed(actr);
-        if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
-    } else next_shot_frame(actr);
-    if (actr->directions == 1) return 0;
-    return actr->last_dir;
+	actr->temp1--;
+	if (!actr->temp1) {
+		actor_destroyed(actr);
+		if (_G(actor[actr->creator]).num_shots)
+			_G(actor[actr->creator]).num_shots--;
+	} else
+		next_shot_frame(actr);
+	if (actr->directions == 1)
+		return 0;
+	return actr->last_dir;
 }
 
 #define YV actr->i1
@@ -347,131 +388,144 @@ int shot_movement_six(ACTOR *actr) {
 
 // Skull drop
 int shot_movement_seven(ACTOR *actr) {
-    if (actr->temp3) {
-        actr->temp3--;
-        goto done;
-    }
-    if (overlap(actr->x, actr->y, actr->x + actr->size_x, actr->y + actr->size_y,
-                _G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15))
-        thor_damaged(actr);
-
-    actr->temp2++;
-    if (actr->temp2 > 2) {
-        if (actr->temp4) actr->temp4--;
-        actr->temp2 = 0;
-    }
-    actr->temp3 = actr->temp4;
-
-    actr->y += 2;
-    if (actr->y > 160 - 36) {
-        actr->x += (4 - g_events->getRandomNumber(8));
-        actr->move = 8;
-        YV = IV;
-        YC = 0;
-        BC = IC;
-        YD = 0;
-        XC = 3;
-        if (actr->x < 150) XD = 1;
-        else XD = 0;
-    }
+	if (actr->temp3) {
+		actr->temp3--;
+		goto done;
+	}
+	if (overlap(actr->x, actr->y, actr->x + actr->size_x, actr->y + actr->size_y,
+				_G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15))
+		thor_damaged(actr);
+
+	actr->temp2++;
+	if (actr->temp2 > 2) {
+		if (actr->temp4)
+			actr->temp4--;
+		actr->temp2 = 0;
+	}
+	actr->temp3 = actr->temp4;
+
+	actr->y += 2;
+	if (actr->y > 160 - 36) {
+		actr->x += (4 - g_events->getRandomNumber(8));
+		actr->move = 8;
+		YV = IV;
+		YC = 0;
+		BC = IC;
+		YD = 0;
+		XC = 3;
+		if (actr->x < 150)
+			XD = 1;
+		else
+			XD = 0;
+	}
 
 done:
-    next_shot_frame(actr);
-    if (actr->directions == 1) return 0;
-    return actr->last_dir;
+	next_shot_frame(actr);
+	if (actr->directions == 1)
+		return 0;
+	return actr->last_dir;
 }
 
 // Skull bounce
 int shot_movement_eight(ACTOR *actr) {
-    int x, y;
-
-    x = actr->x;
-    y = actr->y;
-
-    XC--;
-    if (!XC) {
-        XC = 3;
-        if (XD) x += 2;
-        else x -= 2;
-    }
-    YC += YV;
-    if (YC > (IV - 1)) {
-        if (!YD) {
-            YV -= 8;
-            YC -= IV;
-            y -= 2;
-        } else {
-            YV += 8;
-            YC -= IV;
-            y += 2;
-        }
-    }
-    if (YV < 0) {
-        YV = 0;
-        BC = 1;
-    }
-    if (YV > IV) {
-        YV = IV;
-        BC = 1;
-    }
-    BC--;
-    if (!BC) {
-        BC = IC;
-        if (YD) YV = IV;
-        YD ^= 1;
-    }
-    if (y > 164) y = 164;
-    //   8       311
-    if (x<1 || x>(319 - actr->size_x)) {
-        if (!actr->dead) if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
-        actor_destroyed(actr);
-    }
-    if (overlap(actr->x, actr->y, actr->x + actr->size_x, actr->y + actr->size_y,
-                _G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15))
-        thor_damaged(actr);
-    actr->x = x;
-    actr->y = y;
-
-//done:
-    next_shot_frame(actr);
-    if (actr->directions == 1) return 0;
-    return actr->last_dir;
+	int x, y;
+
+	x = actr->x;
+	y = actr->y;
+
+	XC--;
+	if (!XC) {
+		XC = 3;
+		if (XD)
+			x += 2;
+		else
+			x -= 2;
+	}
+	YC += YV;
+	if (YC > (IV - 1)) {
+		if (!YD) {
+			YV -= 8;
+			YC -= IV;
+			y -= 2;
+		} else {
+			YV += 8;
+			YC -= IV;
+			y += 2;
+		}
+	}
+	if (YV < 0) {
+		YV = 0;
+		BC = 1;
+	}
+	if (YV > IV) {
+		YV = IV;
+		BC = 1;
+	}
+	BC--;
+	if (!BC) {
+		BC = IC;
+		if (YD)
+			YV = IV;
+		YD ^= 1;
+	}
+	if (y > 164)
+		y = 164;
+	//   8       311
+	if (x < 1 || x > (319 - actr->size_x)) {
+		if (!actr->dead)
+			if (_G(actor[actr->creator]).num_shots)
+				_G(actor[actr->creator]).num_shots--;
+		actor_destroyed(actr);
+	}
+	if (overlap(actr->x, actr->y, actr->x + actr->size_x, actr->y + actr->size_y,
+				_G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15))
+		thor_damaged(actr);
+	actr->x = x;
+	actr->y = y;
+
+	//done:
+	next_shot_frame(actr);
+	if (actr->directions == 1)
+		return 0;
+	return actr->last_dir;
 }
 
 // Skull explode
 int shot_movement_nine(ACTOR *actr) {
-    actr->next++;
-    if (actr->next == 3) {
-        _G(actor[actr->creator]).num_shots--;
-        actor_destroyed(actr);
-        return 0;
-    }
-    if (actr->directions == 1) return 0;
-    return actr->last_dir;
+	actr->next++;
+	if (actr->next == 3) {
+		_G(actor[actr->creator]).num_shots--;
+		actor_destroyed(actr);
+		return 0;
+	}
+	if (actr->directions == 1)
+		return 0;
+	return actr->last_dir;
 }
 
 // Skull - stalagtites
 int shot_movement_ten(ACTOR *actr) {
-    int f;
-
-    f = 0;
-    actr->y += 2;
-
-    if (overlap(actr->x, actr->y, actr->x + actr->size_x, actr->y + actr->size_y,
-                _G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15)) {
-        thor_damaged(actr);
-        f = 1;
-    }
-    if ((actr->y > 160) || f) {
-        if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
-        actor_destroyed(actr);
-    }
-
-    return 0;
+	int f;
+
+	f = 0;
+	actr->y += 2;
+
+	if (overlap(actr->x, actr->y, actr->x + actr->size_x, actr->y + actr->size_y,
+				_G(thor)->x, _G(thor)->y + 4, _G(thor)->x + 15, _G(thor)->y + 15)) {
+		thor_damaged(actr);
+		f = 1;
+	}
+	if ((actr->y > 160) || f) {
+		if (_G(actor[actr->creator]).num_shots)
+			_G(actor[actr->creator]).num_shots--;
+		actor_destroyed(actr);
+	}
+
+	return 0;
 }
 
-#undef  YD
-#undef  XD
+#undef YD
+#undef XD
 #define YA actr->i1
 #define XA actr->i2
 #define YD actr->i3
@@ -480,177 +534,193 @@ int shot_movement_ten(ACTOR *actr) {
 #define CNT actr->i6
 
 void calc_angle(int x1, int y1, int x2, int y2, ACTOR *actr) {
-    if (x1 < x2) {
-        XA = -2;
-        XD = x2 - x1;
-    } else if (x1 > x2) {
-        XA = 2;
-        XD = x1 - x2;
-    } else {
-        XA = 0;
-        XD = 0;
-    }
-
-    if (y1 < y2) {
-        YA = -2;
-        YD = y2 - y1;
-    } else if (y1 > y2) {
-        YA = 2;
-        YD = y1 - y2;
-    } else {
-        YA = 0;
-        YD = 0;
-    }
-
-    if (YD >= XD) DIR = 1;
-    else DIR = 0;
-    CNT = 0;
+	if (x1 < x2) {
+		XA = -2;
+		XD = x2 - x1;
+	} else if (x1 > x2) {
+		XA = 2;
+		XD = x1 - x2;
+	} else {
+		XA = 0;
+		XD = 0;
+	}
+
+	if (y1 < y2) {
+		YA = -2;
+		YD = y2 - y1;
+	} else if (y1 > y2) {
+		YA = 2;
+		YD = y1 - y2;
+	} else {
+		YA = 0;
+		YD = 0;
+	}
+
+	if (YD >= XD)
+		DIR = 1;
+	else
+		DIR = 0;
+	CNT = 0;
 }
 
 // Angle throw
 int shot_movement_eleven(ACTOR *actr) {
-    int x1, y1;
-
-    x1 = actr->x;
-    y1 = actr->y;
-
-    if (!actr->temp1) {
-        calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actr);
-        actr->temp1 = 1;
-    }
-
-    if (DIR) {
-        y1 += YA;
-        CNT += XD;
-        if (CNT >= YD) {
-            x1 += XA;
-            CNT -= YD;
-        }
-    } else {
-        x1 += XA;
-        CNT += YD;
-        if (CNT >= XD) {
-            y1 += YA;
-            CNT -= XD;
-        }
-    }
-
-    if (!check_move3(x1, y1, actr)) {
-        if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
-        actor_destroyed(actr);
-    } else next_frame(actr);
-
-    if (actr->directions == 1) return 0;
-    return actr->last_dir;
+	int x1, y1;
+
+	x1 = actr->x;
+	y1 = actr->y;
+
+	if (!actr->temp1) {
+		calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actr);
+		actr->temp1 = 1;
+	}
+
+	if (DIR) {
+		y1 += YA;
+		CNT += XD;
+		if (CNT >= YD) {
+			x1 += XA;
+			CNT -= YD;
+		}
+	} else {
+		x1 += XA;
+		CNT += YD;
+		if (CNT >= XD) {
+			y1 += YA;
+			CNT -= XD;
+		}
+	}
+
+	if (!check_move3(x1, y1, actr)) {
+		if (_G(actor[actr->creator]).num_shots)
+			_G(actor[actr->creator]).num_shots--;
+		actor_destroyed(actr);
+	} else
+		next_frame(actr);
+
+	if (actr->directions == 1)
+		return 0;
+	return actr->last_dir;
 }
 
 // Angle throw Loki
 int shot_movement_twelve(ACTOR *actr) {
-    int x1, y1;
-
-    x1 = actr->x;
-    y1 = actr->y;
-
-    if (!actr->temp5) {
-        calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actr);
-        actr->temp5 = 1;
-    }
-
-    if (DIR) {
-        y1 += YA;
-        CNT += XD;
-        if (CNT >= YD) {
-            x1 += XA;
-            CNT -= YD;
-        }
-    } else {
-        x1 += XA;
-        CNT += YD;
-        if (CNT >= XD) {
-            y1 += YA;
-            CNT -= XD;
-        }
-    }
-
-    if (x1 < 16 || x1>287 || y1 < 16 || y1>159) {
-        calc_angle(g_events->getRandomNumber(319),
-                   g_events->getRandomNumber(191), x1, y1, actr);
-        actr->move = 13;
-        actr->temp4 = 240;
-        actr->next = 2;
-    } else {
-        if (overlap(x1 + 2, y1 + 2, x1 + 14, y1 + 14, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
-            thor_damaged(actr);
-        }
-        actr->x = x1;
-        actr->y = y1;
-    }
-    actr->frame_count--;
-    if (actr->frame_count <= 0) {
-        actr->next++;
-        if (actr->next > 1) actr->next = 0;
-        actr->frame_count = actr->frame_speed;
-    }
-    if (actr->directions == 1) return 0;
-    return actr->last_dir;
+	int x1, y1;
+
+	x1 = actr->x;
+	y1 = actr->y;
+
+	if (!actr->temp5) {
+		calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actr);
+		actr->temp5 = 1;
+	}
+
+	if (DIR) {
+		y1 += YA;
+		CNT += XD;
+		if (CNT >= YD) {
+			x1 += XA;
+			CNT -= YD;
+		}
+	} else {
+		x1 += XA;
+		CNT += YD;
+		if (CNT >= XD) {
+			y1 += YA;
+			CNT -= XD;
+		}
+	}
+
+	if (x1 < 16 || x1 > 287 || y1 < 16 || y1 > 159) {
+		calc_angle(g_events->getRandomNumber(319),
+				   g_events->getRandomNumber(191), x1, y1, actr);
+		actr->move = 13;
+		actr->temp4 = 240;
+		actr->next = 2;
+	} else {
+		if (overlap(x1 + 2, y1 + 2, x1 + 14, y1 + 14, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
+			thor_damaged(actr);
+		}
+		actr->x = x1;
+		actr->y = y1;
+	}
+	actr->frame_count--;
+	if (actr->frame_count <= 0) {
+		actr->next++;
+		if (actr->next > 1)
+			actr->next = 0;
+		actr->frame_count = actr->frame_speed;
+	}
+	if (actr->directions == 1)
+		return 0;
+	return actr->last_dir;
 }
 
 // Angle throw Loki-2
 int shot_movement_thirteen(ACTOR *actr) {
-    int x1, y1;
-
-    x1 = actr->x;
-    y1 = actr->y;
-
-    if (!actr->temp5) {
-        calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actr);
-        actr->temp5 = 1;
-    }
-
-    if (DIR) {
-        y1 += YA;
-        CNT += XD;
-        if (CNT >= YD) {
-            x1 += XA;
-            CNT -= YD;
-        }
-    } else {
-        x1 += XA;
-        CNT += YD;
-        if (CNT >= XD) {
-            y1 += YA;
-            CNT -= XD;
-        }
-    }
-    if (actr->temp4) actr->temp4--;
-    if (!actr->temp4) {
-        if (_G(actor[actr->creator]).num_shots) _G(actor[actr->creator]).num_shots--;
-        actor_destroyed(actr);
-        _G(apple_drop++);
-        if (_G(apple_drop) > 4) {
-            if (_drop_obj(actr, 5)) _G(apple_drop) = 0;
-            else _G(apple_drop) = 4;
-        } else _drop_obj(actr, 4);
-        return 0;
-    }
-    if (x1 < 16 || x1>287 || y1 < 16 || y1>159) {
-        if (x1 < 16 || x1>287) XA = 0 - XA;
-        else YA = 0 - YA;
-    } else {
-        if (overlap(x1 + 4, y1 + 4, x1 + 12, y1 + 12, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
-            thor_damaged(actr);
-        }
-        actr->x = x1;
-        actr->y = y1;
-    }
-    actr->frame_count--;
-    if (actr->frame_count <= 0) {
-        actr->next++;
-        if (actr->next > 3) actr->next = 2;
-        actr->frame_count = actr->frame_speed;
-    }
-    if (actr->directions == 1) return 0;
-    return actr->last_dir;
+	int x1, y1;
+
+	x1 = actr->x;
+	y1 = actr->y;
+
+	if (!actr->temp5) {
+		calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actr);
+		actr->temp5 = 1;
+	}
+
+	if (DIR) {
+		y1 += YA;
+		CNT += XD;
+		if (CNT >= YD) {
+			x1 += XA;
+			CNT -= YD;
+		}
+	} else {
+		x1 += XA;
+		CNT += YD;
+		if (CNT >= XD) {
+			y1 += YA;
+			CNT -= XD;
+		}
+	}
+	if (actr->temp4)
+		actr->temp4--;
+	if (!actr->temp4) {
+		if (_G(actor[actr->creator]).num_shots)
+			_G(actor[actr->creator]).num_shots--;
+		actor_destroyed(actr);
+		_G(apple_drop++);
+		if (_G(apple_drop) > 4) {
+			if (_drop_obj(actr, 5))
+				_G(apple_drop) = 0;
+			else
+				_G(apple_drop) = 4;
+		} else
+			_drop_obj(actr, 4);
+		return 0;
+	}
+	if (x1 < 16 || x1 > 287 || y1 < 16 || y1 > 159) {
+		if (x1 < 16 || x1 > 287)
+			XA = 0 - XA;
+		else
+			YA = 0 - YA;
+	} else {
+		if (overlap(x1 + 4, y1 + 4, x1 + 12, y1 + 12, _G(thor_x1), _G(thor_y1), _G(thor_x2), _G(thor_y2))) {
+			thor_damaged(actr);
+		}
+		actr->x = x1;
+		actr->y = y1;
+	}
+	actr->frame_count--;
+	if (actr->frame_count <= 0) {
+		actr->next++;
+		if (actr->next > 3)
+			actr->next = 2;
+		actr->frame_count = actr->frame_speed;
+	}
+	if (actr->directions == 1)
+		return 0;
+	return actr->last_dir;
 }
 
 } // namespace Got
diff --git a/engines/got/game/shot_pattern.cpp b/engines/got/game/shot_pattern.cpp
index fa158d92dac..16254ec3178 100644
--- a/engines/got/game/shot_pattern.cpp
+++ b/engines/got/game/shot_pattern.cpp
@@ -36,183 +36,188 @@ int shot_pattern_seven(ACTOR *actr);
 int shot_pattern_eight(ACTOR *actr);
 
 int (*const shot_pattern_func[])(ACTOR *actr) = {
-    shot_pattern_none,
-    shot_pattern_one,
-    shot_pattern_two,
-    shot_pattern_three,
-    shot_pattern_four,
-    shot_pattern_five,
-    shot_pattern_six,
-    shot_pattern_seven,
-    shot_pattern_eight,
+	shot_pattern_none,
+	shot_pattern_one,
+	shot_pattern_two,
+	shot_pattern_three,
+	shot_pattern_four,
+	shot_pattern_five,
+	shot_pattern_six,
+	shot_pattern_seven,
+	shot_pattern_eight,
 };
 
 // No shooting
 int shot_pattern_none(ACTOR *actr) {
-    return 0;
+	return 0;
 }
 
 // Uni-directional seek
 int shot_pattern_one(ACTOR *actr) {
-    switch (actr->last_dir) {
-    case 0:
-        if (ABS(_G(thor_x1) - actr->x) < 8) {
-            if (actr->y > _G(thor_real_y1)) {  //r
-                if (actor_shoots(actr, 0)) return 1;
-            }
-        }
-        break;
-    case 1:
-        if (ABS(_G(thor_x1) - actr->x) < 8) {
-            if (actr->y < _G(thor_real_y1)) {  //r
-                if (actor_shoots(actr, 1)) return 1;
-            }
-        }
-        break;
-    case 2:
-        if (ABS(_G(thor_real_y1) - actr->y) < 8) { //r
-            if (actr->x > _G(thor_x1)) {
-                if (actor_shoots(actr, 2)) return 1;
-            }
-        }
-        break;
-    case 3:
-        if (ABS(_G(thor_real_y1) - actr->y) < 8) { //r
-            if (actr->x < _G(thor_x1)) {
-                if (actor_shoots(actr, 3)) return 1;
-            }
-        }
-        break;
-    }
-
-    return 0;
+	switch (actr->last_dir) {
+	case 0:
+		if (ABS(_G(thor_x1) - actr->x) < 8) {
+			if (actr->y > _G(thor_real_y1)) { //r
+				if (actor_shoots(actr, 0))
+					return 1;
+			}
+		}
+		break;
+	case 1:
+		if (ABS(_G(thor_x1) - actr->x) < 8) {
+			if (actr->y < _G(thor_real_y1)) { //r
+				if (actor_shoots(actr, 1))
+					return 1;
+			}
+		}
+		break;
+	case 2:
+		if (ABS(_G(thor_real_y1) - actr->y) < 8) { //r
+			if (actr->x > _G(thor_x1)) {
+				if (actor_shoots(actr, 2))
+					return 1;
+			}
+		}
+		break;
+	case 3:
+		if (ABS(_G(thor_real_y1) - actr->y) < 8) { //r
+			if (actr->x < _G(thor_x1)) {
+				if (actor_shoots(actr, 3))
+					return 1;
+			}
+		}
+		break;
+	}
+
+	return 0;
 }
 
 // Omni directional
 int shot_pattern_two(ACTOR *actr) {
-    if (ABS(_G(thor)->x - actr->x) < 8) {
-        if (_G(thor)->y > actr->y)
-            actor_shoots(actr, 1);
-        else if (_G(thor)->y < actr->y)
-            actor_shoots(actr, 0);
-        else return 0;
-    } else if (ABS(_G(thor)->y - actr->y) < 8) {
-        if (_G(thor)->x > actr->x)
-            actor_shoots(actr, 3);
-        else if (_G(thor)->x < actr->x)
-            actor_shoots(actr, 2);
-    } else {
-        return 0;
-    }
-
-    return 1;
+	if (ABS(_G(thor)->x - actr->x) < 8) {
+		if (_G(thor)->y > actr->y)
+			actor_shoots(actr, 1);
+		else if (_G(thor)->y < actr->y)
+			actor_shoots(actr, 0);
+		else
+			return 0;
+	} else if (ABS(_G(thor)->y - actr->y) < 8) {
+		if (_G(thor)->x > actr->x)
+			actor_shoots(actr, 3);
+		else if (_G(thor)->x < actr->x)
+			actor_shoots(actr, 2);
+	} else {
+		return 0;
+	}
+
+	return 1;
 }
 
 // Uni directional (backwards)
 int shot_pattern_three(ACTOR *actr) {
-    int ld;
+	int ld;
 
-    ld = actr->last_dir;
-    if (shot_pattern_one(actr)) {
-        actr->last_dir = reverse_direction(actr);
-        return 1;
-    }
+	ld = actr->last_dir;
+	if (shot_pattern_one(actr)) {
+		actr->last_dir = reverse_direction(actr);
+		return 1;
+	}
 
-    actr->last_dir = reverse_direction(actr);
-    shot_pattern_one(actr);
-    actr->last_dir = ld;
+	actr->last_dir = reverse_direction(actr);
+	shot_pattern_one(actr);
+	actr->last_dir = ld;
 
-    return 1;
+	return 1;
 }
 
 // Omni-directional not solid shot
 int shot_pattern_four(ACTOR *actr) {
-    if (ABS(_G(thor)->x - actr->x) < 8) {
-        if (_G(thor)->y > actr->y)
-            actor_always_shoots(actr, 1);
-        else if (_G(thor)->y < actr->y)
-            actor_always_shoots(actr, 0);
-        else
-            return 0;
-    } else if (ABS(_G(thor)->y - actr->y) < 8) {
-        if (_G(thor)->x > actr->x)
-            actor_always_shoots(actr, 3);
-        else if (_G(thor)->x < actr->x)
-            actor_always_shoots(actr, 2);
-    } else {
-        return 0;
-    }
-
-    return 1;
+	if (ABS(_G(thor)->x - actr->x) < 8) {
+		if (_G(thor)->y > actr->y)
+			actor_always_shoots(actr, 1);
+		else if (_G(thor)->y < actr->y)
+			actor_always_shoots(actr, 0);
+		else
+			return 0;
+	} else if (ABS(_G(thor)->y - actr->y) < 8) {
+		if (_G(thor)->x > actr->x)
+			actor_always_shoots(actr, 3);
+		else if (_G(thor)->x < actr->x)
+			actor_always_shoots(actr, 2);
+	} else {
+		return 0;
+	}
+
+	return 1;
 }
 
 // Boss - snake
 int shot_pattern_five(ACTOR *actr) {
 	if (_G(rand1) < 15) {
-        if ((actr->temp1 == 0) && (actr->temp2 == 0)) {
-            actr->y += 16;
-            actr->shots_allowed = 3 + _G(setup).skill;
-            actor_shoots(actr, 2);
-            play_sound(BOSS12, false);
-
-            int num = actr->shot_actor;
-            actr->shot_cnt = 50;
-            _G(actor[num]).temp3 = 120;
-            _G(actor[num]).temp4 = 5 + (_G(rand2) % 17);
-            _G(actor[num]).temp5 = _G(actor[num]).temp4;
-            actr->y -= 16;
-            return 1;
-        }
-    }
-
-    return 0;
+		if ((actr->temp1 == 0) && (actr->temp2 == 0)) {
+			actr->y += 16;
+			actr->shots_allowed = 3 + _G(setup).skill;
+			actor_shoots(actr, 2);
+			play_sound(BOSS12, false);
+
+			int num = actr->shot_actor;
+			actr->shot_cnt = 50;
+			_G(actor[num]).temp3 = 120;
+			_G(actor[num]).temp4 = 5 + (_G(rand2) % 17);
+			_G(actor[num]).temp5 = _G(actor[num]).temp4;
+			actr->y -= 16;
+			return 1;
+		}
+	}
+
+	return 0;
 }
 
 // 4 surrounding squares
 int shot_pattern_six(ACTOR *actr) {
 	int pos = ((actr->x) / 16) + (((actr->y) / 16) * 20);
 
-    if (_G(thor_pos) == pos - 20)
-        actor_shoots(actr, 0);
-    else if (_G(thor_pos) == pos + 20)
-        actor_shoots(actr, 1);
-    else if (_G(thor_pos) == pos - 1)
-        actor_shoots(actr, 2);
-    else if (_G(thor_pos) == pos + 1)
-        actor_shoots(actr, 3);
-    else
-        return 0;
-
-    actr->frame_sequence[3] = 3;
-    actr->next = 3;
-    return 1;
+	if (_G(thor_pos) == pos - 20)
+		actor_shoots(actr, 0);
+	else if (_G(thor_pos) == pos + 20)
+		actor_shoots(actr, 1);
+	else if (_G(thor_pos) == pos - 1)
+		actor_shoots(actr, 2);
+	else if (_G(thor_pos) == pos + 1)
+		actor_shoots(actr, 3);
+	else
+		return 0;
+
+	actr->frame_sequence[3] = 3;
+	actr->next = 3;
+	return 1;
 }
 
 // none
 int shot_pattern_seven(ACTOR *actr) {
-    return 0;
+	return 0;
 }
 
 // random
 int shot_pattern_eight(ACTOR *actr) {
-    if (!actr->i2) {
-        actr->i1 = actr->func_pass;
-        actr->i2 = 1;
-    }
-
-    if (actr->i1) {
-        actr->i1--;
-    } else {
-        if (_G(rand1) < 10) {
-            actr->i1 = _G(thor_x1);
-            actr->i2 = _G(thor_real_y1);
-            actr->i1 = actr->func_pass;
-            actor_shoots(actr, 0);
-            return 1;
-        }
-    }
-
-    return 0;
+	if (!actr->i2) {
+		actr->i1 = actr->func_pass;
+		actr->i2 = 1;
+	}
+
+	if (actr->i1) {
+		actr->i1--;
+	} else {
+		if (_G(rand1) < 10) {
+			actr->i1 = _G(thor_x1);
+			actr->i2 = _G(thor_real_y1);
+			actr->i1 = actr->func_pass;
+			actor_shoots(actr, 0);
+			return 1;
+		}
+	}
+
+	return 0;
 }
 
 } // namespace Got
diff --git a/engines/got/game/special_tile.cpp b/engines/got/game/special_tile.cpp
index cf79c78795f..092f5c555c6 100644
--- a/engines/got/game/special_tile.cpp
+++ b/engines/got/game/special_tile.cpp
@@ -20,10 +20,10 @@
  */
 
 #include "got/game/special_tile.h"
+#include "got/events.h"
 #include "got/game/back.h"
 #include "got/game/object.h"
 #include "got/gfx/image.h"
-#include "got/events.h"
 #include "got/vars.h"
 
 namespace Got {
@@ -33,249 +33,253 @@ int cash_door1(int y, int x, int amount);
 void erase_door(int x, int y);
 
 int special_tile_thor(int x, int y, int icon) {
-    int cx, cy, f;
+	int cx, cy, f;
 
-    f = 0;
-    switch (icon) {
-    case 201:
-        return open_door1(x, y);
-    case 202:
-        if (GAME3) {
-            if (_G(thor_info).inventory & 64) {
-                if (_G(thor_info).object == 4) {
-                    erase_door(y, x);
-                    delete_object();
-                    return 1;
-                }
-            }
-            return 0;
-        }
+	f = 0;
+	switch (icon) {
+	case 201:
+		return open_door1(x, y);
+	case 202:
+		if (GAME3) {
+			if (_G(thor_info).inventory & 64) {
+				if (_G(thor_info).object == 4) {
+					erase_door(y, x);
+					delete_object();
+					return 1;
+				}
+			}
+			return 0;
+		}
 
-        if (_G(thor)->x > 300)
-            // Ending bridge
-            _G(end_tile) = true;
-        return 1;
-    case 203:
-        if (!GAME1) {
-            if ((_G(thor_info).inventory & 64) && _G(thor_info).object == 5) {
-                odin_speaks(2012, 0);
-                delete_object();
-                _G(setup).f10 = 1;
-            } else if (!_G(setup).f10) {
-                odin_speaks(2011, 0);
-                _G(setup).f10 = 1;
-            }
-            return 1;
-        }
-        return 0;
-    case 204:
-        if (GAME2) {
-            if (!_G(setup).f19)
-                _G(slip_flag) = true;
-            return 1;
-        } else if (GAME3) {
-            if (_G(thor)->x < 4)
-                _G(end_tile) = true;
-            return 1;
-        }
-        return 0;
-    case 205:
-        if (!_G(diag) && _G(thor)->dir != 1)
-            return 1;
-        break;
-    case 206:
-        if (!_G(diag) && _G(thor)->dir != 0)
-            return 1;
-        break;
-    case 207:
-        if (!_G(diag) && _G(thor)->dir != 3)
-            return 1;
-        break;
-    case 208:
-        if (!_G(diag) && _G(thor)->dir != 2)
-            return 1;
-        break;
-    case 209:
-        return cash_door1(x, y, 10);
-    case 210:
-        return cash_door1(x, y, 100);
-    case 211:
-        if (GAME1) {
-            place_tile(y, x, 79);
-            _G(exit_flag) = 2;
-        } else if (GAME2) {
-            if (_G(thor)->dir == 0 && _G(setup).f29 && _G(setup).f21 && !_G(setup).f22) {
-                actor_visible(1);
-                actor_visible(2);
-                actor_visible(3);
-                actor_visible(4);
-                actor_visible(5);
-                Common::fill(_G(scrn).actor_invis, _G(scrn).actor_invis + 16, 0);
-                _G(thunder_flag) = 60;
-                play_sound(THUNDER, true);
-                _G(setup).f22 = 1;
-            }
-        } else {
-            // Game 3
-            return 0;
-        }
-        return 1;
-    case 212:
-    case 213:
-        return 0;
-    case 214:        // Teleport tiles
-    case 215:
-    case 216:
-    case 217:
-        if ((GAME2 && icon == 217) || GAME3) {
-            cx = (_G(thor_x1) + 7) / 16;
-            cy = (_G(thor_real_y1) + 8) / 16;
-            if (_G(scrn).icon[cy][cx] == icon) {
-                _G(thor)->vunerable = STAMINA;
-                play_sound(WOOP, false);
+		if (_G(thor)->x > 300)
+			// Ending bridge
+			_G(end_tile) = true;
+		return 1;
+	case 203:
+		if (!GAME1) {
+			if ((_G(thor_info).inventory & 64) && _G(thor_info).object == 5) {
+				odin_speaks(2012, 0);
+				delete_object();
+				_G(setup).f10 = 1;
+			} else if (!_G(setup).f10) {
+				odin_speaks(2011, 0);
+				_G(setup).f10 = 1;
+			}
+			return 1;
+		}
+		return 0;
+	case 204:
+		if (GAME2) {
+			if (!_G(setup).f19)
+				_G(slip_flag) = true;
+			return 1;
+		} else if (GAME3) {
+			if (_G(thor)->x < 4)
+				_G(end_tile) = true;
+			return 1;
+		}
+		return 0;
+	case 205:
+		if (!_G(diag) && _G(thor)->dir != 1)
+			return 1;
+		break;
+	case 206:
+		if (!_G(diag) && _G(thor)->dir != 0)
+			return 1;
+		break;
+	case 207:
+		if (!_G(diag) && _G(thor)->dir != 3)
+			return 1;
+		break;
+	case 208:
+		if (!_G(diag) && _G(thor)->dir != 2)
+			return 1;
+		break;
+	case 209:
+		return cash_door1(x, y, 10);
+	case 210:
+		return cash_door1(x, y, 100);
+	case 211:
+		if (GAME1) {
+			place_tile(y, x, 79);
+			_G(exit_flag) = 2;
+		} else if (GAME2) {
+			if (_G(thor)->dir == 0 && _G(setup).f29 && _G(setup).f21 && !_G(setup).f22) {
+				actor_visible(1);
+				actor_visible(2);
+				actor_visible(3);
+				actor_visible(4);
+				actor_visible(5);
+				Common::fill(_G(scrn).actor_invis, _G(scrn).actor_invis + 16, 0);
+				_G(thunder_flag) = 60;
+				play_sound(THUNDER, true);
+				_G(setup).f22 = 1;
+			}
+		} else {
+			// Game 3
+			return 0;
+		}
+		return 1;
+	case 212:
+	case 213:
+		return 0;
+	case 214: // Teleport tiles
+	case 215:
+	case 216:
+	case 217:
+		if ((GAME2 && icon == 217) || GAME3) {
+			cx = (_G(thor_x1) + 7) / 16;
+			cy = (_G(thor_real_y1) + 8) / 16;
+			if (_G(scrn).icon[cy][cx] == icon) {
+				_G(thor)->vunerable = STAMINA;
+				play_sound(WOOP, false);
 
-                int nt = _G(scrn).new_level_loc[icon - 214];
-                int display_page = _G(pge);
-                int draw_page = _G(pge) ^ 1;
+				int nt = _G(scrn).new_level_loc[icon - 214];
+				int display_page = _G(pge);
+				int draw_page = _G(pge) ^ 1;
 
-                _G(thor)->last_x[display_page] = _G(thor)->x;
-                _G(thor)->last_y[display_page] = _G(thor)->y;
-                _G(thor)->x = (nt % 20) * 16;
-                _G(thor)->y = ((nt / 20) * 16) - 2;
-                _G(thor)->last_x[draw_page] = _G(thor)->x;
-                _G(thor)->last_y[draw_page] = _G(thor)->y;
-                return 0;
-            }
-            return 1;
-        }
-        return 0;
-    case 218:
-    case 219:
+				_G(thor)->last_x[display_page] = _G(thor)->x;
+				_G(thor)->last_y[display_page] = _G(thor)->y;
+				_G(thor)->x = (nt % 20) * 16;
+				_G(thor)->y = ((nt / 20) * 16) - 2;
+				_G(thor)->last_x[draw_page] = _G(thor)->x;
+				_G(thor)->last_y[draw_page] = _G(thor)->y;
+				return 0;
+			}
+			return 1;
+		}
+		return 0;
+	case 218:
+	case 219:
 		// Hole tiles
-        f = 1;
+		f = 1;
 		// fall through
-    case 220:
-    case 221:
-    case 222:
-    case 223:
-    case 224:
-    case 225:
-    case 226:
-    case 227:
-    case 228:
-    case 229:
+	case 220:
+	case 221:
+	case 222:
+	case 223:
+	case 224:
+	case 225:
+	case 226:
+	case 227:
+	case 228:
+	case 229:
 		// Hole tiles
-        cx = (_G(thor_x1) + 7) / 16;
-        cy = (_G(thor_real_y1) + 8) / 16;
-        if (_G(scrn).icon[cy][cx] == icon) {
-            _G(thor)->vunerable = STAMINA;
-            if (icon < 224 && icon>219)
+		cx = (_G(thor_x1) + 7) / 16;
+		cy = (_G(thor_real_y1) + 8) / 16;
+		if (_G(scrn).icon[cy][cx] == icon) {
+			_G(thor)->vunerable = STAMINA;
+			if (icon < 224 && icon > 219)
 				play_sound(FALL, false);
-        	
-            _G(new_level) = _G(scrn).new_level[icon - 220 + (f * 6)];
-            _G(warp_scroll) = false;
-            if (_G(new_level) > 119) {
-                _G(warp_scroll) = true;
-                _G(new_level) -= 128;
-            }
 
-            _G(new_level_tile) = _G(scrn).new_level_loc[icon - 220 + (f * 6)];
-            _G(warp_flag) = true;
+			_G(new_level) = _G(scrn).new_level[icon - 220 + (f * 6)];
+			_G(warp_scroll) = false;
+			if (_G(new_level) > 119) {
+				_G(warp_scroll) = true;
+				_G(new_level) -= 128;
+			}
 
-            if (_G(warp_scroll)) {
-                if (_G(thor)->dir == 0) _G(thor)->y = 175;
-                else if (_G(thor)->dir == 1) _G(thor)->y = 0;
-                else if (_G(thor)->dir == 2) _G(thor)->x = 304;
-                else if (_G(thor)->dir == 3) _G(thor)->x = 0;
-            } else {
-                _G(thor)->x = (_G(new_level_tile) % 20) * 16;
-                _G(thor)->y = ((_G(new_level_tile) / 20) * 16) - 2;
-            }
-            _G(thor)->last_x[0] = _G(thor)->x;
-            _G(thor)->last_x[1] = _G(thor)->x;
-            _G(thor)->last_y[0] = _G(thor)->y;
-            _G(thor)->last_y[1] = _G(thor)->y;
-            return 0;
-        }
+			_G(new_level_tile) = _G(scrn).new_level_loc[icon - 220 + (f * 6)];
+			_G(warp_flag) = true;
 
-        return 1;
-    }
-    return 0;
+			if (_G(warp_scroll)) {
+				if (_G(thor)->dir == 0)
+					_G(thor)->y = 175;
+				else if (_G(thor)->dir == 1)
+					_G(thor)->y = 0;
+				else if (_G(thor)->dir == 2)
+					_G(thor)->x = 304;
+				else if (_G(thor)->dir == 3)
+					_G(thor)->x = 0;
+			} else {
+				_G(thor)->x = (_G(new_level_tile) % 20) * 16;
+				_G(thor)->y = ((_G(new_level_tile) / 20) * 16) - 2;
+			}
+			_G(thor)->last_x[0] = _G(thor)->x;
+			_G(thor)->last_x[1] = _G(thor)->x;
+			_G(thor)->last_y[0] = _G(thor)->y;
+			_G(thor)->last_y[1] = _G(thor)->y;
+			return 0;
+		}
+
+		return 1;
+	}
+	return 0;
 }
 
 int special_tile(ACTOR *actr, int x, int y, int icon) {
-    switch (icon) {
-    case 201:
-    case 202:
-    case 203:
-    case 204:
-        break;
-    case 205:
-    case 206:
-    case 207:
-    case 208:
-        return 1;
-    case 209:
-    case 210:
-        return 0;
-    case 214:
-    case 215:
-    case 216:
-    case 217:
-        return 0;
-    case 224:
-    case 225:
-    case 226:
-    case 227:
-        if (!actr->flying) return 0;
-        return 1;
-    default:
-        return 1;
-
-    }
+	switch (icon) {
+	case 201:
+	case 202:
+	case 203:
+	case 204:
+		break;
+	case 205:
+	case 206:
+	case 207:
+	case 208:
+		return 1;
+	case 209:
+	case 210:
+		return 0;
+	case 214:
+	case 215:
+	case 216:
+	case 217:
+		return 0;
+	case 224:
+	case 225:
+	case 226:
+	case 227:
+		if (!actr->flying)
+			return 0;
+		return 1;
+	default:
+		return 1;
+	}
 
-    return 0;
+	return 0;
 }
 
 void erase_door(int x, int y) {
-    play_sound(DOOR, false);
-    _G(scrn).icon[y][x] = _G(scrn).bg_color;
+	play_sound(DOOR, false);
+	_G(scrn).icon[y][x] = _G(scrn).bg_color;
 }
 
 int open_door1(int y, int x) {
-    if (_G(thor_info).keys > 0) {
-        erase_door(x, y);
-        _G(thor_info).keys--;
+	if (_G(thor_info).keys > 0) {
+		erase_door(x, y);
+		_G(thor_info).keys--;
 
-        return 1;
-    } else {
-        if (!_G(door_inform)) {
-            odin_speaks(2003, 0);
-            _G(door_inform) = true;
-        }
-    }
+		return 1;
+	} else {
+		if (!_G(door_inform)) {
+			odin_speaks(2003, 0);
+			_G(door_inform) = true;
+		}
+	}
 
-    return 0;
+	return 0;
 }
 
 int cash_door1(int y, int x, int amount) {
-    if (_G(thor_info).jewels >= amount) {
-        erase_door(x, y);
-        _G(thor_info).jewels -= amount;
+	if (_G(thor_info).jewels >= amount) {
+		erase_door(x, y);
+		_G(thor_info).jewels -= amount;
 
-        return 1;
-    } else {
-        if (amount == 10 && !_G(cash1_inform)) {
-            odin_speaks(2005, 0);
-            _G(cash1_inform) = true;
-        }
-        if (amount == 100 && !_G(cash2_inform)) {
-            odin_speaks(2004, 0);
-            _G(cash2_inform) = true;
-        }
-    }
+		return 1;
+	} else {
+		if (amount == 10 && !_G(cash1_inform)) {
+			odin_speaks(2005, 0);
+			_G(cash1_inform) = true;
+		}
+		if (amount == 100 && !_G(cash2_inform)) {
+			odin_speaks(2004, 0);
+			_G(cash2_inform) = true;
+		}
+	}
 
-    return 0;
+	return 0;
 }
 
 } // namespace Got


Commit: f02b71476880c912160f404350dc7c3297eb673c
    https://github.com/scummvm/scummvm/commit/f02b71476880c912160f404350dc7c3297eb673c
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-01-12T18:11:27+02:00

Commit Message:
GOT: Join declaration and assignment when possible in script, shot_movement and shot_pattern

Changed paths:
    engines/got/game/script.cpp
    engines/got/game/shot_movement.cpp
    engines/got/game/shot_pattern.cpp


diff --git a/engines/got/game/script.cpp b/engines/got/game/script.cpp
index 1ef70e5f41a..63e3af8a723 100644
--- a/engines/got/game/script.cpp
+++ b/engines/got/game/script.cpp
@@ -310,7 +310,6 @@ void Scripts::get_str() {
 }
 
 int Scripts::calc_value() {
-
 	long tmpval2 = 0;
 	char exptype = 1;
 
@@ -489,12 +488,11 @@ int Scripts::get_line(char *src, char *dst) {
 int Scripts::read_script_file() {
 	char temp_buff[255];
 	char quote_flag;
-	int i, len, p, ret, cnt;
-	char ch;
-	char *sb;
-	char *sbuff = nullptr;
+	int len, p, ret, cnt;
 	Common::String str;
 	char tmps[255];
+	char *sbuff = nullptr;
+	char *sb;
 
 	_buffer = (char *)malloc(SCR_BUFF_SIZE);
 	if (!_buffer) {
@@ -505,11 +503,11 @@ int Scripts::read_script_file() {
 	Common::fill(_buffer, _buffer + SCR_BUFF_SIZE, 0);
 
 	sbuff = (char *)malloc(25000l);
+	sb = sbuff;
 	if (!sbuff) {
 		ret = 1;
 		goto done;
 	};
-	sb = sbuff;
 
 	str = Common::String::format("SPEAK%d", _G(area));
 	if (res_read(str.c_str(), sb) < 0) {
@@ -551,8 +549,8 @@ int Scripts::read_script_file() {
 		}
 		quote_flag = 0;
 		p = 0;
-		for (i = 0; i < len; i++) {
-			ch = tmps[i];
+		for (int i = 0; i < len; i++) {
+			char ch = tmps[i];
 			if (ch == 34)
 				quote_flag ^= 1;
 			else if (ch == 13 || ch == 10) { // Check for CR
@@ -598,11 +596,8 @@ done:
 }
 
 void Scripts::script_error(int err_num) {
-	int line_num;
-	char *tb;
-
-	line_num = 1;
-	tb = _buffer;
+	int line_num = 1;
+	char *tb = _buffer;
 
 	while (1) {
 		if (*tb == 0)
@@ -619,17 +614,15 @@ void Scripts::script_error(int err_num) {
 }
 
 int Scripts::cmd_goto() {
-	int i, len;
 	char s[255];
-	char *p;
 
 	Common::strcpy_s(s, _buffPtr);
-	p = strchr(s, ':');
+	char *p = strchr(s, ':');
 	if (p)
 		*p = 0;
 
-	for (i = 0; i < _numLabels; i++) {
-		len = strlen(s);
+	for (int i = 0; i < _numLabels; i++) {
+		int len = strlen(s);
 		if (len == 0)
 			break;
 		if (!strcmp(s, _lineLabel[i])) {
@@ -642,26 +635,25 @@ int Scripts::cmd_goto() {
 }
 
 int Scripts::cmd_if() {
-	long tmpval1, tmpval2;
-	char exptype, ch;
-
 	if (!calc_value())
 		return 5;
-	tmpval1 = _lValue;
-	exptype = *_buffPtr;
+	
+	long tmpval1 = _lValue;
+	char exptype = *_buffPtr;
 	_buffPtr++;
 
-	ch = *_buffPtr;
+	char ch = *_buffPtr;
 	if (ch == 60 || ch == 61 || ch == 62) {
 		if (exptype == *_buffPtr)
 			return 5;
+		
 		exptype += *_buffPtr;
 		_buffPtr++;
 	}
 	if (!calc_value())
 		return 5;
 
-	tmpval2 = _lValue;
+	long tmpval2 = _lValue;
 	_buffPtr += 4;
 
 	switch (exptype) {
@@ -762,8 +754,7 @@ int Scripts::cmd_addscore() {
 }
 
 int Scripts::cmd_say(int mode, int type) {
-	char *p;
-	int obj;
+	int obj = 0;
 
 	if (mode) {
 		if (!calc_value())
@@ -772,13 +763,13 @@ int Scripts::cmd_say(int mode, int type) {
 		obj = (int)_lValue;
 		if (obj < 0 || obj > 32)
 			return 6;
+		
 		if (obj)
 			obj += 10;
-	} else
-		obj = 0;
-
+	}
+	
 	Common::fill(_G(tmp_buff), _G(tmp_buff) + TMP_SIZE, 0);
-	p = (char *)_G(tmp_buff);
+	char *p = (char *)_G(tmp_buff);
 
 	while (calc_string(0)) {
 		Common::strcpy_s(p, TMP_SIZE, _tempS);
@@ -810,6 +801,7 @@ int Scripts::cmd_ask() {
 		_buffPtr++;
 		if (*_buffPtr != ',')
 			return 5;
+		
 		_buffPtr++;
 	} else {
 		return 5;
@@ -864,29 +856,33 @@ int Scripts::cmd_sound() {
 	_buffPtr++;
 	if (_lValue < 1 || _lValue > 16)
 		return 6;
+	
 	play_sound((int)_lValue - 1, true);
 	return 0;
 }
 
 int Scripts::cmd_settile() {
-	int screen, pos, tile;
-
 	if (!calc_value())
 		return 5;
+	
 	_buffPtr++;
-	screen = (int)_lValue;
+	int screen = (int)_lValue;
 	if (!calc_value())
 		return 5;
+	
 	_buffPtr++;
-	pos = (int)_lValue;
+	int pos = (int)_lValue;
 	if (!calc_value())
 		return 5;
-	tile = (int)_lValue;
+	
+	int tile = (int)_lValue;
 
 	if (screen < 0 || screen > 119)
 		return 6;
+	
 	if (pos < 0 || pos > 239)
 		return 6;
+	
 	if (tile < 0 || tile > 230)
 		return 6;
 
@@ -902,13 +898,11 @@ int Scripts::cmd_settile() {
 }
 
 int Scripts::cmd_itemgive() {
-	int i;
-
 	if (!calc_value())
 		return 5;
 
 	_buffPtr++;
-	i = (int)_lValue;
+	int i = (int)_lValue;
 	if (i < 1 || i > 15)
 		return 6;
 
@@ -926,12 +920,10 @@ int Scripts::cmd_itemtake() {
 }
 
 int Scripts::cmd_setflag() {
-	int i;
-
 	if (!calc_value())
 		return 5;
 
-	i = (int)_lValue;
+	int i = (int)_lValue;
 	if (i < 1 || i > 64)
 		return 6;
 
@@ -966,6 +958,7 @@ int Scripts::cmd_ltoa() {
 int Scripts::cmd_pause() {
 	if (!calc_value())
 		return 5;
+	
 	_buffPtr++;
 	if (_lValue < 1 || _lValue > 65535l)
 		return 6;
@@ -977,6 +970,7 @@ int Scripts::cmd_pause() {
 int Scripts::cmd_visible() {
 	if (!calc_value())
 		return 5;
+	
 	_buffPtr++;
 	if (_lValue < 1 || _lValue > 16)
 		return 6;
@@ -986,13 +980,14 @@ int Scripts::cmd_visible() {
 }
 
 int Scripts::cmd_random() {
-	int v, r;
+	int v;
 
 	if (Common::isAlpha(*_buffPtr)) {
 		v = *_buffPtr - 65;
 		_buffPtr++;
 		if (*_buffPtr != ',')
 			return 5;
+		
 		_buffPtr++;
 	} else {
 		return 5;
@@ -1001,7 +996,7 @@ int Scripts::cmd_random() {
 	if (!calc_value())
 		return 5;
 	_buffPtr++;
-	r = (int)_lValue;
+	int r = (int)_lValue;
 	if (r < 1 || r > 1000)
 		return 6;
 
@@ -1025,19 +1020,15 @@ void Scripts::scr_func1() {
 }
 
 void Scripts::scr_func2() {
-	int r;
-
-	r = g_events->getRandomNumber(5);
+	int r = g_events->getRandomNumber(5);
 	Common::strcpy_s(_strVar[0], 81, OFFENSE[r]);
 	Common::strcpy_s(_strVar[1], 81, REASON[r]);
 }
 
 void Scripts::scr_func3() {
-	int p, x, y, o;
-
-	p = (((_G(thor)->y + 8) / 16) * 20) + ((_G(thor)->x + 7) / 16);
-	y = p / 20;
-	x = p % 20;
+	int p = (((_G(thor)->y + 8) / 16) * 20) + ((_G(thor)->x + 7) / 16);
+	int y = p / 20;
+	int x = p % 20;
 
 	if (y < 0 || x < 0 || y > 11 || x > 19) {
 		play_sound(BRAAPP, true);
@@ -1064,7 +1055,7 @@ void Scripts::scr_func3() {
 	if ((g_events->getRandomNumber(99)) < 25 ||
 		(_G(current_level) == 13 && p == 150 && !_G(setup).f26 && _G(setup).f28)) {
 		if (!_G(object_map[p]) && _G(scrn).icon[y][x] >= 140) { // nothing there and solid
-			o = g_events->getRandomNumber(1, 5);
+			int o = g_events->getRandomNumber(1, 5);
 			if (_G(current_level) == 13 && p == 150 && !_G(setup).f26 && _G(setup).f28)
 				o = 20;
 
@@ -1098,10 +1089,9 @@ int Scripts::cmd_exec() {
 }
 
 int Scripts::exec_command(int num) {
-	int ret;
 	char ch;
 
-	ret = 0;
+	int ret = 0;
 	switch (num) {
 	case 1: // end
 		return 0;
diff --git a/engines/got/game/shot_movement.cpp b/engines/got/game/shot_movement.cpp
index b5a75a7d758..50484463fbc 100644
--- a/engines/got/game/shot_movement.cpp
+++ b/engines/got/game/shot_movement.cpp
@@ -207,8 +207,6 @@ int shot_movement_three(ACTOR *actr) {
 
 // Wraith balls
 int shot_movement_four(ACTOR *actr) {
-	int x1, y1, xd, yd, d;
-
 	if (actr->temp1) {
 		actr->temp1--;
 		if (!actr->temp1) {
@@ -231,10 +229,11 @@ int shot_movement_four(ACTOR *actr) {
 		return 0;
 	}
 
-	x1 = actr->x;
-	y1 = actr->y;
-	xd = yd = 0;
-	d = actr->last_dir;
+	int x1 = actr->x;
+	int y1 = actr->y;
+	int yd = 0;
+	int xd = 0;
+	int d = actr->last_dir;
 
 	if ((x1 > (_G(thor_x1)) + 1))
 		xd = -2;
@@ -271,16 +270,15 @@ int shot_movement_four(ACTOR *actr) {
 				return 0;
 			return d;
 		}
-	} else {
-		if (xd == 0 && yd == 2)
-			d = 1;
-		else if (xd == 0 && yd == -2)
-			d = 0;
-		else if (xd == 2 && yd == 0)
-			d = 3;
-		else if (xd == -2 && yd == 0)
-			d = 2;
-	}
+	} else if (xd == 0 && yd == 2)
+		d = 1;
+	else if (xd == 0 && yd == -2)
+		d = 0;
+	else if (xd == 2 && yd == 0)
+		d = 3;
+	else if (xd == -2 && yd == 0)
+		d = 2;
+
 	x1 = actr->x;
 	y1 = actr->y;
 	actr->toggle ^= 1;
@@ -505,9 +503,7 @@ int shot_movement_nine(ACTOR *actr) {
 
 // Skull - stalagtites
 int shot_movement_ten(ACTOR *actr) {
-	int f;
-
-	f = 0;
+	int f = 0;
 	actr->y += 2;
 
 	if (overlap(actr->x, actr->y, actr->x + actr->size_x, actr->y + actr->size_y,
@@ -565,10 +561,8 @@ void calc_angle(int x1, int y1, int x2, int y2, ACTOR *actr) {
 
 // Angle throw
 int shot_movement_eleven(ACTOR *actr) {
-	int x1, y1;
-
-	x1 = actr->x;
-	y1 = actr->y;
+	int x1 = actr->x;
+	int y1 = actr->y;
 
 	if (!actr->temp1) {
 		calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actr);
@@ -605,10 +599,8 @@ int shot_movement_eleven(ACTOR *actr) {
 
 // Angle throw Loki
 int shot_movement_twelve(ACTOR *actr) {
-	int x1, y1;
-
-	x1 = actr->x;
-	y1 = actr->y;
+	int x1 = actr->x;
+	int y1 = actr->y;
 
 	if (!actr->temp5) {
 		calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actr);
@@ -658,10 +650,8 @@ int shot_movement_twelve(ACTOR *actr) {
 
 // Angle throw Loki-2
 int shot_movement_thirteen(ACTOR *actr) {
-	int x1, y1;
-
-	x1 = actr->x;
-	y1 = actr->y;
+	int x1 = actr->x;
+	int y1 = actr->y;
 
 	if (!actr->temp5) {
 		calc_angle(_G(thor_x1), _G(thor_real_y1), x1, y1, actr);
diff --git a/engines/got/game/shot_pattern.cpp b/engines/got/game/shot_pattern.cpp
index 16254ec3178..a185cae7be0 100644
--- a/engines/got/game/shot_pattern.cpp
+++ b/engines/got/game/shot_pattern.cpp
@@ -115,9 +115,7 @@ int shot_pattern_two(ACTOR *actr) {
 
 // Uni directional (backwards)
 int shot_pattern_three(ACTOR *actr) {
-	int ld;
-
-	ld = actr->last_dir;
+	int ld = actr->last_dir;
 	if (shot_pattern_one(actr)) {
 		actr->last_dir = reverse_direction(actr);
 		return 1;
@@ -153,21 +151,19 @@ int shot_pattern_four(ACTOR *actr) {
 
 // Boss - snake
 int shot_pattern_five(ACTOR *actr) {
-	if (_G(rand1) < 15) {
-		if ((actr->temp1 == 0) && (actr->temp2 == 0)) {
-			actr->y += 16;
-			actr->shots_allowed = 3 + _G(setup).skill;
-			actor_shoots(actr, 2);
-			play_sound(BOSS12, false);
-
-			int num = actr->shot_actor;
-			actr->shot_cnt = 50;
-			_G(actor[num]).temp3 = 120;
-			_G(actor[num]).temp4 = 5 + (_G(rand2) % 17);
-			_G(actor[num]).temp5 = _G(actor[num]).temp4;
-			actr->y -= 16;
-			return 1;
-		}
+	if (_G(rand1) < 15 && (actr->temp1 == 0) && (actr->temp2 == 0)) {
+		actr->y += 16;
+		actr->shots_allowed = 3 + _G(setup).skill;
+		actor_shoots(actr, 2);
+		play_sound(BOSS12, false);
+
+		int num = actr->shot_actor;
+		actr->shot_cnt = 50;
+		_G(actor[num]).temp3 = 120;
+		_G(actor[num]).temp4 = 5 + (_G(rand2) % 17);
+		_G(actor[num]).temp5 = _G(actor[num]).temp4;
+		actr->y -= 16;
+		return 1;
 	}
 
 	return 0;
@@ -207,14 +203,12 @@ int shot_pattern_eight(ACTOR *actr) {
 
 	if (actr->i1) {
 		actr->i1--;
-	} else {
-		if (_G(rand1) < 10) {
-			actr->i1 = _G(thor_x1);
-			actr->i2 = _G(thor_real_y1);
-			actr->i1 = actr->func_pass;
-			actor_shoots(actr, 0);
-			return 1;
-		}
+	} else if (_G(rand1) < 10) {
+		actr->i1 = _G(thor_x1);
+		actr->i2 = _G(thor_real_y1);
+		actr->i1 = actr->func_pass;
+		actor_shoots(actr, 0);
+		return 1;
 	}
 
 	return 0;




More information about the Scummvm-git-logs mailing list