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

athrxx noreply at scummvm.org
Sat Dec 5 16:40:13 UTC 2026


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

Summary:
10b1fb46cb SNATCHER: move input handling to separate class and file
d768c33172 SNATCHER: add optional mouse control mode
bc684bf6cb SNATCHER: reset some vars when loading savegames


Commit: 10b1fb46cb34e30de35b031b85e81d338492a8fd
    https://github.com/scummvm/scummvm/commit/10b1fb46cb34e30de35b031b85e81d338492a8fd
Author: athrxx (athrxx at scummvm.org)
Date: 2026-12-05T17:33:55+01:00

Commit Message:
SNATCHER: move input handling to separate class and file

(in preparation of an optional mouse mode)

Changed paths:
  A engines/snatcher/input.cpp
  A engines/snatcher/input.h
    engines/snatcher/action.cpp
    engines/snatcher/action.h
    engines/snatcher/module.mk
    engines/snatcher/saveload.cpp
    engines/snatcher/scene_d0.cpp
    engines/snatcher/scene_d1.cpp
    engines/snatcher/scene_d2.cpp
    engines/snatcher/scene_y16.cpp
    engines/snatcher/script.cpp
    engines/snatcher/snatcher.cpp
    engines/snatcher/snatcher.h
    engines/snatcher/state.h
    engines/snatcher/text.h
    engines/snatcher/ui.cpp
    engines/snatcher/ui.h


diff --git a/engines/snatcher/action.cpp b/engines/snatcher/action.cpp
index ccbb52c483f..c551d2e23ef 100644
--- a/engines/snatcher/action.cpp
+++ b/engines/snatcher/action.cpp
@@ -32,10 +32,7 @@
 
 namespace Snatcher {
 
-ActionSequenceHandler::ActionSequenceHandler(SnatcherEngine *vm, ResourcePointer *scd, bool palTiming) : _vm(vm), _scd(scd), _palTiming(palTiming), _stage(0), _counter1(0), _counter2(0), _progressMSB(0), _progressLSB(0),
-	_weaponState(0), _enemySpeed(0), _active(false), _handleShotPhase(0), _updateEnemiesPhase(0), _enemyAttackStatus(0), _targetField(0), _hscrollB(0), _vscrollB(0),
-		_enemyAppearanceCount(0), _civilianAppearanceCount(0), _abortFight(0), _nextEnemyAppearanceTimer(0), _enemyAttackTimer(0), _shoot_78EE(0), _activeEnemies(0), _result(),
-			_attackerId(0), _animNo(0), _stage2Temp(0), _projectileCoords(nullptr) {
+ActionSequenceHandler::ActionSequenceHandler(SnatcherEngine *vm, ResourcePointer *scd, bool palTiming) : _vm(vm), _scd(scd), _palTiming(palTiming), _result() {
 	_projectileCoords = new int16[18]();
 }
 
@@ -55,7 +52,7 @@ uint16 fromPAL(uint16 value) {
 	return (clc >> 16) + ((clc & 0xFFFF) ? 1 : 0);
 }
 
-bool ActionSequenceHandler::run(bool useLightGun) {
+bool ActionSequenceHandler::run(bool useLightGun, const InputState &input) {
 	_useLightGun = useLightGun;
 	switch (_progressMSB) {
 	case 0:
@@ -154,8 +151,8 @@ bool ActionSequenceHandler::run(bool useLightGun) {
 		break;
 
 	case 2:
-		handleWeaponDrawAndTargetSelection();
-		handleShot();
+		handleWeaponDrawAndTargetSelection(input);
+		handleShot(input);
 		if (_stage == 14) {
 			if (_shoot_78EE) {
 				animSet(22, PosX, 112);
@@ -180,7 +177,7 @@ bool ActionSequenceHandler::run(bool useLightGun) {
 			_vm->gfx()->enqueuePaletteEvent(_scd->makePtr(_result.hitsTaken < 6 ? MemMapping::MEM_PALDATA_04 : MemMapping::MEM_PALDATA_03));
 		animSet(22, Enable, 0);
 		animSet(23, Enable, 0);
-		_vm->allowLightGunInput(false);
+		_vm->enableLightGun(false);
 		_counter1 = 0;
 		_vm->sound()->fmSendCommand(0xFF, 0);
 		++_progressMSB;
@@ -194,8 +191,8 @@ bool ActionSequenceHandler::run(bool useLightGun) {
 			if ((_scd->makePtr(_useLightGun ? MemMapping::MEM_ACTIONSEQDATA_11 : MemMapping::MEM_ACTIONSEQDATA_10)[_stage] == 1) || (++_counter1 >= 64)) {
 					++_progressLSB;
 			} else if (_result.hitsTaken < 6) {
-				handleWeaponDrawAndTargetSelection();
-				handleShot();
+				handleWeaponDrawAndTargetSelection(input);
+				handleShot(input);
 			}
 			break;
 		case 1:
@@ -234,7 +231,7 @@ bool ActionSequenceHandler::run(bool useLightGun) {
 		if (++_counter1 < 2)
 			break;
 		_weaponState = _enemySpeed = _progressMSB = 0;
-		_vm->allowLightGunInput(false);
+		_vm->enableLightGun(false);
 		_active = false;
 		break;
 
@@ -302,7 +299,6 @@ void ActionSequenceHandler::resetVars() {
 	_weaponState = 0;
 	_handleShotPhase = 0;
 	_updateEnemiesPhase = _enemyAttackStatus = _targetField = 0;
-	_hscrollB = _vscrollB = 0;
 	_result = Result();
 	_enemyAppearanceCount = _civilianAppearanceCount = 0;
 	_stage2Temp = _attackerId = 0;
@@ -362,24 +358,24 @@ void ActionSequenceHandler::initStage() {
 	}
 }
 
-void ActionSequenceHandler::handleWeaponDrawAndTargetSelection() {
+void ActionSequenceHandler::handleWeaponDrawAndTargetSelection(const InputState &input) {
 	if (_weaponState < 2) {
 		animSet(23, PosX, 0);
 		animSet(23, PosY, 0);
 		if (_abortFight || _progressMSB >= 4)
 			return;
 
-		uint16 in = _vm->input().singleFrameControllerFlagsRemapped;
+		uint16 in = input.singleFrameControllerFlagsRemapped;
 
 		if ((!_useLightGun && (in & 0x40)) || (_useLightGun && (in & 0x200))) {
-			_vm->allowLightGunInput(false);
+			_vm->enableLightGun(false);
 			_weaponState ^= 1;
 			int16 enableAnim = 0;
 			if (_weaponState) {
 				_vm->sound()->pcmSendCommand(_scd->makePtr(MemMapping::MEM_ACTIONSEQDATA_01)[_stage], -1);
 				_result.weaponDrawn = enableAnim = 1;
 				if (_useLightGun) {
-					_vm->allowLightGunInput(true);
+					_vm->enableLightGun(true);
 					animSet(22, Enable, 0);
 				}
 			}
@@ -395,7 +391,7 @@ void ActionSequenceHandler::handleWeaponDrawAndTargetSelection() {
 		if (!_weaponState || _useLightGun || _shoot_78EE)
 			return;
 
-		in = _vm->input().sustainedControllerFlagsRemapped;
+		in = input.sustainedControllerFlagsRemapped;
 		uint8 horz = 0;
 		uint8 vert = 0;
 		_targetField = 4;
@@ -434,7 +430,7 @@ void ActionSequenceHandler::handleWeaponDrawAndTargetSelection() {
 	}
 }
 
-void ActionSequenceHandler::handleShot() {
+void ActionSequenceHandler::handleShot(const InputState &input) {
 	if (_useLightGun) {
 		// Weirdly, during the calibration, the original substracts an y-offset, but not here. When testing with an
 		// emulator, the aiming is not satisfactory either, so I guess this is either an original bug or it really
@@ -446,19 +442,19 @@ void ActionSequenceHandler::handleShot() {
 		if (v && ++v >= 2) {
 			v = 0;
 			_targetField = 0;
-			if (_vm->input().lightGunPos.x >= 160)
+			if (input.lightGunPos.x >= 160)
 				_targetField = 2;
-			else if (_vm->input().lightGunPos.x >= 96)
+			else if (input.lightGunPos.x >= 96)
 				_targetField = 1;
-			if (_vm->input().lightGunPos.y + yOffs >= 88)
+			if (input.lightGunPos.y + yOffs >= 88)
 				_targetField += 6;
-			else if (_vm->input().lightGunPos.y + yOffs>= 48)
+			else if (input.lightGunPos.y + yOffs>= 48)
 				_targetField += 3;
 		}
 		animSet(21, ActionTimer, v);
 	}
 
-	uint16 in = _vm->input().singleFrameControllerFlagsRemapped;
+	uint16 in = input.singleFrameControllerFlagsRemapped;
 	int16 tf = (_stage == 14) ? 4 : _targetField;
 	int16 vl = 0;
 
@@ -540,7 +536,7 @@ void ActionSequenceHandler::handleShot() {
 				}
 
 				if (_stage == 9) {
-					_vm->allowLightGunInput(false);
+					_vm->enableLightGun(false);
 					_abortFight = 1;
 				}
 			}
diff --git a/engines/snatcher/action.h b/engines/snatcher/action.h
index 9e10118bf01..bc73b7782fc 100644
--- a/engines/snatcher/action.h
+++ b/engines/snatcher/action.h
@@ -24,6 +24,7 @@
 #define SNATCHER_ACTION_H
 
 #include "common/scummsys.h"
+#include "snatcher/state.h"
 
 namespace Common {
 
@@ -38,7 +39,7 @@ public:
 	ActionSequenceHandler(SnatcherEngine *vm, ResourcePointer *scd, bool palTiming);
 	~ActionSequenceHandler();
 
-	bool run(bool useLightGun);
+	bool run(bool useLightGun, const InputState &input);
 	bool resetScore();
 	void setup(uint16 stage);
 	void setDifficulty(uint16 setting);
@@ -61,42 +62,45 @@ public:
 private:
 	void resetVars();
 	void initStage();
-	void handleWeaponDrawAndTargetSelection();
-	void handleShot();
+	void handleWeaponDrawAndTargetSelection(const InputState &input);
+	void handleShot(const InputState &input);
 	void updateEnemies();
 	void updateStage();
 	void enemyAttack();
 	void checkFinished();
 
-	uint16 _stage;
-	int16 _progressMSB;
-	int16 _progressLSB;
-	int16 _weaponState;
-	int16 _enemySpeed;
-	int16 _handleShotPhase;
-	int16 _updateEnemiesPhase;
-	int16 _enemyAttackStatus;
-	int16 _targetField;
-	int16 _hscrollB;
-	int16 _vscrollB;
-	int16 _enemyAppearanceCount;
-	int16 _stage2Temp;
-	int16 _civilianAppearanceCount;
-	int16 _abortFight;
-	int16 _nextEnemyAppearanceTimer;
-	int16 _animNo;
-	int16 _enemyAttackTimer;
-	int16 _shoot_78EE;
-	int16 _counter1;
-	int16 _counter2;
-	int16 _activeEnemies;
-	int16 _attackerId;
-	int16 *_projectileCoords;
-	bool _active;
+	//_stage(0), _counter1(0), _counter2(0), _progressMSB(0), _progressLSB(0),
+	//	_weaponState(0), _enemySpeed(0), _active(false), _handleShotPhase(0), _updateEnemiesPhase(0), _enemyAttackStatus(0), _targetField(0), _hscrollB(0), _vscrollB(0), _useLightGun(false),
+	//	_enemyAppearanceCount(0), _civilianAppearanceCount(0), _abortFight(0), _nextEnemyAppearanceTimer(0), _enemyAttackTimer(0), _shoot_78EE(0), _activeEnemies(0)
+
+
+	uint16 _stage = 0;
+	int16 _progressMSB = 0;
+	int16 _progressLSB = 0;
+	int16 _weaponState = 0;
+	int16 _enemySpeed = 0;
+	int16 _handleShotPhase = 0;
+	int16 _updateEnemiesPhase = 0;
+	int16 _enemyAttackStatus = 0;
+	int16 _targetField = 0;
+	int16 _enemyAppearanceCount = 0;
+	int16 _stage2Temp = 0;
+	int16 _civilianAppearanceCount = 0;
+	int16 _abortFight = 0;
+	int16 _nextEnemyAppearanceTimer = 0;
+	int16 _animNo = 0;
+	int16 _enemyAttackTimer = 0;
+	int16 _shoot_78EE = 0;
+	int16 _counter1 = 0;
+	int16 _counter2 = 0;
+	int16 _activeEnemies = 0;
+	int16 _attackerId = 0;
+	int16 *_projectileCoords = nullptr;
+	bool _active = false;
+	bool _useLightGun = false;
 
 	SnatcherEngine *_vm;
 	ResourcePointer *_scd;
-	bool _useLightGun;
 	const bool _palTiming;
 
 	Result _result;
diff --git a/engines/snatcher/input.cpp b/engines/snatcher/input.cpp
new file mode 100644
index 00000000000..d223a8f0dce
--- /dev/null
+++ b/engines/snatcher/input.cpp
@@ -0,0 +1,155 @@
+/* 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 "snatcher/input.h"
+#include "snatcher/graphics.h"
+#include "common/events.h"
+#include "common/stream.h"
+#include "graphics/cursorman.h"
+
+namespace Snatcher {
+
+struct InputEvent {
+	Common::EventType pressType;
+	Common::EventType releaseType;
+	Common::KeyCode kc;
+	uint16 kFlag;
+	uint16 internalEvent;
+	bool updateCoords;
+};
+
+static const InputEvent _defaultKeyEvents[] = {
+	// Arrow buttons
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_UP,			0x00, 0x01, false },
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP8,		0x00, 0x01, false },
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_DOWN,		0x00, 0x02, false },
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP2,		0x00, 0x02, false },
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_LEFT,		0x00, 0x04, false },
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP4,		0x00, 0x04, false },
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_RIGHT,		0x00, 0x08, false },
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP6,		0x00, 0x08, false },
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP7,		0x00, 0x05, false },
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP9,		0x00, 0x09, false },
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP3,		0x00, 0x0A, false },
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP1,		0x00, 0x06, false },
+	{ Common::EVENT_WHEELUP,		Common::EVENT_INVALID,		Common::KEYCODE_INVALID,	0x00, 0x01, false },
+	{ Common::EVENT_WHEELDOWN,		Common::EVENT_INVALID,		Common::KEYCODE_INVALID,	0x00, 0x02, false },
+
+	// A, B, C buttons
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_a,			0x00, 0x10, false },
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_b,			0x00, 0x20, false },
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_c,			0x00, 0x40, false },
+
+	{ Common::EVENT_MBUTTONDOWN,	Common::EVENT_MBUTTONUP,	Common::KEYCODE_INVALID,	0x00, 0x20, false },
+
+	// Start button
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_RETURN,		0x00, 0x80, false },
+	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_SPACE,		0x00, 0x80, false },
+
+	// Lightgun
+	{ Common::EVENT_LBUTTONDOWN,	Common::EVENT_LBUTTONUP,	Common::KEYCODE_INVALID,	0x00, 0x100, true },
+
+	// Lightgun Start button
+	{ Common::EVENT_RBUTTONDOWN,	Common::EVENT_RBUTTONUP,	Common::KEYCODE_INVALID,	0x00, 0x200, false }
+};
+
+static const uint8 _scdKeyConfigs[6][3] = {
+	{ 6, 4, 5 }, { 6, 5, 4 }, { 4, 6, 5 },
+	{ 4, 5, 6 }, { 5, 4, 6 }, { 5, 6, 4 }
+};
+
+void InputHandler::handleEvents(GameState &state) {
+	Common::Event evt;
+	_lastKeys &= ~_releaseKeys;
+	_releaseKeys = 0;
+	state.input.singleFrameControllerFlags = state.input.singleFrameControllerFlagsRemapped = 0;
+
+	while (_evt->pollEvent(evt)) {
+		for (const InputEvent &k : _defaultKeyEvents) {
+			if (evt.type == k.pressType && (k.kc == Common::KEYCODE_INVALID || evt.kbd.keycode == k.kc) && (k.kFlag == 0 || (evt.kbd.flags & k.kFlag))) {
+				if (k.kc != Common::KEYCODE_INVALID && k.releaseType != Common::EVENT_INVALID) {
+					state.input.sustainedControllerFlags |= k.internalEvent;
+					// The A, B and C buttons can be reconfigured in the main menu. This applies the setting.
+					for (int f = 0; f < 3; ++f) {
+						if (k.internalEvent & ((1 << f) << 4))
+							state.input.sustainedControllerFlagsRemapped |= (1 << _scdKeyConfigs[state.conf.controllerSetup][f]);
+					}
+					state.input.sustainedControllerFlagsRemapped |= (k.internalEvent & ~0x70);
+				}
+
+				if (!(_lastKeys & k.internalEvent)) {
+					state.input.singleFrameControllerFlags |= k.internalEvent;
+					// The A, B and C buttons can be reconfigured in the main menu. This applies the setting.
+					for (int f = 0; f < 3; ++f) {
+						if (k.internalEvent & ((1 << f) << 4))
+							state.input.singleFrameControllerFlagsRemapped |= (1 << _scdKeyConfigs[state.conf.controllerSetup][f]);
+					}
+					state.input.singleFrameControllerFlagsRemapped |= (k.internalEvent & ~0x70);
+					_lastKeys |= k.internalEvent;
+					if (_keyRepeat || k.releaseType == Common::EVENT_INVALID)
+						_releaseKeys |= k.internalEvent;
+					if (k.updateCoords) {
+						_realLightGunPos = evt.mouse;
+						// Revert aspect ratio correction, if necessary.
+						_realLightGunPos.x = (_realLightGunPos.x * _gfx->screenWidth()) / _gfx->realScreenWidth();
+						_realLightGunPos.y = (_realLightGunPos.y * _gfx->screenHeight()) / _gfx->realScreenHeight();
+						// The lightgun coordinates are supposed to be based on a 256 x 256 system, with 128 being
+						// the screen center. I solve this by always adding the diff to the y-bias.
+						state.input.lightGunPos.x = CLIP<int>(_realLightGunPos.x - state.conf.lightGunBias.x, 0, 255);
+						state.input.lightGunPos.y = CLIP<int>(_realLightGunPos.y - state.conf.lightGunBias.y, 0, 255);
+					}
+				}
+
+			} else if ((evt.type == k.releaseType) && (k.kc == Common::KEYCODE_INVALID || evt.kbd.keycode == k.kc) && (k.kFlag == 0 || (evt.kbd.flags & k.kFlag))) {
+				_lastKeys &= ~k.internalEvent;
+				if (k.kc != Common::KEYCODE_INVALID && k.releaseType != Common::EVENT_INVALID) {
+					state.input.sustainedControllerFlags &= ~k.internalEvent;
+					for (int f = 0; f < 3; ++f) {
+						if (k.internalEvent & ((1 << f) << 4))
+							state.input.sustainedControllerFlagsRemapped &= ~(1 << _scdKeyConfigs[state.conf.controllerSetup][f]);
+					}
+					state.input.sustainedControllerFlagsRemapped &= ~(k.internalEvent & ~0x70);
+				}
+			}
+		}
+	}
+
+	if (_enableLightGun && state.input.singleFrameControllerFlags & 0x100)
+		_gfx->setVar(7, _gfx->getVar(7) | 4);
+}
+
+void InputHandler::saveState(Common::SeekableWriteStream *out) const {
+	out->writeByte(_keyRepeat);
+	out->writeByte(_enableLightGun);
+}
+
+void InputHandler::loadState(Common::SeekableReadStream *in) {
+	_keyRepeat = in->readByte();
+	_enableLightGun = in->readByte();
+}
+
+void InputHandler::enableLightGun(bool enable) {
+	_enableLightGun = enable;
+	_gfx->createMouseCursor();
+	CursorMan.showMouse(enable);
+}
+
+} // End of namespace Snatcher
diff --git a/engines/snatcher/input.h b/engines/snatcher/input.h
new file mode 100644
index 00000000000..39662150000
--- /dev/null
+++ b/engines/snatcher/input.h
@@ -0,0 +1,65 @@
+/* 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 SNATCHER_INPUT_H
+#define SNATCHER_INPUT_H
+
+#include "common/scummsys.h"
+#include "snatcher/state.h"
+
+
+namespace Common {
+class SeekableReadStream;
+class SeekableWriteStream;
+class EventManager;
+}
+
+namespace Snatcher {
+
+class GraphicsEngine;
+class InputHandler {
+public:
+	InputHandler(Common::EventManager *eventManager, GraphicsEngine *gfx) : _evt(eventManager), _gfx(gfx) {}
+	~InputHandler() {}
+
+	void handleEvents(GameState &state);
+
+	void saveState(Common::SeekableWriteStream *out) const;
+	void loadState(Common::SeekableReadStream *in);
+
+	void enableLightGun(bool enable);
+	const Common::Point &getLightGunLastRealPos() const { return _realLightGunPos; }
+	
+private:
+	uint16 _lastKeys = 0;
+	uint16 _releaseKeys = 0;
+	Common::Point _realLightGunPos;
+	bool _keyRepeat = false;
+	bool _enableLightGun = false;
+
+	GraphicsEngine *_gfx = nullptr;
+	Common::EventManager *_evt = nullptr;
+};
+
+} // End of namespace Snatcher
+
+#endif // SNATCHER_INPUT_H
diff --git a/engines/snatcher/module.mk b/engines/snatcher/module.mk
index 1ddf23ccca0..38ee8638f57 100644
--- a/engines/snatcher/module.mk
+++ b/engines/snatcher/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
 	fantranslations.o \
 	fantranslations_detection.o \
 	graphics.o \
+	input.o \
 	memory.o \
 	mem_mapping.o \
 	metaengine.o \
diff --git a/engines/snatcher/saveload.cpp b/engines/snatcher/saveload.cpp
index 2c432f14b18..1cb6e91faee 100644
--- a/engines/snatcher/saveload.cpp
+++ b/engines/snatcher/saveload.cpp
@@ -21,6 +21,7 @@
 
 
 #include "snatcher/graphics.h"
+#include "snatcher/input.h"
 #include "snatcher/saveload.h"
 #include "snatcher/script.h"
 #include "snatcher/snatcher.h"
@@ -203,7 +204,7 @@ void SaveLoadManager::loadState(int slot, GameState &state) {
 	Common::InSaveFile *in = openFileForLoading(slot, state, header);
 
 	_vm->_keyRepeat = in->readByte();
-	_vm->_enableLightGun = in->readByte();
+	_vm->enableLightGun(in->readByte());
 
 	state.phase = in->readSint16BE();
 	state.updateFlags = in->readSint16BE();
@@ -252,7 +253,7 @@ void SaveLoadManager::saveState(int slot, GameState &state, SaveFlags flags) {
 	Common::OutSaveFile *out = openFileForSaving(slot, _desc, state);
 
 	out->writeByte(_vm->_keyRepeat);
-	out->writeByte(_vm->_enableLightGun);
+	out->writeByte(_vm->_lightGunEnabled);
 
 	out->writeSint16BE(state.phase);
 	out->writeSint16BE(state.updateFlags);
diff --git a/engines/snatcher/scene_d0.cpp b/engines/snatcher/scene_d0.cpp
index 1ead48f550d..f6c743c678c 100644
--- a/engines/snatcher/scene_d0.cpp
+++ b/engines/snatcher/scene_d0.cpp
@@ -133,7 +133,7 @@ SH_IMPL_UPDT(D0) {
 	} else if (_vm->sound()->cdaGetTime() >= _timeStamp[state.frameNo]) {
 		(*_frameProcs[state.frameNo])(state);
 		++state.frameNo;
-	} else if (_vm->input().singleFrameControllerFlags & 0x80) {
+	} else if (state.input.singleFrameControllerFlags & 0x80) {
 		state.modFinish = -1;
 		state.frameNo = 0;
 	}
diff --git a/engines/snatcher/scene_d1.cpp b/engines/snatcher/scene_d1.cpp
index 963741b607c..821e9b99da0 100644
--- a/engines/snatcher/scene_d1.cpp
+++ b/engines/snatcher/scene_d1.cpp
@@ -123,7 +123,7 @@ SH_IMPL_UPDT(D1) {
 	} else if (_vm->sound()->cdaGetTime() >= _timeStamp[state.frameNo]) {
 		(*_frameProcs[state.frameNo])(state);
 		++state.frameNo;
-	} else if (_vm->input().singleFrameControllerFlags & 0x80) {
+	} else if (state.input.singleFrameControllerFlags & 0x80) {
 		state.modFinish = -1;
 		state.frameNo = 0;
 	}
diff --git a/engines/snatcher/scene_d2.cpp b/engines/snatcher/scene_d2.cpp
index ab8fd3ad4a6..8e123945ba6 100644
--- a/engines/snatcher/scene_d2.cpp
+++ b/engines/snatcher/scene_d2.cpp
@@ -110,11 +110,11 @@ SH_IMPL_FRM(D2, 00) {
 		}
 		break;
 	case 2:
-		if (_vm->input().singleFrameControllerFlags & 3) {
+		if (state.input.singleFrameControllerFlags & 3) {
 			_vm->gfx()->clearAnimParameterFlags(16, GraphicsEngine::kAnimParaControlFlags, ~GraphicsEngine::kAnimHide);
 			_buram0 ^= 1;
 		}
-		if (_vm->input().singleFrameControllerFlags & 0x80) {
+		if (state.input.singleFrameControllerFlags & 0x80) {
 			state.counter = 10;
 			_vm->gfx()->enqueuePaletteEvent(_module->getPtr(MemMapping::MEM_PALDATA_12));
 			++state.frameState;
@@ -253,9 +253,9 @@ SH_IMPL_FRM(D2, 09) {
 		state.frameState += (state.saveInfo.slotUsage ? 1 : 2);
 		break;
 	case 1:
-		if (_vm->input().singleFrameControllerFlags & 3)
+		if (state.input.singleFrameControllerFlags & 3)
 			_vm->gfx()->clearAnimParameterFlags(17, GraphicsEngine::kAnimParaControlFlags, ~GraphicsEngine::kAnimHide);
-		if (_vm->input().singleFrameControllerFlags & 0x80) {
+		if (state.input.singleFrameControllerFlags & 0x80) {
 			_vm->gfx()->setAnimParameter(17, GraphicsEngine::kAnimParaControlFlags, GraphicsEngine::kAnimPause | GraphicsEngine::kAnimHide);
 			state.menuSelect = 1;
 			if (_vm->gfx()->getAnimParameter(17, GraphicsEngine::kAnimParaFrame) == 3) {
@@ -266,7 +266,7 @@ SH_IMPL_FRM(D2, 09) {
 		}
 		break;
 	default:
-		if (_vm->input().singleFrameControllerFlags & 0x80) {
+		if (state.input.singleFrameControllerFlags & 0x80) {
 			++state.frameNo;
 			state.frameState = 0;
 			fin = true;
@@ -300,9 +300,9 @@ SH_IMPL_FRM(D2, 10) {
 		_vm->gfx()->clearAnimParameterFlags(25, GraphicsEngine::kAnimParaControlFlags, 0xFF);
 
 		do {
-			if (_vm->input().singleFrameControllerFlags & 1)
+			if (state.input.singleFrameControllerFlags & 1)
 				--_curSaveFile;
-			if (_vm->input().singleFrameControllerFlags & 2)
+			if (state.input.singleFrameControllerFlags & 2)
 				++_curSaveFile;
 			_curSaveFile &= 3;
 		} while (!(state.saveInfo.slotUsage & (1 << _curSaveFile)));
@@ -310,12 +310,12 @@ SH_IMPL_FRM(D2, 10) {
 		_vm->gfx()->setAnimParameter(24, GraphicsEngine::kAnimParaFrame, _curSaveFile << 2);
 		_vm->gfx()->setAnimParameter(25, GraphicsEngine::kAnimParaFrame, _curSaveFile << 2);
 
-		if (_vm->input().singleFrameControllerFlags & 0x80) {
+		if (state.input.singleFrameControllerFlags & 0x80) {
 			_vm->sound()->fmSendCommand(56, 0, 2);
 			state.pendingSaveLoad = _curSaveFile + 1;
 			_loadCancelled = false;
 			fin = true;
-		} else if (_vm->input().singleFrameControllerFlags & 0x10) {
+		} else if (state.input.singleFrameControllerFlags & 0x10) {
 			_loadCancelled = true;
 			fin = true;
 		}
@@ -374,9 +374,9 @@ SH_IMPL_FRM(D2, 11) {
 			_vm->gfx()->clearAnimParameterFlags(i, GraphicsEngine::kAnimParaControlFlags, 0xFF);
 
 		do {
-			if (_vm->input().singleFrameControllerFlags & 1)
+			if (state.input.singleFrameControllerFlags & 1)
 				--_option;
-			if (_vm->input().singleFrameControllerFlags & 2)
+			if (state.input.singleFrameControllerFlags & 2)
 				++_option;
 			_option = (_option + 5) % 5;
 		} while (_option == 3 && !state.conf.useLightGun);
@@ -388,16 +388,16 @@ SH_IMPL_FRM(D2, 11) {
 		}
 
 		if (_option == 0) {
-			if (state.conf.lightGunAvailable && _vm->input().singleFrameControllerFlags & 0x0C)
+			if (state.conf.lightGunAvailable && state.input.singleFrameControllerFlags & 0x0C)
 				state.conf.useLightGun ^= 1;
 		} else if (_option == 1) {
-			if (_vm->input().singleFrameControllerFlags & 8)
+			if (state.input.singleFrameControllerFlags & 8)
 				++state.conf.controllerSetup;
-			if (_vm->input().singleFrameControllerFlags & 4)
+			if (state.input.singleFrameControllerFlags & 4)
 				--state.conf.controllerSetup;
 			state.conf.controllerSetup = (state.conf.controllerSetup + 5) % 5;
 		} else if (_option == 2) {
-			if (_vm->input().singleFrameControllerFlags & 0x0C)
+			if (state.input.singleFrameControllerFlags & 0x0C)
 				state.conf.disableStereo ^= 1;
 		}
 
@@ -407,9 +407,9 @@ SH_IMPL_FRM(D2, 11) {
 		_vm->gfx()->setAnimParameter(34, GraphicsEngine::kAnimParaFrame, ((_option != 1 ? 6 : 0) + state.conf.controllerSetup) << 1);
 		_vm->gfx()->setAnimParameter(35, GraphicsEngine::kAnimParaFrame, ((_option != 2 ? 2 : 0) + state.conf.disableStereo) << 1);
 
-		if (_vm->input().singleFrameControllerFlags & 0x80)
+		if (state.input.singleFrameControllerFlags & 0x80)
 			fin = (_option != 3) ? 1 : 3;
-		else if (_vm->input().singleFrameControllerFlags & 0x70)
+		else if (state.input.singleFrameControllerFlags & 0x70)
 			fin = (_option == 4) ? 1 : (_option == 3 ? 3 : 0);
 		if (fin) {
 			_vm->sound()->pcmSendCommand(55 + fin, -1);
@@ -433,7 +433,7 @@ SH_IMPL_FRM(D2, 11) {
 	case 2:
 		state.counter  = 0;
 		_counter2 = 0;
-		_vm->allowLightGunInput(true);
+		_vm->enableLightGun(true);
 		_vm->gfx()->setAnimParameter(16, GraphicsEngine::kAnimParaControlFlags, GraphicsEngine::kAnimPause | GraphicsEngine::kAnimHide);
 		for (int i = 0; i < 4; ++i)
 			_vm->gfx()->setAnimParameter(16 + i, GraphicsEngine::kAnimParaFrame, 0);
@@ -445,11 +445,11 @@ SH_IMPL_FRM(D2, 11) {
 		++state.frameState;
 		break;
 	case 3:
-		if (_vm->input().singleFrameControllerFlags & 0x80) {
+		if (state.input.singleFrameControllerFlags & 0x80) {
 			_vm->gfx()->enqueuePaletteEvent(_module->getPtr(MemMapping::MEM_PALDATA_12));
 			state.counter = 10;
 			++state.frameState;
-			_vm->allowLightGunInput(false);
+			_vm->enableLightGun(false);
 			return;
 		}
 
@@ -462,7 +462,7 @@ SH_IMPL_FRM(D2, 11) {
 			++state.counter;
 			break;
 		case 1:
-			if (_vm->input().singleFrameControllerFlags & 0x100) {
+			if (state.input.singleFrameControllerFlags & 0x100) {
 				_vm->sound()->pcmSendCommand(57, -1);
 				_vm->gfx()->setAnimParameter(18, GraphicsEngine::kAnimParaBlink, 0);
 				_vm->gfx()->setAnimParameter(18, GraphicsEngine::kAnimParaAbsSpeedX, 0);
@@ -479,22 +479,22 @@ SH_IMPL_FRM(D2, 11) {
 			++state.counter;
 			break;
 		case 3:
-			if (_vm->input().singleFrameControllerFlags & 0x200) {
+			if (state.input.singleFrameControllerFlags & 0x200) {
 				_vm->gfx()->setAnimParameter(17, GraphicsEngine::kAnimParaBlink, 1);
 				_vm->gfx()->setAnimParameter(17, GraphicsEngine::kAnimParaAbsSpeedX, 1);
 				_vm->gfx()->setAnimParameter(19, GraphicsEngine::kAnimParaBlink, 0);
 				_vm->gfx()->setAnimParameter(19, GraphicsEngine::kAnimParaAbsSpeedX, 0);
-				_vm->allowLightGunInput(false);
+				_vm->enableLightGun(false);
 				state.counter += 2;
 				_vm->sound()->fmSendCommand(29, 0, 2);
-			} else if (_vm->input().singleFrameControllerFlags & 0x100) {
+			} else if (state.input.singleFrameControllerFlags & 0x100) {
 				_vm->sound()->pcmSendCommand(57, -1);
 				state.counter++;
 			}
 			break;
 		case 4:
-			_vm->gfx()->setAnimParameter(16, GraphicsEngine::kAnimParaPosX, _vm->input().lightGunPos.x - 11);
-			_vm->gfx()->setAnimParameter(16, GraphicsEngine::kAnimParaPosY, _vm->input().lightGunPos.y - 35);
+			_vm->gfx()->setAnimParameter(16, GraphicsEngine::kAnimParaPosX, state.input.lightGunPos.x - 11);
+			_vm->gfx()->setAnimParameter(16, GraphicsEngine::kAnimParaPosY, state.input.lightGunPos.y - 35);
 			--state.counter;
 			break;
 		case 5:
diff --git a/engines/snatcher/scene_y16.cpp b/engines/snatcher/scene_y16.cpp
index eaab34039f7..48ce207f400 100644
--- a/engines/snatcher/scene_y16.cpp
+++ b/engines/snatcher/scene_y16.cpp
@@ -235,7 +235,7 @@ SH_IMPL_FRM(Y16, 23) {
 }
 
 SH_IMPL_FRM(Y16, 25) {
-	if (!(_vm->input().singleFrameControllerFlags & 0x80)) {
+	if (!(state.input.singleFrameControllerFlags & 0x80)) {
 		--state.frameNo;
 		return;
 	}
diff --git a/engines/snatcher/script.cpp b/engines/snatcher/script.cpp
index 0f610c323d8..4a91eb1b939 100644
--- a/engines/snatcher/script.cpp
+++ b/engines/snatcher/script.cpp
@@ -204,7 +204,7 @@ void CmdQueue::m_fmMusicStart(const uint16 *&data) {
 }
 
 void CmdQueue::m_displayDialog(const uint16 *&data) {
-	if (_vm->_ui->displayDialog(data[0], data[1], _vm->input().singleFrameControllerFlagsRemapped)) {
+	if (_vm->_ui->displayDialog(data[0], data[1], _state->input.singleFrameControllerFlagsRemapped)) {
 		_progress = -1;
 		data += 2;
 	}
@@ -399,7 +399,7 @@ void CmdQueue::m_unused(const uint16 *&data) {
 }
 
 void CmdQueue::m_shooterSequenceRun(const uint16 *&data) {
-	if (!_vm->_aseq->run(_state->conf.useLightGun))
+	if (!_vm->_aseq->run(_state->conf.useLightGun, _state->input))
 		_progress = -1;
 }
 
@@ -456,7 +456,7 @@ void CmdQueue::m_gfxPostLoadProcess(const uint16 *&data) {
 }
 
 void CmdQueue::m_waitForStartButton(const uint16 *&data) {
-	if (_vm->input().singleFrameControllerFlags & 0x80)
+	if (_state->input.singleFrameControllerFlags & 0x80)
 		_progress = -1;
 }
 
diff --git a/engines/snatcher/snatcher.cpp b/engines/snatcher/snatcher.cpp
index 2204255cf80..79f4d9cb74c 100644
--- a/engines/snatcher/snatcher.cpp
+++ b/engines/snatcher/snatcher.cpp
@@ -22,6 +22,7 @@
 #include "snatcher/action.h"
 #include "snatcher/fantranslations.h"
 #include "snatcher/graphics.h"
+#include "snatcher/input.h"
 #include "snatcher/memory.h"
 #include "snatcher/mem_mapping.h"
 #include "snatcher/resource.h"
@@ -35,11 +36,9 @@
 #include "snatcher/util.h"
 #include "common/config-manager.h"
 #include "common/endian.h"
-#include "common/events.h"
 #include "common/list.h"
 #include "common/str.h"
 #include "common/system.h"
-#include "graphics/cursorman.h"
 #include "graphics/pixelformat.h"
 #include "engines/util.h"
 
@@ -52,9 +51,7 @@
 
 namespace Snatcher {
 
-SnatcherEngine::SnatcherEngine(OSystem *system, GameDescription &dsc) : Engine(system), _game(dsc), _fio(nullptr), _module(nullptr), _scd(nullptr), _gfx(nullptr), _snd(nullptr), _input(),
-	_scriptEngine(nullptr), _cmdQueue(nullptr), _aseq(nullptr), _lastKeys(0), _releaseKeys(0), _keyRepeat(false), _enableLightGun(false), _ui(nullptr), _gfxInfo(), _saveMan(nullptr), _reset(0),
-		_updateGameSettings(false), _memHandler(nullptr), _translator(nullptr), _frameLen((100000 << 14) / (6000000 / 1001)), _realLightGunPos() {
+SnatcherEngine::SnatcherEngine(OSystem *system, GameDescription &dsc) : Engine(system), _game(dsc), _gfxInfo() {
 	assert(system);
 	MemMapping::initMapping(_game.usePALTiming ? 1 : 0);
 }
@@ -72,6 +69,7 @@ SnatcherEngine::~SnatcherEngine() {
 	delete _snd;
 	delete _ui;
 	delete _translator;
+	delete _input;
 }
 
 Common::Error SnatcherEngine::run() {
@@ -87,6 +85,9 @@ Common::Error SnatcherEngine::run() {
 	if (!initSaveLoad())
 		return Common::Error(Common::kUnknownError);
 
+	if (!initUserInterface())
+		return Common::Error(Common::kUnknownError);
+
 	if (!initScriptEngine())
 		return Common::Error(Common::kUnknownError);
 
@@ -165,7 +166,7 @@ bool SnatcherEngine::initSaveLoad() {
 }
 
 bool SnatcherEngine::initSound(Audio::Mixer *mixer, Common::Platform platform, int soundOptions) {
-	assert(_mixer);
+	assert(mixer);
 	assert(_fio);
 
 	_snd = new SoundEngine(_fio, platform, soundOptions);
@@ -177,7 +178,11 @@ bool SnatcherEngine::initSound(Audio::Mixer *mixer, Common::Platform platform, i
 	return true;
 }
 
-bool SnatcherEngine::initScriptEngine() {
+bool SnatcherEngine::initUserInterface() {
+	_input = new InputHandler(_eventMan, _gfx);
+	if (!_input)
+		return false;
+
 	_cmdQueue = new CmdQueue(this);
 	if (!_cmdQueue)
 		return false;
@@ -188,6 +193,10 @@ bool SnatcherEngine::initScriptEngine() {
 	if (!_ui)
 		return false;
 
+	return true;
+}
+
+bool SnatcherEngine::initScriptEngine() {
 	_aseq = new ActionSequenceHandler(this, _scd, _game.usePALTiming);
 	if (!_aseq)
 		return false;
@@ -209,7 +218,7 @@ void SnatcherEngine::reset() {
 	_snd->cdaStop();
 }
 
-void SnatcherEngine::playBootLogoAnimation(const GameState &state) {
+void SnatcherEngine::playBootLogoAnimation(GameState &state) {
 	if (!_reset && ConfMan.hasKey("save_slot"))
 		return; // Skip logo animation when loading a savegame from the launcher
 
@@ -227,7 +236,7 @@ void SnatcherEngine::playBootLogoAnimation(const GameState &state) {
 			_snd->fmSendCommand(63, -1);
 		curSeqState = nextState;
 
-		checkEvents(state);
+		_input->handleEvents(state);
 		_snd->update();
 		delayUntil(nextFrame);
 	}
@@ -296,7 +305,7 @@ bool SnatcherEngine::start() {
 
 		_saveMan->enableSaving(state.phase == 2 && state.modPhaseTop == 5);
 
-		checkEvents(state);
+		_input->handleEvents(state);
 
 		_saveMan->handleSaveLoad(state);
 
@@ -332,116 +341,6 @@ void SnatcherEngine::delayUntil(uint32 end) {
 		_system->delayMillis(end - cur);
 }
 
-struct InputEvent {
-	Common::EventType pressType;
-	Common::EventType releaseType;
-	Common::KeyCode kc;
-	uint16 kFlag;
-	uint16 internalEvent;
-	bool updateCoords;
-};
-
-static const InputEvent _defaultKeyEvents[] = {
-	// Arrow buttons
-	{ Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_UP, 0x00, 0x01, false },
-	{ Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_KP8, 0x00, 0x01, false },
-	{ Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_DOWN, 0x00, 0x02, false },
-	{ Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_KP2, 0x00, 0x02, false },
-	{ Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_LEFT, 0x00, 0x04, false },
-	{ Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_KP4, 0x00, 0x04, false },
-	{ Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_RIGHT, 0x00, 0x08, false },
-	{ Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_KP6, 0x00, 0x08, false},
-	{ Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_KP7, 0x00, 0x05, false },
-	{ Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_KP9, 0x00, 0x09, false },
-	{ Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_KP3, 0x00, 0x0A, false },
-	{ Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_KP1, 0x00, 0x06, false },
-	{ Common::EVENT_WHEELUP, Common::EVENT_INVALID, Common::KEYCODE_INVALID, 0x00, 0x01, false },
-	{ Common::EVENT_WHEELDOWN, Common::EVENT_INVALID, Common::KEYCODE_INVALID, 0x00, 0x02, false },
-
-	// A, B, C buttons
-	{Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_a, 0x00, 0x10, false},
-	{Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_b, 0x00, 0x20, false},
-	{Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_c, 0x00, 0x40, false},
-
-	{ Common::EVENT_MBUTTONDOWN, Common::EVENT_MBUTTONUP, Common::KEYCODE_INVALID, 0x00, 0x20, false },
-
-	// Start button
-	{Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_RETURN, 0x00, 0x80, false},
-	{Common::EVENT_KEYDOWN, Common::EVENT_KEYUP, Common::KEYCODE_SPACE, 0x00, 0x80, false},
-
-	// Lightgun
-	{ Common::EVENT_LBUTTONDOWN, Common::EVENT_LBUTTONUP, Common::KEYCODE_INVALID, 0x00, 0x100, true },
-
-	// Lightgun Start button
-	{ Common::EVENT_RBUTTONDOWN, Common::EVENT_RBUTTONUP, Common::KEYCODE_INVALID, 0x00, 0x200, false },
-};
-
-static const uint8 _scdKeyConfigs[6][3] = {
-	{ 6, 4, 5 }, { 6, 5, 4 },
-	{ 4, 6, 5 }, { 4, 5, 6 },
-	{ 5, 4, 6 }, { 5, 6, 4 }
-};
-
-void SnatcherEngine::checkEvents(const GameState &state) {
-	Common::Event evt;
-	_lastKeys &= ~_releaseKeys;
-	_releaseKeys = 0;
-	_input.singleFrameControllerFlags = _input.singleFrameControllerFlagsRemapped = 0;
-
-	while (_eventMan->pollEvent(evt)) {
-		for (const InputEvent &k : _defaultKeyEvents) {
-			if (evt.type == k.pressType && (k.kc == Common::KEYCODE_INVALID || evt.kbd.keycode == k.kc) && (k.kFlag == 0 || (evt.kbd.flags & k.kFlag))) {
-				if (k.kc != Common::KEYCODE_INVALID && k.releaseType != Common::EVENT_INVALID) {
-					_input.sustainedControllerFlags |= k.internalEvent;
-					// The A, B and C buttons can be reconfigured in the main menu. This applies the setting.
-					for (int f = 0; f < 3; ++f) {
-						if (k.internalEvent & ((1 << f) << 4))
-							_input.sustainedControllerFlagsRemapped |= (1 << _scdKeyConfigs[state.conf.controllerSetup][f]);
-					}
-					_input.sustainedControllerFlagsRemapped |= (k.internalEvent & ~0x70);
-				}
-
-				if (!(_lastKeys & k.internalEvent)) {
-					_input.singleFrameControllerFlags |= k.internalEvent;
-					// The A, B and C buttons can be reconfigured in the main menu. This applies the setting.
-					for (int f = 0; f < 3; ++f) {
-						if (k.internalEvent & ((1 << f) << 4))
-							_input.singleFrameControllerFlagsRemapped |= (1 << _scdKeyConfigs[state.conf.controllerSetup][f]);
-					}
-					_input.singleFrameControllerFlagsRemapped |= (k.internalEvent & ~0x70);
-					_lastKeys |= k.internalEvent;
-					if (_keyRepeat || k.releaseType == Common::EVENT_INVALID)
-						_releaseKeys |= k.internalEvent;
-					if (k.updateCoords) {
-						_realLightGunPos = evt.mouse;
-						// Revert aspect ratio correction, if necessary.
-						_realLightGunPos.x = (_realLightGunPos.x * _gfx->screenWidth()) / _gfx->realScreenWidth();
-						_realLightGunPos.y = (_realLightGunPos.y * _gfx->screenHeight()) / _gfx->realScreenHeight();
-						// The lightgun coordinates are supposed to be based on a 256 x 256 system, with 128 being
-						// the screen center. I solve this by always adding the diff to the y-bias.
-						_input.lightGunPos.x = CLIP<int>(_realLightGunPos.x - state.conf.lightGunBias.x, 0, 255);
-						_input.lightGunPos.y = CLIP<int>(_realLightGunPos.y - state.conf.lightGunBias.y, 0, 255);
-					}
-				}
-
-			} else if ((evt.type == k.releaseType) && (k.kc == Common::KEYCODE_INVALID || evt.kbd.keycode == k.kc) && (k.kFlag == 0 || (evt.kbd.flags & k.kFlag))) {
-				_lastKeys &= ~k.internalEvent;
-				if (k.kc != Common::KEYCODE_INVALID && k.releaseType != Common::EVENT_INVALID) {
-					_input.sustainedControllerFlags &= ~k.internalEvent;
-					for (int f = 0; f < 3; ++f) {
-						if (k.internalEvent & ((1 << f) << 4))
-							_input.sustainedControllerFlagsRemapped &= ~(1 << _scdKeyConfigs[state.conf.controllerSetup][f]);
-					}
-					_input.sustainedControllerFlagsRemapped &= ~(k.internalEvent & ~0x70);
-				}
-			}
-		}
-	}
-
-	if (_enableLightGun && _input.singleFrameControllerFlags & 0x100)
-		_gfx->setVar(7, _gfx->getVar(7) | 4);
-}
-
 void SnatcherEngine::updateMainState(GameState &state) {
 	// The updateFlags variable is an invention to emulate the interaction between the main thread and the
 	// vertical interrupt handlers in the original code. It may complicate things a bit (e. g. I have to
@@ -529,7 +428,7 @@ void SnatcherEngine::updateMainState(GameState &state) {
 			state.updateFlags &= ~0x40;
 		} else if (state.updateFlags & 0x20) {
 			_gfx->setVar(11, 0xFF);
-			if (!_ui->drawVerbs() || !_ui->verbsTabInputPrompt(_input)) {
+			if (!_ui->drawVerbs() || !_ui->verbsTabInputPrompt(state.input)) {
 				state.updateFlags |= 0x80;
 			} else {
 				_scriptEngine->processInput();
@@ -825,17 +724,16 @@ Common::Error SnatcherEngine::saveGameState(int slot, const Common::String &desc
 }
 
 void SnatcherEngine::calibrateLightGun(GameState &state) {
-	state.conf.lightGunBias.x = _realLightGunPos.x - (_gfx->screenWidth() / 2);
-	state.conf.lightGunBias.y = _realLightGunPos.y - (_gfx->screenHeight() / 2);
+	state.conf.lightGunBias.x = _input->getLightGunLastRealPos().x - (_gfx->screenWidth() / 2);
+	state.conf.lightGunBias.y = _input->getLightGunLastRealPos().y - (_gfx->screenHeight() / 2);
 	// The lightgun coordinates are supposed to be based on a 256 x 256 system, with 128 being
 	// the screen center. I just add the diff to the y-bias...
 	state.conf.lightGunBias.y -= ((256 - _gfx->screenHeight()) / 2);
 }
 
-void SnatcherEngine::allowLightGunInput(bool enable) {
-	_enableLightGun = enable;
-	_gfx->createMouseCursor();
-	CursorMan.showMouse(enable);
+void SnatcherEngine::enableLightGun(bool enable) {
+	_input->enableLightGun(enable);
+	_lightGunEnabled = enable;
 }
 
 } // End of namespace Snatcher
diff --git a/engines/snatcher/snatcher.h b/engines/snatcher/snatcher.h
index ac81e6a24a3..1260c8d4696 100644
--- a/engines/snatcher/snatcher.h
+++ b/engines/snatcher/snatcher.h
@@ -36,6 +36,7 @@ class CmdQueue;
 class FanTranslationHandler;
 class FIO;
 class GraphicsEngine;
+class InputHandler;
 class MemAccessHandler;
 class ResourcePointer;
 class SaveLoadManager;
@@ -64,25 +65,25 @@ private:
 	bool initGfx(Common::Platform platform, bool use8BitColorMode);
 	bool initSaveLoad();
 	bool initSound(Audio::Mixer *mixer, Common::Platform platform, int soundOptions);
+	bool initUserInterface();
 	bool initScriptEngine();
 	void reset();
-	void playBootLogoAnimation(const GameState &state);
+	void playBootLogoAnimation(GameState &state);
 
 	// Main loop
 	bool start();
 	void delayUntil(uint32 end);
-	void checkEvents(const GameState &state);
-
 	void updateMainState(GameState &state);
 	void updateModuleState(GameState &state);
 
-	const uint32 _frameLen;
-	uint16 _reset;
+	const uint32 _frameLen = (100000 << 14) / (6000000 / 1001);
+	uint16 _reset = 0;
 
 	// ConfigManager sync
 	void syncSoundSettings() override;
 	void applyGameSettings() override;
-	bool _updateGameSettings;
+
+	bool _updateGameSettings = false;
 
 	// GMM, Save, Load
 	void pauseEngineIntern(bool pause) override;
@@ -91,60 +92,45 @@ private:
 	Common::Error loadGameState(int slot) override;
 	Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
 
-	SaveLoadManager *_saveMan;
+	SaveLoadManager *_saveMan = nullptr;
 
 	// MetaEngine
 	bool hasFeature(EngineFeature f) const override;
 	GameDescription _game;
 
 	// Resource
-	FIO *_fio;
-	SceneModule *_module;
-	ResourcePointer *_scd;
+	FIO *_fio = nullptr;
+	SceneModule *_module = nullptr;
+	ResourcePointer *_scd = nullptr;
 
 	// Graphics
-	GraphicsEngine *_gfx;
+	GraphicsEngine *_gfx = nullptr;
 	VMInfo _gfxInfo;
 
 	// Interface
-	ActionSequenceHandler *_aseq;
-	UI *_ui;
+	ActionSequenceHandler *_aseq = nullptr;
+	UI *_ui = nullptr;
 
 	// Sound
-	SoundEngine *_snd;
+	SoundEngine *_snd = nullptr;
 
 	// Script
-	CmdQueue *_cmdQueue;
-	MemAccessHandler *_memHandler;
-	ScriptEngine *_scriptEngine;
+	CmdQueue *_cmdQueue = nullptr;
+	MemAccessHandler *_memHandler = nullptr;
+	ScriptEngine *_scriptEngine = nullptr;
 
 	// Fan Translations
-	FanTranslationHandler *_translator;
+	FanTranslationHandler *_translator = nullptr;
 
 public:
 	// Input
-	struct Input {
-		Input() : singleFrameControllerFlags(0), sustainedControllerFlags(0), singleFrameControllerFlagsRemapped(0), sustainedControllerFlagsRemapped(0), lightGunPos() {}
-		uint16 singleFrameControllerFlags;
-		uint16 sustainedControllerFlags;
-		uint16 singleFrameControllerFlagsRemapped;
-		uint16 sustainedControllerFlagsRemapped;
-		Common::Point lightGunPos;
-	};
-
-	const Input &input() const { return _input; }
 	void calibrateLightGun(GameState &state);
-	void toggleKeyRepeat(bool enableRepeat) { _keyRepeat = enableRepeat; }
-	void allowLightGunInput(bool enable);
+	void enableLightGun(bool enable);
 
 private:
-	uint16 _lastKeys;
-	uint16 _releaseKeys;
-	Common::Point _realLightGunPos;
-	bool _keyRepeat;
-	bool _enableLightGun;
-
-	Input _input;
+	InputHandler *_input = nullptr;
+	bool _lightGunEnabled = false;
+	bool _keyRepeat = false;
 };
 
 } // End of namespace Snatcher
diff --git a/engines/snatcher/state.h b/engines/snatcher/state.h
index 5def1adc240..cc610aeaf2c 100644
--- a/engines/snatcher/state.h
+++ b/engines/snatcher/state.h
@@ -35,81 +35,86 @@ class SceneModule;
 class FIO;
 
 struct Config {
-	Config() : volumeMusic(0), volumeSFX(0), volumeSpeech(0), lightGunAvailable(1), useLightGun(0), controllerSetup(0), disableStereo(0), hasRAMCart(1), hasFreeBuram(1), lightGunBias(0, -16) {}
-	int16 volumeMusic;
-	int16 volumeSFX;
-	int16 volumeSpeech;
-	int16 lightGunAvailable;
-	int16 useLightGun;
-	int16 controllerSetup;
-	int16 disableStereo;
-	int16 hasRAMCart;
-	int16 hasFreeBuram;
-	Common::Point lightGunBias;
+	Config() {}
+	int16 volumeMusic = 0;
+	int16 volumeSFX = 0;
+	int16 volumeSpeech = 0;
+	int16 lightGunAvailable = 1;
+	int16 useLightGun = 0;
+	int16 controllerSetup = 0;
+	int16 disableStereo = 0;
+	int16 hasRAMCart = 1;
+	int16 hasFreeBuram = 1;
+	Common::Point lightGunBias = Common::Point(0, -16);
 };
 
 struct SaveInfo {
-	SaveInfo() : slotUsage(0), saveCount(0), act(0) {}
+	SaveInfo() {} 
 	struct Slot {
-		Slot() : playTime(0), numSaves(0), act(0), desc() {}
+		Slot() {}
 		Common::String desc;
-		uint16 numSaves;
-		uint16 playTime;
-		uint8 act;
+		uint16 numSaves = 0;
+		uint16 playTime = 0;
+		uint8 act = 0;
 	} slots[4];
-	int16 slotUsage;
-	int16 saveCount;
-	uint8 act;
+	int16 slotUsage = 0;
+	int16 saveCount = 0;
+	uint8 act = 0;
 };
 
 struct Script {
-	Script(uint32 textResourceOffset, int16 &chaptr) : sentenceDone(0), sentencePos(0), data(nullptr), dataSize(0), curPos(0), newPos(0xFFFF), curFileNo(0), curGfxScript(-1), phase(chaptr), textResOffset(textResourceOffset) {}
+	Script(uint32 textResourceOffset, int16 &chaptr) : textResOffset(textResourceOffset), phase(chaptr) {}
 	~Script() {
 		delete[] data;
 	}
 	const uint8 *getTextResource() const {
 		return data + textResOffset;
 	}
-	uint8 sentenceDone;
-	uint8 sentencePos;
-	uint8 curFileNo;
-	int16 curGfxScript;
-	const uint8 *data;
-	uint32 dataSize;
-	uint16 curPos;
-	uint16 newPos;
+	uint8 sentenceDone = 0;
+	uint8 sentencePos = 0;
+	uint8 curFileNo = 0;
+	int16 curGfxScript = -1;
+	const uint8 *data = nullptr;
+	uint32 dataSize = 0;
+	uint16 curPos = 0;
+	uint16 newPos = 0xFFFF;
 	int16 &phase;
-	const uint32 textResOffset;
+	const uint32 textResOffset = 0;
 
 	struct Temp {
-		Temp() : curFileNo(0), curPos(0) {
-			memset(arr4, 0, sizeof(arr4));
-		}
-		uint8 curFileNo;
-		uint16 curPos;
-		uint16 arr4[4];
+		uint8 curFileNo = 0;
+		uint16 curPos = 0;
+		uint16 arr4[4] = {0};
 	} temp;
 };
 
+struct InputState {
+	uint16 singleFrameControllerFlags = 0;
+	uint16 sustainedControllerFlags = 0;
+	uint16 singleFrameControllerFlagsRemapped = 0;
+	uint16 sustainedControllerFlagsRemapped = 0;
+	Common::Point lightGunPos = Common::Point(0, 0);
+};
+
 struct GameState {
-	GameState() : frameNo(0), frameState(0), modFinish(0), modPhaseTop(0), modPhaseSub(0), counter(0), modIndex(0), menuSelect(0), prologue(0),
-		pendingSaveLoad(0), phase(0), updateFlags(0), saveInfo(), conf(), script(MemMapping::MEM_SCRIPT_TEXT_LOCATION - MemMapping::MEM_SCRIPT_LOCATION, phase), totalPlayTime(0) {}
-	int16 frameNo;
-	int16 frameState;
-	int16 modFinish;
-	int16 modPhaseTop;
-	int16 modPhaseSub;
-	int16 counter;
-	int16 modIndex;
-	int16 menuSelect;
-	int16 pendingSaveLoad;
-	int16 prologue;
-	int16 phase;
-	int16 updateFlags;
+	GameState() : saveInfo(), conf(), script(MemMapping::MEM_SCRIPT_TEXT_LOCATION - MemMapping::MEM_SCRIPT_LOCATION, phase) {}
+	int16 frameNo = 0;
+	int16 frameState = 0;
+	int16 modFinish = 0;
+	int16 modPhaseTop = 0;
+	int16 modPhaseSub = 0;
+	int16 counter = 0;
+	int16 modIndex = 0;
+	int16 menuSelect = 0;
+	int16 pendingSaveLoad = 0;
+	int16 prologue = 0;
+	int16 phase = 0;
+	int16 updateFlags = 0;
+	uint32 totalPlayTime = 0;
 	SaveInfo saveInfo;
 	Config conf;
 	Script script;
-	uint32 totalPlayTime;
+	InputState input;
 };
 
 } // End of namespace Snatcher
diff --git a/engines/snatcher/text.h b/engines/snatcher/text.h
index 8230b5a2779..a95601338aa 100644
--- a/engines/snatcher/text.h
+++ b/engines/snatcher/text.h
@@ -40,15 +40,11 @@ public:
 
 	virtual void enqueuePrintJob(const uint8 *text) = 0;
 	virtual void setPrintDelay(int delay) = 0;
-	//virtual void setColor(uint8 color) = 0;
 
 	virtual void draw() = 0;
 	virtual void reset() = 0;
-	//virtual void requestRefresh(bool req) = 0;
 	virtual bool needsPrint() const = 0;
 
-protected:
-
 private:
 	static TextRenderer *createSegaTextRenderer(Animator *animator);
 
diff --git a/engines/snatcher/ui.cpp b/engines/snatcher/ui.cpp
index c6b6e5ee509..c278816bcc0 100644
--- a/engines/snatcher/ui.cpp
+++ b/engines/snatcher/ui.cpp
@@ -33,14 +33,7 @@
 
 namespace Snatcher {
 
-UI::UI(GraphicsEngine *gfx, CmdQueue *que, ResourcePointer *scd, FanTranslationHandler *translator) : _gfx(gfx), _que(que), _scd(scd), _translator(translator), _sceneId(0), _textLineBreak(0),
-	_dialogTextBuffer(nullptr), _textColor(0), _scriptTextResource(nullptr), _scriptCurText(nullptr), _textY(0), _headLineYOffset(0), _sceneTextOffsCur(0), _textLineEnd(0), _sceneInfo(0),
-		_flashLight(), _sceneTextOffsStart(0), _waitCursorFrame(0), _waitCursorAnimDelay(0), _progress(-1), _progress2(-1), _controllerCfg(0), _verbInterfaceMode(0), _verbsInterpreterMode(0),
-			_lastVerbFirstPage(0), _numVerbsFirstPage(0), _numVerbsLastPage(0), _lastVerbLastPage(0), _numVerbsMax(0), _verbsTabCurPage(0), _lastVerbDrawn(0), _verbTextBuffer(nullptr), _sceneTextOffset(0),
-				_scriptVerbsArray(nullptr), _scriptSentenceArray(nullptr), _prevSelectedVerb(0), _selectedVerb(0), _lastHiliteVerb(0), _hiliteVerb(0), _savedHiliteVerb(0), _textInputMarginLeft(0),
-					_videoPhoneMode(0), _textInputColumnCur(0), _textInputColumnMax(0), _textInputCursorState(0), _textInputCursorBlinkCnt(0), _underscoreStr(nullptr), _textInputStr(nullptr),
-						_vkeybPosTotal(0), _vkeybColumnWidth(0), _verbsTabLayoutMap(nullptr), _verbsTabOffsX(0), _verbsTabOffsY(0), _hilitePosX(0), _hilitePosY(0), _vkeybVisible(false) {
-
+UI::UI(GraphicsEngine *gfx, CmdQueue *que, ResourcePointer *scd, FanTranslationHandler *translator) : _gfx(gfx), _que(que), _scd(scd), _translator(translator), _flashLight() {
 	_dialogTextBuffer = new uint8[256]();
 	_verbTextBuffer = new uint8[50]();
 	_underscoreStr = new uint8[12]();
@@ -353,7 +346,7 @@ bool UI::drawVerbs() {
 	return true;
 }
 
-bool UI::verbsTabInputPrompt(const SnatcherEngine::Input &input) {
+bool UI::verbsTabInputPrompt(const InputState &input) {
 	assert (_progress2 >= 100);
 	if (_verbsInterpreterMode == 2) {
 		if (_progress2 & 0x80) {
@@ -762,7 +755,7 @@ void UI::verbSelect2setResult() {
 	_selectedVerb = (i == _scriptVerbsArray->size()) ? 1 : i + 1;
 }
 
-void UI::verbsTabHandleInput(const SnatcherEngine::Input &input) {
+void UI::verbsTabHandleInput(const InputState &input) {
 	if (_progress2 & 0x100) {
 		if (_verbInterfaceMode < 2)
 			drawHiliteVerb(1);
diff --git a/engines/snatcher/ui.h b/engines/snatcher/ui.h
index ec35af7c0c0..0fb7818b322 100644
--- a/engines/snatcher/ui.h
+++ b/engines/snatcher/ui.h
@@ -26,6 +26,7 @@
 
 #include "common/scummsys.h"
 #include "snatcher/saveflags.h"
+#include "snatcher/state.h"
 
 namespace Common {
 class SeekableReadStream;
@@ -50,7 +51,7 @@ public:
 	bool displayDialog(int sceneInfo, int sceneTextOffset, uint16 inputFlags);
 
 	bool drawVerbs();
-	bool verbsTabInputPrompt(const SnatcherEngine::Input &input);
+	bool verbsTabInputPrompt(const InputState &input);
 	void moveFlashLight();
 
 	void setScriptVerbsArray(const ScriptArray *verbsArray) { _scriptVerbsArray = verbsArray; }
@@ -61,11 +62,10 @@ public:
 	void resetVerbSelection() { _prevSelectedVerb = 0; }
 
 	struct FlashLightStatus {
-		FlashLightStatus() : inputFlags(0), posData(0), posX(0), posY(0) {}
-		uint16 inputFlags;
-		int32 posX;
-		int32 posY;
-		uint8 posData;
+		uint16 inputFlags = 0;
+		int32 posX = 0;
+		int32 posY = 0;
+		uint8 posData = 0;
 	};
 
 	const FlashLightStatus &getFlashLightStatus() const { return _flashLight; }
@@ -86,24 +86,23 @@ private:
 	bool checkStringPrintProgress();
 	bool waitWithCursorAnim(uint16 inputFlags);
 
-	uint8 _textColor;
-	uint8 _textY;
-	int16 _headLineYOffset;
-	uint8 _sceneId;
-	uint8 _textLineBreak;
-	uint8 _textLineEnd;
-	uint16 _sceneTextOffsCur;
-	uint16 _sceneInfo;
-	uint16 _sceneTextOffset;
-	uint16 _sceneTextOffsStart;
-	uint8 _waitCursorFrame;
-	uint8 _waitCursorAnimDelay;
-	uint8 *_dialogTextBuffer;
-
-	const uint8 *_scriptTextResource;
-	const uint8 *_scriptCurText;
-	uint8 _controllerCfg;
-	int16 _progress;
+	uint8 _textColor = 0;
+	uint8 _textY = 0;
+	int16 _headLineYOffset = 0;
+	uint8 _sceneId = 0;
+	uint8 _textLineBreak = 0;
+	uint8 _textLineEnd = 0;
+	uint16 _sceneTextOffsCur = 0;
+	uint16 _sceneInfo = 0;
+	uint16 _sceneTextOffset = 0;
+	uint16 _sceneTextOffsStart = 0;
+	uint8 _waitCursorFrame = 0;
+	uint8 _waitCursorAnimDelay = 0;
+	uint8 *_dialogTextBuffer = nullptr;
+	const uint8 *_scriptTextResource = nullptr;
+	const uint8 *_scriptCurText = nullptr;
+	uint8 _controllerCfg = 0;
+	int16 _progress = -1;
 
 private:
 	uint8 drawVerb(uint8 id);
@@ -111,7 +110,7 @@ private:
 	bool drawUnderscoreString();
 	void drawUnderscoreCursor();
 	void verbSelect2setResult();
-	void verbsTabHandleInput(const SnatcherEngine::Input &input);
+	void verbsTabHandleInput(const InputState &input);
 	bool verbsTabMoveHilite(int &pos);
 	void adjustHilitePos();
 	void verbTabSwapPage();
@@ -124,49 +123,49 @@ private:
 	uint8 checkFlashLightPos(int16 x, int16 y);
 	void moveFlashLight(int32 offsX, int32 offsY);
 
-	uint16 _verbsInterpreterMode;
-	uint8 _lastVerbFirstPage;
-	uint8 _numVerbsFirstPage;
-	uint8 _numVerbsLastPage;
-	uint8 _lastVerbLastPage;
-	uint8 _prevSelectedVerb;
-	uint8 _numVerbsMax;
-	uint8 _verbsTabCurPage;
-	int16 _videoPhoneMode;
-	uint8 _textInputMarginLeft;
-	int16 _textInputColumnCur;
-	int16 _textInputColumnMax;
-	uint8 _textInputCursorState;
-	uint8 _textInputCursorBlinkCnt;
-	uint8 _selectedVerb;
-	uint8 _vkeybPosTotal;
-	uint8 _vkeybColumnWidth;
-	uint8 _verbsTabOffsX;
-	uint8 _verbsTabOffsY;
-
-	int8 _lastHiliteVerb;
-	int8 _savedHiliteVerb;
-	int8 _hiliteVerb;
-	uint8 _lastVerbDrawn;
-	uint8 *_verbTextBuffer;
-	uint8 *_underscoreStr;
-	uint8 *_textInputStr;
-	const uint8 *_verbsTabLayoutMap;
-	uint16 _verbInterfaceMode;
-	int16 _hilitePosX;
-	int16 _hilitePosY;
-	bool _vkeybVisible;
-	const ScriptArray *_scriptVerbsArray;
-	const ScriptArray *_scriptSentenceArray;
-	int16 _progress2;
+	uint16 _verbsInterpreterMode = 0;
+	uint8 _lastVerbFirstPage = 0;
+	uint8 _numVerbsFirstPage = 0;
+	uint8 _numVerbsLastPage = 0;
+	uint8 _lastVerbLastPage = 0;
+	uint8 _prevSelectedVerb = 0;
+	uint8 _numVerbsMax = 0;
+	uint8 _verbsTabCurPage = 0;
+	int16 _videoPhoneMode = 0;
+	uint8 _textInputMarginLeft = 0;
+	int16 _textInputColumnCur = 0;
+	int16 _textInputColumnMax = 0;
+	uint8 _textInputCursorState = 0;
+	uint8 _textInputCursorBlinkCnt = 0;
+	uint8 _selectedVerb = 0;
+	uint8 _vkeybPosTotal = 0;
+	uint8 _vkeybColumnWidth = 0;
+	uint8 _verbsTabOffsX = 0;
+	uint8 _verbsTabOffsY = 0;
+
+	int8 _lastHiliteVerb = 0;
+	int8 _savedHiliteVerb = 0;
+	int8 _hiliteVerb = 0;
+	uint8 _lastVerbDrawn = 0;
+	uint8 *_verbTextBuffer = nullptr;
+	uint8 *_underscoreStr = nullptr;
+	uint8 *_textInputStr = nullptr;
+	const uint8 *_verbsTabLayoutMap = nullptr;
+	uint16 _verbInterfaceMode = 0;
+	int16 _hilitePosX = 0;
+	int16 _hilitePosY = 0;
+	bool _vkeybVisible = false;
+	const ScriptArray *_scriptVerbsArray = nullptr;
+	const ScriptArray *_scriptSentenceArray = nullptr;
+	int16 _progress2 = -1;
 
 	FlashLightStatus _flashLight;
 
 private:
-	GraphicsEngine *_gfx;
-	CmdQueue *_que;
-	ResourcePointer *_scd;
-	FanTranslationHandler *_translator;
+	GraphicsEngine *_gfx = nullptr;
+	CmdQueue *_que = nullptr;
+	ResourcePointer *_scd = nullptr;
+	FanTranslationHandler *_translator = nullptr;
 };
 
 } // End of namespace Snatcher


Commit: d768c33172b2016fd3142396b0f20ff76b1ca5f2
    https://github.com/scummvm/scummvm/commit/d768c33172b2016fd3142396b0f20ff76b1ca5f2
Author: athrxx (athrxx at scummvm.org)
Date: 2026-12-05T17:36:46+01:00

Commit Message:
SNATCHER: add optional mouse control mode

Still a bit experimental. I have tried to keep this out of
the engine/ui code as much as possible, since that is
modelled after the original interpreter and I want to
keep that clean. So this is like a layer on top which
just injects the necessary internal events.
The advantage of my approach is that it should be
pretty easy to use it with other versions of the game
(unfortunately, there is not one version that actually has
native mouse control, not even the desktop computer
versions).
The disadvantage is that it is kind of overengineered
and the control could have a slightly indirect feel to
it (since that is what actually happens; however, I am
quite positively surprised how well it works).

Changed paths:
  A engines/snatcher/input_scd.cpp
    engines/snatcher/action.h
    engines/snatcher/animator.h
    engines/snatcher/animator_scd.cpp
    engines/snatcher/graphics.cpp
    engines/snatcher/graphics.h
    engines/snatcher/input.cpp
    engines/snatcher/input.h
    engines/snatcher/metaengine.cpp
    engines/snatcher/module.mk
    engines/snatcher/saveflags.h
    engines/snatcher/saveload.cpp
    engines/snatcher/script.cpp
    engines/snatcher/snatcher.cpp
    engines/snatcher/snatcher.h
    engines/snatcher/state.h
    engines/snatcher/ui.cpp
    engines/snatcher/ui.h


diff --git a/engines/snatcher/action.h b/engines/snatcher/action.h
index bc73b7782fc..1c6402c6926 100644
--- a/engines/snatcher/action.h
+++ b/engines/snatcher/action.h
@@ -69,11 +69,6 @@ private:
 	void enemyAttack();
 	void checkFinished();
 
-	//_stage(0), _counter1(0), _counter2(0), _progressMSB(0), _progressLSB(0),
-	//	_weaponState(0), _enemySpeed(0), _active(false), _handleShotPhase(0), _updateEnemiesPhase(0), _enemyAttackStatus(0), _targetField(0), _hscrollB(0), _vscrollB(0), _useLightGun(false),
-	//	_enemyAppearanceCount(0), _civilianAppearanceCount(0), _abortFight(0), _nextEnemyAppearanceTimer(0), _enemyAttackTimer(0), _shoot_78EE(0), _activeEnemies(0)
-
-
 	uint16 _stage = 0;
 	int16 _progressMSB = 0;
 	int16 _progressLSB = 0;
diff --git a/engines/snatcher/animator.h b/engines/snatcher/animator.h
index f17f4c7284a..424a6bef964 100644
--- a/engines/snatcher/animator.h
+++ b/engines/snatcher/animator.h
@@ -63,11 +63,6 @@ public:
 	virtual uint16 realScreenWidth() const = 0;
 	virtual uint16 realScreenHeight() const = 0;
 
-	// The original game does not have mouse control on any platform. But
-	// the Sega CD version supports a lightgun. So we do have some fundamentals
-	// on which we can set this this up...
-	virtual void createMouseCursor() = 0;
-
 	// This is special code from the CD-ROM boot sectors that does not
 	// share anything with the rest of the game. So it makes sense to
 	// keep it separate.
diff --git a/engines/snatcher/animator_scd.cpp b/engines/snatcher/animator_scd.cpp
index c2e0337e6aa..43077712a2f 100644
--- a/engines/snatcher/animator_scd.cpp
+++ b/engines/snatcher/animator_scd.cpp
@@ -31,7 +31,6 @@
 #include "common/system.h"
 #include "common/debug.h"
 #include "common/endian.h"
-#include "graphics/cursorman.h"
 #include "graphics/pixelformat.h"
 #include "graphics/segagfx.h"
 
@@ -135,8 +134,6 @@ public:
 	uint16 realScreenWidth() const override { return _realScreenWidth; }
 	uint16 realScreenHeight() const override { return _realScreenHeight; }
 
-	void createMouseCursor() override;
-
 	void hINTCallback(Graphics::SegaRenderer *sr) override;
 
 private:
@@ -1579,30 +1576,6 @@ void Animator_SCD::anim_setGroupParameter(AnimObject &a, int para, int16 val, bo
 	}
 }
 
-void Animator_SCD::createMouseCursor() {
-	static const uint8 mouseCursorData[] = {
-		0x02, 0xd9, 0x98, 0x00, 0x00, 0x00, 0x93, 0x03, 0x06, 0x00, 0xff, 0x0a, 0x0e, 0xc7, 0x18, 0x1b, 0x1d, 0x36, 0x04,
-		0x4f, 0xff, 0xff, 0xff, 0x12, 0x53, 0x01, 0x16, 0xff, 0x00, 0x6c, 0x0f, 0x1d, 0x03, 0x2f, 0x02, 0x87, 0x0c, 0x3a,
-		0x04, 0x9b, 0x04, 0xa2, 0x09, 0xa9, 0xff, 0x0d, 0xb5, 0x08, 0xc5, 0x17, 0x1b, 0x0f, 0xea, 0x06, 0xfc, 0x2f, 0x05,
-		0x25, 0x17, 0x11, 0x3f, 0xff, 0x0b, 0x98, 0x0e, 0x64, 0x22, 0x03, 0x04, 0xd6, 0x21, 0x0f, 0x26, 0x17, 0x22, 0x19,
-		0x11, 0x90, 0xff, 0x1c, 0x51, 0x1d, 0xbd, 0x17, 0xd8, 0x3d, 0x29, 0x49, 0x0a, 0x30, 0x60, 0x0e, 0xe9, 0x23, 0xe2,
-		0xff, 0x35, 0xb0, 0x02, 0xfc, 0x34, 0xe6, 0x5a, 0x1c, 0x33, 0x9e, 0x38, 0xb9, 0x34, 0xd4, 0x1f
-	};
-
-	static const uint8 palData[] = { 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF };
-
-	uint16 len = READ_BE_UINT16(mouseCursorData);
-	uint8 *tmp = new uint8[len];
-	assert(tmp);
-	if (len != Util::decodeSCDData(mouseCursorData + 2, tmp))
-		error("%s(): Decode size mismatch", __FUNCTION__);
-
-	CursorMan.replaceCursorPalette(palData, 254, 2);
-	CursorMan.replaceCursor(tmp, 27, 27, 13, 13, 0);
-
-	delete[] tmp;
-}
-
 // Boot logo sequence code. This has nothing to do with the engine graphics code, so I put it at the end, to keep the ugly mess out of sight...
 int Animator_SCD::drawBootLogoFrame(uint8 *screen, int frameNo)  {
 	uint16 *tmp = reinterpret_cast<uint16*>(_tempBuffer);
diff --git a/engines/snatcher/graphics.cpp b/engines/snatcher/graphics.cpp
index b8c5f794bb7..1cbb9ef9af5 100644
--- a/engines/snatcher/graphics.cpp
+++ b/engines/snatcher/graphics.cpp
@@ -26,17 +26,17 @@
 #include "snatcher/resource.h"
 #include "snatcher/text.h"
 #include "snatcher/transition.h"
+#include "snatcher/util.h"
 #include "common/endian.h"
 #include "common/ptr.h"
 #include "common/stream.h"
 #include "common/system.h"
+#include "graphics/cursorman.h"
 #include "graphics/pixelformat.h"
 
 namespace Snatcher {
 
-GraphicsEngine::GraphicsEngine(const Graphics::PixelFormat *pxf, OSystem *system, Common::Platform platform, const VMInfo &vmstate, SoundEngine *snd, bool enableAspectRatioCorrection) :
-	_system(system), _state(vmstate), _animator(nullptr), _text(nullptr), _dataMode(0), _screen(nullptr), _bpp(pxf ? pxf->bytesPerPixel : 1), _verbAreaType(0), _animSaveLoadData(nullptr),
-		_animSaveLoadDataExt(), _trsNeedsUpdate(false) {
+GraphicsEngine::GraphicsEngine(const Graphics::PixelFormat *pxf, OSystem *system, Common::Platform platform, const VMInfo &vmstate, SoundEngine *snd, bool enableAspectRatioCorrection) : _system(system), _state(vmstate), _bpp(pxf ? pxf->bytesPerPixel : 1) {
 	assert(system);
 	_palette = Palette::create(pxf, _system->getPaletteManager(), platform, _state);
 	assert(_palette);
@@ -48,6 +48,7 @@ GraphicsEngine::GraphicsEngine(const Graphics::PixelFormat *pxf, OSystem *system
 	assert(_screen);
 	_animSaveLoadData = new uint8[64]();
 	assert(_animSaveLoadData);
+	createMouseCursors(platform == Common::kPlatformSegaCD);
 }
 
 GraphicsEngine::~GraphicsEngine() {
@@ -57,6 +58,8 @@ GraphicsEngine::~GraphicsEngine() {
 	delete[] _screen;
 	delete _text;
 	delete[] _animSaveLoadData;
+	for (uint i = 0; i < ARRAYSIZE(_mouseCursors); ++i)
+		delete[] _mouseCursors[i].data;
 }
 
 void GraphicsEngine::runScript(ResourcePointer res, int func) {
@@ -183,6 +186,7 @@ void GraphicsEngine::nextFrame() {
 	_palette->processEventQueue();
 	_animator->updateScreen(_screen);
 	_palette->update();
+	updateMouseCursorPalette();
 
 	_system->copyRectToScreen(_screen, _animator->realScreenWidth() * _bpp, 0, 0, _animator->realScreenWidth(), _animator->realScreenHeight());
 	_system->updateScreen();
@@ -500,8 +504,36 @@ void GraphicsEngine::postLoadProcess() {
 	_palette->unblock();
 }
 
-void GraphicsEngine::createMouseCursor() {
-	_animator->createMouseCursor();
+void GraphicsEngine::toggleMouseCursor(MouseCursorType type) {
+	if (_mouseCurType == type)
+		return;
+
+	if (type >= 0 && type < ARRAYSIZE(_mouseCursors)) {
+		const MouseCursor &cursor = _mouseCursors[static_cast<int8>(type)];
+		CursorMan.replaceCursor(cursor.data, cursor.width, cursor.height, cursor.hotX, cursor.hotY, 0);
+
+		if (_mouseCurType == kMouseCursorNone)
+			CursorMan.showMouse(true);
+
+		if (type == kMouseCursorDefault) {
+			_mouseRGBCur = _mouseLoRGB = _mouseMinRGB;
+			_mouseRGBIncr = 3;
+		} else {
+			// The mouse cursor color fading is supposed to improve visibility. But in lightgun mode, with
+			// fast mouse movements, it achieves the opposite effect, so we just keep the color at white.
+			_mouseRGBCur = _mouseMaxRGB;
+			updateMouseCursorPalette(true);
+			_mouseRGBIncr = 0;
+		}
+
+	} else {
+		if (_mouseCurType == kMouseCursorDefault)
+			_mouseLoRGB = 0;
+		else
+			CursorMan.showMouse(false);
+	}
+
+	_mouseCurType = type;
 }
 
 int GraphicsEngine::displayBootLogoFrame(int frameNo) {
@@ -511,6 +543,65 @@ int GraphicsEngine::displayBootLogoFrame(int frameNo) {
 	return res;
 }
 
+void GraphicsEngine::createMouseCursors(bool includeCrosshair) {
+	static const uint8 mouseCursorData0[] = {
+		0x13, 0x13, 0x09, 0x09, 0x01, 0x69, 0xd8, 0x00, 0x00, 0x00, 0x93, 0x96, 0xff, 0x06, 0x0a, 0x10, 0x13, 0x7f,	0x1d,
+		0x26, 0x0c, 0x3c, 0x1d, 0x4c, 0x03, 0x75, 0x10, 0x72, 0x0f, 0x84, 0x08, 0x96, 0xff, 0xfc, 0xff, 0xff, 0x93, 0x03,
+		0xa8, 0x09, 0x0c, 0x1d, 0x47, 0x07, 0xd9, 0x1d, 0xe4, 0x7f, 0x23, 0x0d, 0x3d, 0x0a, 0x23, 0x33, 0x3d, 0x30, 0x23,
+		0x59, 0x27, 0x56, 0x1f
+	};
+
+	static const uint8 mouseCursorData1[] = {
+		0x1B, 0x1B, 0x0D, 0x0D, 0x02, 0xd9, 0x98, 0x00, 0x00, 0x00, 0x93, 0x03, 0x06, 0x00, 0xff, 0x0a, 0x0e, 0xc7, 0x18,
+		0x1b, 0x1d, 0x36, 0x04, 0x4f, 0xff, 0xff, 0xff, 0x12, 0x53, 0x01, 0x16, 0xff, 0x00, 0x6c, 0x0f, 0x1d, 0x03, 0x2f,
+		0x02, 0x87, 0x0c, 0x3a, 0x04, 0x9b, 0x04, 0xa2, 0x09, 0xa9, 0xff, 0x0d, 0xb5, 0x08, 0xc5, 0x17, 0x1b, 0x0f, 0xea,
+		0x06, 0xfc, 0x2f, 0x05, 0x25, 0x17, 0x11, 0x3f, 0xff, 0x0b, 0x98, 0x0e, 0x64, 0x22, 0x03, 0x04, 0xd6, 0x21, 0x0f,
+		0x26, 0x17, 0x22, 0x19, 0x11, 0x90, 0xff, 0x1c, 0x51, 0x1d, 0xbd, 0x17, 0xd8, 0x3d, 0x29, 0x49, 0x0a, 0x30, 0x60,
+		0x0e, 0xe9, 0x23, 0xe2, 0xff, 0x35, 0xb0, 0x02, 0xfc, 0x34, 0xe6, 0x5a, 0x1c, 0x33, 0x9e, 0x38, 0xb9, 0x34, 0xd4,
+		0x1f
+	};
+
+	const uint8 *mouseCursorData[] = { mouseCursorData0, mouseCursorData1 };
+
+	int num = includeCrosshair ? ARRAYSIZE(mouseCursorData) : ARRAYSIZE(mouseCursorData) - 1;
+	for (int i = 0; i < num; ++i) {
+		delete[] _mouseCursors[i].data;
+		_mouseCursors[i].data = nullptr;
+
+		const uint8 *s = mouseCursorData[i];
+		_mouseCursors[i].width = *s++;
+		_mouseCursors[i].height = *s++;
+		_mouseCursors[i].hotX = *s++;
+		_mouseCursors[i].hotY = *s++;
+
+		uint16 len = READ_BE_UINT16(s);
+		uint8 *dest = new uint8[len]();
+		assert(dest);
+		if (len != Util::decodeSCDData(s + 2, dest))
+			error("%s(): Decode size mismatch", __FUNCTION__);
+		_mouseCursors[i].data = dest;
+	}
+}
+
+void GraphicsEngine::updateMouseCursorPalette(bool force) {
+	if (_mouseRGBIncr == 0 && !force)
+		return;
+
+	if (_mouseRGBCur == 0) {
+		CursorMan.showMouse(false);
+		_mouseRGBIncr = 0;
+		return;
+	}
+
+	const uint8 palData[] = { 0, 0, 0, _mouseRGBCur, _mouseRGBCur, _mouseRGBCur };
+	CursorMan.replaceCursorPalette(palData, 254, 2);
+
+	_mouseRGBCur += _mouseRGBIncr;
+
+	if (_mouseRGBCur == _mouseMaxRGB || _mouseRGBCur == _mouseLoRGB)
+		_mouseRGBIncr = -_mouseRGBIncr;
+}
+
 void GraphicsEngine::restoreDefaultsExt() {
 	if (!_state.getVar(4))
 		restoreDefaults();
diff --git a/engines/snatcher/graphics.h b/engines/snatcher/graphics.h
index 2ca7c8977ed..5c34b835de8 100644
--- a/engines/snatcher/graphics.h
+++ b/engines/snatcher/graphics.h
@@ -155,7 +155,15 @@ public:
 	void saveState(Common::SeekableWriteStream *out, SaveFlags flags);
 	void postLoadProcess();
 
-	void createMouseCursor();
+	enum MouseCursorType : int8 {
+		kMouseCursorNone = -1,
+		kMouseCursorDefault = 0,
+		kMouseCursorCrosshair = 1
+	};
+
+	// The original game does not have mouse control on any platform. But the Sega CD version supports a lightgun.
+	// So we use the mouse to emulate the lightgun there. And we also add an optional mouse mode for all platforms.
+	void toggleMouseCursor(MouseCursorType type);
 
 	int displayBootLogoFrame(int frameNo);
 
@@ -218,24 +226,42 @@ public:
 	};
 
 private:
+	void createMouseCursors(bool includeCrossHair);
+	void updateMouseCursorPalette(bool force = false);
 	void restoreDefaultsExt();
 	void restoreDefaults();
 
 	GfxState _state;
 	const uint8 _bpp;
-	uint8 _dataMode;
-	uint8 _verbAreaType;
+	uint8 _dataMode = 0;
+	uint8 _verbAreaType = 0;
 
-	uint8 *_animSaveLoadData;
+	uint8 *_animSaveLoadData = nullptr;
 	Common::SharedPtr<const uint8> _animSaveLoadDataExt;
-	bool _trsNeedsUpdate;
-
-	uint8 *_screen;
-	Animator *_animator;
-	Palette *_palette;
-	TextRenderer *_text;
-	TransitionManager *_trs;
-	OSystem *_system;
+	bool _trsNeedsUpdate = false;
+
+	uint8 *_screen = nullptr;
+	Animator *_animator = nullptr;
+	Palette *_palette = nullptr;
+	TextRenderer *_text = nullptr;
+	TransitionManager *_trs = nullptr;
+	OSystem *_system = nullptr;
+
+	struct MouseCursor {
+		uint8 width = 0;
+		uint8 height = 0;
+		uint8 hotX = 0;
+		uint8 hotY = 0;
+		const uint8 *data = nullptr;
+	};
+
+	MouseCursor _mouseCursors[2];
+	const uint8 _mouseMinRGB = 0xAB;
+	const uint8 _mouseMaxRGB = 0xFF;
+	uint8 _mouseLoRGB = 0;
+	MouseCursorType _mouseCurType = kMouseCursorNone;
+	uint8 _mouseRGBCur = 0;
+	int8 _mouseRGBIncr = 3;
 };
 
 } // End of namespace Snatcher
diff --git a/engines/snatcher/input.cpp b/engines/snatcher/input.cpp
index d223a8f0dce..21608fe9888 100644
--- a/engines/snatcher/input.cpp
+++ b/engines/snatcher/input.cpp
@@ -21,76 +21,447 @@
 
 #include "snatcher/input.h"
 #include "snatcher/graphics.h"
-#include "common/events.h"
-#include "common/stream.h"
-#include "graphics/cursorman.h"
+
 
 namespace Snatcher {
 
-struct InputEvent {
-	Common::EventType pressType;
-	Common::EventType releaseType;
-	Common::KeyCode kc;
-	uint16 kFlag;
-	uint16 internalEvent;
-	bool updateCoords;
-};
-
-static const InputEvent _defaultKeyEvents[] = {
-	// Arrow buttons
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_UP,			0x00, 0x01, false },
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP8,		0x00, 0x01, false },
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_DOWN,		0x00, 0x02, false },
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP2,		0x00, 0x02, false },
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_LEFT,		0x00, 0x04, false },
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP4,		0x00, 0x04, false },
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_RIGHT,		0x00, 0x08, false },
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP6,		0x00, 0x08, false },
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP7,		0x00, 0x05, false },
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP9,		0x00, 0x09, false },
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP3,		0x00, 0x0A, false },
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP1,		0x00, 0x06, false },
-	{ Common::EVENT_WHEELUP,		Common::EVENT_INVALID,		Common::KEYCODE_INVALID,	0x00, 0x01, false },
-	{ Common::EVENT_WHEELDOWN,		Common::EVENT_INVALID,		Common::KEYCODE_INVALID,	0x00, 0x02, false },
-
-	// A, B, C buttons
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_a,			0x00, 0x10, false },
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_b,			0x00, 0x20, false },
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_c,			0x00, 0x40, false },
-
-	{ Common::EVENT_MBUTTONDOWN,	Common::EVENT_MBUTTONUP,	Common::KEYCODE_INVALID,	0x00, 0x20, false },
-
-	// Start button
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_RETURN,		0x00, 0x80, false },
-	{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_SPACE,		0x00, 0x80, false },
-
-	// Lightgun
-	{ Common::EVENT_LBUTTONDOWN,	Common::EVENT_LBUTTONUP,	Common::KEYCODE_INVALID,	0x00, 0x100, true },
-
-	// Lightgun Start button
-	{ Common::EVENT_RBUTTONDOWN,	Common::EVENT_RBUTTONUP,	Common::KEYCODE_INVALID,	0x00, 0x200, false }
-};
-
-static const uint8 _scdKeyConfigs[6][3] = {
-	{ 6, 4, 5 }, { 6, 5, 4 }, { 4, 6, 5 },
-	{ 4, 5, 6 }, { 5, 4, 6 }, { 5, 6, 4 }
-};
-
-void InputHandler::handleEvents(GameState &state) {
+void MouseHandler::addTraceRegion(TraceRegion region) {
+	if (region.numH && region.numV)
+		_traceRegions.push_back(region);
+}
+
+void MouseHandler::clearTraceRegions() {
+	_releaseFlags = _releaseFlagsL = _releaseFlagsR = 0;
+	_traceRegions.clear();
+	_lastActiveRegion = nullptr;
+}
+
+void MouseHandler::parseEvent(const Common::Event &evt) {
+	if (evt.type == Common::EVENT_LBUTTONUP) {
+		if (_buttonFlagsL) {
+			_releaseFlagsL |= _buttonFlagsL;
+			_buttonFlagsL = 0;
+		}
+		_buttonDownL = false;
+	}
+	if (evt.type == Common::EVENT_RBUTTONUP) {
+		if (_buttonFlagsR) {
+			_releaseFlagsR |= _buttonFlagsR;
+			_buttonFlagsR = 0;
+		}
+		_buttonDownR = false;
+	}
+
+	if (evt.type != Common::EVENT_MOUSEMOVE && evt.type != Common::EVENT_LBUTTONDOWN && evt.type != Common::EVENT_RBUTTONDOWN && evt.type != Common::EVENT_WHEELUP && evt.type != Common::EVENT_WHEELDOWN)
+		return;
+
+	Common::Point mousePos(evt.mouse.x * _virtualWidth / _realScreenWidth, evt.mouse.y * _virtualHeight / _realScreenHeight);
+	//debug("MouseHandler::parseEvent(): evt.type=%d, evt.mouse.x=%d, evt.mouse.y=%d", evt.type, mousePos.x, mousePos.y);
+	followMouse(mousePos, evt.type);
+}
+
+void MouseHandler::gotoLastClickPos() {
+	if (_clickedPos.y != -1) {
+		for (const TraceRegion &region : _traceRegions) {
+			if (!region.contains(_clickedPos))
+				continue;
+			followMouse(_clickedPos, Common::EVENT_USER_FIRST_AVAILABLE);
+			_feedTimer = 6; // Take into account the verbs tab's down/up anim time of the (actually only the up movement time, since this is called when the verbs tab is down).
+			break;
+		}
+		_clickedPos.y = -1;
+	}
+}
+
+void MouseHandler::raiseNextEvent(uint16 &singleFrameFlags, uint16 &sustainedFlags) {
+	if (_feedTimer && _feedTimer--)
+		return;
+
+	_feedTimer = _feedDelay;
+
+	if (!_eventChain.empty()) {
+		const ControllerEvent &evt = _eventChain.front();
+
+		if (evt.type & kEventTypeSingleFrame)
+			singleFrameFlags = evt.flags;
+		if (evt.type & kEventTypeSustained)
+			sustainedFlags = evt.flags;
+
+		_eventChain.pop_front();
+	}
+
+	if (_eventChain.empty()) {
+		if (_releaseFlags) {
+			sustainedFlags = (sustainedFlags & ~_releaseFlags) | _buttonFlagsL | _buttonFlagsR;
+			_releaseFlags = 0;
+		}
+		if (_releaseFlagsL) {
+			sustainedFlags &= ~_releaseFlagsL;
+			_releaseFlagsL = 0;
+		}
+		if (_releaseFlagsR) {
+			sustainedFlags &= ~_releaseFlagsR;
+			_releaseFlagsR = 0;
+		}
+	}
+}
+
+bool MouseHandler::isActive() const {
+	return !_traceRegions.empty();
+}
+
+void MouseHandler::followMouse(const Common::Point &newPos, int mouseEventType) {
+	_newActiveRegion = nullptr;
+
+	for (const TraceRegion &region : _traceRegions) {
+		if (!region.contains(newPos)) {
+			if (_eventChain.empty() && region.trackObjectDest.x != -1)
+				region.trackObjectDest = Common::Point(-1, -1);
+			continue;
+		}
+
+		if (region.trackingMode != kNoFollow)
+			_newActiveRegion = ®ion;
+
+		Common::Point vector(0, 0);
+		if (region.tracker != nullptr)
+			(*region.tracker)(vector);
+		Common::Point cpos(vector);
+
+		// Regions that are only clickable and do not track movement get -1 coords.
+		if (region.startPosX != -1 && region.startPosY != -1) {
+			bool hitCell = false;
+			for (int i = 0; i < region.numH; ++i) {
+				for (int j = 0; j < region.numV; ++j) {
+					int16 cellLeft = region.left + i * (region.cellWidth + region.padWidth);
+					int16 cellTop = region.top + j * (region.cellHeight + region.padHeight);
+					int16 cellRight = cellLeft + region.cellWidth - 1;
+					int16 cellBottom = cellTop + region.cellHeight - 1;
+					if (newPos.x >= cellLeft && newPos.x <= cellRight && newPos.y >= cellTop && newPos.y <= cellBottom) {
+						cpos.x = region.startPosX + i;
+						cpos.y = region.startPosY + j;
+						hitCell = true;
+						break;
+					}
+				}
+			}
+			if (!hitCell)
+				continue;
+		}
+
+		if (region.events == nullptr)
+			continue;
+
+		if (((mouseEventType == Common::EVENT_LBUTTONDOWN && (region.trackingMode & kFollowLeftClick)) || (mouseEventType == Common::EVENT_RBUTTONDOWN && (region.trackingMode & kFollowRightClick)) ||
+				(mouseEventType == Common::EVENT_MOUSEMOVE && ((region.trackingMode & kFollowMovement) || (_buttonDownL && (region.trackingMode & kFollowLeftDrag)) || (_buttonDownR && (region.trackingMode & kFollowRightDrag)))) ||
+						mouseEventType == Common::EVENT_USER_FIRST_AVAILABLE) && (cpos != vector && cpos != region.trackObjectDest)
+					/* || (region.trackObjectDest.y != -1 && vector != region.trackObjectDest && _eventChain.empty())*/) {
+
+			int16 diffX = ABS(cpos.x - vector.x);
+			int16 diffY = ABS(cpos.y - vector.y);
+			_eventChain.clear();
+
+			Common::String dbgStr;
+			int timeOut = 80;
+			bool failed = false;
+
+			if (diffX || diffY) {
+				region.trackObjectDest = cpos;
+				Common::Point m(vector);
+
+				int16 ex = cpos.x < vector.x ? region.events->moveLeft.flags : (cpos.x > vector.x ? region.events->moveRight.flags : 0x00);
+				ControllerEventType xt = cpos.x < vector.x ? region.events->moveLeft.type : (cpos.x > vector.x ? region.events->moveRight.type : kEventTypeInvalid);
+				int16 ey = cpos.y < vector.y ? region.events->moveUp.flags : (cpos.y > vector.y ? region.events->moveDown.flags : 0x00);
+				ControllerEventType yt = cpos.y < vector.y ? region.events->moveUp.type : (cpos.y > vector.y ? region.events->moveDown.type : kEventTypeInvalid);
+
+				if (xt & kEventTypeSustained)
+					_releaseFlags |= ex;
+				if (yt & kEventTypeSustained)
+					_releaseFlags |= ey;
+
+				char dbgX = cpos.x < vector.x ? 'L' : 'R';
+				char dbgY = cpos.y < vector.y ? 'U' : 'D';
+				int16 dirX = cpos.x < vector.x ? -1 : 1;
+				int16 dirY = cpos.y < vector.y ? -1 : 1;
+				GetStepProc getStepX = &MouseHandler::getStepDistance<false>;
+				GetStepProc getStepY = &MouseHandler::getStepDistance<true>;
+				int16 c1 = 0;
+				int16 c2 = 0;
+				int16 *mx = &m.x;
+				int16 *my = &m.y;
+
+				bool swp = diffX < diffY;
+
+				if (swp) {
+					SWAP(diffX, diffY);
+					SWAP(ex, ey);
+					SWAP(xt, yt);
+					SWAP(mx, my);
+					SWAP(dirX, dirY);
+					SWAP(getStepX, getStepY);
+					SWAP(dbgX, dbgY);
+				}
+
+				uint32 incr = diffY ? (diffY + 1) * 0x10000 / (diffX + 1) : 0;
+				uint32 cnt = 0;
+
+				ControllerEvent ce;
+
+				while (m != cpos) {
+					int16 stepX = 0;
+					int16 stepY = 0;
+					int16 c3 = 0;
+					ce.flags = 0;
+
+					if (diffX > 0)
+						stepX = (this->*getStepX)(*mx, *my, diffX, diffY, dirX, c1);
+
+					if (diffY == 0 && stepX == 0 && diffX == -c1)
+						c3 = -c1;
+
+					cnt += incr * MAX<int>(1, stepX);
+
+					if (cnt >= 0x10000) {
+						cnt -= 0x10000;
+						if (diffY > 0) {
+							stepY = (this->*getStepY)(*my, *mx + stepX * dirX, diffY, diffX - stepX, dirY, c3);
+							if (stepY == 0)
+								stepY = (this->*getStepY)(*my, *mx, diffY, diffX - stepX, dirY, c3);
+							c2 = c1;
+							if (diffX > 0 && stepY > 0) {
+								int16 stepX2 = (this->*getStepX)(*mx, *my + stepY * dirY, diffX, diffY, dirX, c1);
+								if (stepX2 < stepX) {
+									stepX = stepX2;
+									c2 = c1;
+								}
+							}
+
+							diffY -= stepY;
+							*my += stepY * dirY;
+							c3 -= c2;
+							cnt -= incr * c3;
+						}
+					}
+
+					stepX += c3;
+					diffX -= stepX;
+
+					*mx += stepX * dirX;
+					if (stepX) {
+						ce.flags |= ex;
+						ce.type = ce.type | xt;
+						dbgStr = dbgStr + dbgX + '-';
+						c1 = c2 = 0;
+					}
+
+					if (stepY) {
+						ce.flags |= ey;
+						ce.type = ce.type | yt;
+						dbgStr = dbgStr + dbgY + '-';
+					}
+
+					if (ce.flags)
+						_eventChain.push_back(ce);
+
+					if (diffY < 0 || diffX < 0 || ((diffX == 0 && diffY == 0) && m != cpos) || --timeOut == 0) {
+						failed = true;
+						dbgStr.chop(1);
+						dbgStr += "...ABORT ";
+						break;
+					}
+				}
+
+				if (failed) {
+					dbgStr.chop(1);
+					warning("%s(): Pathfinding from (%d, %d) to (%d, %d)...%s\n  Path='%s'", __FUNCTION__, vector.x, vector.y, cpos.x, cpos.y, /* failed ?*/ "FAILED" /* : "SUCCESS"*/, dbgStr.c_str());
+				}
+			}
+		}
+
+		if (region.events->buttonDownL.type != kEventTypeInvalid && mouseEventType == Common::EVENT_LBUTTONDOWN && !_buttonDownL) {
+			if (region.events->buttonDownL.type & kEventTypeSustained)
+				_buttonFlagsL |= region.events->buttonDownL.flags;
+			_eventChain.push_back(region.events->buttonDownL);
+			_clickedPos = newPos;
+			_buttonDownL = true;
+		}
+		
+		if (region.events->buttonDownR.type != kEventTypeInvalid && mouseEventType == Common::EVENT_RBUTTONDOWN && !_buttonDownR) {
+			if (region.events->buttonDownR.type & kEventTypeSustained)
+				_buttonFlagsR |= region.events->buttonDownR.flags;
+			_eventChain.push_back(region.events->buttonDownR);
+			_clickedPos = newPos;
+			_buttonDownR = true;
+		}
+
+		if (region.events->scrollWheelUp.type != kEventTypeInvalid && mouseEventType == Common::EVENT_WHEELUP)
+			_eventChain.push_back(region.events->scrollWheelUp);
+
+		if (region.events->scrollWheelDown.type != kEventTypeInvalid && mouseEventType == Common::EVENT_WHEELDOWN)
+			_eventChain.push_back(region.events->scrollWheelDown);
+	}
+
+	if (_newActiveRegion != _lastActiveRegion && _lastActiveRegion != nullptr && (_newActiveRegion == nullptr ||
+		(_newActiveRegion->tracker && _lastActiveRegion->tracker && _newActiveRegion->tracker->tid != _lastActiveRegion->tracker->tid))) {
+		if (_lastActiveRegion->events != nullptr) {
+			if (_releaseFlags || _releaseFlagsL || _releaseFlagsR) {
+				_eventChain.clear();
+				_lastActiveRegion->trackObjectDest = Common::Point(-1, -1);
+			}
+		}
+		_clickedPos.y = -1;
+	}
+
+	_lastActiveRegion = _newActiveRegion;
+}
+
+template<bool swp> int16 MouseHandler::getStepDistance(int16 x, int16 y, int16 remX, int16 remY, int16 dir, int16 &correction) const {
+	int16 mxx = swp ? y : x;
+	int16 mxy = swp ? x : y;
+	int16 t1 = 1;
+	const TraceRegion *r1 = nullptr;
+	for (const TraceRegion &r : _traceRegions) {
+		if (r.startPosY == -1)
+			continue;
+		if (mxy >= r.range.top && mxy <= r.range.bottom && mxx >= r.range.left && mxx <= r.range.right) {
+			r1 = &r;
+			t1 = swp ? r.stepV : r.stepH;
+			if ((dir < 0 && (t1 > (swp ? mxy - r.range.top - r.stepV + 1 : mxx - r.range.left - r.stepH + 1))) ||
+				(dir > 0 && (t1 > (swp ? r.range.bottom - mxy - r.stepV + 1 : r.range.right - mxx - r.stepH + 1)))) {
+				t1 = 0;
+				correction = -remX;
+			}
+		}
+	}
+
+	if (r1 == nullptr)
+		return t1;
+
+	assert(r1->tracker);
+
+	int16 t2 = 0;
+	for (const TraceRegion &r : _traceRegions) {
+		if (r.tracker && r.tracker->tid != r1->tracker->tid)
+			t1 = t1;
+
+		if (r.startPosY == -1 || &r == r1 || (r.tracker && r.tracker->tid != r1->tracker->tid))
+			continue;
+
+		int step = swp ? r1->stepV : r1->stepH;
+		int sp1 = swp ? r.startPosY : r.startPosX;
+		int sp1s = swp ? r.startPosX : r.startPosY;
+		int sp2 = swp ? r.startPosY + (r.numV - 1) * r.stepV : r.startPosX + (r.numH - 1) * r.stepH;
+		int sp2s = swp ? r.startPosX + (r.numH - 1) * r.stepH : r.startPosY + (r.numV - 1) * r.stepV;
+
+		if (dir > 0) {
+			int16 spos = swp ? r.range.top : r.range.left;
+			if (spos > x && spos - x <= step && y >= (swp ? r.range.left : r.range.top) && y <= (swp ? r.range.right : r.range.bottom)) {
+				correction = 0;
+				t2 = sp1 - x;
+				if (y < sp1s)
+					correction = y - sp1s;
+				else if (y > sp2s)
+					correction = 1;
+				else if (t2 > remX) {
+					if (remY > 0) {
+						t1 = t2 = 0;
+						correction = -1;
+					} else {
+						t2 = 1;
+						correction = -1;
+					}
+				}
+			}
+		} else {
+			int16 spos = swp ? r.range.bottom : r.range.right;
+			if (spos < x && x - spos <= step && y >= (swp ? r.range.left : r.range.top) && y <= (swp ? r.range.right : r.range.bottom)) {
+				correction = 0;
+				t2 = x - sp2;
+				if (y > sp2s)
+					correction = sp2s - y;
+				else if (y < sp1s)
+					correction = sp1s - y;
+				else if (t2 > remX) {
+					if (remY > 0) {
+						t1 = t2 = 0;
+						correction = -1;
+					} else {
+						t2 = 1;
+						correction = -1;
+					}
+				}
+			}
+		}
+	}
+	return t2 > 0 ? t2 : MIN<int16>(t1, remX);
+}
+
+MouseHandler::TraceRegion::TraceRegion(int16 x, int16 y, uint16 w, uint16 h, uint16 cellW, uint16 cellH, uint16 padW, uint16 padH, MouseTracker *cb, TrackingMode mode, int16 traceStartPosX, int16 traceStartPosY,
+	int16 traceStepH, int16 traceStepV, EventMapping *eventMapping) :
+		left(x), top(y), right(x + w - 1), bottom(y + h - 1), cellWidth(cellW), cellHeight(cellH), padWidth(padW), padHeight(padH), tracker(cb), trackingMode(mode), startPosX(traceStartPosX), startPosY(traceStartPosY),
+			stepH(traceStepH), stepV(traceStepV), events(eventMapping) {
+	numH = (w + padWidth) / (cellWidth + padWidth);
+	numV = (h + padHeight) / (cellHeight + padHeight);
+	range.left = startPosX - ((stepH - 1) / 2);
+	range.right = startPosX + (stepH / 2) + (numH - 1) * stepH;
+	range.top = startPosY - ((stepV - 1) / 2);
+	range.bottom = startPosY + (stepV / 2) + (numV - 1) * stepV;
+	if (cb && traceStartPosX != -1 && traceStartPosY != -1)
+		(*cb)(trackObjectDest);
+}
+
+InputHandler::InputHandler(Common::EventManager *eventManager, GraphicsEngine *gfx) : _evt(eventManager), _gfx(gfx) {
+	static const InputEvent defaultKeyEvents[] = {
+		// Arrow buttons
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_UP,			0x00, 0x01, false },
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP8,		0x00, 0x01, false },
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_DOWN,		0x00, 0x02, false },
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP2,		0x00, 0x02, false },
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_LEFT,		0x00, 0x04, false },
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP4,		0x00, 0x04, false },
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_RIGHT,		0x00, 0x08, false },
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP6,		0x00, 0x08, false },
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP7,		0x00, 0x05, false },
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP9,		0x00, 0x09, false },
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP3,		0x00, 0x0A, false },
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_KP1,		0x00, 0x06, false },
+
+		// Start button
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_RETURN,		0x00, 0x80, false },
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_SPACE,		0x00, 0x80, false }
+	};
+
+	for (const InputEvent &k : defaultKeyEvents)
+		_keyEvents.push_back(k);
+
+	_mouseHandler = new MouseHandler(_gfx->realScreenWidth(), _gfx->realScreenHeight(), _gfx->screenWidth(), _gfx->screenHeight());
+}
+
+InputHandler::~InputHandler() {
+	delete _mouseHandler;
+	_keyEvents.clear();
+}
+
+void InputHandler::update(GameState &state) {
 	Common::Event evt;
 	_lastKeys &= ~_releaseKeys;
 	_releaseKeys = 0;
 	state.input.singleFrameControllerFlags = state.input.singleFrameControllerFlagsRemapped = 0;
 
+	if ((state.conf.mouseControl != 0) != _enableMouse || lightGunModeChanged() || (_mouseHandler->isActive() && !state.aseq) != _mouseHandlerActive)
+		updateMouseCursor(state.conf.mouseControl && !state.aseq);
+
+	updateMouseRegions(state, _enableMouse);
+
 	while (_evt->pollEvent(evt)) {
-		for (const InputEvent &k : _defaultKeyEvents) {
+		for (const InputEvent &k : _keyEvents) {
 			if (evt.type == k.pressType && (k.kc == Common::KEYCODE_INVALID || evt.kbd.keycode == k.kc) && (k.kFlag == 0 || (evt.kbd.flags & k.kFlag))) {
 				if (k.kc != Common::KEYCODE_INVALID && k.releaseType != Common::EVENT_INVALID) {
 					state.input.sustainedControllerFlags |= k.internalEvent;
 					// The A, B and C buttons can be reconfigured in the main menu. This applies the setting.
-					for (int f = 0; f < 3; ++f) {
-						if (k.internalEvent & ((1 << f) << 4))
-							state.input.sustainedControllerFlagsRemapped |= (1 << _scdKeyConfigs[state.conf.controllerSetup][f]);
+					for (int f = 4; f < 7; ++f) {
+						if (k.internalEvent & (1 << f))
+							state.input.sustainedControllerFlagsRemapped |= (1 << remapControllerButton(state.conf.controllerSetup, f));
 					}
 					state.input.sustainedControllerFlagsRemapped |= (k.internalEvent & ~0x70);
 				}
@@ -98,58 +469,95 @@ void InputHandler::handleEvents(GameState &state) {
 				if (!(_lastKeys & k.internalEvent)) {
 					state.input.singleFrameControllerFlags |= k.internalEvent;
 					// The A, B and C buttons can be reconfigured in the main menu. This applies the setting.
-					for (int f = 0; f < 3; ++f) {
-						if (k.internalEvent & ((1 << f) << 4))
-							state.input.singleFrameControllerFlagsRemapped |= (1 << _scdKeyConfigs[state.conf.controllerSetup][f]);
+					for (int f = 4; f < 7; ++f) {
+						if (k.internalEvent & (1 << f))
+							state.input.singleFrameControllerFlagsRemapped |= (1 << remapControllerButton(state.conf.controllerSetup, f));
 					}
 					state.input.singleFrameControllerFlagsRemapped |= (k.internalEvent & ~0x70);
 					_lastKeys |= k.internalEvent;
 					if (_keyRepeat || k.releaseType == Common::EVENT_INVALID)
 						_releaseKeys |= k.internalEvent;
-					if (k.updateCoords) {
-						_realLightGunPos = evt.mouse;
-						// Revert aspect ratio correction, if necessary.
-						_realLightGunPos.x = (_realLightGunPos.x * _gfx->screenWidth()) / _gfx->realScreenWidth();
-						_realLightGunPos.y = (_realLightGunPos.y * _gfx->screenHeight()) / _gfx->realScreenHeight();
-						// The lightgun coordinates are supposed to be based on a 256 x 256 system, with 128 being
-						// the screen center. I solve this by always adding the diff to the y-bias.
-						state.input.lightGunPos.x = CLIP<int>(_realLightGunPos.x - state.conf.lightGunBias.x, 0, 255);
-						state.input.lightGunPos.y = CLIP<int>(_realLightGunPos.y - state.conf.lightGunBias.y, 0, 255);
-					}
+					if (k.updateCoords)
+						lightGunUpdateCoords(state, evt);
 				}
 
 			} else if ((evt.type == k.releaseType) && (k.kc == Common::KEYCODE_INVALID || evt.kbd.keycode == k.kc) && (k.kFlag == 0 || (evt.kbd.flags & k.kFlag))) {
 				_lastKeys &= ~k.internalEvent;
 				if (k.kc != Common::KEYCODE_INVALID && k.releaseType != Common::EVENT_INVALID) {
 					state.input.sustainedControllerFlags &= ~k.internalEvent;
-					for (int f = 0; f < 3; ++f) {
-						if (k.internalEvent & ((1 << f) << 4))
-							state.input.sustainedControllerFlagsRemapped &= ~(1 << _scdKeyConfigs[state.conf.controllerSetup][f]);
+					for (int f = 4; f < 7; ++f) {
+						if (k.internalEvent & (1 << f))
+							state.input.sustainedControllerFlagsRemapped &= ~(1 << remapControllerButton(state.conf.controllerSetup, f));
 					}
 					state.input.sustainedControllerFlagsRemapped &= ~(k.internalEvent & ~0x70);
 				}
 			}
 		}
+
+		if (_enableMouse)
+			_mouseHandler->parseEvent(evt);
+	}
+
+	if (_enableMouse) {
+		if (!state.input.singleFrameControllerFlags) {
+			// If there are no "real" key presses we check if the mouse handler has produced something...
+			_mouseHandler->raiseNextEvent(state.input.singleFrameControllerFlags, state.input.sustainedControllerFlags);
+
+			if (state.input.singleFrameControllerFlags) {
+				state.input.singleFrameControllerFlagsRemapped = state.input.singleFrameControllerFlags & ~0x70;
+				for (int f = 4; f < 7; ++f) {
+					if (state.input.singleFrameControllerFlags & (1 << f))
+						state.input.singleFrameControllerFlagsRemapped |= (1 << remapControllerButton(state.conf.controllerSetup, f));
+				}
+			} else {
+				state.input.singleFrameControllerFlagsRemapped = 0;
+			}
+			if (state.input.sustainedControllerFlags) {
+				state.input.sustainedControllerFlagsRemapped = state.input.sustainedControllerFlags & ~0x70;
+				for (int f = 4; f < 7; ++f) {
+					if (state.input.sustainedControllerFlags & (1 << f))
+						state.input.sustainedControllerFlagsRemapped |= (1 << remapControllerButton(state.conf.controllerSetup, f));
+				}
+			} else {
+				state.input.sustainedControllerFlagsRemapped = 0;
+			}
+		}
 	}
 
-	if (_enableLightGun && state.input.singleFrameControllerFlags & 0x100)
+	if (lightGunActivated() && state.input.singleFrameControllerFlags & 0x100)
 		_gfx->setVar(7, _gfx->getVar(7) | 4);
 }
 
-void InputHandler::saveState(Common::SeekableWriteStream *out) const {
-	out->writeByte(_keyRepeat);
-	out->writeByte(_enableLightGun);
+const Common::Point &InputHandler::getLightGunLastRealPos() const {
+	return _dummy;
 }
 
-void InputHandler::loadState(Common::SeekableReadStream *in) {
-	_keyRepeat = in->readByte();
-	_enableLightGun = in->readByte();
+void InputHandler::resetMouseHandler() {
+	_lastMouseMode = -1;
+	_mouseHandler->clearTraceRegions();
 }
 
-void InputHandler::enableLightGun(bool enable) {
-	_enableLightGun = enable;
-	_gfx->createMouseCursor();
-	CursorMan.showMouse(enable);
+void InputHandler::updateMouseCursor(bool configMouse) {
+	bool lg = lightGunActivated();
+	_enableMouse = configMouse;
+	_mouseHandlerActive = _mouseHandler->isActive();
+	if (lg) {
+		resetMouseHandler();
+		_gfx->toggleMouseCursor(GraphicsEngine::kMouseCursorCrosshair);
+	} else {
+		_gfx->toggleMouseCursor((_enableMouse && _mouseHandlerActive) ? GraphicsEngine::kMouseCursorDefault : GraphicsEngine::kMouseCursorNone);
+	}
+}
+
+InputHandler *InputHandler::create(Common::Platform platform, Common::EventManager *eventManager, GraphicsEngine *gfx, UI *ui) {
+	switch (platform) {
+	case Common::kPlatformSegaCD:
+		return createSegaInputHandler(eventManager, gfx, ui);
+	default:
+		break;
+	};
+
+	return nullptr;
 }
 
 } // End of namespace Snatcher
diff --git a/engines/snatcher/input.h b/engines/snatcher/input.h
index 39662150000..2d6ddbd2478 100644
--- a/engines/snatcher/input.h
+++ b/engines/snatcher/input.h
@@ -23,6 +23,9 @@
 #ifndef SNATCHER_INPUT_H
 #define SNATCHER_INPUT_H
 
+#include "common/events.h"
+#include "common/list.h"
+#include "common/platform.h"
 #include "common/scummsys.h"
 #include "snatcher/state.h"
 
@@ -35,29 +38,191 @@ class EventManager;
 
 namespace Snatcher {
 
+class UI;
+struct MouseTracker;
+
+class MouseHandler {
+public:
+	MouseHandler(int realScreenWidth, int realScreenHeight, int virtualWidth, int virtualHeight) : _traceRegions(), _eventChain(), _realScreenWidth(realScreenWidth), _realScreenHeight(realScreenHeight), _virtualWidth(virtualWidth), _virtualHeight(virtualHeight) {
+		assert(realScreenWidth > 0 && realScreenHeight > 0 && virtualWidth > 0 && virtualHeight > 0);
+	}
+	~MouseHandler() {}
+
+	enum ControllerEventType : uint8 {
+		kEventTypeInvalid = 0,
+		kEventTypeSingleFrame = 1 << 0,
+		kEventTypeSustained = 1 << 1
+	};
+	constexpr friend ControllerEventType operator|(ControllerEventType a, ControllerEventType b) {
+		return static_cast<ControllerEventType>(static_cast<uint8>(a) | static_cast<uint8>(b));
+	}
+
+	struct ControllerEvent {
+		ControllerEvent(ControllerEventType tp, uint16 flg) : type(tp), flags(flg) {}
+		ControllerEvent() {}
+		ControllerEventType type = kEventTypeInvalid;
+		uint16 flags = 0;
+	};
+
+	struct EventMapping {
+		EventMapping() : moveUp(), moveDown(), moveLeft(), moveRight(), buttonDownL(), buttonDownR(), scrollWheelUp(), scrollWheelDown() {}
+		EventMapping(uint8 up, uint8 down, uint8 left, uint8 right, uint8 leftBtn, uint8 rightBtn, uint8 wheelUp, uint8 wheelDown) :
+			moveUp(kEventTypeSingleFrame, up), moveDown(kEventTypeSingleFrame, down), moveLeft(kEventTypeSingleFrame, left), moveRight(kEventTypeSingleFrame, right),
+				buttonDownL(kEventTypeSingleFrame, leftBtn), buttonDownR(kEventTypeSingleFrame, rightBtn), scrollWheelUp(kEventTypeSingleFrame, wheelUp), scrollWheelDown(kEventTypeSingleFrame, wheelDown) {}
+		void clearButtonActions() {
+			buttonDownL = ControllerEvent();
+			buttonDownR = ControllerEvent();
+			scrollWheelUp = ControllerEvent();
+			scrollWheelDown = ControllerEvent();
+		}
+		ControllerEvent moveUp;
+		ControllerEvent moveDown;
+		ControllerEvent moveLeft;
+		ControllerEvent moveRight;
+		ControllerEvent buttonDownL;
+		ControllerEvent buttonDownR;
+		ControllerEvent scrollWheelUp;
+		ControllerEvent scrollWheelDown;
+	};
+
+	enum TrackingMode : uint8 {
+		kNoFollow			= 0,
+		kFollowMovement		= 1 << 0,
+		kFollowLeftClick	= 1 << 1,
+		kFollowRightClick	= 1 << 2,
+		kFollowLeftDrag		= 1 << 3,
+		kFollowRightDrag	= 1 << 4,
+		kFollowDefault		= kFollowMovement | kFollowLeftClick | kFollowRightClick
+	};
+	constexpr friend TrackingMode operator|(TrackingMode a, TrackingMode b) {
+		return static_cast<TrackingMode>(static_cast<uint8>(a) | static_cast<uint8>(b));
+	}
+
+	struct TraceRegion {
+		TraceRegion(int16 x, int16 y, uint16 w, uint16 h, uint16 cellW, uint16 cellH, uint16 padW, uint16 padH, MouseTracker *cb, TrackingMode mode, int16 traceStartPosX, int16 traceStartPosY,
+			int16 traceStepH, int16 traceStepV, EventMapping *eventMapping);
+
+		bool contains(Common::Point p) const {
+			return p.x >= left && p.x <= right && p.y >= top && p.y <= bottom;
+		}
+
+		int16 left = 0;
+		int16 top = 0;
+		int16 right = 0;
+		int16 bottom = 0;
+		int16 numH = 0;
+		int16 numV = 0;
+		int16 cellWidth = 0;
+		int16 cellHeight = 0;
+		int16 padWidth = 0;
+		int16 padHeight = 0;
+		int16 startPosX = 0;
+		int16 startPosY = 0;
+		int16 stepH = 0;
+		int16 stepV = 0;
+		Common::Rect range = Common::Rect(0, 0, 0, 0);
+		EventMapping *events = nullptr;
+		MouseTracker *tracker = nullptr;
+		TrackingMode trackingMode = kNoFollow;
+		mutable Common::Point trackObjectDest = Common::Point(0, 0);
+	};
+
+	void addTraceRegion(TraceRegion region);
+	void clearTraceRegions();
+
+	void parseEvent(const Common::Event &evt);
+	void gotoLastClickPos();
+	void raiseNextEvent(uint16 &singleFrameFlags, uint16 &sustainedFlags);
+	bool isActive() const;
+
+private:
+	void followMouse(const Common::Point &newPos, int mouseEventType);
+	template<bool swp> int16 getStepDistance(int16 x, int16 y, int16 remX, int16 remY, int16 dir, int16 &correction) const;
+	typedef int16 (MouseHandler::*GetStepProc)(int16 x, int16 y, int16 remX, int16 remY, int16 dir, int16 &correction) const;
+
+	Common::List<const ControllerEvent> _eventChain;
+	Common::List<TraceRegion> _traceRegions;
+	const TraceRegion *_newActiveRegion = nullptr;
+	const TraceRegion *_lastActiveRegion = nullptr;
+	Common::Point _clickedPos = Common::Point(0, -1);
+	bool _buttonDownL = false;
+	bool _buttonDownR = false;
+	uint8 _buttonFlagsL = 0;
+	uint8 _buttonFlagsR = 0;
+	uint8 _releaseFlags = 0;
+	uint8 _releaseFlagsL = 0;
+	uint8 _releaseFlagsR = 0;
+	int _feedTimer = 0;
+	const int _realScreenWidth = 0;
+	const int _realScreenHeight = 0;
+	const int _virtualWidth = 0;
+	const int _virtualHeight = 0;
+	const int _feedDelay = 1;
+};
+
 class GraphicsEngine;
+
 class InputHandler {
+	friend struct MouseTracker;
 public:
-	InputHandler(Common::EventManager *eventManager, GraphicsEngine *gfx) : _evt(eventManager), _gfx(gfx) {}
-	~InputHandler() {}
+	virtual ~InputHandler();
 
-	void handleEvents(GameState &state);
+	void update(GameState &state);
 
-	void saveState(Common::SeekableWriteStream *out) const;
-	void loadState(Common::SeekableReadStream *in);
+	virtual void enableLightGun(bool enable) {}
+	virtual const Common::Point &getLightGunLastRealPos() const;
 
-	void enableLightGun(bool enable);
-	const Common::Point &getLightGunLastRealPos() const { return _realLightGunPos; }
+	void resetMouseHandler();
 	
 private:
+	void updateMouseCursor(bool configMouse);
+	virtual void updateMouseRegions(const GameState &state, bool enable) = 0;
+	virtual bool lightGunActivated() const { return false; }
+	virtual bool lightGunModeChanged() const { return false; }
+	virtual void lightGunUpdateCoords(GameState &state, const Common::Event &evt) {}
+	virtual uint8 remapControllerButton(uint8 conf, uint8 bit) const { return bit; }
+	virtual void mouseTrackingCallback(int id, Common::Point &v) const = 0;
+
 	uint16 _lastKeys = 0;
 	uint16 _releaseKeys = 0;
-	Common::Point _realLightGunPos;
 	bool _keyRepeat = false;
-	bool _enableLightGun = false;
+	bool _enableMouse = false;
+	bool _mouseHandlerActive = false;
+	Common::Point _dummy = Common::Point(0, 0);
+	Common::EventManager *_evt = nullptr;
+
+protected:
+	InputHandler(Common::EventManager *eventManager, GraphicsEngine *gfx);
+
+	struct InputEvent {
+		Common::EventType pressType;
+		Common::EventType releaseType;
+		Common::KeyCode kc;
+		uint16 kFlag;
+		uint16 internalEvent;
+		bool updateCoords;
+	};
 
+	Common::List<InputEvent> _keyEvents;
 	GraphicsEngine *_gfx = nullptr;
-	Common::EventManager *_evt = nullptr;
+	MouseHandler *_mouseHandler = nullptr;
+	int _lastMouseMode = -1;
+
+private:
+	static InputHandler *createSegaInputHandler(Common::EventManager *eventManager, GraphicsEngine *gfx, UI *ui);
+
+public:
+	static InputHandler *create(Common::Platform platform, Common::EventManager *eventManager, GraphicsEngine *gfx, UI *ui);
+};
+
+struct MouseTracker {
+	MouseTracker(int id, InputHandler *hdl) : handler(hdl), tid(id) {}
+	InputHandler *handler = nullptr;
+	const int tid = 0;
+	void operator()(Common::Point &point) {
+		if (handler)
+			handler->mouseTrackingCallback(tid, point);
+	}
 };
 
 } // End of namespace Snatcher
diff --git a/engines/snatcher/input_scd.cpp b/engines/snatcher/input_scd.cpp
new file mode 100644
index 00000000000..e4cbde7c244
--- /dev/null
+++ b/engines/snatcher/input_scd.cpp
@@ -0,0 +1,334 @@
+/* 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 "snatcher/graphics.h"
+#include "snatcher/input.h"
+#include "snatcher/ui.h"
+
+namespace Snatcher {
+
+class SCDInputHandler : public InputHandler {
+public:
+	SCDInputHandler(Common::EventManager *eventManager, GraphicsEngine *gfx, UI *ui);
+	~SCDInputHandler();
+
+	void enableLightGun(bool enable) override;
+	const Common::Point &getLightGunLastRealPos() const override;
+
+private:
+	void updateMouseRegions(const GameState &state, bool enable) override;
+	bool lightGunActivated() const override;
+	bool lightGunModeChanged() const override;
+	void lightGunUpdateCoords(GameState &state, const Common::Event &evt) override;
+	uint8 remapControllerButton(uint8 conf, uint8 bit) const override;
+
+	void mouseTrackingCallback(int id, Common::Point &v) const override;
+
+	mutable bool _enableLightGun = false;
+	bool _enableLightGunRequest = false;
+	Common::Point _realLightGunPos = Common::Point();
+
+	UI *_ui = nullptr;
+	int16 _uiMouseFld = 0;
+	int16 _uiAreaType = 0;
+
+	MouseTracker *_mouseTracker = nullptr;
+	MouseTracker *_mouseTracker2 = nullptr;
+	MouseHandler::EventMapping _eventMapping;
+	MouseHandler::EventMapping _eventMapping2;
+	MouseHandler::EventMapping _eventMapping3;
+};
+
+SCDInputHandler::SCDInputHandler(Common::EventManager *eventManager, GraphicsEngine *gfx, UI *ui) : InputHandler(eventManager, gfx), _ui(ui) {
+	static const InputEvent scdKeyEvents[] = {
+		// A, B, C buttons
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_a,			0x00, 0x10, false },
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_b,			0x00, 0x20, false },
+		{ Common::EVENT_KEYDOWN,		Common::EVENT_KEYUP,		Common::KEYCODE_c,			0x00, 0x40, false },
+		// Lightgun
+		{ Common::EVENT_LBUTTONDOWN,	Common::EVENT_LBUTTONUP,	Common::KEYCODE_INVALID,	0x00, 0x100, true },
+		// Lightgun Start button
+		{ Common::EVENT_RBUTTONDOWN,	Common::EVENT_RBUTTONUP,	Common::KEYCODE_INVALID,	0x00, 0x200, false }
+	};
+
+	for (const InputEvent &k : scdKeyEvents)
+		_keyEvents.push_back(k);
+
+	_eventMapping = _eventMapping2 = _eventMapping3 = MouseHandler::EventMapping(0x01, 0x02, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00);
+
+	// Special config for handling the flashlight
+	_eventMapping3.buttonDownL = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSustained, 0x20);
+	_eventMapping3.moveUp.type = _eventMapping3.moveDown.type = _eventMapping3.moveLeft.type = _eventMapping3.moveRight.type = MouseHandler::kEventTypeSingleFrame | MouseHandler::kEventTypeSustained;
+	_eventMapping3.moveUp.flags |= 0x20;
+	_eventMapping3.moveDown.flags |= 0x20;
+	_eventMapping3.moveLeft.flags |= 0x20;
+	_eventMapping3.moveRight.flags |= 0x20;
+	// With these commented out lines, we could make the verbs selectable via mouse wheel and right click for the flashlight scene.
+	// But it seems a bit confusing to suddenly have the C button assigned to right mouse clicking when it is usually left. And I
+	// don't want the dragging of the light on the right button, that's just not comfortable (not even on desktop systems, but even
+	// less on tablets and phones).
+	//_eventMapping3.buttonDownR = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x40);
+	//_eventMapping3.scrollWheelUp = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x01);
+	//_eventMapping3.scrollWheelDown = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x02);
+}
+
+SCDInputHandler::~SCDInputHandler() {
+	delete _mouseTracker;
+	delete _mouseTracker2;
+}
+
+void SCDInputHandler::enableLightGun(bool enable) {
+	_enableLightGunRequest = enable;
+}
+
+const Common::Point &SCDInputHandler::getLightGunLastRealPos() const {
+	return _realLightGunPos;
+}
+
+void SCDInputHandler::mouseTrackingCallback(int id, Common::Point &v) const {
+	v.x = 0;
+	switch (id) {
+	case 0:
+		v.y = (_gfx->getAnimParameter(17, GraphicsEngine::kAnimParaFrame) == 3) ? 0 : 1;
+		break;
+	case 1:
+		v.y = CLIP<int>(_gfx->getAnimParameter(25, GraphicsEngine::kAnimParaFrame) >> 2, 0 , 3);
+		break;
+	case 2:
+		v.y = CLIP<int>(_gfx->getAnimParameter(32, GraphicsEngine::kAnimParaFrame) >> 2, 0, 4);
+		break;
+	case 4:
+		v.x = ((CLIP<int>(_ui->_flashLight.posX >> 16, -71, 69) + 72) >> 1);
+		v.y = ((CLIP<int>(_ui->_flashLight.posY >> 16, -39, 37) + 40) >> 1);
+		break;
+	case 5:
+		v.y = _ui->_hiliteVerb;
+		break;
+	case 6:
+		v.x = CLIP<int>(((_ui->_vkeybPosTotal % 12) - 7) / 2, 0, 2);
+		v.y = CLIP<int>(_ui->_vkeybPosTotal / 12, 0, 3);
+		break;
+	case 7:
+		v.x = CLIP<int>(((_ui->_vkeybPosTotal % 52) - 27) / 2, 0, 12);
+		v.y = CLIP<int>(_ui->_vkeybPosTotal / 52, 0, 2);
+		break;
+	default:
+		v.y = 0;
+		break;
+	}
+}
+
+bool SCDInputHandler::lightGunActivated() const {
+	_enableLightGun = _enableLightGunRequest;
+	return _enableLightGun;
+}
+
+bool SCDInputHandler::lightGunModeChanged() const	{
+	return _enableLightGun != _enableLightGunRequest;
+}
+
+void SCDInputHandler::lightGunUpdateCoords(GameState &state, const Common::Event &evt) {
+	_realLightGunPos = evt.mouse;
+	// Revert aspect ratio correction, if necessary.
+	_realLightGunPos.x = (_realLightGunPos.x * _gfx->screenWidth()) / _gfx->realScreenWidth();
+	_realLightGunPos.y = (_realLightGunPos.y * _gfx->screenHeight()) / _gfx->realScreenHeight();
+	// The lightgun coordinates are supposed to be based on a 256 x 256 system, with 128 being
+	// the screen center. I solve this by always adding the diff to the y-bias.
+	state.input.lightGunPos.x = CLIP<int>(_realLightGunPos.x - state.conf.lightGunBias.x, 0, 255);
+	state.input.lightGunPos.y = CLIP<int>(_realLightGunPos.y - state.conf.lightGunBias.y, 0, 255);
+}
+
+uint8 SCDInputHandler::remapControllerButton(uint8 conf, uint8 bit) const {
+	static const uint8 scdKeyConfigs[6][3] = {
+		{ 6, 4, 5 }, { 6, 5, 4 }, { 4, 6, 5 },
+		{ 4, 5, 6 }, { 5, 4, 6 }, { 5, 6, 4 }
+	};
+
+	bit -= 4;
+	assert(conf < ARRAYSIZE(scdKeyConfigs) && bit < ARRAYSIZE(scdKeyConfigs[0]));
+
+	return scdKeyConfigs[conf][bit];
+}
+
+void SCDInputHandler::updateMouseRegions(const GameState &state, bool enable) {
+	int mouseMode = -1;
+	uint8 saveSlotHRange[4] = { 0 };
+
+	if (enable) {
+		if (state.modPhaseTop == 1 && state.modPhaseSub == 2) {
+			// Main menu, load menu and startup/options menu
+			const uint8 modeMenuFrames[] = {9, 10, 11};
+			for (int i = 0; i < ARRAYSIZE(modeMenuFrames); ++i) {
+				if (state.frameNo == modeMenuFrames[i]) {
+					mouseMode = i;
+					break;
+				}
+			}
+
+			if (state.frameNo == 11) {
+				if (_lastMouseMode == mouseMode && _uiMouseFld != state.conf.useLightGun)
+					_lastMouseMode = -1;
+				_uiMouseFld = state.conf.useLightGun;
+			} else if (state.frameNo == 10) {
+				if (_lastMouseMode != mouseMode) {
+					int r = 1;
+					uint8 *sr = nullptr;
+					for (int i = 0; i < 4; ++i) {
+						// For empty save slots, we have to extend the tracking range of the neighboring mouse regions
+						// with valid slots, so they get smooth hilite transitions. We check the necessary adjustments here.
+						if (state.saveInfo.slotUsage & (1 << i)) {
+							sr = &saveSlotHRange[i];
+							*sr = r;
+							r = 1;
+						} else if (sr) {
+							if (*sr == 1)
+								(*sr)++;
+							else
+								r = 3;
+						}
+					}
+				}
+			}
+
+		} else if (state.modPhaseTop == 5) {
+			if (_ui->_progress == 5) {
+				// Text message display. We want to catch clicks anywhere in the verb area including the wait cursor.
+				mouseMode = 3;
+				if (_lastMouseMode == mouseMode /* && (_uiMouseFld == 0) != (_ui->_sceneId == 0)*/)
+					_lastMouseMode = -1;
+				//_uiMouseFld = _ui->_sceneId;
+			} else if (_ui->_verbInterfaceMode < 2) {
+				// Normal verb interface and flashlight control.
+				mouseMode = 5 - _ui->_verbInterfaceMode;
+				if (_lastMouseMode == mouseMode && (_uiMouseFld != _ui->_lastVerbDrawn || _uiAreaType != _gfx->getVerbAreaType()))
+					_lastMouseMode = -1;
+				_uiMouseFld = _ui->_lastVerbDrawn;
+				_uiAreaType = _gfx->getVerbAreaType();
+				if (_uiMouseFld == 0 || !_gfx->transitionStateBusy())
+					mouseMode = -1;
+			} else if (_ui->_verbInterfaceMode >= 2) {
+				// Videophone and virtual keyboard.
+				mouseMode = _ui->_verbInterfaceMode + 4;
+				_uiMouseFld = 0;
+			}
+		}
+	}
+
+	if (mouseMode == _lastMouseMode)
+		return;
+
+	_mouseHandler->clearTraceRegions();
+	_eventMapping.clearButtonActions();
+	_eventMapping2.clearButtonActions();
+	delete _mouseTracker;
+	delete _mouseTracker2;
+	_mouseTracker = nullptr;
+	_mouseTracker2 = nullptr;
+	_lastMouseMode = mouseMode;
+
+	if (mouseMode == -1)	
+		return;
+
+	_mouseTracker = new MouseTracker(mouseMode, this);
+
+	switch (mouseMode) {
+	case 0: // Main Menu
+		_eventMapping.buttonDownL = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x80);
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(90, 164, 86, 26, 86, 13, 0, 0, _mouseTracker, MouseHandler::kFollowDefault, 0, 0, 1, 1, &_eventMapping));
+		break;
+
+	case 1: // Load Menu
+		_eventMapping.buttonDownL = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x80);
+		_eventMapping.buttonDownR = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x10);
+		for (int i = 0; i < 4; ++i) {
+			if (state.saveInfo.slotUsage & (1 << i)) {
+				// Add trace regions only for valid slots. For the empty ones, we extend the tracking range of the neighboring regions appropriately, so that we get smooth hilite transitions.
+				_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(56, 59 + 32 * i, 146, 27, 146, 27, 0, 0, _mouseTracker, MouseHandler::kFollowDefault, 0, i, 1, saveSlotHRange[i], &_eventMapping));
+			}
+		}
+		_eventMapping2.buttonDownR = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x10);
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(0, 0, 256, 224, 256, 224, 0, 0, nullptr, MouseHandler::kNoFollow, -1, -1, 0, 0, &_eventMapping2));
+		break;
+
+	case 2: // Startup Menu
+		// We need to add a trace region for each button, since they have different dimensions. But this also allows us to handle the input a bit better than what the controller does.
+		// To modify the options we have to press left/right there. The A/B/C buttons do nothing. And if you hit start it will just start the game, regardless of the selected option
+		// (unless it is the lightgun option, then it will start that). So instead, we allow left-clicking or mouse-wheeling the options and only launch the game when clicking the quit button.
+		_eventMapping.buttonDownL = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x04);
+		_eventMapping.scrollWheelUp = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x04);
+		_eventMapping.scrollWheelDown = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x08);
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(40, 44, 175, 22, 175, 22, 0, 0, _mouseTracker, MouseHandler::kFollowDefault, 0, 0, 1, 1, &_eventMapping));
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(40, 72, 175, 38, 175, 38, 0, 0, _mouseTracker, MouseHandler::kFollowDefault, 0, 1, 1, 1, &_eventMapping));
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(40, 116, 175, 22, 175, 22, 0, 0, _mouseTracker, MouseHandler::kFollowDefault, 0, 2, 1, 1, &_eventMapping));
+		_eventMapping2.buttonDownL = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x80);
+		if (_uiMouseFld)
+			_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(40, 144, 175, 22, 175, 22, 0, 0, _mouseTracker, MouseHandler::kFollowDefault, 0, 3, 1, 1, &_eventMapping2));
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(96, 171, 63, 22, 63, 22, 0, 0, _mouseTracker, MouseHandler::kFollowDefault, 0, 4, 1, _uiMouseFld ? 1 : 3, &_eventMapping2));
+		break;
+
+	case 3: // Text Message
+		_eventMapping.buttonDownL = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x40);
+		_eventMapping.buttonDownR = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x20);
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(0, 0, 256, 224, 256, 224, /*16, _uiMouseFld ? 143 : 72, 224, _uiMouseFld ? 63 : 134, 224, _uiMouseFld ? 63 : 134,*/ 0, 0, nullptr, MouseHandler::kNoFollow, -1, -1, 0, 0, &_eventMapping));
+		break;
+
+	case 4: // Flashlight
+		// We make the clickable area a bit larger than the actually explorable zone, so that players can click slightly out of bounds and still move the flashlight.
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(15, 5, 220, 126, 2, 2, 0, 0, _mouseTracker, MouseHandler::kFollowLeftClick | MouseHandler::kFollowLeftDrag, -19, -14, 2, 2, &_eventMapping3));
+		_mouseTracker2 = _mouseTracker;
+		_mouseTracker = new MouseTracker(5, this);
+
+	//fallthrough
+	case 5: // Verb Interface
+		_eventMapping.buttonDownL = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x40);
+		_eventMapping2.buttonDownR = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x20);
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(16, _uiAreaType ? 159 : 143, 224, _uiMouseFld * 9, 224, 9, 0, 0, _mouseTracker, MouseHandler::kFollowDefault, 0, 0, 1, 1, &_eventMapping));
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(16, _uiAreaType ? 159 : 143, 224, 63, 143, 63, 0, 0, nullptr, MouseHandler::kNoFollow, -1, -1, 0, 0, &_eventMapping2));
+		break;
+
+	case 6: // Videophone
+		_eventMapping.buttonDownL = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x40);
+		_eventMapping.buttonDownR = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x20);
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(200, 151, 41, 57, 9, 9, 7, 7, _mouseTracker, MouseHandler::kFollowDefault, 0, 0, 1, 1, &_eventMapping));
+		break;
+
+	case 7: // Virtual Keyboard. We need multiple regions, since the keys in the bottom row have different sizes.
+		_eventMapping.buttonDownL = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x40);
+		_eventMapping.buttonDownR = MouseHandler::ControllerEvent(MouseHandler::kEventTypeSingleFrame, 0x20);
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(25, 161, 206, 30, 14, 14, 2, 2, _mouseTracker, MouseHandler::kFollowDefault, 0, 0, 1, 1, &_eventMapping));
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(25, 193, 46, 14, 14, 14, 2, 0, _mouseTracker, MouseHandler::kFollowDefault, 0, 2, 1, 1, &_eventMapping));
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(72, 193, 46, 14, 46, 14, 0, 0, _mouseTracker, MouseHandler::kFollowDefault, 4, 2, 3, 1, &_eventMapping));
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(121, 193, 62, 14, 62, 14, 0, 0, _mouseTracker, MouseHandler::kFollowDefault, 7, 2, 4, 1, &_eventMapping));
+		_mouseHandler->addTraceRegion(MouseHandler::TraceRegion(185, 193, 46, 14, 46, 14, 0, 0, _mouseTracker, MouseHandler::kFollowDefault, 11, 2, 3, 1, &_eventMapping));
+		break;
+	default:
+		break;
+	}
+
+	_mouseHandler->gotoLastClickPos();
+}
+
+InputHandler *InputHandler::createSegaInputHandler(Common::EventManager *eventManager, GraphicsEngine *gfx, UI *ui) {
+	return new SCDInputHandler(eventManager, gfx, ui);
+}
+
+} // End of namespace Snatcher
diff --git a/engines/snatcher/metaengine.cpp b/engines/snatcher/metaengine.cpp
index 56145c7ede8..5a50fd1584c 100644
--- a/engines/snatcher/metaengine.cpp
+++ b/engines/snatcher/metaengine.cpp
@@ -184,9 +184,10 @@ public:
 private:
 	void defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const override;
 
-	GUI::PopUpWidget *_buttonConfPopup;
-	GUI::CheckboxWidget *_enableLightgunBox;
-	GUI::CheckboxWidget *_monoSoundBox;
+	GUI::PopUpWidget *_buttonConfPopup = nullptr;
+	GUI::CheckboxWidget *_enableLightgunBox = nullptr;
+	GUI::CheckboxWidget *_monoSoundBox = nullptr;
+	GUI::CheckboxWidget *_mouseControlBox = nullptr;
 };
 
 GUI::OptionsContainerWidget *SnatcherMetaEngine::buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const {
@@ -211,7 +212,7 @@ static const char *buttonConfStrings[6] = {
 	_s("A - Select/Shoot, B - Cancel, C - Draw Blaster"),
 	_s("A - Select/Shoot, B - Draw Blaster, C - Cancel")};
 
-SnatcherOptionsWidget::SnatcherOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain) : OptionsContainerWidget(boss, name, "SnatcherOptionsWidget", domain), _buttonConfPopup(nullptr), _enableLightgunBox(nullptr), _monoSoundBox(nullptr) {
+SnatcherOptionsWidget::SnatcherOptionsWidget(GuiObject *boss, const Common::String &name, const Common::String &domain) : OptionsContainerWidget(boss, name, "SnatcherOptionsWidget", domain) {
 	GUI::StaticTextWidget *text = new GUI::StaticTextWidget(widgetsBoss(), "SnatcherOptionsWidget.ButtonRemapLabel", _("Buttons Config:"));
 	text->setAlign(Graphics::TextAlign::kTextAlignEnd);
 
@@ -227,18 +228,22 @@ SnatcherOptionsWidget::SnatcherOptionsWidget(GuiObject *boss, const Common::Stri
 	assert(_enableLightgunBox);
 	_monoSoundBox = new GUI::CheckboxWidget(widgetsBoss(), "SnatcherOptionsWidget.MonoSoundBox", _("Mono Sound Mode"), _("Disable stereo sound."));
 	assert(_monoSoundBox);
+	_mouseControlBox = new GUI::CheckboxWidget(widgetsBoss(), "SnatcherOptionsWidget.MouseControlBox", _("Enable Mouse Control"), _("Enable optional mouse control (ScummVM feature)"));
+	assert(_mouseControlBox);
 }
 
 void SnatcherOptionsWidget::load() {
 	_buttonConfPopup->setSelected(ConfMan.hasKey("controller_conf", _domain) ? ConfMan.getInt("controller_conf", _domain) : 0);
 	_enableLightgunBox->setState(ConfMan.hasKey("lightgun_usage", _domain) && ConfMan.getBool("lightgun_usage", _domain));
 	_monoSoundBox->setState(ConfMan.hasKey("disable_stereo", _domain) && ConfMan.getBool("disable_stereo", _domain));
+	_mouseControlBox->setState(ConfMan.hasKey("mouse_control", _domain) && ConfMan.getBool("mouse_control", _domain));
 }
 
 bool SnatcherOptionsWidget::save() {
 	ConfMan.setInt("controller_conf", _buttonConfPopup->getSelected(), _domain);
 	ConfMan.setBool("lightgun_usage", _enableLightgunBox->getState(), _domain);
 	ConfMan.setBool("disable_stereo", _monoSoundBox->getState(), _domain);
+	ConfMan.setBool("mouse_control", _mouseControlBox->getState(), _domain);
 	return true;
 }
 
@@ -253,9 +258,11 @@ void SnatcherOptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::
 		.addWidget("ButtonRemapPopup", "PopupWidget")
 		.closeLayout()
 		.addPadding(0, 0, 10, 0)
+		.addWidget("MonoSoundBox", "Checkbox")
+		.addPadding(0, 0, 10, 0)
 		.addWidget("EnableLightgunBox", "Checkbox")
 		.addPadding(0, 0, 10, 0)
-		.addWidget("MonoSoundBox", "Checkbox")
+		.addWidget("MouseControlBox", "Checkbox")
 		.closeLayout()
 		.closeDialog();
 }
diff --git a/engines/snatcher/module.mk b/engines/snatcher/module.mk
index 38ee8638f57..5376c774e8c 100644
--- a/engines/snatcher/module.mk
+++ b/engines/snatcher/module.mk
@@ -7,6 +7,7 @@ MODULE_OBJS := \
 	fantranslations_detection.o \
 	graphics.o \
 	input.o \
+	input_scd.o \
 	memory.o \
 	mem_mapping.o \
 	metaengine.o \
diff --git a/engines/snatcher/saveflags.h b/engines/snatcher/saveflags.h
index 0a74a73b858..be73ef68736 100644
--- a/engines/snatcher/saveflags.h
+++ b/engines/snatcher/saveflags.h
@@ -25,7 +25,7 @@
 
 namespace Snatcher {
 
-enum SaveFlags : int {
+enum SaveFlags : uint16 {
 	kFlagNone				=	0,
 	kFlagTempData			=	1 << 0,
 	kFlagScriptedSave		=	1 << 1,
@@ -33,6 +33,10 @@ enum SaveFlags : int {
 	kFlagNeedPaletteData	=	1 << 3
 };
 
+constexpr SaveFlags operator|(SaveFlags a, SaveFlags b) {
+	return static_cast<SaveFlags>(static_cast<uint16>(a) | static_cast<uint16>(b));
+}
+
 } // End of namespace Snatcher
 
 #endif // SNATCHER_SAVEFLAGS_H
diff --git a/engines/snatcher/saveload.cpp b/engines/snatcher/saveload.cpp
index 1cb6e91faee..ea810a4863e 100644
--- a/engines/snatcher/saveload.cpp
+++ b/engines/snatcher/saveload.cpp
@@ -48,12 +48,15 @@ SaveLoadManager::SaveLoadManager(SnatcherEngine *vm) : _vm(vm), _pendingSaveLoad
 	ConfMan.registerDefault("lightgun_usage", false);
 	ConfMan.registerDefault("lightgun_biasX", 0);
 	ConfMan.registerDefault("lightgun_biasY", 0);
+	ConfMan.registerDefault("mouse_control", false);
 }
 
 SaveLoadManager::~SaveLoadManager() {
 }
 
 void SaveLoadManager::loadSettings(Config &config) {
+	if (ConfMan.hasKey("mouse_control"))
+		config.mouseControl = ConfMan.getBool("mouse_control") ? 1 : 0;
 	if (ConfMan.hasKey("controller_conf"))
 		config.controllerSetup = ConfMan.getInt("controller_conf");
 	if (ConfMan.hasKey("disable_stereo"))
@@ -71,6 +74,7 @@ void SaveLoadManager::loadSettings(Config &config) {
 }
 
 void SaveLoadManager::saveSettings(const Config &config) {
+	ConfMan.setBool("mouse_control", config.mouseControl != 0);
 	ConfMan.setInt("controller_conf", config.controllerSetup);
 	ConfMan.setBool("disable_stereo", config.disableStereo != 0);
 	ConfMan.setBool("lightgun_usage", config.useLightGun != 0);
@@ -217,6 +221,7 @@ void SaveLoadManager::loadState(int slot, GameState &state) {
 	state.modPhaseSub = in->readSint16BE();
 	state.modPhaseTop = in->readSint16BE();
 	state.prologue = in->readSint16BE();
+	state.aseq = 0;
 
 	SaveFlags flags = static_cast<SaveFlags>(in->readUint16BE());
 
@@ -300,7 +305,7 @@ void SaveLoadManager::checkSceneSpecificSaveDataNeed(const GameState &state, Sav
 	const uint16 extDataNeedScenes[] = { 0x0F02 };
 
 	if (Common::find(extDataNeedScenes, &extDataNeedScenes[ARRAYSIZE(extDataNeedScenes)], state.script.curGfxScript) != &extDataNeedScenes[ARRAYSIZE(extDataNeedScenes)])
-		flags = static_cast<SaveFlags>(flags | kFlagNeedAnimExtData);
+		flags = flags | kFlagNeedAnimExtData;
 }
 
 Common::SeekableReadStream *SaveLoadManager::openFileForLoading(int slot, GameState &state, SaveHeader &header) {
diff --git a/engines/snatcher/script.cpp b/engines/snatcher/script.cpp
index 4a91eb1b939..e81fe1d321c 100644
--- a/engines/snatcher/script.cpp
+++ b/engines/snatcher/script.cpp
@@ -399,7 +399,8 @@ void CmdQueue::m_unused(const uint16 *&data) {
 }
 
 void CmdQueue::m_shooterSequenceRun(const uint16 *&data) {
-	if (!_vm->_aseq->run(_state->conf.useLightGun, _state->input))
+	_state->aseq = _vm->_aseq->run(_state->conf.useLightGun, _state->input) ? 1 : 0;
+	if (!_state->aseq)
 		_progress = -1;
 }
 
diff --git a/engines/snatcher/snatcher.cpp b/engines/snatcher/snatcher.cpp
index 79f4d9cb74c..80db2b50733 100644
--- a/engines/snatcher/snatcher.cpp
+++ b/engines/snatcher/snatcher.cpp
@@ -85,7 +85,7 @@ Common::Error SnatcherEngine::run() {
 	if (!initSaveLoad())
 		return Common::Error(Common::kUnknownError);
 
-	if (!initUserInterface())
+	if (!initUserInterface(_game.platform))
 		return Common::Error(Common::kUnknownError);
 
 	if (!initScriptEngine())
@@ -153,7 +153,6 @@ bool SnatcherEngine::initGfx(Common::Platform platform, bool use8BitColorMode) {
 		initGraphics(_gfx->realScreenWidth(), _gfx->realScreenHeight(), &pxf);
 		assert(_scd);
 		_gfx->setTextFont(_scd->makePtr(MemMapping::MEM_RAWDATA_04)(), 816, _scd->makePtr(MemMapping::MEM_RAWDATA_05)(), 102);
-		_gfx->createMouseCursor();
 		return true;
 	}
 
@@ -178,11 +177,7 @@ bool SnatcherEngine::initSound(Audio::Mixer *mixer, Common::Platform platform, i
 	return true;
 }
 
-bool SnatcherEngine::initUserInterface() {
-	_input = new InputHandler(_eventMan, _gfx);
-	if (!_input)
-		return false;
-
+bool SnatcherEngine::initUserInterface(Common::Platform platform) {
 	_cmdQueue = new CmdQueue(this);
 	if (!_cmdQueue)
 		return false;
@@ -193,6 +188,10 @@ bool SnatcherEngine::initUserInterface() {
 	if (!_ui)
 		return false;
 
+	_input = InputHandler::create(platform, _eventMan, _gfx, _ui);
+	if (!_input)
+		return false;
+
 	return true;
 }
 
@@ -220,7 +219,7 @@ void SnatcherEngine::reset() {
 
 void SnatcherEngine::playBootLogoAnimation(GameState &state) {
 	if (!_reset && ConfMan.hasKey("save_slot"))
-		return; // Skip logo animation when loading a savegame from the launcher
+		return; // Skip logo animation if loading a savegame from the launcher
 
 	uint32 frameTimer = 0;
 	int curSeqState = 0;
@@ -236,7 +235,7 @@ void SnatcherEngine::playBootLogoAnimation(GameState &state) {
 			_snd->fmSendCommand(63, -1);
 		curSeqState = nextState;
 
-		_input->handleEvents(state);
+		_input->update(state);
 		_snd->update();
 		delayUntil(nextFrame);
 	}
@@ -305,7 +304,7 @@ bool SnatcherEngine::start() {
 
 		_saveMan->enableSaving(state.phase == 2 && state.modPhaseTop == 5);
 
-		_input->handleEvents(state);
+		_input->update(state);
 
 		_saveMan->handleSaveLoad(state);
 
diff --git a/engines/snatcher/snatcher.h b/engines/snatcher/snatcher.h
index 1260c8d4696..ea2562155df 100644
--- a/engines/snatcher/snatcher.h
+++ b/engines/snatcher/snatcher.h
@@ -65,7 +65,7 @@ private:
 	bool initGfx(Common::Platform platform, bool use8BitColorMode);
 	bool initSaveLoad();
 	bool initSound(Audio::Mixer *mixer, Common::Platform platform, int soundOptions);
-	bool initUserInterface();
+	bool initUserInterface(Common::Platform platform);
 	bool initScriptEngine();
 	void reset();
 	void playBootLogoAnimation(GameState &state);
diff --git a/engines/snatcher/state.h b/engines/snatcher/state.h
index cc610aeaf2c..4b83a22ea1d 100644
--- a/engines/snatcher/state.h
+++ b/engines/snatcher/state.h
@@ -43,6 +43,7 @@ struct Config {
 	int16 useLightGun = 0;
 	int16 controllerSetup = 0;
 	int16 disableStereo = 0;
+	int16 mouseControl = 0;
 	int16 hasRAMCart = 1;
 	int16 hasFreeBuram = 1;
 	Common::Point lightGunBias = Common::Point(0, -16);
@@ -110,6 +111,7 @@ struct GameState {
 	int16 prologue = 0;
 	int16 phase = 0;
 	int16 updateFlags = 0;
+	int16 aseq = 0;
 	uint32 totalPlayTime = 0;
 	SaveInfo saveInfo;
 	Config conf;
diff --git a/engines/snatcher/ui.cpp b/engines/snatcher/ui.cpp
index c278816bcc0..ee2c84fd3c1 100644
--- a/engines/snatcher/ui.cpp
+++ b/engines/snatcher/ui.cpp
@@ -865,22 +865,23 @@ void UI::verbsTabHandleInput(const InputState &input) {
 
 		uint8 in = input.singleFrameControllerFlagsRemapped;
 
-		if (in & 1) {
-			for (int cr = _vkeybPosTotal - _vkeybColumnWidth; verbsTabMoveHilite(cr); )
-				cr -= _vkeybColumnWidth;
-
-		} else if (in & 2) {
-			for (int cr = _vkeybPosTotal + _vkeybColumnWidth; verbsTabMoveHilite(cr); )
-				cr += _vkeybColumnWidth;
-
-		} else if (in & 8) {
-			for (int cr = _vkeybPosTotal + 1; verbsTabMoveHilite(cr); )
-				++cr;
-
-		} else if (in & 4) {
-			for (int cr = _vkeybPosTotal - 1; verbsTabMoveHilite(cr); )
-				--cr;
-
+		if (in & 0x0F) {		
+			if (in & 1) {
+				for (int cr = _vkeybPosTotal - _vkeybColumnWidth; verbsTabMoveHilite(cr);)
+					cr -= _vkeybColumnWidth;
+			}
+			if (in & 8) {
+				for (int cr = _vkeybPosTotal + 1; verbsTabMoveHilite(cr); )
+					++cr;
+			}
+			if (in & 4) {
+				for (int cr = _vkeybPosTotal - 1; verbsTabMoveHilite(cr);)
+					--cr;
+			}
+			if (in & 2) {
+				for (int cr = _vkeybPosTotal + _vkeybColumnWidth; verbsTabMoveHilite(cr);)
+					cr += _vkeybColumnWidth;
+			}
 		} else if (in & 0x10) {
 			virtKeybBackspace();
 		} else if ((_videoPhoneMode == 0) && (in & 0x80)) {
diff --git a/engines/snatcher/ui.h b/engines/snatcher/ui.h
index 0fb7818b322..42ac1ab73a9 100644
--- a/engines/snatcher/ui.h
+++ b/engines/snatcher/ui.h
@@ -40,7 +40,10 @@ class FanTranslationHandler;
 class GraphicsEngine;
 class ResourcePointer;
 class ScriptArray;
+
 class UI {
+	friend class SCDInputHandler;
+
 public:
 	UI(GraphicsEngine *gfx, CmdQueue *que, ResourcePointer *scd, FanTranslationHandler *translator);
 	~UI();


Commit: bc684bf6cbbfe0f02191f2e6004f0308224cd094
    https://github.com/scummvm/scummvm/commit/bc684bf6cbbfe0f02191f2e6004f0308224cd094
Author: athrxx (athrxx at scummvm.org)
Date: 2026-12-05T17:38:59+01:00

Commit Message:
SNATCHER: reset some vars when loading savegames

(avoid frequent crashing in certain situations)

Changed paths:
    engines/snatcher/graphics.cpp
    engines/snatcher/transition_scd.cpp


diff --git a/engines/snatcher/graphics.cpp b/engines/snatcher/graphics.cpp
index 1cbb9ef9af5..20672bf2452 100644
--- a/engines/snatcher/graphics.cpp
+++ b/engines/snatcher/graphics.cpp
@@ -286,6 +286,9 @@ void GraphicsEngine::loadState(Common::SeekableReadStream *in, SaveFlags flags)
 	// prevent ugly artifacts on screen during the phase until all postload processing is done.
 	_palette->block();
 
+	reset(kResetAnimations | kResetCopyCmds);
+	_verbAreaType = 0;
+
 	in->read(_animSaveLoadData, 64);
 
 	if (flags & (kFlagTempData))
diff --git a/engines/snatcher/transition_scd.cpp b/engines/snatcher/transition_scd.cpp
index c007809b86e..152d14042aa 100644
--- a/engines/snatcher/transition_scd.cpp
+++ b/engines/snatcher/transition_scd.cpp
@@ -386,6 +386,8 @@ void TransitionManager_SCD::loadState(Common::SeekableReadStream *in, SaveFlags
 	if (in->readUint32BE() != MKTAG('S', 'N', 'A', 'T'))
 		error("%s(): Save file invalid or corrupt", __FUNCTION__);
 
+	resetVars(0x7F);
+
 	_extendedRestore = false;
 	uint8 *s = _restoreData;
 	*s++ = in->readByte();




More information about the Scummvm-git-logs mailing list