[Scummvm-git-logs] scummvm master -> 5f26c2f644b0bb31c59538c5aca3330c97a61cfb

sev- noreply at scummvm.org
Mon May 5 09:05:30 UTC 2025


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

Summary:
4f4def2575 AWE: Initial re-import of AWE engine
0a4f34780f AWE: Metaengine fix
0178a69894 AWE: Switch game detection entry
61cc6984c0 AWE: Null Resource fields, fixing startup crash
5dcbeed7d2 AWE: Add screen updates
7cc7d9cf5f AWE: Engine shouldQuit checks for exit
4b0e033c8b AWE: Fix debug channel usage
02660a9bd4 AWE: Remove deprecated File class
01b37eb1ae AWE: Merge Engine class into AweEngine
f8dc7339d7 AWE: Cleanup of system stub class
cc2d820c9c AWE: Add savegame code
8e956b40dd AWE: Janitorial
3a5309f6ca AWE: Further janitorial
147cece8c2 AWE: Defaults for Logic class members
960b0a23f1 AWE: Further member initialization
530d09ce62 AWE: Add pc to script opcode debug output
5fd9c0e3f5 AWE: Add detection for demo
5316a63445 AWE: Separate melist array for demo version
4d8c51392e AWE: Remove deprecated manual scaling logic
ab95b69ac1 AWE: Fix prompting for code again if you get it wrong
37a8200d77 AWE: Fix debug line for op_setPalette opcode
4d38942129 AWE: Game option for copy protection bypass
75162510da AWE: Uppercase static array names
83ad5ebe05 AWE: Set up keybindings for the main keys
9a4418bd36 AWE: Fix initialization for multi-dimensional arrays
5658030603 AWE: Replacing codebase with rawgl
a3c989904b AWE: Added main run method logic
d504a5d486 AWE: Change Language enum to use Common::Language
6aea75765f AWE: Initializing structure fields
e03a3fedab AWE: Start of dataDir params removal
56f8bb0d07 AWE: Shifting game data type to detection table
90cd956dc4 AWE: Renaming of filenames
a9e680a8ae AWE: Work on SystemStubScummVM class
df32e7744d AWE: Implement ScummVM event loop
bf2b494ff2 AWE: Remove deprecated detectVersion method
88f8b5f12d AWE: Further fields initialization
675136adbf AWE: Change debug lines to use debug channels
ccce5711a3 AWE: Cleanup loading memlist.bin
14941bf896 AWE: Rename the Graphics base class to Gfx
77b3a8e570 AWE: Graphics beginning to display
2f2fc40e45 AWE: Cleanup of startup code, global static initializations
6582a9fd6c AWE: Adding override keyword
a1af080b6f AWE: Change Gfx::_use555 to use PixelFormat
87ab3aad6d AWE: Use 8-bit screen surface for old DOS version
86de190b02 AWE: Re-add original's script patch for incorrect codes
1c6cb1004e AWE: Update copy protection checks to use game option
f990cedf3f AWE: Remove redundant screenshot taking code
9cf1e662cf AWE: Change Mixer class to Sound to avoid confusion with Audio::Mixer
49ef28b095 AWE: Implemented DOS raw sfx sounds
9681e2ecaa AWE: gcc compilation fixes
77ebbc8e7e AWE: Remove redundant dataDir class fields
013f1006d5 AWE: Fix Windows 3.1 detection entry
7d164dd87b AWE: Further gcc compilation fixes
0e40a74ed6 AWE: Added 20th Anniversary detection entry
fcb8eb43f1 AWE: Remove support for running 3do version from an .iso
bb30b9cd7c AWE: Uppercase static arrays
575e53595d AWE: Assert for graphics interface creation
00c97f62c0 AWE: Remove remaining in-engine scaling code
a73c78e96c AWE: Change _t types to ScummVM equivalent types
f46196d21d AWE: Handle jump keybinding in non-anniversary versions
6621333974 AWE: Janitorial - Consistantly use nullptr instead of 0
c6e7cff0aa AWE: Janitorial - Add some constness
b394667430 AWE: Janitorial - check the other while statements
8bc3ba66cc AWE: Janitorial - add missing default values to switches
64c259ca28 AWE: Janitorial - remove dead code in resource.cpp
687dbacdbd AWE: Remove utils
1ee38274b4 AWE: Fix formatting in resource_3do
01d1b3e634 AWE: Add some stubs in engine.cpp
1d8efad269 AWE: Add Potfiles
70796b68df AWE: Update debug channels
5f26c2f644 AWE: Remove some includes in detection.cpp


Commit: 4f4def25758ff0f76a4e6d134e38fbe4d528172e
    https://github.com/scummvm/scummvm/commit/4f4def25758ff0f76a4e6d134e38fbe4d528172e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Initial re-import of AWE engine

This include a large number of updates to bring the engine
up to date with the current ScummVM architecture. At this
point it's only compiling, still needs a lot of work

Changed paths:
  A engines/awe/awe.cpp
  A engines/awe/awe.h
  A engines/awe/bank.cpp
  A engines/awe/bank.h
  A engines/awe/configure.engine
  A engines/awe/credits.pl
  A engines/awe/detection.cpp
  A engines/awe/detection.h
  A engines/awe/detection_tables.h
  A engines/awe/engine.cpp
  A engines/awe/engine.h
  A engines/awe/file.cpp
  A engines/awe/file.h
  A engines/awe/intern.h
  A engines/awe/logic.cpp
  A engines/awe/logic.h
  A engines/awe/metaengine.cpp
  A engines/awe/metaengine.h
  A engines/awe/module.mk
  A engines/awe/resource.cpp
  A engines/awe/resource.h
  A engines/awe/sdlstub.cpp
  A engines/awe/serializer.cpp
  A engines/awe/serializer.h
  A engines/awe/staticres.cpp
  A engines/awe/systemstub.h
  A engines/awe/util.cpp
  A engines/awe/util.h
  A engines/awe/video.cpp
  A engines/awe/video.h


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
new file mode 100644
index 00000000000..961b5fd4e35
--- /dev/null
+++ b/engines/awe/awe.cpp
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "audio/mixer.h"
+#include "common/config-manager.h"
+#include "engines/util.h"
+#include "awe/awe.h"
+#include "awe/engine.h"
+#include "awe/systemstub.h"
+
+namespace Awe {
+
+AweEngine::AweEngine(OSystem *syst, const ADGameDescription *gameDesc)
+	: Engine(syst) {
+}
+
+Common::Error AweEngine::run() {
+	// Setup mixer
+	if (!_mixer->isReady()) {
+		::warning("Sound initialization failed.");
+	}
+
+	// Initialize backend
+	initGraphics(320, 200);
+
+	// Run the game
+	SystemStub *stub = SystemStub_SDL_create();
+	Awe::Engine *e = new Awe::Engine(stub, nullptr, nullptr);
+	e->run();
+	delete e;
+	delete stub;
+
+	return Common::kNoError;
+}
+
+} // namespace Awe
diff --git a/engines/awe/awe.h b/engines/awe/awe.h
new file mode 100644
index 00000000000..26b5b0f7abf
--- /dev/null
+++ b/engines/awe/awe.h
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AWE_AWE_H
+#define AWE_AWE_H
+
+#include "common/scummsys.h"
+#include "engines/engine.h"
+#include "awe/detection.h"
+
+namespace Awe {
+
+#define BYPASS_PROTECTION
+
+enum AWEGameId {
+	GID_WORLDE
+};
+
+class AweEngine : public Engine {
+private:
+	const ADGameDescription *_gameDescription;
+
+public:
+	AweEngine(OSystem *syst, const ADGameDescription *gameDesc);
+	virtual ~AweEngine() {}
+
+	Common::Error run() override;
+
+};
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/bank.cpp b/engines/awe/bank.cpp
new file mode 100644
index 00000000000..5ed47a05cf1
--- /dev/null
+++ b/engines/awe/bank.cpp
@@ -0,0 +1,146 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/file.h"
+#include "awe/awe.h"
+#include "awe/bank.h"
+#include "awe/resource.h"
+
+namespace Awe {
+
+Bank::Bank(const char *dataDir)
+	: _dataDir(dataDir) {
+}
+
+bool Bank::read(const MemEntry *me, uint8 *buf) {
+	bool ret = false;
+	char bankName[10];
+	Common::sprintf_s(bankName, "bank%02x", me->bankNum);
+	Common::File f;
+
+	if (f.open(bankName)) {
+		f.seek(me->bankPos);
+		if (me->packedSize == me->unpackedSize) {
+			f.read(buf, me->packedSize);
+			ret = true;
+		} else {
+			f.read(buf, me->packedSize);
+			_startBuf = buf;
+			_iBuf = buf + me->packedSize - 4;
+			ret = unpack();
+		}
+	} else {
+		::error("Bank::read() unable to open '%s'", bankName);
+	}
+
+	return ret;
+}
+
+void Bank::decUnk1(uint8 numChunks, uint8 addCount) {
+	uint16 count = getCode(numChunks) + addCount + 1;
+	debug(DBG_BANK, "Bank::decUnk1(%d, %d) count=%d", numChunks, addCount, count);
+	_unpCtx.datasize -= count;
+	while (count--) {
+		assert(_oBuf >= _iBuf && _oBuf >= _startBuf);
+		*_oBuf = (uint8)getCode(8);
+		--_oBuf;
+	}
+}
+
+void Bank::decUnk2(uint8 numChunks) {
+	uint16 i = getCode(numChunks);
+	uint16 count = _unpCtx.size + 1;
+	debug(DBG_BANK, "Bank::decUnk2(%d) i=%d count=%d", numChunks, i, count);
+	_unpCtx.datasize -= count;
+	while (count--) {
+		assert(_oBuf >= _iBuf && _oBuf >= _startBuf);
+		*_oBuf = *(_oBuf + i);
+		--_oBuf;
+	}
+}
+
+bool Bank::unpack() {
+	_unpCtx.size = 0;
+	_unpCtx.datasize = READ_BE_UINT32(_iBuf); _iBuf -= 4;
+	_oBuf = _startBuf + _unpCtx.datasize - 1;
+	_unpCtx.crc = READ_BE_UINT32(_iBuf); _iBuf -= 4;
+	_unpCtx.chk = READ_BE_UINT32(_iBuf); _iBuf -= 4;
+	_unpCtx.crc ^= _unpCtx.chk;
+	do {
+		if (!nextChunk()) {
+			_unpCtx.size = 1;
+			if (!nextChunk()) {
+				decUnk1(3, 0);
+			} else {
+				decUnk2(8);
+			}
+		} else {
+			uint16 c = getCode(2);
+			if (c == 3) {
+				decUnk1(8, 8);
+			} else {
+				if (c < 2) {
+					_unpCtx.size = c + 2;
+					decUnk2(c + 9);
+				} else {
+					_unpCtx.size = getCode(8);
+					decUnk2(12);
+				}
+			}
+		}
+	} while (_unpCtx.datasize > 0);
+
+	return (_unpCtx.crc == 0);
+}
+
+uint16 Bank::getCode(uint8 numChunks) {
+	uint16 c = 0;
+	while (numChunks--) {
+		c <<= 1;
+		if (nextChunk()) {
+			c |= 1;
+		}			
+	}
+
+	return c;
+}
+
+bool Bank::nextChunk() {
+	bool CF = rcr(false);
+	if (_unpCtx.chk == 0) {
+		assert(_iBuf >= _startBuf);
+		_unpCtx.chk = READ_BE_UINT32(_iBuf); _iBuf -= 4;
+		_unpCtx.crc ^= _unpCtx.chk;
+		CF = rcr(true);
+	}
+
+	return CF;
+}
+
+bool Bank::rcr(bool CF) {
+	bool rCF = (_unpCtx.chk & 1);
+	_unpCtx.chk >>= 1;
+	if (CF) _unpCtx.chk |= 0x80000000;
+
+	return rCF;
+}
+
+} // namespace Awe
diff --git a/engines/awe/bank.h b/engines/awe/bank.h
new file mode 100644
index 00000000000..1becd8c6717
--- /dev/null
+++ b/engines/awe/bank.h
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AWE_BANK_H
+#define AWE_BANK_H
+
+#include "awe/intern.h"
+
+namespace Awe {
+
+struct MemEntry;
+
+struct UnpackContext {
+	uint16 size;
+	uint32 crc;
+	uint32 chk;
+	int32 datasize;
+};
+
+struct Bank {
+	UnpackContext _unpCtx;
+	const char *_dataDir;
+	uint8 *_iBuf, *_oBuf, *_startBuf;
+
+	Bank(const char *dataDir);
+
+	bool read(const MemEntry *me, uint8 *buf);
+	void decUnk1(uint8 numChunks, uint8 addCount);
+	void decUnk2(uint8 numChunks);
+	bool unpack();
+	uint16 getCode(uint8 numChunks);
+	bool nextChunk();
+	bool rcr(bool CF);
+};
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/configure.engine b/engines/awe/configure.engine
new file mode 100644
index 00000000000..3ebfbe00f20
--- /dev/null
+++ b/engines/awe/configure.engine
@@ -0,0 +1,3 @@
+# This file is included from the main "configure" script
+# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] [components]
+add_engine awe "Another World" no "" "" "" ""
diff --git a/engines/awe/credits.pl b/engines/awe/credits.pl
new file mode 100644
index 00000000000..58aec11e6c6
--- /dev/null
+++ b/engines/awe/credits.pl
@@ -0,0 +1,4 @@
+begin_section("awe");
+	add_person("Gregory Montoir", "cyx", "");
+	add_person("Paul Gilbert", "dreammaster", "");
+end_section();
diff --git a/engines/awe/detection.cpp b/engines/awe/detection.cpp
new file mode 100644
index 00000000000..0a9dde56d93
--- /dev/null
+++ b/engines/awe/detection.cpp
@@ -0,0 +1,41 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "base/plugins.h"
+#include "common/config-manager.h"
+#include "common/file.h"
+#include "common/md5.h"
+#include "common/str-array.h"
+#include "common/translation.h"
+#include "common/util.h"
+#include "awe/detection.h"
+#include "awe/detection_tables.h"
+
+const DebugChannelDef AweMetaEngineDetection::debugFlagList[] = {
+	{ Awe::kDebugGraphics, "Graphics", "Graphics debug level" },
+	DEBUG_CHANNEL_END
+};
+
+AweMetaEngineDetection::AweMetaEngineDetection() : AdvancedMetaEngineDetection(
+	Awe::gameDescriptions, Awe::aweGames) {
+}
+
+REGISTER_PLUGIN_STATIC(AWE_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, AweMetaEngineDetection);
diff --git a/engines/awe/detection.h b/engines/awe/detection.h
new file mode 100644
index 00000000000..e57d59a0202
--- /dev/null
+++ b/engines/awe/detection.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 AWE_DETECTION_H
+#define AWE_DETECTION_H
+
+#include "engines/advancedDetector.h"
+
+namespace Awe {
+
+enum AweDebugChannels {
+	kDebugGraphics = 1
+};
+
+extern const PlainGameDescriptor aweGames[];
+
+extern const ADGameDescription gameDescriptions[];
+
+#define GAMEOPTION_ORIGINAL_SAVELOAD GUIO_GAMEOPTIONS1
+
+} // namespace Awe
+
+class AweMetaEngineDetection : public AdvancedMetaEngineDetection<ADGameDescription> {
+	static const DebugChannelDef debugFlagList[];
+
+public:
+	AweMetaEngineDetection();
+	~AweMetaEngineDetection() override {}
+
+	const char *getName() const override {
+		return "awe";
+	}
+
+	const char *getEngineName() const override {
+		return "Awe";
+	}
+
+	const char *getOriginalCopyright() const override {
+		return "Out of This World (C) 1991 by Delphine Software International";
+	}
+
+	const DebugChannelDef *getDebugChannels() const override {
+		return debugFlagList;
+	}
+};
+
+#endif
diff --git a/engines/awe/detection_tables.h b/engines/awe/detection_tables.h
new file mode 100644
index 00000000000..f3257d4a8f4
--- /dev/null
+++ b/engines/awe/detection_tables.h
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Awe {
+
+const PlainGameDescriptor aweGames[] = {
+	{ "anotherworld", "Another World - Out of this World" },
+	{ 0, 0 }
+};
+
+const ADGameDescription gameDescriptions[] = {
+	{
+		"anotherworld",
+		nullptr,
+		AD_ENTRY1s("bank", "30fb99cb4cbd812273d0b54b7b4a18ca", 987462),
+		Common::EN_ANY,
+		Common::kPlatformDOS,
+		ADGF_UNSTABLE,
+		GUIO1(GUIO_NONE)
+	},
+
+	AD_TABLE_END_MARKER
+};
+
+} // End of namespace Awe
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
new file mode 100644
index 00000000000..c07c2547ce9
--- /dev/null
+++ b/engines/awe/engine.cpp
@@ -0,0 +1,150 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/str.h"
+#include "awe/awe.h"
+#include "awe/engine.h"
+#include "awe/file.h"
+#include "awe/serializer.h"
+#include "awe/systemstub.h"
+
+namespace Awe {
+
+Engine::Engine(SystemStub *stub, const char *dataDir, const char *saveDir)
+	: _stub(stub), _log(&_res, &_vid, stub), _res(&_vid, dataDir), _vid(&_res, stub), 
+	_dataDir(dataDir), _saveDir(saveDir), _stateSlot(0) {
+}
+
+void Engine::run() {
+	_stub->init("Out Of This World");
+	setup();
+	// XXX
+	_log.restartAt(0x3E80); // demo starts at 0x3E81
+	while (!_stub->_pi.quit) {
+		_log.setupScripts();
+		_log.inp_updatePlayer();
+		processInput();
+		_log.runScripts();
+	}
+	finish();
+	_stub->destroy();
+}
+
+void Engine::setup() {
+	_vid.init();
+	_res.allocMemBlock();
+	_res.readEntries();
+	_log.init();
+}
+
+void Engine::finish() {
+	 // XXX
+	 _res.freeMemBlock();
+}
+
+void Engine::processInput() {
+	if (_stub->_pi.load) {
+		loadGameState(_stateSlot);
+		_stub->_pi.load = false;
+	}
+	if (_stub->_pi.save) {
+		saveGameState(_stateSlot, "quicksave");
+		_stub->_pi.save = false;
+	}
+	if (_stub->_pi.fastMode) {
+		_log._fastMode = !_log._fastMode;
+		_stub->_pi.fastMode = false;
+	}
+	if (_stub->_pi.stateSlot != 0) {
+		int8 slot = _stateSlot + _stub->_pi.stateSlot;
+		if (slot >= 0 && slot < MAX_SAVE_SLOTS) {
+			_stateSlot = slot;
+			debug(DBG_INFO, "Current game state slot is %d", _stateSlot);
+		}
+		_stub->_pi.stateSlot = 0;
+	}
+}
+
+void Engine::makeGameStateName(uint8 slot, char *buf) {
+	Common::sprintf_s(buf, 256, "raw.s%02d", slot);
+}
+
+void Engine::saveGameState(uint8 slot, const char *desc) {
+#ifdef TODO
+	char stateFile[20];
+	makeGameStateName(slot, stateFile);
+	File f(true);
+	if (!f.open(stateFile, _saveDir, "wb")) {
+		::warning("Unable to save state file '%s'", stateFile);
+	} else {
+		// header
+		f.writeUint32BE('AWSV');
+		f.writeUint16BE(Serializer::CUR_VER);
+		f.writeUint16BE(0);
+		char hdrdesc[32];
+		strncpy(hdrdesc, desc, sizeof(hdrdesc) - 1);
+		f.write(hdrdesc, sizeof(hdrdesc));
+		// contents
+		Serializer s(&f, Serializer::SM_SAVE, _res._memPtrStart);
+		_log.saveOrLoad(s);
+		_res.saveOrLoad(s);
+		_vid.saveOrLoad(s);
+		if (f.ioErr()) {
+			::warning("I/O error when saving game state");
+		} else {
+			debug(DBG_INFO, "Saved state to slot %d", _stateSlot);
+		}
+	}
+#endif
+}
+
+void Engine::loadGameState(uint8 slot) {
+#ifdef TODO
+	char stateFile[20];
+	makeGameStateName(slot, stateFile);
+	File f(true);
+	if (!f.open(stateFile, _saveDir, "rb")) {
+		::warning("Unable to open state file '%s'", stateFile);
+	} else {
+		uint32 id = f.readUint32BE();
+		if (id != 'AWSV') {
+			::warning("Bad savegame format");
+		} else {
+			uint16 ver = f.readUint16BE();
+			f.readUint16BE();
+			char hdrdesc[32];
+			f.read(hdrdesc, sizeof(hdrdesc));
+			// contents
+			Serializer s(&f, Serializer::SM_LOAD, _res._memPtrStart, ver);
+			_log.saveOrLoad(s);
+			_res.saveOrLoad(s);
+			_vid.saveOrLoad(s);
+		}
+		if (f.ioErr()) {
+			::warning("I/O error when loading game state");
+		} else {
+			debug(DBG_INFO, "Loaded state from slot %d", _stateSlot);
+		}
+	}
+#endif
+}
+
+} // namespace Awe
diff --git a/engines/awe/engine.h b/engines/awe/engine.h
new file mode 100644
index 00000000000..d5daf1dc764
--- /dev/null
+++ b/engines/awe/engine.h
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AWE_ENGINE_H
+#define AWE_ENGINE_H
+
+#include "awe/intern.h"
+#include "awe/logic.h"
+#include "awe/resource.h"
+#include "awe/video.h"
+
+namespace Awe {
+
+struct SystemStub;
+
+struct Engine {
+	enum {
+		MAX_SAVE_SLOTS = 100
+	};
+
+	SystemStub *_stub;
+	Logic _log;
+	Resource _res;
+	Video _vid;
+	const char *_dataDir, *_saveDir;
+	uint8 _stateSlot;
+
+	Engine(SystemStub *stub, const char *dataDir, const char *saveDir);
+
+	void run();
+	void setup();
+	void finish();
+	void processInput();
+	
+	void makeGameStateName(uint8 slot, char *buf);
+	void saveGameState(uint8 slot, const char *desc);
+	void loadGameState(uint8 slot);
+};
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/file.cpp b/engines/awe/file.cpp
new file mode 100644
index 00000000000..e6785b139cb
--- /dev/null
+++ b/engines/awe/file.cpp
@@ -0,0 +1,191 @@
+/* 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 "awe/file.h"
+
+namespace Awe {
+#ifdef DEPRECATED
+
+struct File_impl {
+	bool _ioErr;
+	File_impl() : _ioErr(false) {}
+	virtual bool open(const char *path, const char *mode) = 0;
+	virtual void close() = 0;
+	virtual void seek(int32 off) = 0;
+	virtual void read(void *ptr, uint32 size) = 0;
+	virtual void write(void *ptr, uint32 size) = 0;
+};
+
+struct stdFile : File_impl {
+	FILE *_fp;
+	stdFile() : _fp(0) {}
+	bool open(const char *path, const char *mode) {
+		_ioErr = false;
+		_fp = fopen(path, mode);
+		return (_fp != NULL);
+	}
+	void close() {
+		if (_fp) {
+			fclose(_fp);
+			_fp = 0;
+		}
+	}
+	void seek(int32 off) {
+		if (_fp) {
+			fseek(_fp, off, SEEK_SET);
+		}
+	}
+	void read(void *ptr, uint32 size) {
+		if (_fp) {
+			uint32 r = fread(ptr, 1, size, _fp);
+			if (r != size) {
+				_ioErr = true;
+			}
+		}
+	}
+	void write(void *ptr, uint32 size) {
+		if (_fp) {
+			uint32 r = fwrite(ptr, 1, size, _fp);
+			if (r != size) {
+				_ioErr = true;
+			}
+		}
+	}
+};
+
+struct zlibFile : File_impl {
+	gzFile _fp;
+	zlibFile() : _fp(0) {}
+	bool open(const char *path, const char *mode) {
+		_ioErr = false;
+		_fp = gzopen(path, mode);
+		return (_fp != NULL);
+	}
+	void close() {
+		if (_fp) {
+			gzclose(_fp);
+			_fp = 0;
+		}
+	}
+	void seek(int32 off) {
+		if (_fp) {
+			gzseek(_fp, off, SEEK_SET);
+		}
+	}
+	void read(void *ptr, uint32 size) {
+		if (_fp) {
+			uint32 r = gzread(_fp, ptr, size);
+			if (r != size) {
+				_ioErr = true;
+			}
+		}
+	}
+	void write(void *ptr, uint32 size) {
+		if (_fp) {
+			uint32 r = gzwrite(_fp, ptr, size);
+			if (r != size) {
+				_ioErr = true;
+			}
+		}
+	}
+};
+
+File::File(bool gzipped) {
+	if (gzipped) {
+		_impl = new zlibFile;
+	} else {
+		_impl = new stdFile;
+	}
+}
+
+File::~File() {
+	_impl->close();
+	delete _impl;
+}
+
+bool File::open(const char *filename, const char *directory, const char *mode) {	
+	_impl->close();
+	char buf[512];
+	sprintf(buf, "%s/%s", directory, filename);
+	char *p = buf + strlen(directory) + 1;
+	string_lower(p);
+	bool opened = _impl->open(buf, mode);
+	if (!opened) { // let's try uppercase
+		string_upper(p);
+		opened = _impl->open(buf, mode);
+	}
+	return opened;
+}
+
+void File::close() {
+	_impl->close();
+}
+
+bool File::ioErr() const {
+	return _impl->_ioErr;
+}
+
+void File::seek(int32 off) {
+	_impl->seek(off);
+}
+
+void File::read(void *ptr, uint32 size) {
+	_impl->read(ptr, size);
+}
+
+uint8 File::readByte() {
+	uint8 b;
+	read(&b, 1);
+	return b;
+}
+
+uint16 File::readUint16BE() {
+	uint8 hi = readByte();
+	uint8 lo = readByte();
+	return (hi << 8) | lo;
+}
+
+uint32 File::readUint32BE() {
+	uint16 hi = readUint16BE();
+	uint16 lo = readUint16BE();
+	return (hi << 16) | lo;
+}
+
+void File::write(void *ptr, uint32 size) {
+	_impl->write(ptr, size);
+}
+
+void File::writeByte(uint8 b) {
+	write(&b, 1);
+}
+
+void File::writeUint16BE(uint16 n) {
+	writeByte(n >> 8);
+	writeByte(n & 0xFF);
+}
+
+void File::writeUint32BE(uint32 n) {
+	writeUint16BE(n >> 16);
+	writeUint16BE(n & 0xFFFF);
+}
+#endif
+
+} // namespace Awe
diff --git a/engines/awe/file.h b/engines/awe/file.h
new file mode 100644
index 00000000000..ef23b409777
--- /dev/null
+++ b/engines/awe/file.h
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AWE_FILE_H
+#define AWE_FILE_H
+
+#include "awe/intern.h"
+
+namespace Awe {
+#ifdef DEPRECATED
+struct File_impl;
+
+struct File {
+	File_impl *_impl;
+
+	File(bool gzipped = false);
+	~File();
+
+	bool open(const char *filename, const char *directory, const char *mode="rb");
+	void close();
+	bool ioErr() const;
+	void seek(int32 off);
+	void read(void *ptr, uint32 size);
+	uint8 readByte();
+	uint16 readUint16BE();
+	uint32 readUint32BE();
+	void write(void *ptr, uint32 size);
+	void writeByte(uint8 b);
+	void writeUint16BE(uint16 n);
+	void writeUint32BE(uint32 n);
+};
+#endif
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/intern.h b/engines/awe/intern.h
new file mode 100644
index 00000000000..d55a1d2535f
--- /dev/null
+++ b/engines/awe/intern.h
@@ -0,0 +1,50 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AWE_INTERN_H
+#define AWE_INTERN_H
+
+#include "common/algorithm.h"
+#include "common/endian.h"
+#include "common/rect.h"
+#include "awe/util.h"
+
+namespace Awe {
+
+using Common::Point;
+
+struct Ptr {
+	uint8 *pc;
+	
+	uint8 fetchByte() {
+		return *pc++;
+	}
+	
+	uint16 fetchWord() {
+		uint16 i = READ_BE_UINT16(pc);
+		pc += 2;
+		return i;
+	}
+};
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/logic.cpp b/engines/awe/logic.cpp
new file mode 100644
index 00000000000..f40f5bb3936
--- /dev/null
+++ b/engines/awe/logic.cpp
@@ -0,0 +1,513 @@
+/* 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 "awe/awe.h"
+#include "awe/logic.h"
+#include "awe/resource.h"
+#include "awe/video.h"
+#include "awe/serializer.h"
+#include "awe/systemstub.h"
+
+namespace Awe {
+
+Logic::Logic(Resource *res, Video *vid, SystemStub *stub)
+	: _res(res), _vid(vid), _stub(stub) {
+}
+
+void Logic::init() {
+	memset(_scriptVars, 0, sizeof(_scriptVars));
+	_scriptVars[0x54] = 0x81;
+	_scriptVars[VAR_RANDOM_SEED] = 0;
+#ifdef DEPRECATED
+	time(0);
+#endif
+	_fastMode = false;
+}
+
+void Logic::op_movConst() {
+	uint8 i = _scriptPtr.fetchByte();
+	int16 n = _scriptPtr.fetchWord();
+	debug(DBG_LOGIC, "Logic::op_movConst(0x%02X, %d)", i, n);
+	_scriptVars[i] = n;
+}
+
+void Logic::op_mov() {
+	uint8 i = _scriptPtr.fetchByte();
+	uint8 j = _scriptPtr.fetchByte();	
+	debug(DBG_LOGIC, "Logic::op_mov(0x%02X, 0x%02X)", i, j);
+	_scriptVars[i] = _scriptVars[j];
+}
+
+void Logic::op_add() {
+	uint8 i = _scriptPtr.fetchByte();
+	uint8 j = _scriptPtr.fetchByte();
+	debug(DBG_LOGIC, "Logic::op_add(0x%02X, 0x%02X)", i, j);
+	_scriptVars[i] += _scriptVars[j];
+}
+
+void Logic::op_addConst() {
+	uint8 i = _scriptPtr.fetchByte();
+	int16 n = _scriptPtr.fetchWord();
+	debug(DBG_LOGIC, "Logic::op_addConst(0x%02X, %d)", i, n);
+	_scriptVars[i] += n;
+}
+
+void Logic::op_call() {
+	uint16 off = _scriptPtr.fetchWord();
+	uint8 sp = _stackPtr;
+	debug(DBG_LOGIC, "Logic::op_call(0x%X)", off);
+	_scriptStackCalls[sp] = _scriptPtr.pc - _res->_segCode;
+	++_stackPtr;
+	_scriptPtr.pc = _res->_segCode + off;
+}
+
+void Logic::op_ret() {
+	debug(DBG_LOGIC, "Logic::op_ret()");
+	--_stackPtr;
+	uint8 sp = _stackPtr;
+	_scriptPtr.pc = _res->_segCode + _scriptStackCalls[sp];
+}
+
+void Logic::op_break() {
+	debug(DBG_LOGIC, "Logic::op_break()");
+	_scriptHalted = true;
+}
+
+void Logic::op_jmp() {
+	uint16 off = _scriptPtr.fetchWord();
+	debug(DBG_LOGIC, "Logic::op_jmp(0x%02X)", off);
+	_scriptPtr.pc = _res->_segCode + off;	
+}
+
+void Logic::op_setScriptPos() {
+	uint8 i = _scriptPtr.fetchByte();
+	uint16 n = _scriptPtr.fetchWord();
+	debug(DBG_LOGIC, "Logic::op_setScriptPos(0x%X, 0x%X)", i, n);
+	_scriptPos[1][i] = n;
+}
+
+void Logic::op_jnz() {
+	uint8 i = _scriptPtr.fetchByte();
+	debug(DBG_LOGIC, "Logic::op_jnz(0x%02X)", i);
+	--_scriptVars[i];
+	if (_scriptVars[i] != 0) {
+		op_jmp();
+	} else {
+		_scriptPtr.fetchWord();
+	}
+}
+
+void Logic::op_condJmp() {
+#ifdef BYPASS_PROTECTION
+	if (_res->_curPtrsId == 0x3E80 && _scriptPtr.pc == _res->_segCode + 0xCB9) {
+		// (0x0CB8) condJmp(0x80, VAR(41), VAR(30), 0xCD3)
+		*(_scriptPtr.pc + 0x00) = 0x81;
+		*(_scriptPtr.pc + 0x03) = 0x0D;
+		*(_scriptPtr.pc + 0x04) = 0x24;
+		// (0x0D4E) condJmp(0x4, VAR(50), 6, 0xDBC)		
+		*(_scriptPtr.pc + 0x99) = 0x0D;
+		*(_scriptPtr.pc + 0x9A) = 0x5A;
+		::warning("Logic::op_condJmp() bypassing protection");	
+	}
+#endif
+	uint8 op = _scriptPtr.fetchByte();
+	int16 b = _scriptVars[_scriptPtr.fetchByte()];
+	int16 a = _scriptPtr.fetchByte();	
+	if (op & 0x80) {
+		a = _scriptVars[a];
+	} else {
+		if (op & 0x40) {
+			a = (a << 8) | _scriptPtr.fetchByte();
+		}
+	}
+	debug(DBG_LOGIC, "Logic::op_condJmp(%d, 0x%02X, 0x%02X)", op, b, a);
+	bool expr = false;
+	switch (op & 7) {
+	case 0:	// jz
+		expr = (b == a);
+		break;
+	case 1: // jnz
+		expr = (b != a);
+		break;
+	case 2: // jg
+		expr = (b > a);
+		break;
+	case 3: // jge
+		expr = (b >= a);
+		break;
+	case 4: // jl
+		expr = (b < a);
+		break;
+	case 5: // jle
+		expr = (b <= a);
+		break;
+	default:
+		::warning("Logic::op_condJmp() invalid condition %d", (op & 7));
+		break;
+	}
+	if (expr) {
+		op_jmp();
+	} else {
+		_scriptPtr.fetchWord();
+	}
+}
+
+void Logic::op_setPalette() {
+	uint16 i = _scriptPtr.fetchWord();
+	debug(DBG_LOGIC, "Logic::op_changePalette(%d)", i);
+	_vid->_newPal = i >> 8;
+}
+
+void Logic::op_resetScript() {
+	uint8 j = _scriptPtr.fetchByte();
+	uint8 i = _scriptPtr.fetchByte();
+	int8 n = (i & 0x3F) - j;
+	if (n < 0) {
+		::warning("Logic::op_resetScript() ec=0x%X (n < 0)", 0x880);
+		return;
+	}
+	++n;
+	uint8 _al = _scriptPtr.fetchByte();
+
+	debug(DBG_LOGIC, "Logic::op_resetScript(%d, %d, %d)", j, i, _al);
+
+	if (_al == 2) {
+		uint16 *_si = &_scriptPos[1][j];
+		while (n--) {
+			*_si = 0xFFFE;
+			++_si;
+		}
+	} else if (_al < 2) {
+		uint8 *_si = &_scriptPaused[1][j];
+		while (n--) {
+			*_si = _al;
+			++_si;
+		}
+	}
+}
+
+void Logic::op_selectPage() {
+	uint8 i = _scriptPtr.fetchByte();
+	debug(DBG_LOGIC, "Logic::op_selectPage(%d)", i);
+	_vid->changePagePtr1(i);
+}
+
+void Logic::op_fillPage() {
+	uint8 screen = _scriptPtr.fetchByte();
+	uint8 color = _scriptPtr.fetchByte();
+	debug(DBG_LOGIC, "Logic::op_fillPage(%d, %d)", screen, color);
+	_vid->fillPage(screen, color);
+}
+
+void Logic::op_copyPage() {
+	uint8 i = _scriptPtr.fetchByte();
+	uint8 j = _scriptPtr.fetchByte();
+	debug(DBG_LOGIC, "Logic::op_copyPage(%d, %d)", i, j);
+	_vid->copyPage(i, j, _scriptVars[VAR_SCROLL_Y]);
+}
+
+void Logic::op_updateDisplay() {
+	uint8 page = _scriptPtr.fetchByte();
+	debug(DBG_LOGIC, "Logic::op_updateDisplay(%d)", page);
+	inp_handleSpecialKeys();
+	if (_res->_curPtrsId == 0x3E80 && _scriptVars[0x67] == 1) {
+		_scriptVar_0xBF = _scriptVars[0xBF];
+		_scriptVars[0xDC] = 0x21;
+	}
+
+	static uint32 tstamp = 0;
+	if (!_fastMode) {
+		// XXX experimental
+		int32 delay = _stub->getTimeStamp() - tstamp;
+		int32 pause = _scriptVars[VAR_PAUSE_SLICES] * 20 - delay;
+		if (pause > 0) {
+			_stub->sleep(pause);
+		}
+	}
+	_scriptVars[0xF7] = 0;
+
+	_vid->updateDisplay(page);
+	tstamp = _stub->getTimeStamp();
+}
+
+void Logic::op_halt() {
+	debug(DBG_LOGIC, "Logic::op_halt()");
+	_scriptPtr.pc = _res->_segCode + 0xFFFF;
+	_scriptHalted = true;
+}
+
+void Logic::op_drawString() {
+	uint16 strId = _scriptPtr.fetchWord();
+	uint16 x = _scriptPtr.fetchByte();
+	uint16 y = _scriptPtr.fetchByte();
+	uint16 col = _scriptPtr.fetchByte();
+	debug(DBG_LOGIC, "Logic::op_drawString(0x%03X, %d, %d, %d)", strId, x, y, col);
+	_vid->drawString(col, x, y, strId);
+}
+
+void Logic::op_sub() {
+	uint8 i = _scriptPtr.fetchByte();
+	uint8 j = _scriptPtr.fetchByte();
+	debug(DBG_LOGIC, "Logic::op_sub(0x%02X, 0x%02X)", i, j);
+	_scriptVars[i] -= _scriptVars[j];
+}
+
+void Logic::op_and() {
+	uint8 i = _scriptPtr.fetchByte();
+	uint16 n = _scriptPtr.fetchWord();
+	debug(DBG_LOGIC, "Logic::op_and(0x%02X, %d)", i, n);
+	_scriptVars[i] = (uint16)_scriptVars[i] & n;
+}
+
+void Logic::op_or() {
+	uint8 i = _scriptPtr.fetchByte();
+	uint16 n = _scriptPtr.fetchWord();
+	debug(DBG_LOGIC, "Logic::op_or(0x%02X, %d)", i, n);
+	_scriptVars[i] = (uint16)_scriptVars[i] | n;
+}
+
+void Logic::op_shl() {
+	uint8 i = _scriptPtr.fetchByte();
+	uint16 n = _scriptPtr.fetchWord();
+	debug(DBG_LOGIC, "Logic::op_shl(0x%02X, %d)", i, n);
+	_scriptVars[i] = (uint16)_scriptVars[i] << n;
+}
+
+void Logic::op_shr() {
+	uint8 i = _scriptPtr.fetchByte();
+	uint16 n = _scriptPtr.fetchWord();
+	debug(DBG_LOGIC, "Logic::op_shr(0x%02X, %d)", i, n);
+	_scriptVars[i] = (uint16)_scriptVars[i] >> n;
+}
+
+void Logic::op_soundUnk1() {
+	uint16 b = _scriptPtr.fetchWord();
+	uint16 c = _scriptPtr.fetchWord();
+	uint8 a = _scriptPtr.fetchByte();
+	debug(DBG_LOGIC, "Logic::op_soundUnk1(0x%X, 0x%X, %d)", b, c, a);
+	// XXX
+}
+
+void Logic::op_updateMemList() {
+	uint16 num = _scriptPtr.fetchWord();
+	debug(DBG_LOGIC, "Logic::op_updateMemList(%d)", num);
+	_res->update(num);
+}
+
+void Logic::op_soundUnk2() {
+	uint16 b = _scriptPtr.fetchWord();
+	uint16 c = _scriptPtr.fetchWord();
+	uint8 a = _scriptPtr.fetchByte();
+	debug(DBG_LOGIC, "Logic::op_soundUnk2(0x%X, 0x%X, %d)", b, c, a);
+	// XXX
+}
+
+void Logic::restartAt(uint16 ptrId) {
+	// XXX
+	_scriptVars[0xE4] = 0x14;
+	_res->setupPtrs(ptrId);
+	memset((uint8 *)_scriptPos, 0xFF, sizeof(_scriptPos));
+	memset((uint8 *)_scriptPaused, 0, sizeof(_scriptPaused));
+	_scriptPos[0][0] = 0;	
+}
+
+void Logic::setupScripts() {
+	if (_res->_newPtrsId != 0) {
+		restartAt(_res->_newPtrsId);
+		_res->_newPtrsId = 0;
+	}
+	for (int i = 0; i < 0x40; ++i) {
+		_scriptPaused[0][i] = _scriptPaused[1][i];
+		uint16 n = _scriptPos[1][i];
+		if (n != 0xFFFF) {
+			_scriptPos[0][i] = (n == 0xFFFE) ? 0xFFFF : n;
+			_scriptPos[1][i] = 0xFFFF;
+		}
+	}
+}
+
+void Logic::runScripts() {
+	for (int i = 0; i < 0x40; ++i) {
+		if (_scriptPaused[0][i] == 0) {
+			uint16 n = _scriptPos[0][i];
+			if (n != 0xFFFF) {
+				_scriptPtr.pc = _res->_segCode + n;
+				_stackPtr = 0;
+				_scriptHalted = false;
+				debug(DBG_LOGIC, "Logic::runScripts() i=0x%02X n=0x%02X *p=0x%02X", i, n, *_scriptPtr.pc);
+				executeScript();
+				_scriptPos[0][i] = _scriptPtr.pc - _res->_segCode;
+				debug(DBG_LOGIC, "Logic::runScripts() i=0x%02X pos=0x%X", i, _scriptPos[0][i]);
+				if (_stub->_pi.quit) {
+					break;
+				}
+			}
+		}
+	}
+}
+
+void Logic::executeScript() {
+	while (!_scriptHalted) {
+		uint8 opcode = _scriptPtr.fetchByte();
+		if (opcode & 0x80) {
+			uint16 off = ((opcode << 8) | _scriptPtr.fetchByte()) * 2;
+			_res->_useSegVideo2 = false;
+			int16 x = _scriptPtr.fetchByte();
+			int16 y = _scriptPtr.fetchByte();
+			int16 h = y - 199;
+			if (h > 0) {
+				y = 199;
+				x += h;
+			}
+			debug(DBG_VIDEO, "vid_opcd_0x80 : opcode=0x%X off=0x%X x=%d y=%d", opcode, off, x, y);
+			_vid->setDataBuffer(_res->_segVideo1, off);
+			_vid->drawShape(0xFF, 0x40, Point(x,y));
+		} else if (opcode & 0x40) {
+			int16 x, y;
+			uint16 off = _scriptPtr.fetchWord() * 2;
+			x = _scriptPtr.fetchByte();
+			_res->_useSegVideo2 = false;
+			if (!(opcode & 0x20)) {
+				if (!(opcode & 0x10)) {
+					x = (x << 8) | _scriptPtr.fetchByte();
+				} else {
+					x = _scriptVars[x];
+				}
+			} else {
+				if (opcode & 0x10) {
+					x += 0x100;
+				}
+			}
+			y = _scriptPtr.fetchByte();
+			if (!(opcode & 8)) {
+				if (!(opcode & 4)) {
+					y = (y << 8) | _scriptPtr.fetchByte();
+				} else {
+					y = _scriptVars[y];
+				}
+			}
+			uint16 zoom = _scriptPtr.fetchByte();
+			if (!(opcode & 2)) {
+				if (!(opcode & 1)) {
+					--_scriptPtr.pc;
+					zoom = 0x40;
+				} else {
+					zoom = _scriptVars[zoom];
+				}
+			} else {
+				if (opcode & 1) {
+					_res->_useSegVideo2 = true;
+					--_scriptPtr.pc;
+					zoom = 0x40;
+				}
+			}
+			debug(DBG_VIDEO, "vid_opcd_0x40 : off=0x%X x=%d y=%d", off, x, y);
+			_vid->setDataBuffer(_res->_useSegVideo2 ? _res->_segVideo2 : _res->_segVideo1, off);
+			_vid->drawShape(0xFF, zoom, Point(x, y));
+		} else {
+			if (opcode > 0x1A) {
+				::error("Logic::executeScript() ec=0x%X invalid opcode=0x%X", 0xFFF, opcode);
+			} else {
+				(this->*_opTable[opcode])();
+			}
+		}
+	}
+}
+
+void Logic::inp_updatePlayer() {
+	_stub->processEvents();
+	if (_res->_curPtrsId == 0x3E89) {
+		char c = _stub->_pi.lastChar;
+		if (c == 8 || /*c == 0xD ||*/ c == 0 || (c >= 'a' && c <= 'z')) {
+			_scriptVars[VAR_LAST_KEYCHAR] = c & ~0x20;
+			_stub->_pi.lastChar = 0;
+		}
+	}
+	int16 lr = 0;
+	int16 m = 0;
+	int16 ud = 0;
+	if (_stub->_pi.dirMask & PlayerInput::DIR_RIGHT) {
+		lr = 1;
+		m |= 1;
+	}
+	if (_stub->_pi.dirMask & PlayerInput::DIR_LEFT) {
+		lr = -1;
+		m |= 2;
+	}
+	if (_stub->_pi.dirMask & PlayerInput::DIR_DOWN) {
+		ud = 1;
+		m |= 4;
+	}
+	_scriptVars[VAR_HERO_POS_UP_DOWN] = ud;
+	if (_stub->_pi.dirMask & PlayerInput::DIR_UP) {
+		_scriptVars[VAR_HERO_POS_UP_DOWN] = -1;
+	}
+	if (_stub->_pi.dirMask & PlayerInput::DIR_UP) { // inpJump
+		ud = -1;
+		m |= 8;
+	}
+	_scriptVars[VAR_HERO_POS_JUMP_DOWN] = ud;
+	_scriptVars[VAR_HERO_POS_LEFT_RIGHT] = lr;
+	_scriptVars[VAR_HERO_POS_MASK] = m;
+	int16 button = 0;
+	if (_stub->_pi.button) { // inpButton
+		button = 1;
+		m |= 0x80;
+	}
+	_scriptVars[VAR_HERO_ACTION] = button;
+	_scriptVars[VAR_HERO_ACTION_POS_MASK] = m;
+}
+
+void Logic::inp_handleSpecialKeys() {
+	if (_stub->_pi.pause) {
+		if (_res->_curPtrsId != 0x3E80 && _res->_curPtrsId != 0x3E81) {
+			_stub->_pi.pause = false;
+			while (!_stub->_pi.pause) {
+				_stub->processEvents();
+				_stub->sleep(200);
+			}
+		}
+		_stub->_pi.pause = false;
+	}
+	if (_stub->_pi.code) {
+		_stub->_pi.code = false;
+		if (_res->_curPtrsId != 0x3E89 && _res->_curPtrsId != 0x3E80) {
+			_res->_newPtrsId = 0x3E89;
+		}
+	}
+	// XXX
+	if (_scriptVars[0xC9] == 1) {
+		::warning("Logic::inp_handleSpecialKeys() unhandled case (_scriptVars[0xC9] == 1)");
+	}
+}
+
+void Logic::saveOrLoad(Serializer &ser) {
+	Serializer::Entry entries[] = {
+		SE_ARRAY(_scriptVars, 0x100, Serializer::SES_INT16, VER(1)),
+		SE_ARRAY(_scriptStackCalls, 0x100, Serializer::SES_INT16, VER(1)),
+		SE_ARRAY(_scriptPos, 0x40 * 2, Serializer::SES_INT16, VER(1)),
+		SE_ARRAY(_scriptPaused, 0x40 * 2, Serializer::SES_INT8, VER(1)),
+		SE_END()
+	};
+	ser.saveOrLoadEntries(entries);
+}
+
+} // namespace Awe
diff --git a/engines/awe/logic.h b/engines/awe/logic.h
new file mode 100644
index 00000000000..da34ae65b3f
--- /dev/null
+++ b/engines/awe/logic.h
@@ -0,0 +1,114 @@
+/* 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 AWE_LOGIC_H
+#define AWE_LOGIC_H
+
+#include "awe/intern.h"
+
+namespace Awe {
+
+struct Resource;
+struct Serializer;
+struct SystemStub;
+struct Video;
+
+struct Logic {
+	typedef void (Logic::*OpcodeStub)();
+
+	enum ScriptVars {
+		VAR_RANDOM_SEED          = 0x3C,
+		
+		VAR_LAST_KEYCHAR         = 0xDA,
+
+		VAR_HERO_POS_UP_DOWN     = 0xE5,
+
+		VAR_SCROLL_Y             = 0xF9,
+		VAR_HERO_ACTION          = 0xFA,
+		VAR_HERO_POS_JUMP_DOWN   = 0xFB,
+		VAR_HERO_POS_LEFT_RIGHT  = 0xFC,
+		VAR_HERO_POS_MASK        = 0xFD,
+		VAR_HERO_ACTION_POS_MASK = 0xFE,
+		VAR_PAUSE_SLICES         = 0xFF
+	};
+	
+	static const OpcodeStub _opTable[];
+
+	Resource *_res;
+	Video *_vid;
+	SystemStub *_stub;
+
+	int16 _scriptVar_0xBF;
+	int16 _scriptVars[0x100];
+	uint16 _scriptStackCalls[0x40];
+	uint16 _scriptPos[2][0x40];
+	uint8 _scriptPaused[2][0x40];
+	Ptr _scriptPtr;
+	uint8 _stackPtr;
+	bool _scriptHalted;
+	bool _fastMode;
+
+	Logic(Resource *res, Video *vid, SystemStub *stub);
+	void init();
+	
+	void op_movConst();
+	void op_mov();
+	void op_add();
+	void op_addConst();
+	void op_call();
+	void op_ret();
+	void op_break();
+	void op_jmp();
+	void op_setScriptPos();
+	void op_jnz();
+	void op_condJmp();
+	void op_setPalette();
+	void op_resetScript();
+	void op_selectPage();
+	void op_fillPage();
+	void op_copyPage();
+	void op_updateDisplay();
+	void op_halt();	
+	void op_drawString();
+	void op_sub();
+	void op_and();
+	void op_or();
+	void op_shl();
+	void op_shr();
+	void op_soundUnk1();
+	void op_updateMemList();
+	void op_soundUnk2();
+
+	void restartAt(uint16 ptrId);
+	void setupPtrs(uint16 ptrId);
+	void setupScripts();
+	void runScripts();
+	void executeScript();
+
+	void inp_updatePlayer();
+	void inp_handleSpecialKeys();
+	
+	void saveOrLoad(Serializer &ser);
+};
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/metaengine.cpp b/engines/awe/metaengine.cpp
new file mode 100644
index 00000000000..d5e446638c4
--- /dev/null
+++ b/engines/awe/metaengine.cpp
@@ -0,0 +1,69 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/translation.h"
+
+#include "awe/metaengine.h"
+#include "awe/detection.h"
+#include "awe/awe.h"
+
+namespace Awe {
+
+static const ADExtraGuiOptionsMap optionsList[] = {
+	{
+		GAMEOPTION_ORIGINAL_SAVELOAD,
+		{
+			_s("Use original save/load screens"),
+			_s("Use the original save/load screens instead of the ScummVM ones"),
+			"original_menus",
+			false,
+			0,
+			0
+		}
+	},
+	AD_EXTRA_GUI_OPTIONS_TERMINATOR
+};
+
+} // End of namespace Awe
+
+const char *AweMetaEngine::getName() const {
+	return "xyzzy";
+}
+
+const ADExtraGuiOptionsMap *AweMetaEngine::getAdvancedExtraGuiOptions() const {
+	return Awe::optionsList;
+}
+
+Common::Error AweMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+	*engine = new Awe::AweEngine(syst, desc);
+	return Common::kNoError;
+}
+
+bool AweMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return checkExtendedSaves(f) ||
+		(f == kSupportsLoadingDuringStartup);
+}
+
+#if PLUGIN_ENABLED_DYNAMIC(AWE)
+REGISTER_PLUGIN_DYNAMIC(AWE, PLUGIN_TYPE_ENGINE, AweMetaEngine);
+#else
+REGISTER_PLUGIN_STATIC(AWE, PLUGIN_TYPE_ENGINE, AweMetaEngine);
+#endif
diff --git a/engines/awe/metaengine.h b/engines/awe/metaengine.h
new file mode 100644
index 00000000000..06b688af85f
--- /dev/null
+++ b/engines/awe/metaengine.h
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AWE_METAENGINE_H
+#define AWE_METAENGINE_H
+
+#include "engines/advancedDetector.h"
+
+class AweMetaEngine : public AdvancedMetaEngine<ADGameDescription> {
+public:
+	const char *getName() const override;
+
+	Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
+
+	/**
+	 * Determine whether the engine supports the specified MetaEngine feature.
+	 *
+	 * Used by e.g. the launcher to determine whether to enable the Load button.
+	 */
+	bool hasFeature(MetaEngineFeature f) const override;
+
+	const ADExtraGuiOptionsMap *getAdvancedExtraGuiOptions() const override;
+};
+
+#endif
diff --git a/engines/awe/module.mk b/engines/awe/module.mk
new file mode 100644
index 00000000000..3901ba82171
--- /dev/null
+++ b/engines/awe/module.mk
@@ -0,0 +1,26 @@
+MODULE := engines/awe
+
+MODULE_OBJS = \
+	metaengine.o \
+	awe.o \
+	bank.o \
+	engine.o \
+	file.o \
+	logic.o \
+	resource.o \
+	sdlstub.o \
+	serializer.o \
+	staticres.o \
+	util.o \
+	video.o
+
+# This module can be built as a plugin
+ifeq ($(ENABLE_AWE), DYNAMIC_PLUGIN)
+PLUGIN := 1
+endif
+
+# Include common rules
+include $(srcdir)/rules.mk
+
+# Detection objects
+DETECT_OBJS += $(MODULE)/detection.o
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
new file mode 100644
index 00000000000..70159a77e50
--- /dev/null
+++ b/engines/awe/resource.cpp
@@ -0,0 +1,278 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/file.h"
+#include "awe/awe.h"
+#include "awe/resource.h"
+#include "awe/bank.h"
+#include "awe/file.h"
+#include "awe/serializer.h"
+#include "awe/video.h"
+
+namespace Awe {
+
+Resource::Resource(Video *vid, const char *dataDir) 
+	: _vid(vid), _dataDir(dataDir) {
+}
+
+void Resource::readBank(const MemEntry *me, uint8 *dstBuf) {
+	uint16 n = me - _memList;
+	debug(DBG_BANK, "Resource::readBank(%d)", n);
+#ifdef USE_UNPACKED
+	char bankEntryName[64];
+	sprintf(bankEntryName, "ootw-%02X-%d.dump", n, me->type);
+	File f;
+	if (!f.open(bankEntryName, _dataDir)) {
+		::error("Resource::readBank() unable to open '%s' file\n", bankEntryName);
+	}
+	f.read(dstBuf, me->unpackedSize);
+#else
+	Bank bk(_dataDir);
+	if (!bk.read(me, dstBuf)) {
+		::error("Resource::readBank() unable to unpack entry %d\n", n);
+	}
+#endif
+}
+
+void Resource::readEntries() {	
+	Common::File f;
+	if (!f.open("memlist.bin")) {
+		::error("Resource::readEntries() unable to open 'memlist.bin' file\n");
+	}
+	_numMemList = 0;
+	MemEntry *me = _memList;
+	while (1) {
+		assert(_numMemList < ARRAYSIZE(_memList));
+		me->valid = f.readByte();
+		me->type = f.readByte();
+		me->bufPtr = 0; f.readUint16BE();
+		me->unk4 = f.readUint16BE();
+		me->rankNum = f.readByte();
+		me->bankNum = f.readByte();
+		me->bankPos = f.readUint32BE();
+		me->unkC = f.readUint16BE();
+		me->packedSize = f.readUint16BE();
+		me->unk10 = f.readUint16BE();
+		me->unpackedSize = f.readUint16BE();
+		if (me->valid == 0xFF) {
+			break;
+		}
+		++_numMemList;
+		++me;
+	}
+}
+
+void Resource::load() {
+	while (1) {
+		MemEntry *it = _memList;
+		MemEntry *me = 0;
+
+		// get resource with max rankNum
+		uint8 maxNum = 0;
+		uint16 i = _numMemList;
+		while (i--) {
+			if (it->valid == 2 && maxNum <= it->rankNum) {
+				maxNum = it->rankNum;
+				me = it;
+			}
+			++it;
+		}
+		if (me == 0) {
+			break; // no entry found
+		}
+
+		uint8 *memPtr = 0;
+		// XXX if (_audio_no_sound != 0 && _audio_use_roland != 0 && me->type < 2) {
+		// XXX		me->valid = 0;
+		// XXX		continue;
+		// XXX }
+		if (me->type == 2) {
+			memPtr = _vidCurPtr;
+		} else {
+			memPtr = _scriptCurPtr;
+			if (me->unpackedSize > _vidBakPtr - _scriptCurPtr) {
+				::warning("Resource::load() not enough memory");
+				me->valid = 0;
+				continue;
+			}
+		}
+		if (me->bankNum == 0) {
+			::warning("Resource::load() ec=0x%X (me->bankNum == 0)", 0xF00);
+			me->valid = 0;
+		} else {
+			debug(DBG_BANK, "Resource::load() bufPos=%X size=%X type=%X pos=%X bankNum=%X", memPtr - _memPtrStart, me->packedSize, me->type, me->bankPos, me->bankNum);
+			readBank(me, memPtr);
+			if(me->type == 2) {
+				_vid->copyPagePtr(_vidCurPtr);
+				me->valid = 0;
+			} else {
+				me->bufPtr = memPtr;
+				me->valid = 1;
+				_scriptCurPtr += me->unpackedSize;
+			}
+		}
+	}
+}
+
+void Resource::invalidateRes() {
+	// XXX call ds:sound_stub_1_ptr
+	MemEntry *me = _memList;
+	uint16 i = _numMemList;
+	while (i--) {
+		if (me->type <= 2 || me->type > 6) {
+			me->valid = 0;
+		}
+		++me;
+	}
+	_scriptCurPtr = _scriptBakPtr;
+}
+
+void Resource::invalidateAll() {
+	MemEntry *me = _memList;
+	uint16 i = _numMemList;
+	while (i--) {
+		me->valid = 0;
+		++me;
+	}
+	_scriptCurPtr = _memPtrStart;
+}
+
+void Resource::update(uint16 num) {
+	if (num == 0) {
+		invalidateRes();
+	} else {
+		if (num > _numMemList) {
+			_newPtrsId = num;
+		} else {
+			if (false) { // XXX (_audio_use_pro_or_adlib == 1 || _audio_use_spk == 1) {
+				for (const uint16 *ml = _memListAudio; *ml != 0xFFFF; ++ml) {
+					if (*ml == num)
+						return;
+				}
+			}
+			MemEntry *me = &_memList[num];
+			if (me->valid == 0) {
+				me->valid = 2;
+				load();
+			}
+		}
+	}
+}
+
+void Resource::setupPtrs(uint16 ptrId) {
+	if (ptrId != _curPtrsId) {
+		uint8 ipal = 0;
+		uint8 icod = 0;
+		uint8 ivd1 = 0;
+		uint8 ivd2 = 0;
+		if (ptrId >= 0x3E80 && ptrId <= 0x3E89) {
+			uint16 part = ptrId - 0x3E80;
+			ipal = _memListParts[part][0];
+			icod = _memListParts[part][1];
+			ivd1 = _memListParts[part][2];
+			ivd2 = _memListParts[part][3];
+		} else {
+			::error("Resource::setupPtrs() ec=0x%X invalid ptrId", 0xF07);
+		}
+		invalidateAll();
+		_memList[ipal].valid = 2;
+		_memList[icod].valid = 2;
+		_memList[ivd1].valid = 2;
+		if (ivd2 != 0) {
+			_memList[ivd2].valid = 2;
+		}
+		load();
+		_segVideoPal = _memList[ipal].bufPtr;
+		_segCode = _memList[icod].bufPtr;
+		_segVideo1 = _memList[ivd1].bufPtr;
+		if (ivd2 != 0) {
+			_segVideo2 = _memList[ivd2].bufPtr;
+		}
+		_curPtrsId = ptrId;
+	}
+	_scriptBakPtr = _scriptCurPtr;	
+}
+
+void Resource::allocMemBlock() {
+	_memPtrStart = (uint8 *)malloc(MEM_BLOCK_SIZE);
+	_scriptBakPtr = _scriptCurPtr = _memPtrStart;
+	_vidBakPtr = _vidCurPtr = _memPtrStart + MEM_BLOCK_SIZE - 0x800 * 16;
+	_useSegVideo2 = false;
+}
+
+void Resource::freeMemBlock() {
+	free(_memPtrStart);
+}
+
+void Resource::saveOrLoad(Serializer &ser) {
+	uint8 loadedList[64];
+	if (ser._mode == Serializer::SM_SAVE) {
+		memset(loadedList, 0, sizeof(loadedList));
+		uint8 *p = loadedList;
+		uint8 *q = _memPtrStart;
+		while (1) {
+			MemEntry *it = _memList;
+			MemEntry *me = 0;
+			uint16 num = _numMemList;
+			while (num--) {
+				if (it->valid == 1 && it->bufPtr == q) {
+					me = it;
+				}
+				++it;
+			}
+			if (me == 0) {
+				break;
+			} else {
+				assert(p < loadedList + 64);
+				*p++ = me - _memList;
+				q += me->unpackedSize;
+			}
+		}
+	}
+	Serializer::Entry entries[] = {
+		SE_ARRAY(loadedList, 64, Serializer::SES_INT8, VER(1)),
+		SE_INT(&_curPtrsId, Serializer::SES_INT16, VER(1)),
+		SE_PTR(&_scriptBakPtr, VER(1)),
+		SE_PTR(&_scriptCurPtr, VER(1)),
+		SE_PTR(&_vidBakPtr, VER(1)),
+		SE_PTR(&_vidCurPtr, VER(1)),
+		SE_INT(&_useSegVideo2, Serializer::SES_INT8, VER(1)),
+		SE_PTR(&_segVideoPal, VER(1)),
+		SE_PTR(&_segCode, VER(1)),
+		SE_PTR(&_segVideo1, VER(1)),
+		SE_PTR(&_segVideo2, VER(1)),
+		SE_END()		
+	};
+	ser.saveOrLoadEntries(entries);
+	if (ser._mode == Serializer::SM_LOAD) {
+		uint8 *p = loadedList;
+		uint8 *q = _memPtrStart;
+		while (*p) {
+			MemEntry *me = &_memList[*p++];
+			readBank(me, q);
+			me->bufPtr = q;
+			me->valid = 1;
+			q += me->unpackedSize;
+		}
+	}	
+}
+
+} // namespace Awe
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
new file mode 100644
index 00000000000..5b59a9cb54e
--- /dev/null
+++ b/engines/awe/resource.h
@@ -0,0 +1,92 @@
+/* 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 AWE_RESOURCE_H
+#define AWE_RESOURCE_H
+
+#include "awe/intern.h"
+
+namespace Awe {
+
+struct MemEntry {
+	uint8 valid;         // 0x0
+	uint8 type;          // 0x1, Resource::ResType
+	uint8 *bufPtr;       // 0x2
+	uint16 unk4;         // 0x4, unused ?
+	uint8 rankNum;       // 0x6
+	uint8 bankNum;       // 0x7
+	uint32 bankPos;      // 0x8 0xA
+	uint16 unkC;         // 0xC, unused ?
+	uint16 packedSize;   // 0xE
+	uint16 unk10;        // 0x10, unused ?
+	uint16 unpackedSize; // 0x12
+};
+
+struct Serializer;
+struct Video;
+
+struct Resource {
+	enum ResType {
+		RT_SOUND  = 0,
+		RT_MUSIC  = 1,
+		RT_VIDBUF = 2, // full screen video buffer, size=0x7D00
+		RT_PAL    = 3, // palette (1024=vga + 1024=ega), size=2048
+		RT_SCRIPT = 4,
+		RT_VBMP   = 5
+	};
+	
+	enum {
+		MEM_BLOCK_SIZE = 600 * 1024
+	};
+	
+	static const uint16 _memListAudio[];
+	static const uint16 _memListParts[][4];
+	
+	Video *_vid;
+	const char *_dataDir;
+	MemEntry _memList[150];
+	uint16 _numMemList;
+	uint16 _curPtrsId, _newPtrsId;
+	uint8 *_memPtrStart, *_scriptBakPtr, *_scriptCurPtr, *_vidBakPtr, *_vidCurPtr;
+	bool _useSegVideo2;
+	uint8 *_segVideoPal;
+	uint8 *_segCode;
+	uint8 *_segVideo1;
+	uint8 *_segVideo2;
+
+	Resource(Video *vid, const char *dataDir);
+	
+	void readBank(const MemEntry *me, uint8 *dstBuf);
+	void readEntries();
+	void load();
+	void invalidateAll();
+	void invalidateRes();	
+	void update(uint16 num);
+	void setupPtrs(uint16 ptrId);
+	void allocMemBlock();
+	void freeMemBlock();
+	
+	void saveOrLoad(Serializer &ser);
+};
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/sdlstub.cpp b/engines/awe/sdlstub.cpp
new file mode 100644
index 00000000000..e9cd2d80dad
--- /dev/null
+++ b/engines/awe/sdlstub.cpp
@@ -0,0 +1,308 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/system.h"
+#include "common/events.h"
+#include "graphics/screen.h"
+#include "awe/awe.h"
+#include "awe/systemstub.h"
+#include "awe/util.h"
+
+namespace Awe {
+
+struct SDLStub : SystemStub {
+	typedef void (SDLStub::*ScaleProc)(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h);
+
+	enum {
+		SCREEN_W = 320,
+		SCREEN_H = 200
+	};
+
+	struct Scaler {
+		const char *name;
+		ScaleProc proc;
+		uint8 factor;
+	};
+	
+	static const Scaler _scalers[];
+
+	uint8 *_offscreen;
+	Graphics::Screen *_screen;
+	//SDL_Surface *_sclscreen;
+	bool _fullscreen;
+	uint8 _scaler;
+	Graphics::PaletteLookup _palLookup;
+	uint16 _pal[16];
+
+	virtual ~SDLStub() {}
+	virtual void init(const char *title);
+	virtual void destroy();
+	virtual void setPalette(uint8 s, uint8 n, const uint8 *buf);
+	virtual void copyRect(uint16 x, uint16 y, uint16 w, uint16 h, const uint8 *buf, uint32 pitch);
+	virtual void processEvents();
+	virtual void sleep(uint32 duration);
+	virtual uint32 getTimeStamp();
+
+	void prepareGfxMode();
+	void cleanupGfxMode();
+	void switchGfxMode(bool fullscreen, uint8 scaler);
+
+	void point1x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h);
+	void point2x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h);
+	void point3x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h);
+};
+
+const SDLStub::Scaler SDLStub::_scalers[] = {
+	{ "Point1x", &SDLStub::point1x, 1 },
+	{ "Point2x", &SDLStub::point2x, 2 },
+	{ "Point3x", &SDLStub::point3x, 3 }
+};
+
+SystemStub *SystemStub_SDL_create() {
+	return new SDLStub();
+}
+
+void SDLStub::init(const char *title) {
+	memset(&_pi, 0, sizeof(_pi));
+	_offscreen = (uint8 *)malloc(SCREEN_W * SCREEN_H * 2);
+	if (!_offscreen) {
+		::error("Unable to allocate offscreen buffer");
+	}
+	_fullscreen = false;
+	_scaler = 1;
+	prepareGfxMode();
+}
+
+void SDLStub::destroy() {
+	cleanupGfxMode();
+}
+
+void SDLStub::setPalette(uint8 s, uint8 n, const uint8 *buf) {
+	assert(s + n <= 16);
+	for (int i = s; i < s + n; ++i) {
+		uint8 c[3];
+		for (int j = 0; j < 3; ++j) {
+			uint8 col = buf[i * 3 + j];
+			c[j] =  (col << 2) | (col & 3);
+		}
+
+		
+		_pal[i] = _palLookup.findBestColor(c[0], c[1], c[2]);
+	}	
+}
+
+void SDLStub::copyRect(uint16 x, uint16 y, uint16 w, uint16 h, const uint8 *buf, uint32 pitch) {
+	buf += y * pitch + x;
+	uint16 *p = (uint16 *)_offscreen;
+	while (h--) {
+		for (int i = 0; i < w / 2; ++i) {
+			uint8 p1 = *(buf + i) >> 4;
+			uint8 p2 = *(buf + i) & 0xF;
+			*(p + i * 2 + 0) = _pal[p1];
+			*(p + i * 2 + 1) = _pal[p2];
+		}
+		p += SCREEN_W;
+		buf += pitch;
+	}
+
+	_screen->copyRectToSurface(_offscreen, SCREEN_W,
+		0, 0, SCREEN_W, SCREEN_H);
+}
+
+void SDLStub::processEvents() {
+	Common::Event ev;
+
+	while (g_engine->shouldQuit() &&
+			g_system->getEventManager()->pollEvent(ev)) {
+		switch (ev.type) {
+		case Common::EVENT_KEYUP:
+			switch(ev.kbd.keycode) {
+			case Common::KEYCODE_LEFT:
+				_pi.dirMask &= ~PlayerInput::DIR_LEFT;
+				break;
+			case Common::KEYCODE_RIGHT:
+				_pi.dirMask &= ~PlayerInput::DIR_RIGHT;
+				break;
+			case Common::KEYCODE_UP:
+				_pi.dirMask &= ~PlayerInput::DIR_UP;
+				break;
+			case Common::KEYCODE_DOWN:
+				_pi.dirMask &= ~PlayerInput::DIR_DOWN;
+				break;
+			case Common::KEYCODE_SPACE:
+			case Common::KEYCODE_RETURN:
+				_pi.button = false;
+				break;
+			default:
+				break;
+			}
+			break;
+		case Common::EVENT_KEYDOWN:
+			if (ev.kbd.flags & Common::KBD_ALT) {
+				if (ev.kbd.keycode == Common::KEYCODE_RETURN) {
+					switchGfxMode(!_fullscreen, _scaler);
+				} else if (ev.kbd.keycode == Common::KEYCODE_KP_PLUS) {
+					uint8 s = _scaler + 1;
+					if (s < ARRAYSIZE(_scalers)) {
+						switchGfxMode(_fullscreen, s);
+					}
+				} else if (ev.kbd.keycode == Common::KEYCODE_KP_MINUS) {
+					int8 s = _scaler - 1;
+					if (_scaler > 0) {
+						switchGfxMode(_fullscreen, s);
+					}
+				} else if (ev.kbd.keycode == Common::KEYCODE_x) {
+					_pi.quit = true;
+				}
+				break;
+			} else if (ev.kbd.flags & Common::KBD_CTRL) {
+				if (ev.kbd.keycode == Common::KEYCODE_s) {
+					_pi.save = true;
+				} else if (ev.kbd.keycode == Common::KEYCODE_l) {
+					_pi.load = true;
+				} else if (ev.kbd.keycode == Common::KEYCODE_f) {
+					_pi.fastMode = true;
+				} else if (ev.kbd.keycode == Common::KEYCODE_KP_PLUS) {
+					_pi.stateSlot = 1;
+				} else if (ev.kbd.keycode == Common::KEYCODE_KP_MINUS) {
+					_pi.stateSlot = -1;
+				}
+				break;
+			}
+			_pi.lastChar = ev.kbd.keycode;
+			switch(ev.kbd.keycode) {
+			case Common::KEYCODE_LEFT:
+				_pi.dirMask |= PlayerInput::DIR_LEFT;
+				break;
+			case Common::KEYCODE_RIGHT:
+				_pi.dirMask |= PlayerInput::DIR_RIGHT;
+				break;
+			case Common::KEYCODE_UP:
+				_pi.dirMask |= PlayerInput::DIR_UP;
+				break;
+			case Common::KEYCODE_DOWN:
+				_pi.dirMask |= PlayerInput::DIR_DOWN;
+				break;
+			case Common::KEYCODE_SPACE:
+			case Common::KEYCODE_RETURN:
+				_pi.button = true;
+				break;
+			case Common::KEYCODE_c:
+				_pi.code = true;
+				break;
+			case Common::KEYCODE_p:
+				_pi.pause = true;
+				break;
+			default:
+				break;
+			}
+			break;
+		default:
+			break;
+		}
+	}
+}
+
+void SDLStub::sleep(uint32 duration) {
+	g_system->delayMillis(duration);
+}
+
+uint32 SDLStub::getTimeStamp() {
+	return g_system->getMillis();	
+}
+
+void SDLStub::prepareGfxMode() {
+//	int w = SCREEN_W * _scalers[_scaler].factor;
+//	int h = SCREEN_H * _scalers[_scaler].factor;
+	_screen = new Graphics::Screen();
+}
+
+void SDLStub::cleanupGfxMode() {
+	if (_offscreen) {
+		free(_offscreen);
+		_offscreen = nullptr;
+	}
+
+	if (_screen) {
+		delete _screen;
+		_screen = nullptr;
+	}
+}
+
+void SDLStub::switchGfxMode(bool fullscreen, uint8 scaler) {
+#ifdef DEPRECATED
+	SDL_Surface *prev_sclscreen = _sclscreen;
+	SDL_FreeSurface(_screen); 	
+	_fullscreen = fullscreen;
+	_scaler = scaler;
+	prepareGfxMode();
+	SDL_BlitSurface(prev_sclscreen, NULL, _sclscreen, NULL);
+	SDL_FreeSurface(prev_sclscreen);
+#endif
+}
+
+void SDLStub::point1x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
+	dstPitch >>= 1;
+	while (h--) {
+		memcpy(dst, src, w * 2);
+		dst += dstPitch;
+		src += dstPitch;
+	}
+}
+
+void SDLStub::point2x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
+	dstPitch >>= 1;
+	while (h--) {
+		uint16 *p = dst;
+		for (int i = 0; i < w; ++i, p += 2) {
+			uint16 c = *(src + i);
+			*(p + 0) = c;
+			*(p + 1) = c;
+			*(p + 0 + dstPitch) = c;
+			*(p + 1 + dstPitch) = c;
+		}
+		dst += dstPitch * 2;
+		src += srcPitch;
+	}
+}
+
+void SDLStub::point3x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
+	dstPitch >>= 1;
+	while (h--) {
+		uint16 *p = dst;
+		for (int i = 0; i < w; ++i, p += 3) {
+			uint16 c = *(src + i);
+			*(p + 0) = c;
+			*(p + 1) = c;
+			*(p + 2) = c;
+			*(p + 0 + dstPitch) = c;
+			*(p + 1 + dstPitch) = c;
+			*(p + 2 + dstPitch) = c;
+			*(p + 0 + dstPitch * 2) = c;
+			*(p + 1 + dstPitch * 2) = c;
+			*(p + 2 + dstPitch * 2) = c;
+		}
+		dst += dstPitch * 3;
+		src += srcPitch;
+	}
+}
+
+} // namespace Awe
diff --git a/engines/awe/serializer.cpp b/engines/awe/serializer.cpp
new file mode 100644
index 00000000000..01f120d45ba
--- /dev/null
+++ b/engines/awe/serializer.cpp
@@ -0,0 +1,139 @@
+/* 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 "awe/serializer.h"
+#include "awe/file.h"
+#include "awe/util.h"
+
+namespace Awe {
+
+Serializer::Serializer(Common::Stream *stream, Mode mode, uint8 *ptrBlock, uint16 saveVer)
+	: _stream(stream), _mode(mode), _ptrBlock(ptrBlock), _saveVer(saveVer) {
+}
+
+void Serializer::saveOrLoadEntries(Entry *entry) {
+	switch (_mode) {
+	case SM_SAVE:
+		saveEntries(entry);
+		break;
+	case SM_LOAD:
+		loadEntries(entry);
+		break;	
+	}
+}
+
+void Serializer::saveEntries(Entry *entry) {
+	Common::WriteStream *stream =
+		dynamic_cast<Common::WriteStream *>(_stream);
+
+	for (; entry->type != SET_END; ++entry) {
+		if (entry->maxVer == CUR_VER) {
+			switch (entry->type) {
+			case SET_INT:
+				saveInt(entry->size, entry->data);
+				break;
+			case SET_ARRAY:
+				if (entry->size == Serializer::SES_INT8) {
+					stream->write(entry->data, entry->n);
+				} else {
+					uint8 *p = (uint8 *)entry->data;
+					for (int i = 0; i < entry->n; ++i) {
+						saveInt(entry->size, p);
+						p += entry->size;
+					}
+				}
+				break;
+			case SET_PTR:
+				stream->writeUint32BE(*(uint8 **)(entry->data) - _ptrBlock);
+				break;
+			case SET_END:
+				break;
+			}
+		}
+	}
+}
+
+void Serializer::loadEntries(Entry *entry) {
+	Common::SeekableReadStream *stream =
+		dynamic_cast<Common::SeekableReadStream *>(_stream);
+
+	for (; entry->type != SET_END; ++entry) {
+		if (_saveVer >= entry->minVer && _saveVer <= entry->maxVer) {
+			switch (entry->type) {
+			case SET_INT:
+				loadInt(entry->size, entry->data);
+				break;
+			case SET_ARRAY:
+				if (entry->size == Serializer::SES_INT8) {
+					stream->read(entry->data, entry->n);
+				} else {
+					uint8 *p = (uint8 *)entry->data;
+					for (int i = 0; i < entry->n; ++i) {
+						loadInt(entry->size, p);
+						p += entry->size;
+					}
+				}
+				break;
+			case SET_PTR:
+				*(uint8 **)(entry->data) = _ptrBlock + stream->readUint32BE();
+				break;
+			case SET_END:
+				break;				
+			}
+		}
+	}
+}
+
+void Serializer::saveInt(uint8 es, void *p) {
+	Common::WriteStream *stream =
+		dynamic_cast<Common::WriteStream *>(_stream);
+
+	switch (es) {
+	case SES_INT8:
+		stream->writeByte(*(uint8 *)p);
+		break;
+	case SES_INT16:
+		stream->writeUint16BE(*(uint16 *)p);
+		break;
+	case SES_INT32:
+		stream->writeUint32BE(*(uint32 *)p);
+		break;
+	}
+}
+
+void Serializer::loadInt(uint8 es, void *p) {
+	Common::SeekableReadStream *stream =
+		dynamic_cast<Common::SeekableReadStream *>(_stream);
+
+	switch (es) {
+	case SES_INT8:
+		*(uint8 *)p = stream->readByte();
+		break;
+	case SES_INT16:
+		*(uint16 *)p = stream->readUint16BE();
+		break;
+	case SES_INT32:
+		*(uint32 *)p = stream->readUint32BE();
+		break;
+	}
+}
+
+} // namespace Awe
diff --git a/engines/awe/serializer.h b/engines/awe/serializer.h
new file mode 100644
index 00000000000..1264a87a4f4
--- /dev/null
+++ b/engines/awe/serializer.h
@@ -0,0 +1,89 @@
+/* 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 AWE_SERIALIZER_H
+#define AWE_SERIALIZER_H
+
+#include "common/stream.h"
+#include "awe/intern.h"
+
+namespace Awe {
+
+#define VER(x) x
+
+#define SE_INT(i,sz,ver)     { Serializer::SET_INT, sz, 1, i, ver, Serializer::CUR_VER }
+#define SE_ARRAY(a,n,sz,ver) { Serializer::SET_ARRAY, sz, n, a, ver, Serializer::CUR_VER }
+#define SE_PTR(p,ver)        { Serializer::SET_PTR, 0, 0, p, ver, Serializer::CUR_VER }
+#define SE_END()             { Serializer::SET_END, 0, 0, 0, 0, 0 }
+
+struct File;
+
+struct Serializer {
+	enum {
+		CUR_VER = 1
+	};
+
+	enum EntryType {
+		SET_INT,
+		SET_ARRAY,
+		SET_PTR,
+		SET_END
+	};
+
+	enum {
+		SES_INT8  = 1,
+		SES_INT16 = 2,
+		SES_INT32 = 4
+	};
+
+	enum Mode {
+		SM_SAVE,
+		SM_LOAD
+	};
+
+	struct Entry {
+		EntryType type;
+		uint8 size;
+		uint16 n;
+		void *data;
+		uint16 minVer;
+		uint16 maxVer;
+	};
+
+	Common::Stream *_stream;
+	Mode _mode;
+	uint8 *_ptrBlock;
+	uint16 _saveVer;
+	
+	Serializer(Common::Stream *stream, Mode mode, uint8 *ptrBlock, uint16 saveVer = CUR_VER);
+
+	void saveOrLoadEntries(Entry *entry);
+
+	void saveEntries(Entry *entry);
+	void loadEntries(Entry *entry);
+
+	void saveInt(uint8 es, void *p);
+	void loadInt(uint8 es, void *p);
+};
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/staticres.cpp b/engines/awe/staticres.cpp
new file mode 100644
index 00000000000..a1a3af9ba4b
--- /dev/null
+++ b/engines/awe/staticres.cpp
@@ -0,0 +1,403 @@
+/* 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 "awe/logic.h"
+#include "awe/resource.h"
+#include "awe/video.h"
+
+namespace Awe {
+
+const Logic::OpcodeStub Logic::_opTable[] = {
+	/* 0x00 */
+	&Logic::op_movConst,
+	&Logic::op_mov,
+	&Logic::op_add,
+	&Logic::op_addConst,
+	/* 0x04 */
+	&Logic::op_call,
+	&Logic::op_ret,
+	&Logic::op_break,
+	&Logic::op_jmp,
+	/* 0x08 */
+	&Logic::op_setScriptPos,
+	&Logic::op_jnz,
+	&Logic::op_condJmp,
+	&Logic::op_setPalette,
+	/* 0x0C */
+	&Logic::op_resetScript,
+	&Logic::op_selectPage,
+	&Logic::op_fillPage,
+	&Logic::op_copyPage,
+	/* 0x10 */
+	&Logic::op_updateDisplay,
+	&Logic::op_halt,
+	&Logic::op_drawString,
+	&Logic::op_sub,
+	/* 0x14 */
+	&Logic::op_and,
+	&Logic::op_or,
+	&Logic::op_shl,
+	&Logic::op_shr,
+	/* 0x18 */
+	&Logic::op_soundUnk1,
+	&Logic::op_updateMemList,
+	&Logic::op_soundUnk2
+};
+
+const uint16 Resource::_memListAudio[] = { 
+	8, 0x10, 0x61, 0x66, 0xFFFF
+};
+
+const uint16 Resource::_memListParts[][4] = {
+	{ 0x14, 0x15, 0x16, 0x00 }, // protection screens
+	{ 0x17, 0x18, 0x19, 0x00 }, // introduction
+	{ 0x1A, 0x1B, 0x1C, 0x11 },
+	{ 0x1D, 0x1E, 0x1F, 0x11 },
+	{ 0x20, 0x21, 0x22, 0x11 },
+	{ 0x23, 0x24, 0x25, 0x00 },
+	{ 0x26, 0x27, 0x28, 0x11 },
+	{ 0x29, 0x2A, 0x2B, 0x11 },
+	{ 0x7D, 0x7E, 0x7F, 0x00 },
+	{ 0x7D, 0x7E, 0x7F, 0x00 }  // password screen
+};
+
+const uint8 Video::_font[] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00,
+	0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x7E, 0x24, 0x24, 0x7E, 0x24, 0x00,
+	0x08, 0x3E, 0x48, 0x3C, 0x12, 0x7C, 0x10, 0x00, 0x42, 0xA4, 0x48, 0x10, 0x24, 0x4A, 0x84, 0x00,
+	0x60, 0x90, 0x90, 0x70, 0x8A, 0x84, 0x7A, 0x00, 0x08, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x06, 0x08, 0x10, 0x10, 0x10, 0x08, 0x06, 0x00, 0xC0, 0x20, 0x10, 0x10, 0x10, 0x20, 0xC0, 0x00,
+	0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x10, 0x10, 0x7C, 0x10, 0x10, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x20, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x10, 0x28, 0x10, 0x00, 0x00, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00,
+	0x78, 0x84, 0x8C, 0x94, 0xA4, 0xC4, 0x78, 0x00, 0x10, 0x30, 0x50, 0x10, 0x10, 0x10, 0x7C, 0x00,
+	0x78, 0x84, 0x04, 0x08, 0x30, 0x40, 0xFC, 0x00, 0x78, 0x84, 0x04, 0x38, 0x04, 0x84, 0x78, 0x00,
+	0x08, 0x18, 0x28, 0x48, 0xFC, 0x08, 0x08, 0x00, 0xFC, 0x80, 0xF8, 0x04, 0x04, 0x84, 0x78, 0x00,
+	0x38, 0x40, 0x80, 0xF8, 0x84, 0x84, 0x78, 0x00, 0xFC, 0x04, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00,
+	0x78, 0x84, 0x84, 0x78, 0x84, 0x84, 0x78, 0x00, 0x78, 0x84, 0x84, 0x7C, 0x04, 0x08, 0x70, 0x00,
+	0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x10, 0x10, 0x60,
+	0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0xFE, 0x00, 0x00,
+	0x20, 0x10, 0x08, 0x04, 0x08, 0x10, 0x20, 0x00, 0x7C, 0x82, 0x02, 0x0C, 0x10, 0x00, 0x10, 0x00,
+	0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0x00, 0x78, 0x84, 0x84, 0xFC, 0x84, 0x84, 0x84, 0x00,
+	0xF8, 0x84, 0x84, 0xF8, 0x84, 0x84, 0xF8, 0x00, 0x78, 0x84, 0x80, 0x80, 0x80, 0x84, 0x78, 0x00,
+	0xF8, 0x84, 0x84, 0x84, 0x84, 0x84, 0xF8, 0x00, 0x7C, 0x40, 0x40, 0x78, 0x40, 0x40, 0x7C, 0x00,
+	0xFC, 0x80, 0x80, 0xF0, 0x80, 0x80, 0x80, 0x00, 0x7C, 0x80, 0x80, 0x8C, 0x84, 0x84, 0x7C, 0x00,
+	0x84, 0x84, 0x84, 0xFC, 0x84, 0x84, 0x84, 0x00, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7C, 0x00,
+	0x04, 0x04, 0x04, 0x04, 0x84, 0x84, 0x78, 0x00, 0x8C, 0x90, 0xA0, 0xE0, 0x90, 0x88, 0x84, 0x00,
+	0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFC, 0x00, 0x82, 0xC6, 0xAA, 0x92, 0x82, 0x82, 0x82, 0x00,
+	0x84, 0xC4, 0xA4, 0x94, 0x8C, 0x84, 0x84, 0x00, 0x78, 0x84, 0x84, 0x84, 0x84, 0x84, 0x78, 0x00,
+	0xF8, 0x84, 0x84, 0xF8, 0x80, 0x80, 0x80, 0x00, 0x78, 0x84, 0x84, 0x84, 0x84, 0x8C, 0x7C, 0x03,
+	0xF8, 0x84, 0x84, 0xF8, 0x90, 0x88, 0x84, 0x00, 0x78, 0x84, 0x80, 0x78, 0x04, 0x84, 0x78, 0x00,
+	0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x78, 0x00,
+	0x84, 0x84, 0x84, 0x84, 0x84, 0x48, 0x30, 0x00, 0x82, 0x82, 0x82, 0x82, 0x92, 0xAA, 0xC6, 0x00,
+	0x82, 0x44, 0x28, 0x10, 0x28, 0x44, 0x82, 0x00, 0x82, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, 0x00,
+	0xFC, 0x04, 0x08, 0x10, 0x20, 0x40, 0xFC, 0x00, 0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00,
+	0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00, 0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00,
+	0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE,
+	0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00, 0x00, 0x00, 0x38, 0x04, 0x3C, 0x44, 0x3C, 0x00,
+	0x40, 0x40, 0x78, 0x44, 0x44, 0x44, 0x78, 0x00, 0x00, 0x00, 0x3C, 0x40, 0x40, 0x40, 0x3C, 0x00,
+	0x04, 0x04, 0x3C, 0x44, 0x44, 0x44, 0x3C, 0x00, 0x00, 0x00, 0x38, 0x44, 0x7C, 0x40, 0x3C, 0x00,
+	0x38, 0x44, 0x40, 0x60, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x3C, 0x44, 0x44, 0x3C, 0x04, 0x78,
+	0x40, 0x40, 0x58, 0x64, 0x44, 0x44, 0x44, 0x00, 0x10, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00,
+	0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x42, 0x3C, 0x40, 0x40, 0x46, 0x48, 0x70, 0x48, 0x46, 0x00,
+	0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0xEC, 0x92, 0x92, 0x92, 0x92, 0x00,
+	0x00, 0x00, 0x78, 0x44, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00,
+	0x00, 0x00, 0x78, 0x44, 0x44, 0x78, 0x40, 0x40, 0x00, 0x00, 0x3C, 0x44, 0x44, 0x3C, 0x04, 0x04,
+	0x00, 0x00, 0x4C, 0x70, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x3C, 0x40, 0x38, 0x04, 0x78, 0x00,
+	0x10, 0x10, 0x3C, 0x10, 0x10, 0x10, 0x0C, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x78, 0x00,
+	0x00, 0x00, 0x44, 0x44, 0x44, 0x28, 0x10, 0x00, 0x00, 0x00, 0x82, 0x82, 0x92, 0xAA, 0xC6, 0x00,
+	0x00, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x42, 0x22, 0x24, 0x18, 0x08, 0x30,
+	0x00, 0x00, 0x7C, 0x08, 0x10, 0x20, 0x7C, 0x00, 0x60, 0x90, 0x20, 0x40, 0xF0, 0x00, 0x00, 0x00,
+	0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0x00, 0x38, 0x44, 0xBA, 0xA2, 0xBA, 0x44, 0x38, 0x00,
+	0x38, 0x44, 0x82, 0x82, 0x44, 0x28, 0xEE, 0x00, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA
+};
+
+const StrEntry Video::_stringsTableEng[] = {
+	{ 0x001, "P E A N U T  3000" },
+	{ 0x002, "Copyright  } 1990 Peanut Computer, Inc.\nAll rights reserved.\n\nCDOS Version 5.01" },
+	{ 0x003, "2" },
+	{ 0x004, "3" },
+	{ 0x005, "." },
+	{ 0x006, "A" },
+	{ 0x007, "@" },
+	{ 0x008, "PEANUT 3000" },
+	{ 0x00A, "R" },
+	{ 0x00B, "U" },
+	{ 0x00C, "N" },
+	{ 0x00D, "P" },
+	{ 0x00E, "R" },
+	{ 0x00F, "O" },
+	{ 0x010, "J" },
+	{ 0x011, "E" },
+	{ 0x012, "C" },
+	{ 0x013, "T" },
+	{ 0x014, "Shield 9A.5f Ok" },
+	{ 0x015, "Flux % 5.0177 Ok" },
+	{ 0x016, "CDI Vector ok" },
+	{ 0x017, " %%%ddd ok" },
+	{ 0x018, "Race-Track ok" },
+	{ 0x019, "SYNCHROTRON" },
+	{ 0x01A, "E: 23%\ng: .005\n\nRK: 77.2L\n\nopt: g+\n\n Shield:\n1: OFF\n2: ON\n3: ON\n\nP~: 1\n" },
+	{ 0x01B, "ON" },
+	{ 0x01C, "-" },
+	{ 0x021, "|" },
+	{ 0x022, "--- Theoretical study ---" },
+	{ 0x023, " THE EXPERIMENT WILL BEGIN IN    SECONDS" },
+	{ 0x024, "  20" },
+	{ 0x025, "  19" },
+	{ 0x026, "  18" },
+	{ 0x027, "  4" },
+	{ 0x028, "  3" },
+	{ 0x029, "  2" },
+	{ 0x02A, "  1" },
+	{ 0x02B, "  0" },
+	{ 0x02C, "L E T ' S   G O" },
+	{ 0x031, "- Phase 0:\nINJECTION of particles\ninto synchrotron" },
+	{ 0x032, "- Phase 1:\nParticle ACCELERATION." },
+	{ 0x033, "- Phase 2:\nEJECTION of particles\non the shield." },
+	{ 0x034, "A  N  A  L  Y  S  I  S" },
+	{ 0x035, "- RESULT:\nProbability of creating:\n ANTIMATTER: 91.V %\n NEUTRINO 27:  0.04 %\n NEUTRINO 424: 18 %\n" },
+	{ 0x036, "   Practical verification Y/N ?" },
+	{ 0x037, "SURE ?" },
+	{ 0x038, "MODIFICATION OF PARAMETERS\nRELATING TO PARTICLE\nACCELERATOR (SYNCHROTRON)." },
+	{ 0x039, "       RUN EXPERIMENT ?" },
+	{ 0x03C, "t---t" },
+	{ 0x03D, "000 ~" },
+	{ 0x03E, ".20x14dd" },
+	{ 0x03F, "gj5r5r" },
+	{ 0x040, "tilgor 25%" },
+	{ 0x041, "12% 33% checked" },
+	{ 0x042, "D=4.2158005584" },
+	{ 0x043, "d=10.00001" },
+	{ 0x044, "+" },
+	{ 0x045, "*" },
+	{ 0x046, "% 304" },
+	{ 0x047, "gurgle 21" },
+	{ 0x048, "{{{{" },
+	{ 0x049, "Delphine Software" },
+	{ 0x04A, "By Eric Chahi" },
+	{ 0x04B, "  5" },
+	{ 0x04C, "  17" },
+	{ 0x12C, "0" },
+	{ 0x12D, "1" },
+	{ 0x12E, "2" },
+	{ 0x12F, "3" },
+	{ 0x130, "4" },
+	{ 0x131, "5" },
+	{ 0x132, "6" },
+	{ 0x133, "7" },
+	{ 0x134, "8" },
+	{ 0x135, "9" },
+	{ 0x136, "A" },
+	{ 0x137, "B" },
+	{ 0x138, "C" },
+	{ 0x139, "D" },
+	{ 0x13A, "E" },
+	{ 0x13B, "F" },
+	{ 0x13C, "        ACCESS CODE:" },
+	{ 0x13D, "PRESS BUTTON OR RETURN TO CONTINUE" },
+	{ 0x13E, "   ENTER ACCESS CODE" },
+	{ 0x13F, "   INVALID PASSWORD !" },
+	{ 0x140, "ANNULER" },
+	{ 0x141, "      INSERT DISK ?\n\n\n\n\n\n\n\n\nPRESS ANY KEY TO CONTINUE" },
+	{ 0x142, " SELECT SYMBOLS CORRESPONDING TO\n THE POSITION\n ON THE CODE WHEEL" },
+	{ 0x143, "    LOADING..." },
+	{ 0x144, "              ERROR" },
+	{ 0x15E, "LDKD" },
+	{ 0x15F, "HTDC" },
+	{ 0x160, "CLLD" },
+	{ 0x161, "FXLC" },
+	{ 0x162, "KRFK" },
+	{ 0x163, "XDDJ" },
+	{ 0x164, "LBKG" },
+	{ 0x165, "KLFB" },
+	{ 0x166, "TTCT" },
+	{ 0x167, "DDRX" },
+	{ 0x168, "TBHK" },
+	{ 0x169, "BRTD" },
+	{ 0x16A, "CKJL" },
+	{ 0x16B, "LFCK" },
+	{ 0x16C, "BFLX" },
+	{ 0x16D, "XJRT" },
+	{ 0x16E, "HRTB" },
+	{ 0x16F, "HBHK" },
+	{ 0x170, "JCGB" },
+	{ 0x171, "HHFL" },
+	{ 0x172, "TFBB" },
+	{ 0x173, "TXHF" },
+	{ 0x174, "JHJL" },
+	{ 0x181, " BY" },
+	{ 0x182, "ERIC CHAHI" },
+	{ 0x183, "         MUSIC AND SOUND EFFECTS" },
+	{ 0x184, " " },
+	{ 0x185, "JEAN-FRANCOIS FREITAS" },
+	{ 0x186, "IBM PC VERSION" },
+	{ 0x187, "      BY" },
+	{ 0x188, " DANIEL MORAIS" },
+	{ 0x18B, "       THEN PRESS FIRE" },
+	{ 0x18C, " PUT THE PADDLE ON THE UPPER LEFT CORNER" },
+	{ 0x18D, "PUT THE PADDLE IN CENTRAL POSITION" },
+	{ 0x18E, "PUT THE PADDLE ON THE LOWER RIGHT CORNER" },
+	{ 0x258, "      Designed by ..... Eric Chahi" },
+	{ 0x259, "    Programmed by...... Eric Chahi" },
+	{ 0x25A, "      Artwork ......... Eric Chahi" },
+	{ 0x25B, "Music by ........ Jean-francois Freitas" },
+	{ 0x25C, "            Sound effects" },
+	{ 0x25D, "        Jean-Francois Freitas\n             Eric Chahi" },
+	{ 0x263, "              Thanks To" },
+	{ 0x264, "           Jesus Martinez\n\n          Daniel Morais\n\n        Frederic Savoir\n\n      Cecile Chahi\n\n    Philippe Delamarre\n\n  Philippe Ulrich\n\nSebastien Berthet\n\nPierre Gousseau" },
+	{ 0x265, "Now Go Out Of This World" },
+	{ 0x190, "Good evening professor." },
+	{ 0x191, "I see you have driven here in your\nFerrari." },
+	{ 0x192, "IDENTIFICATION" },
+	{ 0x193, "Monsieur est en parfaite sante." },
+	{ 0x194, "Y\n" },
+	{ 0x193, "AU BOULOT !!!\n" },
+	{ 0xFFFF, "" }
+};
+
+const StrEntry Video::_stringsTableDemo[] = {
+	{ 0x001, "P E A N U T  3000" },
+	{ 0x002, "Copyright  } 1990 Peanut Computer, Inc.\nAll rights reserved.\n\nCDOS Version 5.01" },
+	{ 0x003, "2" },
+	{ 0x004, "3" },
+	{ 0x005, "." },
+	{ 0x006, "A" },
+	{ 0x007, "@" },
+	{ 0x008, "PEANUT 3000" },
+	{ 0x00A, "R" },
+	{ 0x00B, "U" },
+	{ 0x00C, "N" },
+	{ 0x00D, "P" },
+	{ 0x00E, "R" },
+	{ 0x00F, "O" },
+	{ 0x010, "J" },
+	{ 0x011, "E" },
+	{ 0x012, "C" },
+	{ 0x013, "T" },
+	{ 0x014, "Shield 9A.5f Ok" },
+	{ 0x015, "Flux % 5.0177 Ok" },
+	{ 0x016, "CDI Vector ok" },
+	{ 0x017, " %%%ddd ok" },
+	{ 0x018, "Race-Track ok" },
+	{ 0x019, "SYNCHROTRON" },
+	{ 0x01A, "E: 23%\ng: .005\n\nRK: 77.2L\n\nopt: g+\n\n Shield:\n1: OFF\n2: ON\n3: ON\n\nP~: 1\n" },
+	{ 0x01B, "ON" },
+	{ 0x01C, "-" },
+	{ 0x021, "|" },
+	{ 0x022, "--- Theoretical study ---" },
+	{ 0x023, " THE EXPERIMENT WILL BEGIN IN    SECONDS" },
+	{ 0x024, "  20" },
+	{ 0x025, "  19" },
+	{ 0x026, "  18" },
+	{ 0x027, "  4" },
+	{ 0x028, "  3" },
+	{ 0x029, "  2" },
+	{ 0x02A, "  1" },
+	{ 0x02B, "  0" },
+	{ 0x02C, "L E T ' S   G O" },
+	{ 0x031, "- Phase 0:\nINJECTION of particles\ninto synchrotron" },
+	{ 0x032, "- Phase 1:\nParticle ACCELERATION." },
+	{ 0x033, "- Phase 2:\nEJECTION of particles\non the shield." },
+	{ 0x034, "A  N  A  L  Y  S  I  S" },
+	{ 0x035, "- RESULT:\nProbability of creating:\n ANTIMATTER: 91.V %\n NEUTRINO 27:  0.04 %\n NEUTRINO 424: 18 %\n" },
+	{ 0x036, "   Practical verification Y/N ?" },
+	{ 0x037, "SURE ?" },
+	{ 0x038, "MODIFICATION OF PARAMETERS\nRELATING TO PARTICLE\nACCELERATOR (SYNCHROTRON)." },
+	{ 0x039, "       RUN EXPERIMENT ?" },
+	{ 0x03C, "t---t" },
+	{ 0x03D, "000 ~" },
+	{ 0x03E, ".20x14dd" },
+	{ 0x03F, "gj5r5r" },
+	{ 0x040, "tilgor 25%" },
+	{ 0x041, "12% 33% checked" },
+	{ 0x042, "D=4.2158005584" },
+	{ 0x043, "d=10.00001" },
+	{ 0x044, "+" },
+	{ 0x045, "*" },
+	{ 0x046, "% 304" },
+	{ 0x047, "gurgle 21" },
+	{ 0x048, "{{{{" },
+	{ 0x049, "Delphine Software" },
+	{ 0x04A, "By Eric Chahi" },
+	{ 0x04B, "  5" },
+	{ 0x04C, "  17" },
+	{ 0x12C, "0" },
+	{ 0x12D, "1" },
+	{ 0x12E, "2" },
+	{ 0x12F, "3" },
+	{ 0x130, "4" },
+	{ 0x131, "5" },
+	{ 0x132, "6" },
+	{ 0x133, "7" },
+	{ 0x134, "8" },
+	{ 0x135, "9" },
+	{ 0x136, "A" },
+	{ 0x137, "B" },
+	{ 0x138, "C" },
+	{ 0x139, "D" },
+	{ 0x13A, "E" },
+	{ 0x13B, "F" },
+	{ 0x13D, "PRESS BUTTON OR RETURN TO CONTINUE" },
+	{ 0x13E, "   ENTER ACCESS CODE" },
+	{ 0x13F, "   INVALID PASSWORD !" },
+	{ 0x140, "ANNULER" },
+	{ 0x141, "          INSERT DISK ?" },
+	{ 0x142, " SELECT SYMBOLS CORRESPONDING TO\n THE POSITION\n ON THE CODE WHEEL" },
+	{ 0x143, "    LOADING..." },
+	{ 0x144, "              ERROR" },
+	{ 0x181, " BY" },
+	{ 0x182, "ERIC CHAHI" },
+	{ 0x183, "         MUSIC AND SOUND EFFECTS" },
+	{ 0x184, " " },
+	{ 0x185, "JEAN-FRANCOIS FREITAS" },
+	{ 0x186, "IBM PC VERSION" },
+	{ 0x187, "      BY" },
+	{ 0x188, " DANIEL MORAIS" },
+	{ 0x18B, "       THEN PRESS FIRE" },
+	{ 0x18C, " PUT THE PADDLE ON THE UPPER LEFT CORNER" },
+	{ 0x18D, "PUT THE PADDLE IN CENTRAL POSITION" },
+	{ 0x18E, "PUT THE PADDLE ON THE LOWER RIGHT CORNER" },
+	{ 0x1F4, "Over Two Years in the Making" },
+	{ 0x1F5, "   A New, State\nof the Art, Polygon\n  Graphics System" },
+	{ 0x1F6, "   Comes to the\nComputer With Full\n Screen Graphics" },
+	{ 0x1F7, "While conducting a nuclear fission\nexperiment at your local\nparticle accelerator ..." },
+	{ 0x1F8, "Nature decides to put a little\n    extra spin on the ball" },
+	{ 0x1F9, "And sends you ..." },
+	{ 0x1FA, "     Out of this World\nA Cinematic Action Adventure\n Coming soon to a computer\n      screen near you\n from Interplay Productions\n   coming soon to the IBM" },
+	{ 0x258, "      Designed by ..... Eric Chahi" },
+	{ 0x259, "    Programmed by...... Eric Chahi" },
+	{ 0x25A, "      Artwork ......... Eric Chahi" },
+	{ 0x25B, "Music by ........ Jean-francois Freitas" },
+	{ 0x25C, "            Sound effects" },
+	{ 0x25D, "        Jean-Francois Freitas\n             Eric Chahi" },
+	{ 0x263, "              Thanks To" },
+	{ 0x264, "           Jesus Martinez\n\n          Daniel Morais\n\n        Frederic Savoir\n\n      Cecile Chahi\n\n    Philippe Delamarre\n\n  Philippe Ulrich\n\nSebastien Berthet\n\nPierre Gousseau" },
+	{ 0x265, "Now Go Out Of This World" },
+	{ 0x190, "Good evening professor." },
+	{ 0x191, "I see you have driven here in your\nFerrari." },
+	{ 0x192, "IDENTIFICATION" },
+	{ 0x193, "Monsieur est en parfaite sante." },
+	{ 0x194, "Y\n" },
+	{ 0x193, "AU BOULOT !!!\n" },
+};
+
+} // namespace Awe
diff --git a/engines/awe/systemstub.h b/engines/awe/systemstub.h
new file mode 100644
index 00000000000..c17945a7f0b
--- /dev/null
+++ b/engines/awe/systemstub.h
@@ -0,0 +1,68 @@
+/* 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 AWE_SYSTEMSTUB_H
+#define AWE_SYSTEMSTUB_H
+
+#include "awe/intern.h"
+
+namespace Awe {
+
+struct PlayerInput {
+	enum {
+		DIR_LEFT  = 1 << 0,
+		DIR_RIGHT = 1 << 1,
+		DIR_UP    = 1 << 2,
+		DIR_DOWN  = 1 << 3
+	};
+
+	uint8 dirMask;
+	bool button;
+	bool code;
+	bool pause;
+	bool quit;
+	char lastChar;
+	bool save, load;
+	bool fastMode;
+	int8 stateSlot;
+};
+
+struct SystemStub {
+	PlayerInput _pi;
+
+	virtual ~SystemStub() {}
+
+	virtual void init(const char *title) = 0;
+	virtual void destroy() = 0;
+
+	virtual void setPalette(uint8 s, uint8 n, const uint8 *buf) = 0;
+	virtual void copyRect(uint16 x, uint16 y, uint16 w, uint16 h, const uint8 *buf, uint32 pitch) = 0;
+
+	virtual void processEvents() = 0;
+	virtual void sleep(uint32 duration) = 0;
+	virtual uint32 getTimeStamp() = 0;
+};
+
+extern SystemStub *SystemStub_SDL_create();
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/util.cpp b/engines/awe/util.cpp
new file mode 100644
index 00000000000..8b9296d0584
--- /dev/null
+++ b/engines/awe/util.cpp
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "awe/util.h"
+
+namespace Awe {
+
+void string_lower(char *p) {
+	for (; *p; ++p) {
+		if (*p >= 'A' && *p <= 'Z') {
+			*p += 'a' - 'A';
+		}
+	}
+}
+
+void string_upper(char *p) {
+	for (; *p; ++p) {
+		if (*p >= 'a' && *p <= 'z') {
+			*p += 'A' - 'a';
+		}
+	}
+}
+
+} // namespace Awe
diff --git a/engines/awe/util.h b/engines/awe/util.h
new file mode 100644
index 00000000000..3287a4caabb
--- /dev/null
+++ b/engines/awe/util.h
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AWE_UTIL_H
+#define AWE_UTIL_H
+
+#include "common/textconsole.h"
+#include "awe/intern.h"
+
+namespace Awe {
+
+enum {
+	DBG_LOGIC = 1 << 0,
+	DBG_BANK  = 1 << 1,
+	DBG_VIDEO = 1 << 2,
+	DBG_INFO  = 1 << 3
+};
+
+extern uint16 g_debugMask;
+
+extern void string_lower(char *p);
+extern void string_upper(char *p);
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
new file mode 100644
index 00000000000..6be66de75fc
--- /dev/null
+++ b/engines/awe/video.cpp
@@ -0,0 +1,516 @@
+/* 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 "awe/awe.h"
+#include "awe/video.h"
+#include "awe/resource.h"
+#include "awe/serializer.h"
+#include "awe/systemstub.h"
+
+namespace Awe {
+
+void Polygon::init(const uint8 *p, uint16 zoom) {
+	bbw = (*p++) * zoom / 64;
+	bbh = (*p++) * zoom / 64;
+	numPoints = *p++;
+	assert((numPoints & 1) == 0 && numPoints < MAX_POINTS);
+	for (int i = 0; i < numPoints; ++i) {
+		Point *pt = &points[i];
+		pt->x = (*p++) * zoom / 64;
+		pt->y = (*p++) * zoom / 64;
+	}
+}
+
+Video::Video(Resource *res, SystemStub *stub) 
+	: _res(res), _stub(stub) {
+}
+
+void Video::init() {
+	_newPal = 0xFF;
+	for (int i = 0; i < 4; ++i) {
+		_pagePtrs[i] = allocPage();
+	}
+	_curPagePtr3 = getPagePtr(1);
+	_curPagePtr2 = getPagePtr(2);
+	changePagePtr1(0xFE);
+	_interpTable[0] = 0x4000;
+	for (int i = 1; i < 0x400; ++i) {
+		_interpTable[i] = 0x4000 / i;
+	}
+}
+
+void Video::setDataBuffer(uint8 *dataBuf, uint16 offset) {
+	_dataBuf = dataBuf;
+	_pData.pc = dataBuf + offset;
+}
+
+void Video::drawShape(uint8 color, uint16 zoom, const Point &pt) {
+	uint8 i = _pData.fetchByte();
+	if (i >= 0xC0) {
+		if (color & 0x80) {
+			color = i & 0x3F;
+		}
+		_pg.init(_pData.pc, zoom);
+		fillPolygon(color, zoom, pt);
+	} else {
+		i &= 0x3F;
+		if (i == 1) {
+			::warning("Video::drawShape() ec=0x%X (i != 2)", 0xF80);
+		} else if (i == 2) {
+			drawShapeParts(zoom, pt);
+		} else {
+			::warning("Video::drawShape() ec=0x%X (i != 2)", 0xFBB);
+		}
+	}
+}
+
+void Video::fillPolygon(uint16 color, uint16 zoom, const Point &pt) {
+	if (_pg.bbw == 0 && _pg.bbh == 1 && _pg.numPoints == 4) {
+		drawPoint(color, pt.x, pt.y);
+		return;
+	}
+	
+	int16 x1 = pt.x - _pg.bbw / 2;
+	int16 x2 = pt.x + _pg.bbw / 2;
+	int16 y1 = pt.y - _pg.bbh / 2;
+	int16 y2 = pt.y + _pg.bbh / 2;
+
+	if (x1 > 319 || x2 < 0 || y1 > 199 || y2 < 0)
+		return;
+
+	_hliney = y1;
+	
+	uint16 i, j;
+	i = 0;
+	j = _pg.numPoints - 1;
+	
+	x2 = _pg.points[i].x + x1;
+	x1 = _pg.points[j].x + x1;
+
+	++i;
+	--j;
+
+	drawLine pdl;
+	if (color < 0x10) {
+		pdl = &Video::drawLineN;
+	} else if (color > 0x10) {
+		pdl = &Video::drawLineP;
+	} else {
+		pdl = &Video::drawLineT;
+	}
+
+	uint32 cpt1 = x1 << 16;
+	uint32 cpt2 = x2 << 16;
+
+	while (1) {
+		_pg.numPoints -= 2;
+		if (_pg.numPoints == 0) {
+			return;
+		}
+		uint16 h;
+		int32 step1 = calcStep(_pg.points[j + 1], _pg.points[j], h);
+		int32 step2 = calcStep(_pg.points[i - 1], _pg.points[i], h);
+
+		++i;
+		--j;
+
+		cpt1 = (cpt1 & 0xFFFF0000) | 0x7FFF;
+		cpt2 = (cpt2 & 0xFFFF0000) | 0x8000;
+
+		if (h == 0) {	
+			cpt1 += step1;
+			cpt2 += step2;
+		} else {
+			for (; h != 0; --h) {
+				if (_hliney >= 0) {
+					x1 = cpt1 >> 16;
+					x2 = cpt2 >> 16;
+					if (x1 <= 319 && x2 >= 0) {
+						if (x1 < 0) x1 = 0;
+						if (x2 > 319) x2 = 319;
+						(this->*pdl)(x1, x2, color);
+					}
+				}
+				cpt1 += step1;
+				cpt2 += step2;
+				++_hliney;					
+				if (_hliney > 199) return;
+			}
+		}
+	}
+}
+
+void Video::drawShapeParts(uint16 zoom, const Point &pgc) {
+	Point pt(pgc);
+	pt.x -= _pData.fetchByte() * zoom / 64;
+	pt.y -= _pData.fetchByte() * zoom / 64;
+	int16 n = _pData.fetchByte();
+	debug(DBG_VIDEO, "Video::drawShapeParts n=%d", n);
+	for ( ; n >= 0; --n) {
+		uint16 off = _pData.fetchWord();
+		Point po(pt);
+		po.x += _pData.fetchByte() * zoom / 64;
+		po.y += _pData.fetchByte() * zoom / 64;
+		uint16 color = 0xFF;
+		uint16 _bp = off;
+		off &= 0x7FFF;
+		if (_bp & 0x8000) {
+			color = *_pData.pc & 0x7F;
+			_pData.pc += 2;
+		}
+		uint8 *bak = _pData.pc;
+		_pData.pc = _dataBuf + off * 2;
+		drawShape(color, zoom, po);
+		_pData.pc = bak;
+	}
+}
+
+int32 Video::calcStep(const Point &p1, const Point &p2, uint16 &dy) {
+	dy = p2.y - p1.y;
+	return (p2.x - p1.x) * _interpTable[dy] * 4;
+}
+
+void Video::drawString(uint8 color, uint16 x, uint16 y, uint16 strId) {
+	const StrEntry *se = _stringsTableEng;
+	while (se->id != 0xFFFF && se->id != strId) ++se;
+	debug(DBG_VIDEO, "drawString(%d, %d, %d, '%s')", color, x, y, se->str);
+	uint16 xx = x;
+	int len = strlen(se->str);
+	for (int i = 0; i < len; ++i) {
+		if (se->str[i] == '\n') {
+			y += 8;
+			x = xx;
+		} else {
+			drawChar(se->str[i], x, y, color, _curPagePtr1);
+			++x;
+		}
+	}
+}
+
+void Video::drawChar(uint8 c, uint16 x, uint16 y, uint8 color, uint8 *buf) {
+	if (x <= 39 && y <= 192) {
+		const uint8 *ft = _font + (c - 0x20) * 8;
+		uint8 *p = buf + x * 4 + y * 160;
+		for (int j = 0; j < 8; ++j) {
+			uint8 ch = *(ft + j);
+			for (int i = 0; i < 4; ++i) {
+				uint8 b = *(p + i);
+				uint8 cmask = 0xFF;
+				uint8 colb = 0;
+				if (ch & 0x80) {
+					colb |= color << 4;
+					cmask &= 0x0F;
+				}
+				ch <<= 1;
+				if (ch & 0x80) {
+					colb |= color;
+					cmask &= 0xF0;
+				}
+				ch <<= 1;
+				*(p + i) = (b & cmask) | colb;
+			}
+			p += 160;
+		}
+	}
+}
+
+void Video::drawPoint(uint8 color, int16 x, int16 y) {
+	debug(DBG_VIDEO, "drawPoint(%d, %d, %d)", color, x, y);
+	if (x >= 0 && x <= 319 && y >= 0 && y <= 199) {
+		uint16 off = y * 160 + x / 2;
+	
+		uint8 cmasko, cmaskn;
+		if (x & 1) {
+			cmaskn = 0x0F;
+			cmasko = 0xF0;
+		} else {
+			cmaskn = 0xF0;
+			cmasko = 0x0F;
+		}
+
+		uint8 colb = (color << 4) | color;
+		if (color == 0x10) {
+			cmaskn &= 0x88;
+			cmasko = ~cmaskn;
+			colb = 0x88;		
+		} else if (color == 0x11) {
+			colb = *(_pagePtrs[0] + off);
+		}
+		uint8 b = *(_curPagePtr1 + off);
+		*(_curPagePtr1 + off) = (b & cmasko) | (colb & cmaskn);
+	}
+}
+
+void Video::drawLineT(int16 x1, int16 x2, uint8 color) {
+	debug(DBG_VIDEO, "drawLineT(%d, %d, %d)", x1, x2, color);
+	int16 xmax = MAX(x1, x2);
+	int16 xmin = MIN(x1, x2);
+	uint8 *p = _curPagePtr1 + _hliney * 160 + xmin / 2;
+
+	uint16 w = xmax / 2 - xmin / 2 + 1;
+	uint8 cmaske = 0;
+	uint8 cmasks = 0;	
+	if (xmin & 1) {
+		--w;
+		cmasks = 0xF7;
+	}
+	if (!(xmax & 1)) {
+		--w;
+		cmaske = 0x7F;
+	}
+
+	if (cmasks != 0) {
+		*p = (*p & cmasks) | 0x08;
+		++p;
+	}
+	while (w--) {
+		*p = (*p & 0x77) | 0x88;
+		++p;
+	}
+	if (cmaske != 0) {
+		*p = (*p & cmaske) | 0x80;
+		++p;
+	}
+}
+
+void Video::drawLineN(int16 x1, int16 x2, uint8 color) {
+	debug(DBG_VIDEO, "drawLineN(%d, %d, %d)", x1, x2, color);
+	int16 xmax = MAX(x1, x2);
+	int16 xmin = MIN(x1, x2);
+	uint8 *p = _curPagePtr1 + _hliney * 160 + xmin / 2;
+
+	uint16 w = xmax / 2 - xmin / 2 + 1;
+	uint8 cmaske = 0;
+	uint8 cmasks = 0;	
+	if (xmin & 1) {
+		--w;
+		cmasks = 0xF0;
+	}
+	if (!(xmax & 1)) {
+		--w;
+		cmaske = 0x0F;
+	}
+
+	uint8 colb = ((color & 0xF) << 4) | (color & 0xF);	
+	if (cmasks != 0) {
+		*p = (*p & cmasks) | (colb & 0x0F);
+		++p;
+	}
+	while (w--) {
+		*p++ = colb;
+	}
+	if (cmaske != 0) {
+		*p = (*p & cmaske) | (colb & 0xF0);
+		++p;		
+	}
+}
+
+void Video::drawLineP(int16 x1, int16 x2, uint8 color) {
+	debug(DBG_VIDEO, "drawLineP(%d, %d, %d)", x1, x2, color);
+	int16 xmax = MAX(x1, x2);
+	int16 xmin = MIN(x1, x2);
+	uint16 off = _hliney * 160 + xmin / 2;
+	uint8 *p = _curPagePtr1 + off;
+	uint8 *q = _pagePtrs[0] + off;
+
+	uint8 w = xmax / 2 - xmin / 2 + 1;
+	uint8 cmaske = 0;
+	uint8 cmasks = 0;	
+	if (xmin & 1) {
+		--w;
+		cmasks = 0xF0;
+	}
+	if (!(xmax & 1)) {
+		--w;
+		cmaske = 0x0F;
+	}
+
+	if (cmasks != 0) {
+		*p = (*p & cmasks) | (*q & 0x0F);
+		++p;
+		++q;
+	}
+	while (w--) {
+		*p++ = *q++;			
+	}
+	if (cmaske != 0) {
+		*p = (*p & cmaske) | (*q & 0xF0);
+		++p;
+		++q;
+	}
+}
+
+uint8 *Video::getPagePtr(uint8 page) {
+	uint8 *p;
+	if (page <= 3) {
+		p = _pagePtrs[page];
+	} else {
+		switch (page) {
+		case 0xFF:
+			p = _curPagePtr3;
+			break;
+		case 0xFE:
+			p = _curPagePtr2;
+			break;
+		default:
+			p = _pagePtrs[0]; // XXX check
+			::warning("Video::getPagePtr() p != [0,1,2,3,0xFF,0xFE] == 0x%X", page);
+			break;
+		}
+	}
+	return p;
+}
+
+void Video::changePagePtr1(uint8 page) {
+	debug(DBG_VIDEO, "Video::changePagePtr1(%d)", page);
+	_curPagePtr1 = getPagePtr(page);
+}
+
+void Video::fillPage(uint8 page, uint8 color) {
+	debug(DBG_VIDEO, "Video::fillPage(%d, %d)", page, color);
+	uint8 *p = getPagePtr(page);
+	uint8 c = (color << 4) | color;
+	memset(p, c, VID_PAGE_SIZE);
+}
+
+void Video::copyPage(uint8 src, uint8 dst, int16 vscroll) {
+	debug(DBG_VIDEO, "Video::copyPage(%d, %d)", src, dst);
+	if (src >= 0xFE || !((src &= 0xBF) & 0x80)) {
+		uint8 *p = getPagePtr(src);
+		uint8 *q = getPagePtr(dst);
+		if (p != q) {
+			memcpy(q, p, VID_PAGE_SIZE);
+		}		
+	} else {
+		uint8 *p = getPagePtr(src & 3);
+		uint8 *q = getPagePtr(dst);
+		if (p != q && vscroll >= -199 && vscroll <= 199) {
+			uint16 h = 200;
+			if (vscroll < 0) {
+				h += vscroll;
+				p += -vscroll * 160;
+			} else {
+				h -= vscroll;
+				q += vscroll * 160;
+			}
+			memcpy(q, p, h * 160);
+		}
+	}
+}
+
+void Video::copyPagePtr(const uint8 *src) {
+	debug(DBG_VIDEO, "Video::copyPagePtr()");
+	uint8 *dst = _pagePtrs[0];
+	int h = 200;
+	while (h--) {
+		int w = 40;
+		while (w--) {
+			uint8 p[] = {
+				*(src + 8000 * 3),
+				*(src + 8000 * 2),
+				*(src + 8000 * 1),
+				*(src + 8000 * 0)
+			};
+			for(int j = 0; j < 4; ++j) {
+				uint8 acc = 0;
+				for (int i = 0; i < 8; ++i) {
+					acc <<= 1;
+					acc |= (p[i & 3] & 0x80) ? 1 : 0;
+					p[i & 3] <<= 1;
+				}
+				*dst++ = acc;
+			}			
+			++src;
+		}
+	}
+}
+
+uint8 *Video::allocPage() {
+	uint8 *buf = (uint8 *)malloc(VID_PAGE_SIZE);
+	memset(buf, 0, VID_PAGE_SIZE);
+	return buf;
+}
+
+void Video::changePal(uint8 palNum) {
+	if (palNum < 32) {
+		uint8 *p = _res->_segVideoPal + palNum * 32;
+		uint8 pal[16 * 3];
+		for (int i = 0; i < 16; ++i) {
+			uint8 c1 = *(p + 0);
+			uint8 c2 = *(p + 1);
+			p += 2;
+			pal[i * 3 + 0] = ((c1 & 0x0F) << 2) | ((c1 & 0x0F) >> 2); // r
+			pal[i * 3 + 1] = ((c2 & 0xF0) >> 2) | ((c2 & 0xF0) >> 6); // g
+			pal[i * 3 + 2] = ((c2 & 0x0F) >> 2) | ((c2 & 0x0F) << 2); // b
+		}
+		_stub->setPalette(0, 16, pal);
+		_curPal = palNum;
+	}
+}
+
+void Video::updateDisplay(uint8 page) {
+	debug(DBG_VIDEO, "Video::updateDisplay(%d)", page);
+	if (page != 0xFE) {
+		if (page == 0xFF) {
+			SWAP(_curPagePtr2, _curPagePtr3);
+		} else {
+			_curPagePtr2 = getPagePtr(page);
+		}
+	}
+	if (_newPal != 0xFF) {
+		changePal(_newPal);
+		_newPal = 0xFF;
+	}
+	_stub->copyRect(0, 0, 320, 200, _curPagePtr2, 160);
+}
+
+void Video::saveOrLoad(Serializer &ser) {
+	uint8 mask = 0;
+	if (ser._mode == Serializer::SM_SAVE) {
+		for (int i = 0; i < 4; ++i) {
+			if (_pagePtrs[i] == _curPagePtr1)
+				mask |= i << 4;
+			if (_pagePtrs[i] == _curPagePtr2)
+				mask |= i << 2;
+			if (_pagePtrs[i] == _curPagePtr3)
+				mask |= i << 0;
+		}		
+	}
+	Serializer::Entry entries[] = {
+		SE_INT(&_curPal, Serializer::SES_INT8, VER(1)),
+		SE_INT(&_newPal, Serializer::SES_INT8, VER(1)),
+		SE_INT(&mask, Serializer::SES_INT8, VER(1)),
+		SE_ARRAY(_pagePtrs[0], Video::VID_PAGE_SIZE, Serializer::SES_INT8, VER(1)),
+		SE_ARRAY(_pagePtrs[1], Video::VID_PAGE_SIZE, Serializer::SES_INT8, VER(1)),
+		SE_ARRAY(_pagePtrs[2], Video::VID_PAGE_SIZE, Serializer::SES_INT8, VER(1)),
+		SE_ARRAY(_pagePtrs[3], Video::VID_PAGE_SIZE, Serializer::SES_INT8, VER(1)),
+		SE_END()
+	};
+	ser.saveOrLoadEntries(entries);
+	if (ser._mode == Serializer::SM_LOAD) {
+		_curPagePtr1 = _pagePtrs[(mask >> 4) & 0x3];
+		_curPagePtr2 = _pagePtrs[(mask >> 2) & 0x3];
+		_curPagePtr3 = _pagePtrs[(mask >> 0) & 0x3];
+		changePal(_curPal);
+	}
+}
+
+} // namespace Awe
diff --git a/engines/awe/video.h b/engines/awe/video.h
new file mode 100644
index 00000000000..fdba4a62263
--- /dev/null
+++ b/engines/awe/video.h
@@ -0,0 +1,102 @@
+/* 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 AWE_VIDEO_H
+#define AWE_VIDEO_H
+
+#include "intern.h"
+
+namespace Awe {
+
+struct StrEntry {
+	uint16 id;
+	const char *str;
+};
+
+struct Polygon {
+	enum {
+		MAX_POINTS = 50
+	};
+
+	uint16 bbw, bbh;
+	uint8 numPoints;
+	Point points[MAX_POINTS];
+
+	void init(const uint8 *p, uint16 zoom);
+};
+
+struct Resource;
+struct Serializer;
+struct SystemStub;
+
+struct Video {
+	typedef void (Video::*drawLine)(int16 x1, int16 x2, uint8 col);
+
+	enum {
+		VID_PAGE_SIZE  = 320 * 200 / 2
+	};
+
+	static const uint8 _font[];
+	static const StrEntry _stringsTableEng[];
+	static const StrEntry _stringsTableDemo[];
+
+	Resource *_res;
+	SystemStub *_stub;
+
+	uint8 _newPal, _curPal;
+	uint8 *_pagePtrs[4];
+	uint8 *_curPagePtr1, *_curPagePtr2, *_curPagePtr3;
+	Polygon _pg;
+	int16 _hliney;
+	uint16 _interpTable[0x400];
+	Ptr _pData;
+	uint8 *_dataBuf;
+
+	Video(Resource *res, SystemStub *stub);
+	void init();
+
+	void setDataBuffer(uint8 *dataBuf, uint16 offset);
+	void drawShape(uint8 color, uint16 zoom, const Point &pt);
+	void fillPolygon(uint16 color, uint16 zoom, const Point &pt);
+	void drawShapeParts(uint16 zoom, const Point &pt);
+	int32 calcStep(const Point &p1, const Point &p2, uint16 &dy);
+
+	void drawString(uint8 color, uint16 x, uint16 y, uint16 strId);
+	void drawChar(uint8 c, uint16 x, uint16 y, uint8 color, uint8 *buf);
+	void drawPoint(uint8 color, int16 x, int16 y);
+	void drawLineT(int16 x1, int16 x2, uint8 color);
+	void drawLineN(int16 x1, int16 x2, uint8 color);
+	void drawLineP(int16 x1, int16 x2, uint8 color);
+	uint8 *getPagePtr(uint8 page);
+	void changePagePtr1(uint8 page);
+	void fillPage(uint8 page, uint8 color);
+	void copyPage(uint8 src, uint8 dst, int16 vscroll);
+	void copyPagePtr(const uint8 *src);
+	uint8 *allocPage();
+	void changePal(uint8 pal);
+	void updateDisplay(uint8 page);
+	
+	void saveOrLoad(Serializer &ser);
+};
+
+} // namespace Awe
+
+#endif


Commit: 0a4f34780f0e73c69b8f5613ec1935e050caa63d
    https://github.com/scummvm/scummvm/commit/0a4f34780f0e73c69b8f5613ec1935e050caa63d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Metaengine fix

Changed paths:
    engines/awe/awe.cpp
    engines/awe/metaengine.cpp
    engines/awe/sdlstub.cpp


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 961b5fd4e35..67a5c077ddb 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -29,7 +29,7 @@
 namespace Awe {
 
 AweEngine::AweEngine(OSystem *syst, const ADGameDescription *gameDesc)
-	: Engine(syst) {
+	: Engine(syst), _gameDescription(gameDesc) {
 }
 
 Common::Error AweEngine::run() {
diff --git a/engines/awe/metaengine.cpp b/engines/awe/metaengine.cpp
index d5e446638c4..3613b3bf36c 100644
--- a/engines/awe/metaengine.cpp
+++ b/engines/awe/metaengine.cpp
@@ -45,7 +45,7 @@ static const ADExtraGuiOptionsMap optionsList[] = {
 } // End of namespace Awe
 
 const char *AweMetaEngine::getName() const {
-	return "xyzzy";
+	return "awe";
 }
 
 const ADExtraGuiOptionsMap *AweMetaEngine::getAdvancedExtraGuiOptions() const {
diff --git a/engines/awe/sdlstub.cpp b/engines/awe/sdlstub.cpp
index e9cd2d80dad..5d9b020158b 100644
--- a/engines/awe/sdlstub.cpp
+++ b/engines/awe/sdlstub.cpp
@@ -21,6 +21,7 @@
 
 #include "common/system.h"
 #include "common/events.h"
+#include "graphics/paletteman.h"
 #include "graphics/screen.h"
 #include "awe/awe.h"
 #include "awe/systemstub.h"
@@ -46,11 +47,10 @@ struct SDLStub : SystemStub {
 
 	uint8 *_offscreen;
 	Graphics::Screen *_screen;
-	//SDL_Surface *_sclscreen;
 	bool _fullscreen;
 	uint8 _scaler;
 	Graphics::PaletteLookup _palLookup;
-	uint16 _pal[16];
+	byte _pal[16];
 
 	virtual ~SDLStub() {}
 	virtual void init(const char *title);
@@ -104,14 +104,15 @@ void SDLStub::setPalette(uint8 s, uint8 n, const uint8 *buf) {
 			c[j] =  (col << 2) | (col & 3);
 		}
 
-		
-		_pal[i] = _palLookup.findBestColor(c[0], c[1], c[2]);
+		g_system->getPaletteManager()->setPalette(
+			c, i, 1);
+		_pal[i] = i;
 	}	
 }
 
 void SDLStub::copyRect(uint16 x, uint16 y, uint16 w, uint16 h, const uint8 *buf, uint32 pitch) {
 	buf += y * pitch + x;
-	uint16 *p = (uint16 *)_offscreen;
+	byte *p = (byte *)_offscreen;
 	while (h--) {
 		for (int i = 0; i < w / 2; ++i) {
 			uint8 p1 = *(buf + i) >> 4;


Commit: 0178a6989424c663bebf07ed6e2d77d92fa2ce10
    https://github.com/scummvm/scummvm/commit/0178a6989424c663bebf07ed6e2d77d92fa2ce10
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Switch game detection entry

The version I added detection for doesn't actually have
a memlist.bin, which the game requires for operation.

Changed paths:
    engines/awe/detection_tables.h


diff --git a/engines/awe/detection_tables.h b/engines/awe/detection_tables.h
index f3257d4a8f4..dbcd25d0446 100644
--- a/engines/awe/detection_tables.h
+++ b/engines/awe/detection_tables.h
@@ -30,13 +30,25 @@ const ADGameDescription gameDescriptions[] = {
 	{
 		"anotherworld",
 		nullptr,
-		AD_ENTRY1s("bank", "30fb99cb4cbd812273d0b54b7b4a18ca", 987462),
+		AD_ENTRY1s("memlist.bin", "f2bf61fe20c98108b2256e96d57d3fe0", 2940),
 		Common::EN_ANY,
 		Common::kPlatformDOS,
 		ADGF_UNSTABLE,
 		GUIO1(GUIO_NONE)
 	},
 
+#if 0
+	// Unsupported release that doesn't have a memlist.bin
+	{
+		"anotherworld",
+		nullptr,
+		AD_ENTRY1s("bank", "30fb99cb4cbd812273d0b54b7b4a18ca", 987462),
+		Common::EN_ANY,
+		Common::kPlatformDOS,
+		ADGF_UNSTABLE,
+		GUIO1(GUIO_NONE)
+	},
+#endif
 	AD_TABLE_END_MARKER
 };
 


Commit: 61cc6984c09d7995e41f0e3cf67aafa52c9d8c3e
    https://github.com/scummvm/scummvm/commit/61cc6984c09d7995e41f0e3cf67aafa52c9d8c3e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Null Resource fields, fixing startup crash

Changed paths:
    engines/awe/resource.h


diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index 5b59a9cb54e..3a233469fb6 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -27,17 +27,17 @@
 namespace Awe {
 
 struct MemEntry {
-	uint8 valid;         // 0x0
-	uint8 type;          // 0x1, Resource::ResType
-	uint8 *bufPtr;       // 0x2
-	uint16 unk4;         // 0x4, unused ?
-	uint8 rankNum;       // 0x6
-	uint8 bankNum;       // 0x7
-	uint32 bankPos;      // 0x8 0xA
-	uint16 unkC;         // 0xC, unused ?
-	uint16 packedSize;   // 0xE
-	uint16 unk10;        // 0x10, unused ?
-	uint16 unpackedSize; // 0x12
+	uint8 valid = 0;			// 0x0
+	uint8 type = 0;				// 0x1, Resource::ResType
+	uint8 *bufPtr = nullptr;	// 0x2
+	uint16 unk4 = 0;			// 0x4, unused ?
+	uint8 rankNum = 0;			// 0x6
+	uint8 bankNum = 0;			// 0x7
+	uint32 bankPos = 0;			// 0x8 0xA
+	uint16 unkC = 0;			// 0xC, unused ?
+	uint16 packedSize = 0;		// 0xE
+	uint16 unk10 = 0;			// 0x10, unused ?
+	uint16 unpackedSize = 0;	// 0x12
 };
 
 struct Serializer;
@@ -60,17 +60,21 @@ struct Resource {
 	static const uint16 _memListAudio[];
 	static const uint16 _memListParts[][4];
 	
-	Video *_vid;
-	const char *_dataDir;
+	Video *_vid = nullptr;
+	const char *_dataDir = nullptr;
 	MemEntry _memList[150];
-	uint16 _numMemList;
-	uint16 _curPtrsId, _newPtrsId;
-	uint8 *_memPtrStart, *_scriptBakPtr, *_scriptCurPtr, *_vidBakPtr, *_vidCurPtr;
-	bool _useSegVideo2;
-	uint8 *_segVideoPal;
-	uint8 *_segCode;
-	uint8 *_segVideo1;
-	uint8 *_segVideo2;
+	uint16 _numMemList = 0;
+	uint16 _curPtrsId = 0, _newPtrsId = 0;
+	uint8 *_memPtrStart = nullptr,
+		*_scriptBakPtr = nullptr,
+		*_scriptCurPtr = nullptr,
+		*_vidBakPtr = nullptr,
+		*_vidCurPtr = nullptr;
+	bool _useSegVideo2 = false;
+	uint8 *_segVideoPal = nullptr;
+	uint8 *_segCode = nullptr;
+	uint8 *_segVideo1 = nullptr;
+	uint8 *_segVideo2 = nullptr;
 
 	Resource(Video *vid, const char *dataDir);
 	


Commit: 5dcbeed7d28ce1dbc3402deba98dd1b889557212
    https://github.com/scummvm/scummvm/commit/5dcbeed7d28ce1dbc3402deba98dd1b889557212
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Add screen updates

Changed paths:
    engines/awe/sdlstub.cpp


diff --git a/engines/awe/sdlstub.cpp b/engines/awe/sdlstub.cpp
index 5d9b020158b..4c73816e813 100644
--- a/engines/awe/sdlstub.cpp
+++ b/engines/awe/sdlstub.cpp
@@ -126,6 +126,7 @@ void SDLStub::copyRect(uint16 x, uint16 y, uint16 w, uint16 h, const uint8 *buf,
 
 	_screen->copyRectToSurface(_offscreen, SCREEN_W,
 		0, 0, SCREEN_W, SCREEN_H);
+	_screen->update();
 }
 
 void SDLStub::processEvents() {


Commit: 7cc7d9cf5ff901d71235869790a10d915bf45eaf
    https://github.com/scummvm/scummvm/commit/7cc7d9cf5ff901d71235869790a10d915bf45eaf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Engine shouldQuit checks for exit

Changed paths:
    engines/awe/engine.cpp
    engines/awe/logic.cpp
    engines/awe/sdlstub.cpp


diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index c07c2547ce9..5f66264164a 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -38,7 +38,7 @@ void Engine::run() {
 	setup();
 	// XXX
 	_log.restartAt(0x3E80); // demo starts at 0x3E81
-	while (!_stub->_pi.quit) {
+	while (!_stub->_pi.quit && !g_engine->shouldQuit()) {
 		_log.setupScripts();
 		_log.inp_updatePlayer();
 		processInput();
diff --git a/engines/awe/logic.cpp b/engines/awe/logic.cpp
index f40f5bb3936..78d7f92cbb0 100644
--- a/engines/awe/logic.cpp
+++ b/engines/awe/logic.cpp
@@ -345,7 +345,7 @@ void Logic::setupScripts() {
 }
 
 void Logic::runScripts() {
-	for (int i = 0; i < 0x40; ++i) {
+	for (int i = 0; i < 0x40 && !g_engine->shouldQuit(); ++i) {
 		if (_scriptPaused[0][i] == 0) {
 			uint16 n = _scriptPos[0][i];
 			if (n != 0xFFFF) {
@@ -365,7 +365,7 @@ void Logic::runScripts() {
 }
 
 void Logic::executeScript() {
-	while (!_scriptHalted) {
+	while (!_scriptHalted && !g_engine->shouldQuit()) {
 		uint8 opcode = _scriptPtr.fetchByte();
 		if (opcode & 0x80) {
 			uint16 off = ((opcode << 8) | _scriptPtr.fetchByte()) * 2;
diff --git a/engines/awe/sdlstub.cpp b/engines/awe/sdlstub.cpp
index 4c73816e813..2ae035bf5bb 100644
--- a/engines/awe/sdlstub.cpp
+++ b/engines/awe/sdlstub.cpp
@@ -132,7 +132,7 @@ void SDLStub::copyRect(uint16 x, uint16 y, uint16 w, uint16 h, const uint8 *buf,
 void SDLStub::processEvents() {
 	Common::Event ev;
 
-	while (g_engine->shouldQuit() &&
+	while (!g_engine->shouldQuit() &&
 			g_system->getEventManager()->pollEvent(ev)) {
 		switch (ev.type) {
 		case Common::EVENT_KEYUP:


Commit: 4b0e033c8b9c8e24f6424c279158493420725ed5
    https://github.com/scummvm/scummvm/commit/4b0e033c8b9c8e24f6424c279158493420725ed5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Fix debug channel usage

Changed paths:
    engines/awe/bank.cpp
    engines/awe/detection.cpp
    engines/awe/detection.h
    engines/awe/engine.cpp
    engines/awe/logic.cpp
    engines/awe/resource.cpp
    engines/awe/util.h
    engines/awe/video.cpp


diff --git a/engines/awe/bank.cpp b/engines/awe/bank.cpp
index 5ed47a05cf1..e2f6abb70b7 100644
--- a/engines/awe/bank.cpp
+++ b/engines/awe/bank.cpp
@@ -56,7 +56,7 @@ bool Bank::read(const MemEntry *me, uint8 *buf) {
 
 void Bank::decUnk1(uint8 numChunks, uint8 addCount) {
 	uint16 count = getCode(numChunks) + addCount + 1;
-	debug(DBG_BANK, "Bank::decUnk1(%d, %d) count=%d", numChunks, addCount, count);
+	debugC(kDebugBank, "Bank::decUnk1(%d, %d) count=%d", numChunks, addCount, count);
 	_unpCtx.datasize -= count;
 	while (count--) {
 		assert(_oBuf >= _iBuf && _oBuf >= _startBuf);
@@ -68,7 +68,7 @@ void Bank::decUnk1(uint8 numChunks, uint8 addCount) {
 void Bank::decUnk2(uint8 numChunks) {
 	uint16 i = getCode(numChunks);
 	uint16 count = _unpCtx.size + 1;
-	debug(DBG_BANK, "Bank::decUnk2(%d) i=%d count=%d", numChunks, i, count);
+	debugC(kDebugBank, "Bank::decUnk2(%d) i=%d count=%d", numChunks, i, count);
 	_unpCtx.datasize -= count;
 	while (count--) {
 		assert(_oBuf >= _iBuf && _oBuf >= _startBuf);
diff --git a/engines/awe/detection.cpp b/engines/awe/detection.cpp
index 0a9dde56d93..587410fad07 100644
--- a/engines/awe/detection.cpp
+++ b/engines/awe/detection.cpp
@@ -30,7 +30,10 @@
 #include "awe/detection_tables.h"
 
 const DebugChannelDef AweMetaEngineDetection::debugFlagList[] = {
-	{ Awe::kDebugGraphics, "Graphics", "Graphics debug level" },
+	{ Awe::kDebugLogic, "Logic", "Logic debug level" },
+	{ Awe::kDebugBank, "Bank", "Bank debug level" },
+	{ Awe::kDebugVideo, "Video", "Video debug level" },
+	{ Awe::kDebugInfo, "Info", "Info debug level" },
 	DEBUG_CHANNEL_END
 };
 
diff --git a/engines/awe/detection.h b/engines/awe/detection.h
index e57d59a0202..44db8224a20 100644
--- a/engines/awe/detection.h
+++ b/engines/awe/detection.h
@@ -27,7 +27,10 @@
 namespace Awe {
 
 enum AweDebugChannels {
-	kDebugGraphics = 1
+	kDebugLogic = 1 << 0,
+	kDebugBank = 1 << 1,
+	kDebugVideo = 1 << 2,
+	kDebugInfo = 1 << 3
 };
 
 extern const PlainGameDescriptor aweGames[];
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index 5f66264164a..b6035b8a0dd 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -77,7 +77,7 @@ void Engine::processInput() {
 		int8 slot = _stateSlot + _stub->_pi.stateSlot;
 		if (slot >= 0 && slot < MAX_SAVE_SLOTS) {
 			_stateSlot = slot;
-			debug(DBG_INFO, "Current game state slot is %d", _stateSlot);
+			debugC(kDebugInfo, "Current game state slot is %d", _stateSlot);
 		}
 		_stub->_pi.stateSlot = 0;
 	}
@@ -110,7 +110,7 @@ void Engine::saveGameState(uint8 slot, const char *desc) {
 		if (f.ioErr()) {
 			::warning("I/O error when saving game state");
 		} else {
-			debug(DBG_INFO, "Saved state to slot %d", _stateSlot);
+			debugC(kDebugInfo, "Saved state to slot %d", _stateSlot);
 		}
 	}
 #endif
@@ -141,7 +141,7 @@ void Engine::loadGameState(uint8 slot) {
 		if (f.ioErr()) {
 			::warning("I/O error when loading game state");
 		} else {
-			debug(DBG_INFO, "Loaded state from slot %d", _stateSlot);
+			debugC(kDebugInfo, "Loaded state from slot %d", _stateSlot);
 		}
 	}
 #endif
diff --git a/engines/awe/logic.cpp b/engines/awe/logic.cpp
index 78d7f92cbb0..ac6eda8163a 100644
--- a/engines/awe/logic.cpp
+++ b/engines/awe/logic.cpp
@@ -45,68 +45,68 @@ void Logic::init() {
 void Logic::op_movConst() {
 	uint8 i = _scriptPtr.fetchByte();
 	int16 n = _scriptPtr.fetchWord();
-	debug(DBG_LOGIC, "Logic::op_movConst(0x%02X, %d)", i, n);
+	debugC(kDebugLogic, "Logic::op_movConst(0x%02X, %d)", i, n);
 	_scriptVars[i] = n;
 }
 
 void Logic::op_mov() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint8 j = _scriptPtr.fetchByte();	
-	debug(DBG_LOGIC, "Logic::op_mov(0x%02X, 0x%02X)", i, j);
+	debugC(kDebugLogic, "Logic::op_mov(0x%02X, 0x%02X)", i, j);
 	_scriptVars[i] = _scriptVars[j];
 }
 
 void Logic::op_add() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint8 j = _scriptPtr.fetchByte();
-	debug(DBG_LOGIC, "Logic::op_add(0x%02X, 0x%02X)", i, j);
+	debugC(kDebugLogic, "Logic::op_add(0x%02X, 0x%02X)", i, j);
 	_scriptVars[i] += _scriptVars[j];
 }
 
 void Logic::op_addConst() {
 	uint8 i = _scriptPtr.fetchByte();
 	int16 n = _scriptPtr.fetchWord();
-	debug(DBG_LOGIC, "Logic::op_addConst(0x%02X, %d)", i, n);
+	debugC(kDebugLogic, "Logic::op_addConst(0x%02X, %d)", i, n);
 	_scriptVars[i] += n;
 }
 
 void Logic::op_call() {
 	uint16 off = _scriptPtr.fetchWord();
 	uint8 sp = _stackPtr;
-	debug(DBG_LOGIC, "Logic::op_call(0x%X)", off);
+	debugC(kDebugLogic, "Logic::op_call(0x%X)", off);
 	_scriptStackCalls[sp] = _scriptPtr.pc - _res->_segCode;
 	++_stackPtr;
 	_scriptPtr.pc = _res->_segCode + off;
 }
 
 void Logic::op_ret() {
-	debug(DBG_LOGIC, "Logic::op_ret()");
+	debugC(kDebugLogic, "Logic::op_ret()");
 	--_stackPtr;
 	uint8 sp = _stackPtr;
 	_scriptPtr.pc = _res->_segCode + _scriptStackCalls[sp];
 }
 
 void Logic::op_break() {
-	debug(DBG_LOGIC, "Logic::op_break()");
+	debugC(kDebugLogic, "Logic::op_break()");
 	_scriptHalted = true;
 }
 
 void Logic::op_jmp() {
 	uint16 off = _scriptPtr.fetchWord();
-	debug(DBG_LOGIC, "Logic::op_jmp(0x%02X)", off);
+	debugC(kDebugLogic, "Logic::op_jmp(0x%02X)", off);
 	_scriptPtr.pc = _res->_segCode + off;	
 }
 
 void Logic::op_setScriptPos() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint16 n = _scriptPtr.fetchWord();
-	debug(DBG_LOGIC, "Logic::op_setScriptPos(0x%X, 0x%X)", i, n);
+	debugC(kDebugLogic, "Logic::op_setScriptPos(0x%X, 0x%X)", i, n);
 	_scriptPos[1][i] = n;
 }
 
 void Logic::op_jnz() {
 	uint8 i = _scriptPtr.fetchByte();
-	debug(DBG_LOGIC, "Logic::op_jnz(0x%02X)", i);
+	debugC(kDebugLogic, "Logic::op_jnz(0x%02X)", i);
 	--_scriptVars[i];
 	if (_scriptVars[i] != 0) {
 		op_jmp();
@@ -138,7 +138,7 @@ void Logic::op_condJmp() {
 			a = (a << 8) | _scriptPtr.fetchByte();
 		}
 	}
-	debug(DBG_LOGIC, "Logic::op_condJmp(%d, 0x%02X, 0x%02X)", op, b, a);
+	debugC(kDebugLogic, "Logic::op_condJmp(%d, 0x%02X, 0x%02X)", op, b, a);
 	bool expr = false;
 	switch (op & 7) {
 	case 0:	// jz
@@ -172,7 +172,7 @@ void Logic::op_condJmp() {
 
 void Logic::op_setPalette() {
 	uint16 i = _scriptPtr.fetchWord();
-	debug(DBG_LOGIC, "Logic::op_changePalette(%d)", i);
+	debugC(kDebugLogic, "Logic::op_changePalette(%d)", i);
 	_vid->_newPal = i >> 8;
 }
 
@@ -187,7 +187,7 @@ void Logic::op_resetScript() {
 	++n;
 	uint8 _al = _scriptPtr.fetchByte();
 
-	debug(DBG_LOGIC, "Logic::op_resetScript(%d, %d, %d)", j, i, _al);
+	debugC(kDebugLogic, "Logic::op_resetScript(%d, %d, %d)", j, i, _al);
 
 	if (_al == 2) {
 		uint16 *_si = &_scriptPos[1][j];
@@ -206,27 +206,27 @@ void Logic::op_resetScript() {
 
 void Logic::op_selectPage() {
 	uint8 i = _scriptPtr.fetchByte();
-	debug(DBG_LOGIC, "Logic::op_selectPage(%d)", i);
+	debugC(kDebugLogic, "Logic::op_selectPage(%d)", i);
 	_vid->changePagePtr1(i);
 }
 
 void Logic::op_fillPage() {
 	uint8 screen = _scriptPtr.fetchByte();
 	uint8 color = _scriptPtr.fetchByte();
-	debug(DBG_LOGIC, "Logic::op_fillPage(%d, %d)", screen, color);
+	debugC(kDebugLogic, "Logic::op_fillPage(%d, %d)", screen, color);
 	_vid->fillPage(screen, color);
 }
 
 void Logic::op_copyPage() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint8 j = _scriptPtr.fetchByte();
-	debug(DBG_LOGIC, "Logic::op_copyPage(%d, %d)", i, j);
+	debugC(kDebugLogic, "Logic::op_copyPage(%d, %d)", i, j);
 	_vid->copyPage(i, j, _scriptVars[VAR_SCROLL_Y]);
 }
 
 void Logic::op_updateDisplay() {
 	uint8 page = _scriptPtr.fetchByte();
-	debug(DBG_LOGIC, "Logic::op_updateDisplay(%d)", page);
+	debugC(kDebugLogic, "Logic::op_updateDisplay(%d)", page);
 	inp_handleSpecialKeys();
 	if (_res->_curPtrsId == 0x3E80 && _scriptVars[0x67] == 1) {
 		_scriptVar_0xBF = _scriptVars[0xBF];
@@ -249,7 +249,7 @@ void Logic::op_updateDisplay() {
 }
 
 void Logic::op_halt() {
-	debug(DBG_LOGIC, "Logic::op_halt()");
+	debugC(kDebugLogic, "Logic::op_halt()");
 	_scriptPtr.pc = _res->_segCode + 0xFFFF;
 	_scriptHalted = true;
 }
@@ -259,42 +259,42 @@ void Logic::op_drawString() {
 	uint16 x = _scriptPtr.fetchByte();
 	uint16 y = _scriptPtr.fetchByte();
 	uint16 col = _scriptPtr.fetchByte();
-	debug(DBG_LOGIC, "Logic::op_drawString(0x%03X, %d, %d, %d)", strId, x, y, col);
+	debugC(kDebugLogic, "Logic::op_drawString(0x%03X, %d, %d, %d)", strId, x, y, col);
 	_vid->drawString(col, x, y, strId);
 }
 
 void Logic::op_sub() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint8 j = _scriptPtr.fetchByte();
-	debug(DBG_LOGIC, "Logic::op_sub(0x%02X, 0x%02X)", i, j);
+	debugC(kDebugLogic, "Logic::op_sub(0x%02X, 0x%02X)", i, j);
 	_scriptVars[i] -= _scriptVars[j];
 }
 
 void Logic::op_and() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint16 n = _scriptPtr.fetchWord();
-	debug(DBG_LOGIC, "Logic::op_and(0x%02X, %d)", i, n);
+	debugC(kDebugLogic, "Logic::op_and(0x%02X, %d)", i, n);
 	_scriptVars[i] = (uint16)_scriptVars[i] & n;
 }
 
 void Logic::op_or() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint16 n = _scriptPtr.fetchWord();
-	debug(DBG_LOGIC, "Logic::op_or(0x%02X, %d)", i, n);
+	debugC(kDebugLogic, "Logic::op_or(0x%02X, %d)", i, n);
 	_scriptVars[i] = (uint16)_scriptVars[i] | n;
 }
 
 void Logic::op_shl() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint16 n = _scriptPtr.fetchWord();
-	debug(DBG_LOGIC, "Logic::op_shl(0x%02X, %d)", i, n);
+	debugC(kDebugLogic, "Logic::op_shl(0x%02X, %d)", i, n);
 	_scriptVars[i] = (uint16)_scriptVars[i] << n;
 }
 
 void Logic::op_shr() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint16 n = _scriptPtr.fetchWord();
-	debug(DBG_LOGIC, "Logic::op_shr(0x%02X, %d)", i, n);
+	debugC(kDebugLogic, "Logic::op_shr(0x%02X, %d)", i, n);
 	_scriptVars[i] = (uint16)_scriptVars[i] >> n;
 }
 
@@ -302,13 +302,13 @@ void Logic::op_soundUnk1() {
 	uint16 b = _scriptPtr.fetchWord();
 	uint16 c = _scriptPtr.fetchWord();
 	uint8 a = _scriptPtr.fetchByte();
-	debug(DBG_LOGIC, "Logic::op_soundUnk1(0x%X, 0x%X, %d)", b, c, a);
+	debugC(kDebugLogic, "Logic::op_soundUnk1(0x%X, 0x%X, %d)", b, c, a);
 	// XXX
 }
 
 void Logic::op_updateMemList() {
 	uint16 num = _scriptPtr.fetchWord();
-	debug(DBG_LOGIC, "Logic::op_updateMemList(%d)", num);
+	debugC(kDebugLogic, "Logic::op_updateMemList(%d)", num);
 	_res->update(num);
 }
 
@@ -316,7 +316,7 @@ void Logic::op_soundUnk2() {
 	uint16 b = _scriptPtr.fetchWord();
 	uint16 c = _scriptPtr.fetchWord();
 	uint8 a = _scriptPtr.fetchByte();
-	debug(DBG_LOGIC, "Logic::op_soundUnk2(0x%X, 0x%X, %d)", b, c, a);
+	debugC(kDebugLogic, "Logic::op_soundUnk2(0x%X, 0x%X, %d)", b, c, a);
 	// XXX
 }
 
@@ -352,10 +352,10 @@ void Logic::runScripts() {
 				_scriptPtr.pc = _res->_segCode + n;
 				_stackPtr = 0;
 				_scriptHalted = false;
-				debug(DBG_LOGIC, "Logic::runScripts() i=0x%02X n=0x%02X *p=0x%02X", i, n, *_scriptPtr.pc);
+				debugC(kDebugLogic, "Logic::runScripts() i=0x%02X n=0x%02X *p=0x%02X", i, n, *_scriptPtr.pc);
 				executeScript();
 				_scriptPos[0][i] = _scriptPtr.pc - _res->_segCode;
-				debug(DBG_LOGIC, "Logic::runScripts() i=0x%02X pos=0x%X", i, _scriptPos[0][i]);
+				debugC(kDebugLogic, "Logic::runScripts() i=0x%02X pos=0x%X", i, _scriptPos[0][i]);
 				if (_stub->_pi.quit) {
 					break;
 				}
@@ -377,7 +377,7 @@ void Logic::executeScript() {
 				y = 199;
 				x += h;
 			}
-			debug(DBG_VIDEO, "vid_opcd_0x80 : opcode=0x%X off=0x%X x=%d y=%d", opcode, off, x, y);
+			debugC(kDebugVideo, "vid_opcd_0x80 : opcode=0x%X off=0x%X x=%d y=%d", opcode, off, x, y);
 			_vid->setDataBuffer(_res->_segVideo1, off);
 			_vid->drawShape(0xFF, 0x40, Point(x,y));
 		} else if (opcode & 0x40) {
@@ -419,7 +419,7 @@ void Logic::executeScript() {
 					zoom = 0x40;
 				}
 			}
-			debug(DBG_VIDEO, "vid_opcd_0x40 : off=0x%X x=%d y=%d", off, x, y);
+			debugC(kDebugVideo, "vid_opcd_0x40 : off=0x%X x=%d y=%d", off, x, y);
 			_vid->setDataBuffer(_res->_useSegVideo2 ? _res->_segVideo2 : _res->_segVideo1, off);
 			_vid->drawShape(0xFF, zoom, Point(x, y));
 		} else {
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 70159a77e50..f45266529e7 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -35,7 +35,7 @@ Resource::Resource(Video *vid, const char *dataDir)
 
 void Resource::readBank(const MemEntry *me, uint8 *dstBuf) {
 	uint16 n = me - _memList;
-	debug(DBG_BANK, "Resource::readBank(%d)", n);
+	debugC(kDebugBank, "Resource::readBank(%d)", n);
 #ifdef USE_UNPACKED
 	char bankEntryName[64];
 	sprintf(bankEntryName, "ootw-%02X-%d.dump", n, me->type);
@@ -118,7 +118,7 @@ void Resource::load() {
 			::warning("Resource::load() ec=0x%X (me->bankNum == 0)", 0xF00);
 			me->valid = 0;
 		} else {
-			debug(DBG_BANK, "Resource::load() bufPos=%X size=%X type=%X pos=%X bankNum=%X", memPtr - _memPtrStart, me->packedSize, me->type, me->bankPos, me->bankNum);
+			debugC(kDebugBank, "Resource::load() bufPos=%X size=%X type=%X pos=%X bankNum=%X", memPtr - _memPtrStart, me->packedSize, me->type, me->bankPos, me->bankNum);
 			readBank(me, memPtr);
 			if(me->type == 2) {
 				_vid->copyPagePtr(_vidCurPtr);
diff --git a/engines/awe/util.h b/engines/awe/util.h
index 3287a4caabb..f0f53ee5f39 100644
--- a/engines/awe/util.h
+++ b/engines/awe/util.h
@@ -27,15 +27,6 @@
 
 namespace Awe {
 
-enum {
-	DBG_LOGIC = 1 << 0,
-	DBG_BANK  = 1 << 1,
-	DBG_VIDEO = 1 << 2,
-	DBG_INFO  = 1 << 3
-};
-
-extern uint16 g_debugMask;
-
 extern void string_lower(char *p);
 extern void string_upper(char *p);
 
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index 6be66de75fc..7e68bfe3aca 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -163,7 +163,7 @@ void Video::drawShapeParts(uint16 zoom, const Point &pgc) {
 	pt.x -= _pData.fetchByte() * zoom / 64;
 	pt.y -= _pData.fetchByte() * zoom / 64;
 	int16 n = _pData.fetchByte();
-	debug(DBG_VIDEO, "Video::drawShapeParts n=%d", n);
+	debugC(kDebugVideo, "Video::drawShapeParts n=%d", n);
 	for ( ; n >= 0; --n) {
 		uint16 off = _pData.fetchWord();
 		Point po(pt);
@@ -191,7 +191,7 @@ int32 Video::calcStep(const Point &p1, const Point &p2, uint16 &dy) {
 void Video::drawString(uint8 color, uint16 x, uint16 y, uint16 strId) {
 	const StrEntry *se = _stringsTableEng;
 	while (se->id != 0xFFFF && se->id != strId) ++se;
-	debug(DBG_VIDEO, "drawString(%d, %d, %d, '%s')", color, x, y, se->str);
+	debugC(kDebugVideo, "drawString(%d, %d, %d, '%s')", color, x, y, se->str);
 	uint16 xx = x;
 	int len = strlen(se->str);
 	for (int i = 0; i < len; ++i) {
@@ -233,7 +233,7 @@ void Video::drawChar(uint8 c, uint16 x, uint16 y, uint8 color, uint8 *buf) {
 }
 
 void Video::drawPoint(uint8 color, int16 x, int16 y) {
-	debug(DBG_VIDEO, "drawPoint(%d, %d, %d)", color, x, y);
+	debugC(kDebugVideo, "drawPoint(%d, %d, %d)", color, x, y);
 	if (x >= 0 && x <= 319 && y >= 0 && y <= 199) {
 		uint16 off = y * 160 + x / 2;
 	
@@ -260,7 +260,7 @@ void Video::drawPoint(uint8 color, int16 x, int16 y) {
 }
 
 void Video::drawLineT(int16 x1, int16 x2, uint8 color) {
-	debug(DBG_VIDEO, "drawLineT(%d, %d, %d)", x1, x2, color);
+	debugC(kDebugVideo, "drawLineT(%d, %d, %d)", x1, x2, color);
 	int16 xmax = MAX(x1, x2);
 	int16 xmin = MIN(x1, x2);
 	uint8 *p = _curPagePtr1 + _hliney * 160 + xmin / 2;
@@ -292,7 +292,7 @@ void Video::drawLineT(int16 x1, int16 x2, uint8 color) {
 }
 
 void Video::drawLineN(int16 x1, int16 x2, uint8 color) {
-	debug(DBG_VIDEO, "drawLineN(%d, %d, %d)", x1, x2, color);
+	debugC(kDebugVideo, "drawLineN(%d, %d, %d)", x1, x2, color);
 	int16 xmax = MAX(x1, x2);
 	int16 xmin = MIN(x1, x2);
 	uint8 *p = _curPagePtr1 + _hliney * 160 + xmin / 2;
@@ -324,7 +324,7 @@ void Video::drawLineN(int16 x1, int16 x2, uint8 color) {
 }
 
 void Video::drawLineP(int16 x1, int16 x2, uint8 color) {
-	debug(DBG_VIDEO, "drawLineP(%d, %d, %d)", x1, x2, color);
+	debugC(kDebugVideo, "drawLineP(%d, %d, %d)", x1, x2, color);
 	int16 xmax = MAX(x1, x2);
 	int16 xmin = MIN(x1, x2);
 	uint16 off = _hliney * 160 + xmin / 2;
@@ -380,19 +380,19 @@ uint8 *Video::getPagePtr(uint8 page) {
 }
 
 void Video::changePagePtr1(uint8 page) {
-	debug(DBG_VIDEO, "Video::changePagePtr1(%d)", page);
+	debugC(kDebugVideo, "Video::changePagePtr1(%d)", page);
 	_curPagePtr1 = getPagePtr(page);
 }
 
 void Video::fillPage(uint8 page, uint8 color) {
-	debug(DBG_VIDEO, "Video::fillPage(%d, %d)", page, color);
+	debugC(kDebugVideo, "Video::fillPage(%d, %d)", page, color);
 	uint8 *p = getPagePtr(page);
 	uint8 c = (color << 4) | color;
 	memset(p, c, VID_PAGE_SIZE);
 }
 
 void Video::copyPage(uint8 src, uint8 dst, int16 vscroll) {
-	debug(DBG_VIDEO, "Video::copyPage(%d, %d)", src, dst);
+	debugC(kDebugVideo, "Video::copyPage(%d, %d)", src, dst);
 	if (src >= 0xFE || !((src &= 0xBF) & 0x80)) {
 		uint8 *p = getPagePtr(src);
 		uint8 *q = getPagePtr(dst);
@@ -417,7 +417,7 @@ void Video::copyPage(uint8 src, uint8 dst, int16 vscroll) {
 }
 
 void Video::copyPagePtr(const uint8 *src) {
-	debug(DBG_VIDEO, "Video::copyPagePtr()");
+	debugC(kDebugVideo, "Video::copyPagePtr()");
 	uint8 *dst = _pagePtrs[0];
 	int h = 200;
 	while (h--) {
@@ -467,7 +467,7 @@ void Video::changePal(uint8 palNum) {
 }
 
 void Video::updateDisplay(uint8 page) {
-	debug(DBG_VIDEO, "Video::updateDisplay(%d)", page);
+	debugC(kDebugVideo, "Video::updateDisplay(%d)", page);
 	if (page != 0xFE) {
 		if (page == 0xFF) {
 			SWAP(_curPagePtr2, _curPagePtr3);


Commit: 02660a9bd418e20c7fd2cd963a19df18e7fee91e
    https://github.com/scummvm/scummvm/commit/02660a9bd418e20c7fd2cd963a19df18e7fee91e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Remove deprecated File class

Changed paths:
  R engines/awe/file.cpp
  R engines/awe/file.h
    engines/awe/engine.cpp
    engines/awe/module.mk
    engines/awe/resource.cpp
    engines/awe/serializer.cpp


diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index b6035b8a0dd..1a3914a119a 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -22,7 +22,6 @@
 #include "common/str.h"
 #include "awe/awe.h"
 #include "awe/engine.h"
-#include "awe/file.h"
 #include "awe/serializer.h"
 #include "awe/systemstub.h"
 
diff --git a/engines/awe/file.cpp b/engines/awe/file.cpp
deleted file mode 100644
index e6785b139cb..00000000000
--- a/engines/awe/file.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "awe/file.h"
-
-namespace Awe {
-#ifdef DEPRECATED
-
-struct File_impl {
-	bool _ioErr;
-	File_impl() : _ioErr(false) {}
-	virtual bool open(const char *path, const char *mode) = 0;
-	virtual void close() = 0;
-	virtual void seek(int32 off) = 0;
-	virtual void read(void *ptr, uint32 size) = 0;
-	virtual void write(void *ptr, uint32 size) = 0;
-};
-
-struct stdFile : File_impl {
-	FILE *_fp;
-	stdFile() : _fp(0) {}
-	bool open(const char *path, const char *mode) {
-		_ioErr = false;
-		_fp = fopen(path, mode);
-		return (_fp != NULL);
-	}
-	void close() {
-		if (_fp) {
-			fclose(_fp);
-			_fp = 0;
-		}
-	}
-	void seek(int32 off) {
-		if (_fp) {
-			fseek(_fp, off, SEEK_SET);
-		}
-	}
-	void read(void *ptr, uint32 size) {
-		if (_fp) {
-			uint32 r = fread(ptr, 1, size, _fp);
-			if (r != size) {
-				_ioErr = true;
-			}
-		}
-	}
-	void write(void *ptr, uint32 size) {
-		if (_fp) {
-			uint32 r = fwrite(ptr, 1, size, _fp);
-			if (r != size) {
-				_ioErr = true;
-			}
-		}
-	}
-};
-
-struct zlibFile : File_impl {
-	gzFile _fp;
-	zlibFile() : _fp(0) {}
-	bool open(const char *path, const char *mode) {
-		_ioErr = false;
-		_fp = gzopen(path, mode);
-		return (_fp != NULL);
-	}
-	void close() {
-		if (_fp) {
-			gzclose(_fp);
-			_fp = 0;
-		}
-	}
-	void seek(int32 off) {
-		if (_fp) {
-			gzseek(_fp, off, SEEK_SET);
-		}
-	}
-	void read(void *ptr, uint32 size) {
-		if (_fp) {
-			uint32 r = gzread(_fp, ptr, size);
-			if (r != size) {
-				_ioErr = true;
-			}
-		}
-	}
-	void write(void *ptr, uint32 size) {
-		if (_fp) {
-			uint32 r = gzwrite(_fp, ptr, size);
-			if (r != size) {
-				_ioErr = true;
-			}
-		}
-	}
-};
-
-File::File(bool gzipped) {
-	if (gzipped) {
-		_impl = new zlibFile;
-	} else {
-		_impl = new stdFile;
-	}
-}
-
-File::~File() {
-	_impl->close();
-	delete _impl;
-}
-
-bool File::open(const char *filename, const char *directory, const char *mode) {	
-	_impl->close();
-	char buf[512];
-	sprintf(buf, "%s/%s", directory, filename);
-	char *p = buf + strlen(directory) + 1;
-	string_lower(p);
-	bool opened = _impl->open(buf, mode);
-	if (!opened) { // let's try uppercase
-		string_upper(p);
-		opened = _impl->open(buf, mode);
-	}
-	return opened;
-}
-
-void File::close() {
-	_impl->close();
-}
-
-bool File::ioErr() const {
-	return _impl->_ioErr;
-}
-
-void File::seek(int32 off) {
-	_impl->seek(off);
-}
-
-void File::read(void *ptr, uint32 size) {
-	_impl->read(ptr, size);
-}
-
-uint8 File::readByte() {
-	uint8 b;
-	read(&b, 1);
-	return b;
-}
-
-uint16 File::readUint16BE() {
-	uint8 hi = readByte();
-	uint8 lo = readByte();
-	return (hi << 8) | lo;
-}
-
-uint32 File::readUint32BE() {
-	uint16 hi = readUint16BE();
-	uint16 lo = readUint16BE();
-	return (hi << 16) | lo;
-}
-
-void File::write(void *ptr, uint32 size) {
-	_impl->write(ptr, size);
-}
-
-void File::writeByte(uint8 b) {
-	write(&b, 1);
-}
-
-void File::writeUint16BE(uint16 n) {
-	writeByte(n >> 8);
-	writeByte(n & 0xFF);
-}
-
-void File::writeUint32BE(uint32 n) {
-	writeUint16BE(n >> 16);
-	writeUint16BE(n & 0xFFFF);
-}
-#endif
-
-} // namespace Awe
diff --git a/engines/awe/file.h b/engines/awe/file.h
deleted file mode 100644
index ef23b409777..00000000000
--- a/engines/awe/file.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AWE_FILE_H
-#define AWE_FILE_H
-
-#include "awe/intern.h"
-
-namespace Awe {
-#ifdef DEPRECATED
-struct File_impl;
-
-struct File {
-	File_impl *_impl;
-
-	File(bool gzipped = false);
-	~File();
-
-	bool open(const char *filename, const char *directory, const char *mode="rb");
-	void close();
-	bool ioErr() const;
-	void seek(int32 off);
-	void read(void *ptr, uint32 size);
-	uint8 readByte();
-	uint16 readUint16BE();
-	uint32 readUint32BE();
-	void write(void *ptr, uint32 size);
-	void writeByte(uint8 b);
-	void writeUint16BE(uint16 n);
-	void writeUint32BE(uint32 n);
-};
-#endif
-
-} // namespace Awe
-
-#endif
diff --git a/engines/awe/module.mk b/engines/awe/module.mk
index 3901ba82171..4c755f1ddc1 100644
--- a/engines/awe/module.mk
+++ b/engines/awe/module.mk
@@ -5,7 +5,6 @@ MODULE_OBJS = \
 	awe.o \
 	bank.o \
 	engine.o \
-	file.o \
 	logic.o \
 	resource.o \
 	sdlstub.o \
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index f45266529e7..0a0bb0c8c24 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -23,7 +23,6 @@
 #include "awe/awe.h"
 #include "awe/resource.h"
 #include "awe/bank.h"
-#include "awe/file.h"
 #include "awe/serializer.h"
 #include "awe/video.h"
 
diff --git a/engines/awe/serializer.cpp b/engines/awe/serializer.cpp
index 01f120d45ba..631e3ac17cb 100644
--- a/engines/awe/serializer.cpp
+++ b/engines/awe/serializer.cpp
@@ -20,7 +20,6 @@
  */
 
 #include "awe/serializer.h"
-#include "awe/file.h"
 #include "awe/util.h"
 
 namespace Awe {


Commit: 01b37eb1aeb2901fedcd6bd1162bac9b138d7557
    https://github.com/scummvm/scummvm/commit/01b37eb1aeb2901fedcd6bd1162bac9b138d7557
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Merge Engine class into AweEngine

Changed paths:
  R engines/awe/engine.cpp
  R engines/awe/engine.h
    engines/awe/awe.cpp
    engines/awe/awe.h
    engines/awe/bank.cpp
    engines/awe/bank.h
    engines/awe/module.mk
    engines/awe/resource.cpp
    engines/awe/resource.h


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 67a5c077ddb..90dec1af72e 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -1,4 +1,4 @@
-/* ScummVM - Graphic Adventure Engine
+/* ScummVM - Graphic Adventure AweEngine
  *
  * ScummVM is the legal property of its developers, whose names
  * are too numerous to list here. Please refer to the COPYRIGHT
@@ -22,14 +22,21 @@
 #include "audio/mixer.h"
 #include "common/config-manager.h"
 #include "engines/util.h"
+#include "awe/util.h"
 #include "awe/awe.h"
-#include "awe/engine.h"
-#include "awe/systemstub.h"
 
 namespace Awe {
 
 AweEngine::AweEngine(OSystem *syst, const ADGameDescription *gameDesc)
-	: Engine(syst), _gameDescription(gameDesc) {
+	: Engine(syst), _gameDescription(gameDesc),
+	_stub(SystemStub_SDL_create()),
+	_res(&_vid),
+	_vid(&_res, _stub),
+	_log(&_res, &_vid, _stub) {
+}
+
+AweEngine::~AweEngine() {
+	delete _stub;
 }
 
 Common::Error AweEngine::run() {
@@ -41,14 +48,58 @@ Common::Error AweEngine::run() {
 	// Initialize backend
 	initGraphics(320, 200);
 
+	// Setup
+	_stub->init("Out Of This World");
+	setup();
+
 	// Run the game
-	SystemStub *stub = SystemStub_SDL_create();
-	Awe::Engine *e = new Awe::Engine(stub, nullptr, nullptr);
-	e->run();
-	delete e;
-	delete stub;
+	_log.restartAt(0x3E80); // demo starts at 0x3E81
+	while (!_stub->_pi.quit && !g_engine->shouldQuit()) {
+		_log.setupScripts();
+		_log.inp_updatePlayer();
+		processInput();
+		_log.runScripts();
+	}
+
+	finish();
+	_stub->destroy();
 
 	return Common::kNoError;
 }
 
+void AweEngine::setup() {
+	_vid.init();
+	_res.allocMemBlock();
+	_res.readEntries();
+	_log.init();
+}
+
+void AweEngine::finish() {
+	// XXX
+	_res.freeMemBlock();
+}
+
+void AweEngine::processInput() {
+	if (_stub->_pi.load) {
+		loadGameState(_stateSlot);
+		_stub->_pi.load = false;
+	}
+	if (_stub->_pi.save) {
+		saveGameState(_stateSlot, "Quicksave");
+		_stub->_pi.save = false;
+	}
+	if (_stub->_pi.fastMode) {
+		_log._fastMode = !_log._fastMode;
+		_stub->_pi.fastMode = false;
+	}
+	if (_stub->_pi.stateSlot != 0) {
+		int8 slot = _stateSlot + _stub->_pi.stateSlot;
+		if (slot >= 0 && slot < 999) {
+			_stateSlot = slot;
+			debugC(kDebugInfo, "Current game state slot is %d", _stateSlot);
+		}
+		_stub->_pi.stateSlot = 0;
+	}
+}
+
 } // namespace Awe
diff --git a/engines/awe/awe.h b/engines/awe/awe.h
index 26b5b0f7abf..6a1214322a2 100644
--- a/engines/awe/awe.h
+++ b/engines/awe/awe.h
@@ -25,6 +25,11 @@
 #include "common/scummsys.h"
 #include "engines/engine.h"
 #include "awe/detection.h"
+#include "awe/intern.h"
+#include "awe/logic.h"
+#include "awe/resource.h"
+#include "awe/systemstub.h"
+#include "awe/video.h"
 
 namespace Awe {
 
@@ -38,12 +43,23 @@ class AweEngine : public Engine {
 private:
 	const ADGameDescription *_gameDescription;
 
+private:
+	void setup();
+	void finish();
+	void processInput();
+
+public:
+	SystemStub *_stub;
+	Logic _log;
+	Resource _res;
+	Video _vid;
+	int _stateSlot = 0;
+
 public:
 	AweEngine(OSystem *syst, const ADGameDescription *gameDesc);
-	virtual ~AweEngine() {}
+	~AweEngine() override;
 
 	Common::Error run() override;
-
 };
 
 } // namespace Awe
diff --git a/engines/awe/bank.cpp b/engines/awe/bank.cpp
index e2f6abb70b7..138325c48bb 100644
--- a/engines/awe/bank.cpp
+++ b/engines/awe/bank.cpp
@@ -26,8 +26,7 @@
 
 namespace Awe {
 
-Bank::Bank(const char *dataDir)
-	: _dataDir(dataDir) {
+Bank::Bank() {
 }
 
 bool Bank::read(const MemEntry *me, uint8 *buf) {
diff --git a/engines/awe/bank.h b/engines/awe/bank.h
index 1becd8c6717..ab51d7fe77f 100644
--- a/engines/awe/bank.h
+++ b/engines/awe/bank.h
@@ -37,10 +37,9 @@ struct UnpackContext {
 
 struct Bank {
 	UnpackContext _unpCtx;
-	const char *_dataDir;
 	uint8 *_iBuf, *_oBuf, *_startBuf;
 
-	Bank(const char *dataDir);
+	Bank();
 
 	bool read(const MemEntry *me, uint8 *buf);
 	void decUnk1(uint8 numChunks, uint8 addCount);
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
deleted file mode 100644
index 1a3914a119a..00000000000
--- a/engines/awe/engine.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "common/str.h"
-#include "awe/awe.h"
-#include "awe/engine.h"
-#include "awe/serializer.h"
-#include "awe/systemstub.h"
-
-namespace Awe {
-
-Engine::Engine(SystemStub *stub, const char *dataDir, const char *saveDir)
-	: _stub(stub), _log(&_res, &_vid, stub), _res(&_vid, dataDir), _vid(&_res, stub), 
-	_dataDir(dataDir), _saveDir(saveDir), _stateSlot(0) {
-}
-
-void Engine::run() {
-	_stub->init("Out Of This World");
-	setup();
-	// XXX
-	_log.restartAt(0x3E80); // demo starts at 0x3E81
-	while (!_stub->_pi.quit && !g_engine->shouldQuit()) {
-		_log.setupScripts();
-		_log.inp_updatePlayer();
-		processInput();
-		_log.runScripts();
-	}
-	finish();
-	_stub->destroy();
-}
-
-void Engine::setup() {
-	_vid.init();
-	_res.allocMemBlock();
-	_res.readEntries();
-	_log.init();
-}
-
-void Engine::finish() {
-	 // XXX
-	 _res.freeMemBlock();
-}
-
-void Engine::processInput() {
-	if (_stub->_pi.load) {
-		loadGameState(_stateSlot);
-		_stub->_pi.load = false;
-	}
-	if (_stub->_pi.save) {
-		saveGameState(_stateSlot, "quicksave");
-		_stub->_pi.save = false;
-	}
-	if (_stub->_pi.fastMode) {
-		_log._fastMode = !_log._fastMode;
-		_stub->_pi.fastMode = false;
-	}
-	if (_stub->_pi.stateSlot != 0) {
-		int8 slot = _stateSlot + _stub->_pi.stateSlot;
-		if (slot >= 0 && slot < MAX_SAVE_SLOTS) {
-			_stateSlot = slot;
-			debugC(kDebugInfo, "Current game state slot is %d", _stateSlot);
-		}
-		_stub->_pi.stateSlot = 0;
-	}
-}
-
-void Engine::makeGameStateName(uint8 slot, char *buf) {
-	Common::sprintf_s(buf, 256, "raw.s%02d", slot);
-}
-
-void Engine::saveGameState(uint8 slot, const char *desc) {
-#ifdef TODO
-	char stateFile[20];
-	makeGameStateName(slot, stateFile);
-	File f(true);
-	if (!f.open(stateFile, _saveDir, "wb")) {
-		::warning("Unable to save state file '%s'", stateFile);
-	} else {
-		// header
-		f.writeUint32BE('AWSV');
-		f.writeUint16BE(Serializer::CUR_VER);
-		f.writeUint16BE(0);
-		char hdrdesc[32];
-		strncpy(hdrdesc, desc, sizeof(hdrdesc) - 1);
-		f.write(hdrdesc, sizeof(hdrdesc));
-		// contents
-		Serializer s(&f, Serializer::SM_SAVE, _res._memPtrStart);
-		_log.saveOrLoad(s);
-		_res.saveOrLoad(s);
-		_vid.saveOrLoad(s);
-		if (f.ioErr()) {
-			::warning("I/O error when saving game state");
-		} else {
-			debugC(kDebugInfo, "Saved state to slot %d", _stateSlot);
-		}
-	}
-#endif
-}
-
-void Engine::loadGameState(uint8 slot) {
-#ifdef TODO
-	char stateFile[20];
-	makeGameStateName(slot, stateFile);
-	File f(true);
-	if (!f.open(stateFile, _saveDir, "rb")) {
-		::warning("Unable to open state file '%s'", stateFile);
-	} else {
-		uint32 id = f.readUint32BE();
-		if (id != 'AWSV') {
-			::warning("Bad savegame format");
-		} else {
-			uint16 ver = f.readUint16BE();
-			f.readUint16BE();
-			char hdrdesc[32];
-			f.read(hdrdesc, sizeof(hdrdesc));
-			// contents
-			Serializer s(&f, Serializer::SM_LOAD, _res._memPtrStart, ver);
-			_log.saveOrLoad(s);
-			_res.saveOrLoad(s);
-			_vid.saveOrLoad(s);
-		}
-		if (f.ioErr()) {
-			::warning("I/O error when loading game state");
-		} else {
-			debugC(kDebugInfo, "Loaded state from slot %d", _stateSlot);
-		}
-	}
-#endif
-}
-
-} // namespace Awe
diff --git a/engines/awe/engine.h b/engines/awe/engine.h
deleted file mode 100644
index d5daf1dc764..00000000000
--- a/engines/awe/engine.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AWE_ENGINE_H
-#define AWE_ENGINE_H
-
-#include "awe/intern.h"
-#include "awe/logic.h"
-#include "awe/resource.h"
-#include "awe/video.h"
-
-namespace Awe {
-
-struct SystemStub;
-
-struct Engine {
-	enum {
-		MAX_SAVE_SLOTS = 100
-	};
-
-	SystemStub *_stub;
-	Logic _log;
-	Resource _res;
-	Video _vid;
-	const char *_dataDir, *_saveDir;
-	uint8 _stateSlot;
-
-	Engine(SystemStub *stub, const char *dataDir, const char *saveDir);
-
-	void run();
-	void setup();
-	void finish();
-	void processInput();
-	
-	void makeGameStateName(uint8 slot, char *buf);
-	void saveGameState(uint8 slot, const char *desc);
-	void loadGameState(uint8 slot);
-};
-
-} // namespace Awe
-
-#endif
diff --git a/engines/awe/module.mk b/engines/awe/module.mk
index 4c755f1ddc1..c1348858e9e 100644
--- a/engines/awe/module.mk
+++ b/engines/awe/module.mk
@@ -4,7 +4,6 @@ MODULE_OBJS = \
 	metaengine.o \
 	awe.o \
 	bank.o \
-	engine.o \
 	logic.o \
 	resource.o \
 	sdlstub.o \
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 0a0bb0c8c24..9bd3885c5ab 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -28,8 +28,7 @@
 
 namespace Awe {
 
-Resource::Resource(Video *vid, const char *dataDir) 
-	: _vid(vid), _dataDir(dataDir) {
+Resource::Resource(Video *vid) : _vid(vid) {
 }
 
 void Resource::readBank(const MemEntry *me, uint8 *dstBuf) {
@@ -44,7 +43,7 @@ void Resource::readBank(const MemEntry *me, uint8 *dstBuf) {
 	}
 	f.read(dstBuf, me->unpackedSize);
 #else
-	Bank bk(_dataDir);
+	Bank bk;
 	if (!bk.read(me, dstBuf)) {
 		::error("Resource::readBank() unable to unpack entry %d\n", n);
 	}
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index 3a233469fb6..9639be2fb35 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -61,7 +61,6 @@ struct Resource {
 	static const uint16 _memListParts[][4];
 	
 	Video *_vid = nullptr;
-	const char *_dataDir = nullptr;
 	MemEntry _memList[150];
 	uint16 _numMemList = 0;
 	uint16 _curPtrsId = 0, _newPtrsId = 0;
@@ -76,7 +75,7 @@ struct Resource {
 	uint8 *_segVideo1 = nullptr;
 	uint8 *_segVideo2 = nullptr;
 
-	Resource(Video *vid, const char *dataDir);
+	Resource(Video *vid);
 	
 	void readBank(const MemEntry *me, uint8 *dstBuf);
 	void readEntries();


Commit: f8dc7339d7a4e6f93d914beb9f3bfa8be11abcbd
    https://github.com/scummvm/scummvm/commit/f8dc7339d7a4e6f93d914beb9f3bfa8be11abcbd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Cleanup of system stub class

Changed paths:
  A engines/awe/system_stub.cpp
  A engines/awe/system_stub.h
  R engines/awe/sdlstub.cpp
  R engines/awe/systemstub.h
    engines/awe/awe.cpp
    engines/awe/awe.h
    engines/awe/logic.cpp
    engines/awe/module.mk
    engines/awe/video.cpp


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 90dec1af72e..b5ac8ccb0b0 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -29,7 +29,7 @@ namespace Awe {
 
 AweEngine::AweEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	: Engine(syst), _gameDescription(gameDesc),
-	_stub(SystemStub_SDL_create()),
+	_stub(SystemStub_create()),
 	_res(&_vid),
 	_vid(&_res, _stub),
 	_log(&_res, &_vid, _stub) {
diff --git a/engines/awe/awe.h b/engines/awe/awe.h
index 6a1214322a2..990c8983a03 100644
--- a/engines/awe/awe.h
+++ b/engines/awe/awe.h
@@ -28,7 +28,7 @@
 #include "awe/intern.h"
 #include "awe/logic.h"
 #include "awe/resource.h"
-#include "awe/systemstub.h"
+#include "awe/system_stub.h"
 #include "awe/video.h"
 
 namespace Awe {
diff --git a/engines/awe/logic.cpp b/engines/awe/logic.cpp
index ac6eda8163a..5f90bb5dc0c 100644
--- a/engines/awe/logic.cpp
+++ b/engines/awe/logic.cpp
@@ -24,7 +24,7 @@
 #include "awe/resource.h"
 #include "awe/video.h"
 #include "awe/serializer.h"
-#include "awe/systemstub.h"
+#include "awe/system_stub.h"
 
 namespace Awe {
 
diff --git a/engines/awe/module.mk b/engines/awe/module.mk
index c1348858e9e..fd062dfe6da 100644
--- a/engines/awe/module.mk
+++ b/engines/awe/module.mk
@@ -6,9 +6,9 @@ MODULE_OBJS = \
 	bank.o \
 	logic.o \
 	resource.o \
-	sdlstub.o \
 	serializer.o \
 	staticres.o \
+	system_stub.o \
 	util.o \
 	video.o
 
diff --git a/engines/awe/sdlstub.cpp b/engines/awe/system_stub.cpp
similarity index 83%
rename from engines/awe/sdlstub.cpp
rename to engines/awe/system_stub.cpp
index 2ae035bf5bb..efb192c76cd 100644
--- a/engines/awe/sdlstub.cpp
+++ b/engines/awe/system_stub.cpp
@@ -24,13 +24,13 @@
 #include "graphics/paletteman.h"
 #include "graphics/screen.h"
 #include "awe/awe.h"
-#include "awe/systemstub.h"
+#include "awe/system_stub.h"
 #include "awe/util.h"
 
 namespace Awe {
 
-struct SDLStub : SystemStub {
-	typedef void (SDLStub::*ScaleProc)(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h);
+struct ScummVMStub : SystemStub {
+	typedef void (ScummVMStub::*ScaleProc)(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h);
 
 	enum {
 		SCREEN_W = 320,
@@ -52,7 +52,7 @@ struct SDLStub : SystemStub {
 	Graphics::PaletteLookup _palLookup;
 	byte _pal[16];
 
-	virtual ~SDLStub() {}
+	virtual ~ScummVMStub() {}
 	virtual void init(const char *title);
 	virtual void destroy();
 	virtual void setPalette(uint8 s, uint8 n, const uint8 *buf);
@@ -70,17 +70,17 @@ struct SDLStub : SystemStub {
 	void point3x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h);
 };
 
-const SDLStub::Scaler SDLStub::_scalers[] = {
-	{ "Point1x", &SDLStub::point1x, 1 },
-	{ "Point2x", &SDLStub::point2x, 2 },
-	{ "Point3x", &SDLStub::point3x, 3 }
+const ScummVMStub::Scaler ScummVMStub::_scalers[] = {
+	{ "Point1x", &ScummVMStub::point1x, 1 },
+	{ "Point2x", &ScummVMStub::point2x, 2 },
+	{ "Point3x", &ScummVMStub::point3x, 3 }
 };
 
-SystemStub *SystemStub_SDL_create() {
-	return new SDLStub();
+SystemStub *SystemStub_create() {
+	return new ScummVMStub();
 }
 
-void SDLStub::init(const char *title) {
+void ScummVMStub::init(const char *title) {
 	memset(&_pi, 0, sizeof(_pi));
 	_offscreen = (uint8 *)malloc(SCREEN_W * SCREEN_H * 2);
 	if (!_offscreen) {
@@ -91,11 +91,11 @@ void SDLStub::init(const char *title) {
 	prepareGfxMode();
 }
 
-void SDLStub::destroy() {
+void ScummVMStub::destroy() {
 	cleanupGfxMode();
 }
 
-void SDLStub::setPalette(uint8 s, uint8 n, const uint8 *buf) {
+void ScummVMStub::setPalette(uint8 s, uint8 n, const uint8 *buf) {
 	assert(s + n <= 16);
 	for (int i = s; i < s + n; ++i) {
 		uint8 c[3];
@@ -110,7 +110,7 @@ void SDLStub::setPalette(uint8 s, uint8 n, const uint8 *buf) {
 	}	
 }
 
-void SDLStub::copyRect(uint16 x, uint16 y, uint16 w, uint16 h, const uint8 *buf, uint32 pitch) {
+void ScummVMStub::copyRect(uint16 x, uint16 y, uint16 w, uint16 h, const uint8 *buf, uint32 pitch) {
 	buf += y * pitch + x;
 	byte *p = (byte *)_offscreen;
 	while (h--) {
@@ -129,7 +129,7 @@ void SDLStub::copyRect(uint16 x, uint16 y, uint16 w, uint16 h, const uint8 *buf,
 	_screen->update();
 }
 
-void SDLStub::processEvents() {
+void ScummVMStub::processEvents() {
 	Common::Event ev;
 
 	while (!g_engine->shouldQuit() &&
@@ -223,21 +223,21 @@ void SDLStub::processEvents() {
 	}
 }
 
-void SDLStub::sleep(uint32 duration) {
+void ScummVMStub::sleep(uint32 duration) {
 	g_system->delayMillis(duration);
 }
 
-uint32 SDLStub::getTimeStamp() {
+uint32 ScummVMStub::getTimeStamp() {
 	return g_system->getMillis();	
 }
 
-void SDLStub::prepareGfxMode() {
+void ScummVMStub::prepareGfxMode() {
 //	int w = SCREEN_W * _scalers[_scaler].factor;
 //	int h = SCREEN_H * _scalers[_scaler].factor;
 	_screen = new Graphics::Screen();
 }
 
-void SDLStub::cleanupGfxMode() {
+void ScummVMStub::cleanupGfxMode() {
 	if (_offscreen) {
 		free(_offscreen);
 		_offscreen = nullptr;
@@ -249,7 +249,7 @@ void SDLStub::cleanupGfxMode() {
 	}
 }
 
-void SDLStub::switchGfxMode(bool fullscreen, uint8 scaler) {
+void ScummVMStub::switchGfxMode(bool fullscreen, uint8 scaler) {
 #ifdef DEPRECATED
 	SDL_Surface *prev_sclscreen = _sclscreen;
 	SDL_FreeSurface(_screen); 	
@@ -261,7 +261,7 @@ void SDLStub::switchGfxMode(bool fullscreen, uint8 scaler) {
 #endif
 }
 
-void SDLStub::point1x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
+void ScummVMStub::point1x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
 	dstPitch >>= 1;
 	while (h--) {
 		memcpy(dst, src, w * 2);
@@ -270,7 +270,7 @@ void SDLStub::point1x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 sr
 	}
 }
 
-void SDLStub::point2x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
+void ScummVMStub::point2x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
 	dstPitch >>= 1;
 	while (h--) {
 		uint16 *p = dst;
@@ -286,7 +286,7 @@ void SDLStub::point2x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 sr
 	}
 }
 
-void SDLStub::point3x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
+void ScummVMStub::point3x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
 	dstPitch >>= 1;
 	while (h--) {
 		uint16 *p = dst;
diff --git a/engines/awe/systemstub.h b/engines/awe/system_stub.h
similarity index 94%
rename from engines/awe/systemstub.h
rename to engines/awe/system_stub.h
index c17945a7f0b..529622853f6 100644
--- a/engines/awe/systemstub.h
+++ b/engines/awe/system_stub.h
@@ -19,8 +19,8 @@
  *
  */
 
-#ifndef AWE_SYSTEMSTUB_H
-#define AWE_SYSTEMSTUB_H
+#ifndef AWE_SYSTEM_STUB_H
+#define AWE_SYSTEM_STUB_H
 
 #include "awe/intern.h"
 
@@ -61,7 +61,7 @@ struct SystemStub {
 	virtual uint32 getTimeStamp() = 0;
 };
 
-extern SystemStub *SystemStub_SDL_create();
+extern SystemStub *SystemStub_create();
 
 } // namespace Awe
 
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index 7e68bfe3aca..dd4f7db9260 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -23,7 +23,7 @@
 #include "awe/video.h"
 #include "awe/resource.h"
 #include "awe/serializer.h"
-#include "awe/systemstub.h"
+#include "awe/system_stub.h"
 
 namespace Awe {
 


Commit: cc2d820c9cbcf7708e83c10f26297671fb5ee3c0
    https://github.com/scummvm/scummvm/commit/cc2d820c9cbcf7708e83c10f26297671fb5ee3c0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Add savegame code

Changed paths:
    engines/awe/awe.cpp
    engines/awe/awe.h
    engines/awe/serializer.cpp
    engines/awe/serializer.h


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index b5ac8ccb0b0..1cee2d2ce48 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -21,9 +21,11 @@
 
 #include "audio/mixer.h"
 #include "common/config-manager.h"
+#include "common/stream.h"
 #include "engines/util.h"
-#include "awe/util.h"
 #include "awe/awe.h"
+#include "awe/serializer.h"
+#include "awe/util.h"
 
 namespace Awe {
 
@@ -102,4 +104,49 @@ void AweEngine::processInput() {
 	}
 }
 
+Common::Error AweEngine::saveGameStream(Common::WriteStream *stream, bool isAutosave) {
+	// Header
+	stream->writeUint32BE(MKTAG('A', 'W', 'S', 'V'));
+	stream->writeUint16BE(Serializer::CUR_VER);
+	stream->writeUint16BE(0);
+
+	// Contents
+	Serializer s(stream, _res._memPtrStart);
+	_log.saveOrLoad(s);
+	_res.saveOrLoad(s);
+	_vid.saveOrLoad(s);
+	if (stream->err()) {
+		warning("I/O error when saving game state");
+		return Common::kUnknownError;
+	} else {
+		debugC(kDebugInfo, "Saved state to slot %d", _stateSlot);
+		return Common::kNoError;
+	}
+}
+
+Common::Error AweEngine::loadGameStream(Common::SeekableReadStream *stream) {
+	uint32 id = stream->readUint32BE();
+	if (id != MKTAG('A', 'W', 'S', 'V')) {
+		warning("Bad savegame format");
+		return Common::kUnknownError;
+	}
+
+	uint16 ver = stream->readUint16BE();
+	(void)stream->readUint16BE();
+
+	// Contents
+	Serializer s(stream, _res._memPtrStart, ver);
+	_log.saveOrLoad(s);
+	_res.saveOrLoad(s);
+	_vid.saveOrLoad(s);
+
+	if (stream->err()) {
+		warning("I/O error when loading game state");
+		return Common::kUnknownError;
+	} else {
+		debugC(kDebugInfo, "Loaded state from slot %d", _stateSlot);
+		return Common::kNoError;
+	}
+}
+
 } // namespace Awe
diff --git a/engines/awe/awe.h b/engines/awe/awe.h
index 990c8983a03..79aad602068 100644
--- a/engines/awe/awe.h
+++ b/engines/awe/awe.h
@@ -35,10 +35,6 @@ namespace Awe {
 
 #define BYPASS_PROTECTION
 
-enum AWEGameId {
-	GID_WORLDE
-};
-
 class AweEngine : public Engine {
 private:
 	const ADGameDescription *_gameDescription;
@@ -60,6 +56,9 @@ public:
 	~AweEngine() override;
 
 	Common::Error run() override;
+
+	Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
+	Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
 };
 
 } // namespace Awe
diff --git a/engines/awe/serializer.cpp b/engines/awe/serializer.cpp
index 631e3ac17cb..ccf0d6648ed 100644
--- a/engines/awe/serializer.cpp
+++ b/engines/awe/serializer.cpp
@@ -24,8 +24,12 @@
 
 namespace Awe {
 
-Serializer::Serializer(Common::Stream *stream, Mode mode, uint8 *ptrBlock, uint16 saveVer)
-	: _stream(stream), _mode(mode), _ptrBlock(ptrBlock), _saveVer(saveVer) {
+Serializer::Serializer(Common::WriteStream *stream, uint8 *ptrBlock, uint16 saveVer)
+	: _stream(stream), _mode(SM_SAVE), _ptrBlock(ptrBlock), _saveVer(saveVer) {
+}
+
+Serializer::Serializer(Common::SeekableReadStream *stream, uint8 *ptrBlock, uint16 saveVer)
+	: _stream(stream), _mode(SM_LOAD), _ptrBlock(ptrBlock), _saveVer(saveVer) {
 }
 
 void Serializer::saveOrLoadEntries(Entry *entry) {
diff --git a/engines/awe/serializer.h b/engines/awe/serializer.h
index 1264a87a4f4..5ab1be8c515 100644
--- a/engines/awe/serializer.h
+++ b/engines/awe/serializer.h
@@ -72,8 +72,11 @@ struct Serializer {
 	Mode _mode;
 	uint8 *_ptrBlock;
 	uint16 _saveVer;
-	
-	Serializer(Common::Stream *stream, Mode mode, uint8 *ptrBlock, uint16 saveVer = CUR_VER);
+
+	Serializer(Common::WriteStream *stream,
+		uint8 *ptrBlock, uint16 saveVer = CUR_VER);
+	Serializer(Common::SeekableReadStream *stream,
+		uint8 *ptrBlock, uint16 saveVer = CUR_VER);
 
 	void saveOrLoadEntries(Entry *entry);
 


Commit: 8e956b40dda0100235b39d1456df7c9ac11317d8
    https://github.com/scummvm/scummvm/commit/8e956b40dda0100235b39d1456df7c9ac11317d8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Janitorial

Changed paths:
    engines/awe/awe.cpp
    engines/awe/logic.cpp
    engines/awe/resource.cpp
    engines/awe/video.cpp


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 1cee2d2ce48..b38f3263d6c 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -44,7 +44,7 @@ AweEngine::~AweEngine() {
 Common::Error AweEngine::run() {
 	// Setup mixer
 	if (!_mixer->isReady()) {
-		::warning("Sound initialization failed.");
+		warning("Sound initialization failed.");
 	}
 
 	// Initialize backend
diff --git a/engines/awe/logic.cpp b/engines/awe/logic.cpp
index 5f90bb5dc0c..f0f1bdcd8d0 100644
--- a/engines/awe/logic.cpp
+++ b/engines/awe/logic.cpp
@@ -36,9 +36,6 @@ void Logic::init() {
 	memset(_scriptVars, 0, sizeof(_scriptVars));
 	_scriptVars[0x54] = 0x81;
 	_scriptVars[VAR_RANDOM_SEED] = 0;
-#ifdef DEPRECATED
-	time(0);
-#endif
 	_fastMode = false;
 }
 
@@ -125,12 +122,13 @@ void Logic::op_condJmp() {
 		// (0x0D4E) condJmp(0x4, VAR(50), 6, 0xDBC)		
 		*(_scriptPtr.pc + 0x99) = 0x0D;
 		*(_scriptPtr.pc + 0x9A) = 0x5A;
-		::warning("Logic::op_condJmp() bypassing protection");	
+		warning("Logic::op_condJmp() bypassing protection");
 	}
 #endif
 	uint8 op = _scriptPtr.fetchByte();
 	int16 b = _scriptVars[_scriptPtr.fetchByte()];
-	int16 a = _scriptPtr.fetchByte();	
+	int16 a = _scriptPtr.fetchByte();
+
 	if (op & 0x80) {
 		a = _scriptVars[a];
 	} else {
@@ -138,8 +136,10 @@ void Logic::op_condJmp() {
 			a = (a << 8) | _scriptPtr.fetchByte();
 		}
 	}
+
 	debugC(kDebugLogic, "Logic::op_condJmp(%d, 0x%02X, 0x%02X)", op, b, a);
 	bool expr = false;
+
 	switch (op & 7) {
 	case 0:	// jz
 		expr = (b == a);
@@ -160,7 +160,7 @@ void Logic::op_condJmp() {
 		expr = (b <= a);
 		break;
 	default:
-		::warning("Logic::op_condJmp() invalid condition %d", (op & 7));
+		warning("Logic::op_condJmp() invalid condition %d", (op & 7));
 		break;
 	}
 	if (expr) {
@@ -181,7 +181,7 @@ void Logic::op_resetScript() {
 	uint8 i = _scriptPtr.fetchByte();
 	int8 n = (i & 0x3F) - j;
 	if (n < 0) {
-		::warning("Logic::op_resetScript() ec=0x%X (n < 0)", 0x880);
+		warning("Logic::op_resetScript() ec=0x%X (n < 0)", 0x880);
 		return;
 	}
 	++n;
@@ -495,7 +495,7 @@ void Logic::inp_handleSpecialKeys() {
 	}
 	// XXX
 	if (_scriptVars[0xC9] == 1) {
-		::warning("Logic::inp_handleSpecialKeys() unhandled case (_scriptVars[0xC9] == 1)");
+		warning("Logic::inp_handleSpecialKeys() unhandled case (_scriptVars[0xC9] == 1)");
 	}
 }
 
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 9bd3885c5ab..bf434535400 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -107,13 +107,13 @@ void Resource::load() {
 		} else {
 			memPtr = _scriptCurPtr;
 			if (me->unpackedSize > _vidBakPtr - _scriptCurPtr) {
-				::warning("Resource::load() not enough memory");
+				warning("Resource::load() not enough memory");
 				me->valid = 0;
 				continue;
 			}
 		}
 		if (me->bankNum == 0) {
-			::warning("Resource::load() ec=0x%X (me->bankNum == 0)", 0xF00);
+			warning("Resource::load() ec=0x%X (me->bankNum == 0)", 0xF00);
 			me->valid = 0;
 		} else {
 			debugC(kDebugBank, "Resource::load() bufPos=%X size=%X type=%X pos=%X bankNum=%X", memPtr - _memPtrStart, me->packedSize, me->type, me->bankPos, me->bankNum);
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index dd4f7db9260..dfd8795877b 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -73,11 +73,11 @@ void Video::drawShape(uint8 color, uint16 zoom, const Point &pt) {
 	} else {
 		i &= 0x3F;
 		if (i == 1) {
-			::warning("Video::drawShape() ec=0x%X (i != 2)", 0xF80);
+			warning("Video::drawShape() ec=0x%X (i != 2)", 0xF80);
 		} else if (i == 2) {
 			drawShapeParts(zoom, pt);
 		} else {
-			::warning("Video::drawShape() ec=0x%X (i != 2)", 0xFBB);
+			warning("Video::drawShape() ec=0x%X (i != 2)", 0xFBB);
 		}
 	}
 }
@@ -372,7 +372,7 @@ uint8 *Video::getPagePtr(uint8 page) {
 			break;
 		default:
 			p = _pagePtrs[0]; // XXX check
-			::warning("Video::getPagePtr() p != [0,1,2,3,0xFF,0xFE] == 0x%X", page);
+			warning("Video::getPagePtr() p != [0,1,2,3,0xFF,0xFE] == 0x%X", page);
 			break;
 		}
 	}


Commit: 3a5309f6ca3c38b4815408b1946cdb173216ef6f
    https://github.com/scummvm/scummvm/commit/3a5309f6ca3c38b4815408b1946cdb173216ef6f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Further janitorial

Changed paths:
    engines/awe/bank.cpp
    engines/awe/logic.cpp
    engines/awe/resource.cpp
    engines/awe/system_stub.cpp


diff --git a/engines/awe/bank.cpp b/engines/awe/bank.cpp
index 138325c48bb..587d98bdb2d 100644
--- a/engines/awe/bank.cpp
+++ b/engines/awe/bank.cpp
@@ -47,7 +47,7 @@ bool Bank::read(const MemEntry *me, uint8 *buf) {
 			ret = unpack();
 		}
 	} else {
-		::error("Bank::read() unable to open '%s'", bankName);
+		error("Bank::read() unable to open '%s'", bankName);
 	}
 
 	return ret;
diff --git a/engines/awe/logic.cpp b/engines/awe/logic.cpp
index f0f1bdcd8d0..6b6faedd06b 100644
--- a/engines/awe/logic.cpp
+++ b/engines/awe/logic.cpp
@@ -424,7 +424,7 @@ void Logic::executeScript() {
 			_vid->drawShape(0xFF, zoom, Point(x, y));
 		} else {
 			if (opcode > 0x1A) {
-				::error("Logic::executeScript() ec=0x%X invalid opcode=0x%X", 0xFFF, opcode);
+				error("Logic::executeScript() ec=0x%X invalid opcode=0x%X", 0xFFF, opcode);
 			} else {
 				(this->*_opTable[opcode])();
 			}
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index bf434535400..17a5f9d7487 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -39,13 +39,13 @@ void Resource::readBank(const MemEntry *me, uint8 *dstBuf) {
 	sprintf(bankEntryName, "ootw-%02X-%d.dump", n, me->type);
 	File f;
 	if (!f.open(bankEntryName, _dataDir)) {
-		::error("Resource::readBank() unable to open '%s' file\n", bankEntryName);
+		error("Resource::readBank() unable to open '%s' file\n", bankEntryName);
 	}
 	f.read(dstBuf, me->unpackedSize);
 #else
 	Bank bk;
 	if (!bk.read(me, dstBuf)) {
-		::error("Resource::readBank() unable to unpack entry %d\n", n);
+		error("Resource::readBank() unable to unpack entry %d\n", n);
 	}
 #endif
 }
@@ -53,7 +53,7 @@ void Resource::readBank(const MemEntry *me, uint8 *dstBuf) {
 void Resource::readEntries() {	
 	Common::File f;
 	if (!f.open("memlist.bin")) {
-		::error("Resource::readEntries() unable to open 'memlist.bin' file\n");
+		error("Resource::readEntries() unable to open 'memlist.bin' file\n");
 	}
 	_numMemList = 0;
 	MemEntry *me = _memList;
@@ -188,7 +188,7 @@ void Resource::setupPtrs(uint16 ptrId) {
 			ivd1 = _memListParts[part][2];
 			ivd2 = _memListParts[part][3];
 		} else {
-			::error("Resource::setupPtrs() ec=0x%X invalid ptrId", 0xF07);
+			error("Resource::setupPtrs() ec=0x%X invalid ptrId", 0xF07);
 		}
 		invalidateAll();
 		_memList[ipal].valid = 2;
diff --git a/engines/awe/system_stub.cpp b/engines/awe/system_stub.cpp
index efb192c76cd..7b0edc8859f 100644
--- a/engines/awe/system_stub.cpp
+++ b/engines/awe/system_stub.cpp
@@ -84,7 +84,7 @@ void ScummVMStub::init(const char *title) {
 	memset(&_pi, 0, sizeof(_pi));
 	_offscreen = (uint8 *)malloc(SCREEN_W * SCREEN_H * 2);
 	if (!_offscreen) {
-		::error("Unable to allocate offscreen buffer");
+		error("Unable to allocate offscreen buffer");
 	}
 	_fullscreen = false;
 	_scaler = 1;


Commit: 147cece8c2ccd2b23cbb54cc3d53e9b37f0bad57
    https://github.com/scummvm/scummvm/commit/147cece8c2ccd2b23cbb54cc3d53e9b37f0bad57
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Defaults for Logic class members

Changed paths:
    engines/awe/intern.h
    engines/awe/logic.cpp
    engines/awe/logic.h


diff --git a/engines/awe/intern.h b/engines/awe/intern.h
index d55a1d2535f..65c65ed4d27 100644
--- a/engines/awe/intern.h
+++ b/engines/awe/intern.h
@@ -32,7 +32,7 @@ namespace Awe {
 using Common::Point;
 
 struct Ptr {
-	uint8 *pc;
+	uint8 *pc = nullptr;
 	
 	uint8 fetchByte() {
 		return *pc++;
diff --git a/engines/awe/logic.cpp b/engines/awe/logic.cpp
index 6b6faedd06b..86d402f79b4 100644
--- a/engines/awe/logic.cpp
+++ b/engines/awe/logic.cpp
@@ -366,7 +366,9 @@ void Logic::runScripts() {
 
 void Logic::executeScript() {
 	while (!_scriptHalted && !g_engine->shouldQuit()) {
+		
 		uint8 opcode = _scriptPtr.fetchByte();
+
 		if (opcode & 0x80) {
 			uint16 off = ((opcode << 8) | _scriptPtr.fetchByte()) * 2;
 			_res->_useSegVideo2 = false;
diff --git a/engines/awe/logic.h b/engines/awe/logic.h
index da34ae65b3f..06bf9ecae51 100644
--- a/engines/awe/logic.h
+++ b/engines/awe/logic.h
@@ -56,15 +56,15 @@ struct Logic {
 	Video *_vid;
 	SystemStub *_stub;
 
-	int16 _scriptVar_0xBF;
-	int16 _scriptVars[0x100];
-	uint16 _scriptStackCalls[0x40];
-	uint16 _scriptPos[2][0x40];
-	uint8 _scriptPaused[2][0x40];
+	int16 _scriptVar_0xBF = { 0 };
+	int16 _scriptVars[0x100] = { 0 };
+	uint16 _scriptStackCalls[0x40] = { 0 };
+	uint16 _scriptPos[2][0x40] = { 0 };
+	uint8 _scriptPaused[2][0x40] = { 0 };
 	Ptr _scriptPtr;
-	uint8 _stackPtr;
-	bool _scriptHalted;
-	bool _fastMode;
+	uint8 _stackPtr = 0;
+	bool _scriptHalted = false;
+	bool _fastMode = false;
 
 	Logic(Resource *res, Video *vid, SystemStub *stub);
 	void init();


Commit: 960b0a23f1e6a1231582e84a21e3ea40d5e5a37e
    https://github.com/scummvm/scummvm/commit/960b0a23f1e6a1231582e84a21e3ea40d5e5a37e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Further member initialization

Changed paths:
    engines/awe/video.h


diff --git a/engines/awe/video.h b/engines/awe/video.h
index fdba4a62263..7ec8112c374 100644
--- a/engines/awe/video.h
+++ b/engines/awe/video.h
@@ -36,8 +36,8 @@ struct Polygon {
 		MAX_POINTS = 50
 	};
 
-	uint16 bbw, bbh;
-	uint8 numPoints;
+	uint16 bbw = 0, bbh = 0;
+	uint8 numPoints = 0;
 	Point points[MAX_POINTS];
 
 	void init(const uint8 *p, uint16 zoom);
@@ -61,14 +61,16 @@ struct Video {
 	Resource *_res;
 	SystemStub *_stub;
 
-	uint8 _newPal, _curPal;
-	uint8 *_pagePtrs[4];
-	uint8 *_curPagePtr1, *_curPagePtr2, *_curPagePtr3;
+	uint8 _newPal = 0, _curPal = 0;
+	uint8 *_pagePtrs[4] = { nullptr };
+	uint8 *_curPagePtr1 = nullptr,
+		*_curPagePtr2 = nullptr,
+		*_curPagePtr3 = nullptr;
 	Polygon _pg;
-	int16 _hliney;
-	uint16 _interpTable[0x400];
+	int16 _hliney = 0;
+	uint16 _interpTable[0x400] = { 0 };
 	Ptr _pData;
-	uint8 *_dataBuf;
+	uint8 *_dataBuf = nullptr;
 
 	Video(Resource *res, SystemStub *stub);
 	void init();


Commit: 530d09ce62e0f3bd05809266ef8c7f3593acb4f5
    https://github.com/scummvm/scummvm/commit/530d09ce62e0f3bd05809266ef8c7f3593acb4f5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Add pc to script opcode debug output

Changed paths:
    engines/awe/logic.cpp
    engines/awe/logic.h


diff --git a/engines/awe/logic.cpp b/engines/awe/logic.cpp
index 86d402f79b4..9c8765ef7f2 100644
--- a/engines/awe/logic.cpp
+++ b/engines/awe/logic.cpp
@@ -42,68 +42,75 @@ void Logic::init() {
 void Logic::op_movConst() {
 	uint8 i = _scriptPtr.fetchByte();
 	int16 n = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "Logic::op_movConst(0x%02X, %d)", i, n);
+	debugC(kDebugLogic, "%.4x - op_movConst(0x%02X, %d)",
+		_lastOpcodeOffset, i, n);
 	_scriptVars[i] = n;
 }
 
 void Logic::op_mov() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint8 j = _scriptPtr.fetchByte();	
-	debugC(kDebugLogic, "Logic::op_mov(0x%02X, 0x%02X)", i, j);
+	debugC(kDebugLogic, "%.4x - op_mov(0x%02X, 0x%02X)",
+		_lastOpcodeOffset, i, j);
 	_scriptVars[i] = _scriptVars[j];
 }
 
 void Logic::op_add() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint8 j = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "Logic::op_add(0x%02X, 0x%02X)", i, j);
+	debugC(kDebugLogic, "%.4x - op_add(0x%02X, 0x%02X)",
+		_lastOpcodeOffset, i, j);
 	_scriptVars[i] += _scriptVars[j];
 }
 
 void Logic::op_addConst() {
 	uint8 i = _scriptPtr.fetchByte();
 	int16 n = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "Logic::op_addConst(0x%02X, %d)", i, n);
+	debugC(kDebugLogic, "%.4x - op_addConst(0x%02X, %d)",
+		_lastOpcodeOffset, i, n);
 	_scriptVars[i] += n;
 }
 
 void Logic::op_call() {
 	uint16 off = _scriptPtr.fetchWord();
 	uint8 sp = _stackPtr;
-	debugC(kDebugLogic, "Logic::op_call(0x%X)", off);
+	debugC(kDebugLogic, "%.4x - op_call(0x%X)",
+		_lastOpcodeOffset, off);
 	_scriptStackCalls[sp] = _scriptPtr.pc - _res->_segCode;
 	++_stackPtr;
 	_scriptPtr.pc = _res->_segCode + off;
 }
 
 void Logic::op_ret() {
-	debugC(kDebugLogic, "Logic::op_ret()");
+	debugC(kDebugLogic, "%.4x - op_ret()", _lastOpcodeOffset);
 	--_stackPtr;
 	uint8 sp = _stackPtr;
 	_scriptPtr.pc = _res->_segCode + _scriptStackCalls[sp];
 }
 
 void Logic::op_break() {
-	debugC(kDebugLogic, "Logic::op_break()");
+	debugC(kDebugLogic, "%.4x - op_break()", _lastOpcodeOffset);
 	_scriptHalted = true;
 }
 
 void Logic::op_jmp() {
 	uint16 off = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "Logic::op_jmp(0x%02X)", off);
+	debugC(kDebugLogic, "%.4x - op_jmp(0x%02X)", _lastOpcodeOffset, off);
 	_scriptPtr.pc = _res->_segCode + off;	
 }
 
 void Logic::op_setScriptPos() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint16 n = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "Logic::op_setScriptPos(0x%X, 0x%X)", i, n);
+	debugC(kDebugLogic, "%.4x - op_setScriptPos(0x%X, 0x%X)",
+		_lastOpcodeOffset, i, n);
 	_scriptPos[1][i] = n;
 }
 
 void Logic::op_jnz() {
 	uint8 i = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "Logic::op_jnz(0x%02X)", i);
+	debugC(kDebugLogic, "%.4x - op_jnz(0x%02X)",
+		_lastOpcodeOffset, i);
 	--_scriptVars[i];
 	if (_scriptVars[i] != 0) {
 		op_jmp();
@@ -137,7 +144,8 @@ void Logic::op_condJmp() {
 		}
 	}
 
-	debugC(kDebugLogic, "Logic::op_condJmp(%d, 0x%02X, 0x%02X)", op, b, a);
+	debugC(kDebugLogic, "%.4x - op_condJmp(%d, 0x%02X, 0x%02X)",
+		_lastOpcodeOffset, op, b, a);
 	bool expr = false;
 
 	switch (op & 7) {
@@ -172,7 +180,7 @@ void Logic::op_condJmp() {
 
 void Logic::op_setPalette() {
 	uint16 i = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "Logic::op_changePalette(%d)", i);
+	debugC(kDebugLogic, "%.4x - op_changePalette(%d)", _lastOpcodeOffset, i);
 	_vid->_newPal = i >> 8;
 }
 
@@ -187,7 +195,8 @@ void Logic::op_resetScript() {
 	++n;
 	uint8 _al = _scriptPtr.fetchByte();
 
-	debugC(kDebugLogic, "Logic::op_resetScript(%d, %d, %d)", j, i, _al);
+	debugC(kDebugLogic, "%.4x - op_resetScript(%d, %d, %d)",
+		_lastOpcodeOffset, j, i, _al);
 
 	if (_al == 2) {
 		uint16 *_si = &_scriptPos[1][j];
@@ -206,50 +215,56 @@ void Logic::op_resetScript() {
 
 void Logic::op_selectPage() {
 	uint8 i = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "Logic::op_selectPage(%d)", i);
+	debugC(kDebugLogic, "%.4x - op_selectPage(%d)",
+		_lastOpcodeOffset, i);
 	_vid->changePagePtr1(i);
 }
 
 void Logic::op_fillPage() {
 	uint8 screen = _scriptPtr.fetchByte();
 	uint8 color = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "Logic::op_fillPage(%d, %d)", screen, color);
+	debugC(kDebugLogic, "%.4x - op_fillPage(%d, %d)",
+		_lastOpcodeOffset, screen, color);
 	_vid->fillPage(screen, color);
 }
 
 void Logic::op_copyPage() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint8 j = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "Logic::op_copyPage(%d, %d)", i, j);
+	debugC(kDebugLogic, "%.4x - op_copyPage(%d, %d)",
+		_lastOpcodeOffset, i, j);
 	_vid->copyPage(i, j, _scriptVars[VAR_SCROLL_Y]);
 }
 
 void Logic::op_updateDisplay() {
 	uint8 page = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "Logic::op_updateDisplay(%d)", page);
+	debugC(kDebugLogic, "%.4x - op_updateDisplay(%d)",
+		_lastOpcodeOffset, page);
 	inp_handleSpecialKeys();
 	if (_res->_curPtrsId == 0x3E80 && _scriptVars[0x67] == 1) {
 		_scriptVar_0xBF = _scriptVars[0xBF];
 		_scriptVars[0xDC] = 0x21;
 	}
 
-	static uint32 tstamp = 0;
+	uint32 tstamp = _stub->getTimeStamp();
+
 	if (!_fastMode) {
 		// XXX experimental
-		int32 delay = _stub->getTimeStamp() - tstamp;
+		int32 delay = tstamp - _lastTimestamp;
 		int32 pause = _scriptVars[VAR_PAUSE_SLICES] * 20 - delay;
 		if (pause > 0) {
 			_stub->sleep(pause);
 		}
 	}
+
 	_scriptVars[0xF7] = 0;
 
 	_vid->updateDisplay(page);
-	tstamp = _stub->getTimeStamp();
+	_lastTimestamp = tstamp;
 }
 
 void Logic::op_halt() {
-	debugC(kDebugLogic, "Logic::op_halt()");
+	debugC(kDebugLogic, "%.4x - op_halt()", _lastOpcodeOffset);
 	_scriptPtr.pc = _res->_segCode + 0xFFFF;
 	_scriptHalted = true;
 }
@@ -259,42 +274,48 @@ void Logic::op_drawString() {
 	uint16 x = _scriptPtr.fetchByte();
 	uint16 y = _scriptPtr.fetchByte();
 	uint16 col = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "Logic::op_drawString(0x%03X, %d, %d, %d)", strId, x, y, col);
+	debugC(kDebugLogic, "%.4x - op_drawString(0x%03X, %d, %d, %d)",
+		_lastOpcodeOffset, strId, x, y, col);
 	_vid->drawString(col, x, y, strId);
 }
 
 void Logic::op_sub() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint8 j = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "Logic::op_sub(0x%02X, 0x%02X)", i, j);
+	debugC(kDebugLogic, "%.4x - op_sub(0x%02X, 0x%02X)",
+		_lastOpcodeOffset, i, j);
 	_scriptVars[i] -= _scriptVars[j];
 }
 
 void Logic::op_and() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint16 n = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "Logic::op_and(0x%02X, %d)", i, n);
+	debugC(kDebugLogic, "%.4x - op_and(0x%02X, %d)",
+		_lastOpcodeOffset, i, n);
 	_scriptVars[i] = (uint16)_scriptVars[i] & n;
 }
 
 void Logic::op_or() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint16 n = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "Logic::op_or(0x%02X, %d)", i, n);
+	debugC(kDebugLogic, "%.4x - op_or(0x%02X, %d)",
+		_lastOpcodeOffset, i, n);
 	_scriptVars[i] = (uint16)_scriptVars[i] | n;
 }
 
 void Logic::op_shl() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint16 n = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "Logic::op_shl(0x%02X, %d)", i, n);
+	debugC(kDebugLogic, "%.4x - op_shl(0x%02X, %d)",
+		_lastOpcodeOffset, i, n);
 	_scriptVars[i] = (uint16)_scriptVars[i] << n;
 }
 
 void Logic::op_shr() {
 	uint8 i = _scriptPtr.fetchByte();
 	uint16 n = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "Logic::op_shr(0x%02X, %d)", i, n);
+	debugC(kDebugLogic, "%.4x - op_shr(0x%02X, %d)",
+		_lastOpcodeOffset, i, n);
 	_scriptVars[i] = (uint16)_scriptVars[i] >> n;
 }
 
@@ -302,13 +323,15 @@ void Logic::op_soundUnk1() {
 	uint16 b = _scriptPtr.fetchWord();
 	uint16 c = _scriptPtr.fetchWord();
 	uint8 a = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "Logic::op_soundUnk1(0x%X, 0x%X, %d)", b, c, a);
+	debugC(kDebugLogic, "%.4x - op_soundUnk1(0x%X, 0x%X, %d)",
+		_lastOpcodeOffset, b, c, a);
 	// XXX
 }
 
 void Logic::op_updateMemList() {
 	uint16 num = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "Logic::op_updateMemList(%d)", num);
+	debugC(kDebugLogic, "%.4x - op_updateMemList(%d)",
+		_lastOpcodeOffset, num);
 	_res->update(num);
 }
 
@@ -316,7 +339,8 @@ void Logic::op_soundUnk2() {
 	uint16 b = _scriptPtr.fetchWord();
 	uint16 c = _scriptPtr.fetchWord();
 	uint8 a = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "Logic::op_soundUnk2(0x%X, 0x%X, %d)", b, c, a);
+	debugC(kDebugLogic, "%.4x - op_soundUnk2(0x%X, 0x%X, %d)",
+		_lastOpcodeOffset, b, c, a);
 	// XXX
 }
 
@@ -366,7 +390,8 @@ void Logic::runScripts() {
 
 void Logic::executeScript() {
 	while (!_scriptHalted && !g_engine->shouldQuit()) {
-		
+		// Get the next opcode
+		_lastOpcodeOffset = _scriptPtr.pc - _res->_segCode;
 		uint8 opcode = _scriptPtr.fetchByte();
 
 		if (opcode & 0x80) {
diff --git a/engines/awe/logic.h b/engines/awe/logic.h
index 06bf9ecae51..707d33269f8 100644
--- a/engines/awe/logic.h
+++ b/engines/awe/logic.h
@@ -65,6 +65,8 @@ struct Logic {
 	uint8 _stackPtr = 0;
 	bool _scriptHalted = false;
 	bool _fastMode = false;
+	int _lastOpcodeOffset = 0;
+	uint32 _lastTimestamp = 0;
 
 	Logic(Resource *res, Video *vid, SystemStub *stub);
 	void init();


Commit: 5fd9c0e3f506b098a9b1182d2d894915337350cb
    https://github.com/scummvm/scummvm/commit/5fd9c0e3f506b098a9b1182d2d894915337350cb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Add detection for demo

Changed paths:
    engines/awe/awe.cpp
    engines/awe/awe.h
    engines/awe/detection_tables.h
    engines/awe/video.cpp


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index b38f3263d6c..38690f72183 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -29,12 +29,15 @@
 
 namespace Awe {
 
+AweEngine *g_engine;
+
 AweEngine::AweEngine(OSystem *syst, const ADGameDescription *gameDesc)
-	: Engine(syst), _gameDescription(gameDesc),
-	_stub(SystemStub_create()),
-	_res(&_vid),
-	_vid(&_res, _stub),
-	_log(&_res, &_vid, _stub) {
+		: Engine(syst), _gameDescription(gameDesc),
+		_stub(SystemStub_create()),
+		_res(&_vid),
+		_vid(&_res, _stub),
+		_log(&_res, &_vid, _stub) {
+	g_engine = this;
 }
 
 AweEngine::~AweEngine() {
@@ -55,7 +58,8 @@ Common::Error AweEngine::run() {
 	setup();
 
 	// Run the game
-	_log.restartAt(0x3E80); // demo starts at 0x3E81
+	_log.restartAt(isDemo() ? 0x3e81 : 0x3e80);
+
 	while (!_stub->_pi.quit && !g_engine->shouldQuit()) {
 		_log.setupScripts();
 		_log.inp_updatePlayer();
@@ -149,4 +153,14 @@ Common::Error AweEngine::loadGameStream(Common::SeekableReadStream *stream) {
 	}
 }
 
+bool AweEngine::hasFeature(EngineFeature f) const {
+	return
+		(f == kSupportsReturnToLauncher);
+}
+
+bool AweEngine::isDemo() const {
+	return (_gameDescription->flags & ADGF_DEMO) != 0;
+}
+
+
 } // namespace Awe
diff --git a/engines/awe/awe.h b/engines/awe/awe.h
index 79aad602068..c0ce27a03c0 100644
--- a/engines/awe/awe.h
+++ b/engines/awe/awe.h
@@ -56,11 +56,15 @@ public:
 	~AweEngine() override;
 
 	Common::Error run() override;
+	bool hasFeature(EngineFeature f) const override;
+	bool isDemo() const;
 
 	Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
 	Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
 };
 
+extern AweEngine *g_engine;
+
 } // namespace Awe
 
 #endif
diff --git a/engines/awe/detection_tables.h b/engines/awe/detection_tables.h
index dbcd25d0446..d3960d6d03b 100644
--- a/engines/awe/detection_tables.h
+++ b/engines/awe/detection_tables.h
@@ -36,6 +36,15 @@ const ADGameDescription gameDescriptions[] = {
 		ADGF_UNSTABLE,
 		GUIO1(GUIO_NONE)
 	},
+	{
+		"anotherworld",
+		"Demo",
+		AD_ENTRY1s("memlist.bin", "11e0cc58aeb47ad1dfc1c4dae8dcd9ee", 2940),
+		Common::EN_ANY,
+		Common::kPlatformDOS,
+		ADGF_DEMO | ADGF_UNSTABLE,
+		GUIO1(GUIO_NONE)
+	},
 
 #if 0
 	// Unsupported release that doesn't have a memlist.bin
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index dfd8795877b..dfc4bf20fa9 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -189,7 +189,9 @@ int32 Video::calcStep(const Point &p1, const Point &p2, uint16 &dy) {
 }
 
 void Video::drawString(uint8 color, uint16 x, uint16 y, uint16 strId) {
-	const StrEntry *se = _stringsTableEng;
+	const StrEntry *se = g_engine->isDemo() ?
+		_stringsTableDemo : _stringsTableEng;
+
 	while (se->id != 0xFFFF && se->id != strId) ++se;
 	debugC(kDebugVideo, "drawString(%d, %d, %d, '%s')", color, x, y, se->str);
 	uint16 xx = x;


Commit: 5316a63445cf512428a52670386f2ce585d22abf
    https://github.com/scummvm/scummvm/commit/5316a63445cf512428a52670386f2ce585d22abf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Separate melist array for demo version

Changed paths:
    engines/awe/resource.cpp
    engines/awe/resource.h
    engines/awe/staticres.cpp


diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 17a5f9d7487..abcd51ce753 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -181,12 +181,19 @@ void Resource::setupPtrs(uint16 ptrId) {
 		uint8 icod = 0;
 		uint8 ivd1 = 0;
 		uint8 ivd2 = 0;
+
+		static const auto &parts = g_engine->isDemo() ?
+			MEM_LIST_DEMO_PARTS : MEM_LIST_PARTS;
+
 		if (ptrId >= 0x3E80 && ptrId <= 0x3E89) {
 			uint16 part = ptrId - 0x3E80;
-			ipal = _memListParts[part][0];
-			icod = _memListParts[part][1];
-			ivd1 = _memListParts[part][2];
-			ivd2 = _memListParts[part][3];
+			ipal = MEM_LIST_PARTS[part][0];
+			icod = MEM_LIST_PARTS[part][1];
+			ivd1 = MEM_LIST_PARTS[part][2];
+			ivd2 = MEM_LIST_PARTS[part][3];
+
+			if (g_engine->isDemo() && ptrId == 0x3e82) {
+			}
 		} else {
 			error("Resource::setupPtrs() ec=0x%X invalid ptrId", 0xF07);
 		}
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index 9639be2fb35..550f8988233 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -58,8 +58,9 @@ struct Resource {
 	};
 	
 	static const uint16 _memListAudio[];
-	static const uint16 _memListParts[][4];
-	
+	static const uint16 MEM_LIST_PARTS[][4];
+	static const uint16 MEM_LIST_DEMO_PARTS[][4];
+
 	Video *_vid = nullptr;
 	MemEntry _memList[150];
 	uint16 _numMemList = 0;
diff --git a/engines/awe/staticres.cpp b/engines/awe/staticres.cpp
index a1a3af9ba4b..fd6f46985f0 100644
--- a/engines/awe/staticres.cpp
+++ b/engines/awe/staticres.cpp
@@ -66,7 +66,7 @@ const uint16 Resource::_memListAudio[] = {
 	8, 0x10, 0x61, 0x66, 0xFFFF
 };
 
-const uint16 Resource::_memListParts[][4] = {
+const uint16 Resource::MEM_LIST_PARTS[][4] = {
 	{ 0x14, 0x15, 0x16, 0x00 }, // protection screens
 	{ 0x17, 0x18, 0x19, 0x00 }, // introduction
 	{ 0x1A, 0x1B, 0x1C, 0x11 },
@@ -79,6 +79,19 @@ const uint16 Resource::_memListParts[][4] = {
 	{ 0x7D, 0x7E, 0x7F, 0x00 }  // password screen
 };
 
+const uint16 Resource::MEM_LIST_DEMO_PARTS[][4] = {
+	{ 0x14, 0x15, 0x16, 0x00 }, // Protection: unused in demo
+	{ 0x17, 0x18, 0x19, 0x00 }, // Introduction: start
+	{ 0x1A, 0x1B, 0x1C, 0x00 },
+	{ 0x1D, 0x1E, 0x1F, 0x11 },
+	{ 0x20, 0x21, 0x22, 0x11 },
+	{ 0x23, 0x24, 0x25, 0x00 },
+	{ 0x26, 0x27, 0x28, 0x11 },
+	{ 0x29, 0x2A, 0x2B, 0x00 },
+	{ 0x7D, 0x7E, 0x7F, 0x00 },
+	{ 0x7D, 0x7E, 0x7F, 0x00 }
+};
+
 const uint8 Video::_font[] = {
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00,
 	0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x7E, 0x24, 0x24, 0x7E, 0x24, 0x00,


Commit: 4d8c51392e801c12c0a9f347fc9ef97c0d75109d
    https://github.com/scummvm/scummvm/commit/4d8c51392e801c12c0a9f347fc9ef97c0d75109d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Remove deprecated manual scaling logic

Changed paths:
    engines/awe/system_stub.cpp


diff --git a/engines/awe/system_stub.cpp b/engines/awe/system_stub.cpp
index 7b0edc8859f..10acf524d96 100644
--- a/engines/awe/system_stub.cpp
+++ b/engines/awe/system_stub.cpp
@@ -37,19 +37,8 @@ struct ScummVMStub : SystemStub {
 		SCREEN_H = 200
 	};
 
-	struct Scaler {
-		const char *name;
-		ScaleProc proc;
-		uint8 factor;
-	};
-	
-	static const Scaler _scalers[];
-
 	uint8 *_offscreen;
 	Graphics::Screen *_screen;
-	bool _fullscreen;
-	uint8 _scaler;
-	Graphics::PaletteLookup _palLookup;
 	byte _pal[16];
 
 	virtual ~ScummVMStub() {}
@@ -63,17 +52,6 @@ struct ScummVMStub : SystemStub {
 
 	void prepareGfxMode();
 	void cleanupGfxMode();
-	void switchGfxMode(bool fullscreen, uint8 scaler);
-
-	void point1x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h);
-	void point2x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h);
-	void point3x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h);
-};
-
-const ScummVMStub::Scaler ScummVMStub::_scalers[] = {
-	{ "Point1x", &ScummVMStub::point1x, 1 },
-	{ "Point2x", &ScummVMStub::point2x, 2 },
-	{ "Point3x", &ScummVMStub::point3x, 3 }
 };
 
 SystemStub *SystemStub_create() {
@@ -86,8 +64,7 @@ void ScummVMStub::init(const char *title) {
 	if (!_offscreen) {
 		error("Unable to allocate offscreen buffer");
 	}
-	_fullscreen = false;
-	_scaler = 1;
+
 	prepareGfxMode();
 }
 
@@ -159,19 +136,7 @@ void ScummVMStub::processEvents() {
 			break;
 		case Common::EVENT_KEYDOWN:
 			if (ev.kbd.flags & Common::KBD_ALT) {
-				if (ev.kbd.keycode == Common::KEYCODE_RETURN) {
-					switchGfxMode(!_fullscreen, _scaler);
-				} else if (ev.kbd.keycode == Common::KEYCODE_KP_PLUS) {
-					uint8 s = _scaler + 1;
-					if (s < ARRAYSIZE(_scalers)) {
-						switchGfxMode(_fullscreen, s);
-					}
-				} else if (ev.kbd.keycode == Common::KEYCODE_KP_MINUS) {
-					int8 s = _scaler - 1;
-					if (_scaler > 0) {
-						switchGfxMode(_fullscreen, s);
-					}
-				} else if (ev.kbd.keycode == Common::KEYCODE_x) {
+				if (ev.kbd.keycode == Common::KEYCODE_x) {
 					_pi.quit = true;
 				}
 				break;
@@ -249,62 +214,4 @@ void ScummVMStub::cleanupGfxMode() {
 	}
 }
 
-void ScummVMStub::switchGfxMode(bool fullscreen, uint8 scaler) {
-#ifdef DEPRECATED
-	SDL_Surface *prev_sclscreen = _sclscreen;
-	SDL_FreeSurface(_screen); 	
-	_fullscreen = fullscreen;
-	_scaler = scaler;
-	prepareGfxMode();
-	SDL_BlitSurface(prev_sclscreen, NULL, _sclscreen, NULL);
-	SDL_FreeSurface(prev_sclscreen);
-#endif
-}
-
-void ScummVMStub::point1x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
-	dstPitch >>= 1;
-	while (h--) {
-		memcpy(dst, src, w * 2);
-		dst += dstPitch;
-		src += dstPitch;
-	}
-}
-
-void ScummVMStub::point2x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
-	dstPitch >>= 1;
-	while (h--) {
-		uint16 *p = dst;
-		for (int i = 0; i < w; ++i, p += 2) {
-			uint16 c = *(src + i);
-			*(p + 0) = c;
-			*(p + 1) = c;
-			*(p + 0 + dstPitch) = c;
-			*(p + 1 + dstPitch) = c;
-		}
-		dst += dstPitch * 2;
-		src += srcPitch;
-	}
-}
-
-void ScummVMStub::point3x(uint16 *dst, uint16 dstPitch, const uint16 *src, uint16 srcPitch, uint16 w, uint16 h) {
-	dstPitch >>= 1;
-	while (h--) {
-		uint16 *p = dst;
-		for (int i = 0; i < w; ++i, p += 3) {
-			uint16 c = *(src + i);
-			*(p + 0) = c;
-			*(p + 1) = c;
-			*(p + 2) = c;
-			*(p + 0 + dstPitch) = c;
-			*(p + 1 + dstPitch) = c;
-			*(p + 2 + dstPitch) = c;
-			*(p + 0 + dstPitch * 2) = c;
-			*(p + 1 + dstPitch * 2) = c;
-			*(p + 2 + dstPitch * 2) = c;
-		}
-		dst += dstPitch * 3;
-		src += srcPitch;
-	}
-}
-
 } // namespace Awe


Commit: ab95b69ac1676f323d0e3b9d9f724e027cb19dc0
    https://github.com/scummvm/scummvm/commit/ab95b69ac1676f323d0e3b9d9f724e027cb19dc0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Fix prompting for code again if you get it wrong

Original interpreter actually has a code fix in the
conditional jump opcode that patches the scripts
to make it work properly

Changed paths:
    engines/awe/logic.cpp


diff --git a/engines/awe/logic.cpp b/engines/awe/logic.cpp
index 9c8765ef7f2..e04356bf32b 100644
--- a/engines/awe/logic.cpp
+++ b/engines/awe/logic.cpp
@@ -132,6 +132,14 @@ void Logic::op_condJmp() {
 		warning("Logic::op_condJmp() bypassing protection");
 	}
 #endif
+	// Patch original interpreter triggers if code is wrong
+	if (_res->_curPtrsId == 0x3e80 && _lastOpcodeOffset == 0xc4b) {
+		byte *script = _scriptPtr.pc;
+		*script = 0x81;
+		WRITE_BE_UINT16(script + 3, 0xcb7);
+		WRITE_BE_UINT16(script + 153, 0xced);
+	}
+
 	uint8 op = _scriptPtr.fetchByte();
 	int16 b = _scriptVars[_scriptPtr.fetchByte()];
 	int16 a = _scriptPtr.fetchByte();


Commit: 37a8200d777910594429414f94d4929c5a2fe2b8
    https://github.com/scummvm/scummvm/commit/37a8200d777910594429414f94d4929c5a2fe2b8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Fix debug line for op_setPalette opcode

Changed paths:
    engines/awe/logic.cpp


diff --git a/engines/awe/logic.cpp b/engines/awe/logic.cpp
index e04356bf32b..a4d6d60ff0f 100644
--- a/engines/awe/logic.cpp
+++ b/engines/awe/logic.cpp
@@ -188,7 +188,7 @@ void Logic::op_condJmp() {
 
 void Logic::op_setPalette() {
 	uint16 i = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "%.4x - op_changePalette(%d)", _lastOpcodeOffset, i);
+	debugC(kDebugLogic, "%.4x - op_setPalette(%d)", _lastOpcodeOffset, i);
 	_vid->_newPal = i >> 8;
 }
 


Commit: 4d38942129fbe9218f5d16ce9ae9353422e5b48a
    https://github.com/scummvm/scummvm/commit/4d38942129fbe9218f5d16ce9ae9353422e5b48a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Game option for copy protection bypass

Changed paths:
    engines/awe/awe.h
    engines/awe/detection.h
    engines/awe/detection_tables.h
    engines/awe/logic.cpp
    engines/awe/logic.h
    engines/awe/metaengine.cpp


diff --git a/engines/awe/awe.h b/engines/awe/awe.h
index c0ce27a03c0..aaf9e614585 100644
--- a/engines/awe/awe.h
+++ b/engines/awe/awe.h
@@ -33,8 +33,6 @@
 
 namespace Awe {
 
-#define BYPASS_PROTECTION
-
 class AweEngine : public Engine {
 private:
 	const ADGameDescription *_gameDescription;
diff --git a/engines/awe/detection.h b/engines/awe/detection.h
index 44db8224a20..bcbbb722cb1 100644
--- a/engines/awe/detection.h
+++ b/engines/awe/detection.h
@@ -37,7 +37,7 @@ extern const PlainGameDescriptor aweGames[];
 
 extern const ADGameDescription gameDescriptions[];
 
-#define GAMEOPTION_ORIGINAL_SAVELOAD GUIO_GAMEOPTIONS1
+#define GAMEOPTION_COPY_PROTECTION		GUIO_GAMEOPTIONS1
 
 } // namespace Awe
 
diff --git a/engines/awe/detection_tables.h b/engines/awe/detection_tables.h
index d3960d6d03b..b3e7ae2dfb1 100644
--- a/engines/awe/detection_tables.h
+++ b/engines/awe/detection_tables.h
@@ -34,7 +34,7 @@ const ADGameDescription gameDescriptions[] = {
 		Common::EN_ANY,
 		Common::kPlatformDOS,
 		ADGF_UNSTABLE,
-		GUIO1(GUIO_NONE)
+		GUIO1(GAMEOPTION_COPY_PROTECTION)
 	},
 	{
 		"anotherworld",
@@ -43,17 +43,18 @@ const ADGameDescription gameDescriptions[] = {
 		Common::EN_ANY,
 		Common::kPlatformDOS,
 		ADGF_DEMO | ADGF_UNSTABLE,
-		GUIO1(GUIO_NONE)
+		GUIO1(GAMEOPTION_COPY_PROTECTION)
 	},
 
 #if 0
-	// Unsupported release that doesn't have a memlist.bin
+	// Unsupported Windows release that doesn't have a memlist.bin
+	// Need to investigate further.. maybe an embedded resource?
 	{
 		"anotherworld",
 		nullptr,
 		AD_ENTRY1s("bank", "30fb99cb4cbd812273d0b54b7b4a18ca", 987462),
 		Common::EN_ANY,
-		Common::kPlatformDOS,
+		Common::kPlatformWindows,
 		ADGF_UNSTABLE,
 		GUIO1(GUIO_NONE)
 	},
diff --git a/engines/awe/logic.cpp b/engines/awe/logic.cpp
index a4d6d60ff0f..534232b5a21 100644
--- a/engines/awe/logic.cpp
+++ b/engines/awe/logic.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "common/config-manager.h"
 #include "awe/awe.h"
 #include "awe/logic.h"
 #include "awe/resource.h"
@@ -29,7 +30,8 @@
 namespace Awe {
 
 Logic::Logic(Resource *res, Video *vid, SystemStub *stub)
-	: _res(res), _vid(vid), _stub(stub) {
+	: _res(res), _vid(vid), _stub(stub),
+	_copyProtection(ConfMan.getBool("copy_protection")) {
 }
 
 void Logic::init() {
@@ -120,8 +122,8 @@ void Logic::op_jnz() {
 }
 
 void Logic::op_condJmp() {
-#ifdef BYPASS_PROTECTION
-	if (_res->_curPtrsId == 0x3E80 && _scriptPtr.pc == _res->_segCode + 0xCB9) {
+	if (!_copyProtection && _res->_curPtrsId == 0x3E80 &&
+			_lastOpcodeOffset == 0xCB8) {
 		// (0x0CB8) condJmp(0x80, VAR(41), VAR(30), 0xCD3)
 		*(_scriptPtr.pc + 0x00) = 0x81;
 		*(_scriptPtr.pc + 0x03) = 0x0D;
@@ -129,9 +131,9 @@ void Logic::op_condJmp() {
 		// (0x0D4E) condJmp(0x4, VAR(50), 6, 0xDBC)		
 		*(_scriptPtr.pc + 0x99) = 0x0D;
 		*(_scriptPtr.pc + 0x9A) = 0x5A;
-		warning("Logic::op_condJmp() bypassing protection");
+		debugC(kDebugLogic, "Logic::op_condJmp() bypassing protection");
 	}
-#endif
+
 	// Patch original interpreter triggers if code is wrong
 	if (_res->_curPtrsId == 0x3e80 && _lastOpcodeOffset == 0xc4b) {
 		byte *script = _scriptPtr.pc;
diff --git a/engines/awe/logic.h b/engines/awe/logic.h
index 707d33269f8..c7c3a858c51 100644
--- a/engines/awe/logic.h
+++ b/engines/awe/logic.h
@@ -55,6 +55,7 @@ struct Logic {
 	Resource *_res;
 	Video *_vid;
 	SystemStub *_stub;
+	bool _copyProtection;
 
 	int16 _scriptVar_0xBF = { 0 };
 	int16 _scriptVars[0x100] = { 0 };
diff --git a/engines/awe/metaengine.cpp b/engines/awe/metaengine.cpp
index 3613b3bf36c..43fe8e5ce20 100644
--- a/engines/awe/metaengine.cpp
+++ b/engines/awe/metaengine.cpp
@@ -29,15 +29,15 @@ namespace Awe {
 
 static const ADExtraGuiOptionsMap optionsList[] = {
 	{
-		GAMEOPTION_ORIGINAL_SAVELOAD,
+		GAMEOPTION_COPY_PROTECTION,
 		{
-			_s("Use original save/load screens"),
-			_s("Use the original save/load screens instead of the ScummVM ones"),
-			"original_menus",
+			_s("Enable copy protection"),
+			_s("Enable any copy protection that would otherwise be bypassed by default."),
+			"copy_protection",
 			false,
 			0,
 			0
-		}
+		},
 	},
 	AD_EXTRA_GUI_OPTIONS_TERMINATOR
 };


Commit: 75162510da94923eb928add3a3516d4bb87df289
    https://github.com/scummvm/scummvm/commit/75162510da94923eb928add3a3516d4bb87df289
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Uppercase static array names

Changed paths:
    engines/awe/logic.cpp
    engines/awe/logic.h
    engines/awe/resource.cpp
    engines/awe/resource.h
    engines/awe/staticres.cpp
    engines/awe/video.cpp
    engines/awe/video.h


diff --git a/engines/awe/logic.cpp b/engines/awe/logic.cpp
index 534232b5a21..37cc780c8fd 100644
--- a/engines/awe/logic.cpp
+++ b/engines/awe/logic.cpp
@@ -463,7 +463,7 @@ void Logic::executeScript() {
 			if (opcode > 0x1A) {
 				error("Logic::executeScript() ec=0x%X invalid opcode=0x%X", 0xFFF, opcode);
 			} else {
-				(this->*_opTable[opcode])();
+				(this->*OPCODE_TABLE[opcode])();
 			}
 		}
 	}
diff --git a/engines/awe/logic.h b/engines/awe/logic.h
index c7c3a858c51..b067115762b 100644
--- a/engines/awe/logic.h
+++ b/engines/awe/logic.h
@@ -50,7 +50,7 @@ struct Logic {
 		VAR_PAUSE_SLICES         = 0xFF
 	};
 	
-	static const OpcodeStub _opTable[];
+	static const OpcodeStub OPCODE_TABLE[];
 
 	Resource *_res;
 	Video *_vid;
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index abcd51ce753..67996e30cc9 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -161,7 +161,7 @@ void Resource::update(uint16 num) {
 			_newPtrsId = num;
 		} else {
 			if (false) { // XXX (_audio_use_pro_or_adlib == 1 || _audio_use_spk == 1) {
-				for (const uint16 *ml = _memListAudio; *ml != 0xFFFF; ++ml) {
+				for (const uint16 *ml = MEMLIST_AUDIO; *ml != 0xFFFF; ++ml) {
 					if (*ml == num)
 						return;
 				}
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index 550f8988233..ca3b1bcef70 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -57,7 +57,7 @@ struct Resource {
 		MEM_BLOCK_SIZE = 600 * 1024
 	};
 	
-	static const uint16 _memListAudio[];
+	static const uint16 MEMLIST_AUDIO[];
 	static const uint16 MEM_LIST_PARTS[][4];
 	static const uint16 MEM_LIST_DEMO_PARTS[][4];
 
diff --git a/engines/awe/staticres.cpp b/engines/awe/staticres.cpp
index fd6f46985f0..7d6da114249 100644
--- a/engines/awe/staticres.cpp
+++ b/engines/awe/staticres.cpp
@@ -25,7 +25,7 @@
 
 namespace Awe {
 
-const Logic::OpcodeStub Logic::_opTable[] = {
+const Logic::OpcodeStub Logic::OPCODE_TABLE[] = {
 	/* 0x00 */
 	&Logic::op_movConst,
 	&Logic::op_mov,
@@ -62,7 +62,7 @@ const Logic::OpcodeStub Logic::_opTable[] = {
 	&Logic::op_soundUnk2
 };
 
-const uint16 Resource::_memListAudio[] = { 
+const uint16 Resource::MEMLIST_AUDIO[] = { 
 	8, 0x10, 0x61, 0x66, 0xFFFF
 };
 
@@ -92,7 +92,7 @@ const uint16 Resource::MEM_LIST_DEMO_PARTS[][4] = {
 	{ 0x7D, 0x7E, 0x7F, 0x00 }
 };
 
-const uint8 Video::_font[] = {
+const uint8 Video::FONT[] = {
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00,
 	0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x7E, 0x24, 0x24, 0x7E, 0x24, 0x00,
 	0x08, 0x3E, 0x48, 0x3C, 0x12, 0x7C, 0x10, 0x00, 0x42, 0xA4, 0x48, 0x10, 0x24, 0x4A, 0x84, 0x00,
@@ -143,7 +143,7 @@ const uint8 Video::_font[] = {
 	0x38, 0x44, 0x82, 0x82, 0x44, 0x28, 0xEE, 0x00, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA
 };
 
-const StrEntry Video::_stringsTableEng[] = {
+const StrEntry Video::STRINGS_TABLE_ENG[] = {
 	{ 0x001, "P E A N U T  3000" },
 	{ 0x002, "Copyright  } 1990 Peanut Computer, Inc.\nAll rights reserved.\n\nCDOS Version 5.01" },
 	{ 0x003, "2" },
@@ -287,7 +287,7 @@ const StrEntry Video::_stringsTableEng[] = {
 	{ 0xFFFF, "" }
 };
 
-const StrEntry Video::_stringsTableDemo[] = {
+const StrEntry Video::STRINGS_TABLE_DEMO[] = {
 	{ 0x001, "P E A N U T  3000" },
 	{ 0x002, "Copyright  } 1990 Peanut Computer, Inc.\nAll rights reserved.\n\nCDOS Version 5.01" },
 	{ 0x003, "2" },
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index dfc4bf20fa9..d5d711cc719 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -190,7 +190,7 @@ int32 Video::calcStep(const Point &p1, const Point &p2, uint16 &dy) {
 
 void Video::drawString(uint8 color, uint16 x, uint16 y, uint16 strId) {
 	const StrEntry *se = g_engine->isDemo() ?
-		_stringsTableDemo : _stringsTableEng;
+		STRINGS_TABLE_DEMO : STRINGS_TABLE_ENG;
 
 	while (se->id != 0xFFFF && se->id != strId) ++se;
 	debugC(kDebugVideo, "drawString(%d, %d, %d, '%s')", color, x, y, se->str);
@@ -209,7 +209,7 @@ void Video::drawString(uint8 color, uint16 x, uint16 y, uint16 strId) {
 
 void Video::drawChar(uint8 c, uint16 x, uint16 y, uint8 color, uint8 *buf) {
 	if (x <= 39 && y <= 192) {
-		const uint8 *ft = _font + (c - 0x20) * 8;
+		const uint8 *ft = FONT + (c - 0x20) * 8;
 		uint8 *p = buf + x * 4 + y * 160;
 		for (int j = 0; j < 8; ++j) {
 			uint8 ch = *(ft + j);
diff --git a/engines/awe/video.h b/engines/awe/video.h
index 7ec8112c374..11fa9fb6008 100644
--- a/engines/awe/video.h
+++ b/engines/awe/video.h
@@ -54,9 +54,9 @@ struct Video {
 		VID_PAGE_SIZE  = 320 * 200 / 2
 	};
 
-	static const uint8 _font[];
-	static const StrEntry _stringsTableEng[];
-	static const StrEntry _stringsTableDemo[];
+	static const uint8 FONT[];
+	static const StrEntry STRINGS_TABLE_ENG[];
+	static const StrEntry STRINGS_TABLE_DEMO[];
 
 	Resource *_res;
 	SystemStub *_stub;


Commit: 83ad5ebe05a1225334062d95a5f90e2dfcace5b4
    https://github.com/scummvm/scummvm/commit/83ad5ebe05a1225334062d95a5f90e2dfcace5b4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Set up keybindings for the main keys

Changed paths:
    engines/awe/metaengine.cpp
    engines/awe/metaengine.h
    engines/awe/system_stub.cpp


diff --git a/engines/awe/metaengine.cpp b/engines/awe/metaengine.cpp
index 43fe8e5ce20..f31b9b4cdf4 100644
--- a/engines/awe/metaengine.cpp
+++ b/engines/awe/metaengine.cpp
@@ -20,7 +20,8 @@
  */
 
 #include "common/translation.h"
-
+#include "backends/keymapper/action.h"
+#include "backends/keymapper/keymapper.h"
 #include "awe/metaengine.h"
 #include "awe/detection.h"
 #include "awe/awe.h"
@@ -42,6 +43,26 @@ static const ADExtraGuiOptionsMap optionsList[] = {
 	AD_EXTRA_GUI_OPTIONS_TERMINATOR
 };
 
+
+struct KeybindingRecord {
+	KeybindingAction _action;
+	const char *_id;
+	const char *_desc;
+	const char *_key1;
+	const char *_key2;
+	const char *_joy;
+};
+
+static const KeybindingRecord GAME_KEYS[] = {
+	{ KEYBIND_UP, "UP", _s("Up"), "UP", nullptr, "JOY_UP"},
+	{ KEYBIND_DOWN, "DOWN", _s("Down"), "DOWN", nullptr, "JOY_DOWN"},
+	{ KEYBIND_LEFT, "LEFT", _s("Left"), "LEFT", nullptr, "JOY_LEFT"},
+	{ KEYBIND_RIGHT, "RIGHT", _s("Right"), "RIGHT", nullptr, "JOY_RIGHT"},
+	{ KEYBIND_SELECT, "SELECT", _s("Select/Kick/Run"), "SPACE", "RETURN", "JOY_A" },
+	{ KEYBIND_CODE, "CODE", _s("Enter Level Code"), "c", nullptr, "JOY_B" },
+	{ KEYBIND_NONE, nullptr, nullptr, nullptr, nullptr, nullptr }
+};
+
 } // End of namespace Awe
 
 const char *AweMetaEngine::getName() const {
@@ -62,6 +83,28 @@ bool AweMetaEngine::hasFeature(MetaEngineFeature f) const {
 		(f == kSupportsLoadingDuringStartup);
 }
 
+Common::Array<Common::Keymap *> AweMetaEngine::initKeymaps(const char *target) const {
+	Common::KeymapArray keymapArray;
+	Common::Keymap *keyMap = new Common::Keymap(Common::Keymap::kKeymapTypeGame, "got", _s("Game Keys"));
+	keymapArray.push_back(keyMap);
+
+	for (const Awe::KeybindingRecord *r = Awe::GAME_KEYS; r->_id; ++r) {
+		Common::Action *act = new Common::Action(r->_id, _(r->_desc));
+		act->setCustomEngineActionEvent(r->_action);
+		act->allowKbdRepeats();
+
+		act->addDefaultInputMapping(r->_key1);
+		if (r->_key2)
+			act->addDefaultInputMapping(r->_key2);
+		if (r->_joy)
+			act->addDefaultInputMapping(r->_joy);
+
+		keyMap->addAction(act);
+	}
+
+	return keymapArray;
+}
+
 #if PLUGIN_ENABLED_DYNAMIC(AWE)
 REGISTER_PLUGIN_DYNAMIC(AWE, PLUGIN_TYPE_ENGINE, AweMetaEngine);
 #else
diff --git a/engines/awe/metaengine.h b/engines/awe/metaengine.h
index 06b688af85f..455304069cd 100644
--- a/engines/awe/metaengine.h
+++ b/engines/awe/metaengine.h
@@ -24,6 +24,20 @@
 
 #include "engines/advancedDetector.h"
 
+namespace Awe {
+
+enum KeybindingAction {
+	KEYBIND_NONE,
+	KEYBIND_UP,
+	KEYBIND_DOWN,
+	KEYBIND_LEFT,
+	KEYBIND_RIGHT,
+	KEYBIND_SELECT,
+	KEYBIND_CODE
+};
+
+} // namespace Awe
+
 class AweMetaEngine : public AdvancedMetaEngine<ADGameDescription> {
 public:
 	const char *getName() const override;
@@ -38,6 +52,8 @@ public:
 	bool hasFeature(MetaEngineFeature f) const override;
 
 	const ADExtraGuiOptionsMap *getAdvancedExtraGuiOptions() const override;
+
+	Common::Array<Common::Keymap *> initKeymaps(const char *target) const override;
 };
 
 #endif
diff --git a/engines/awe/system_stub.cpp b/engines/awe/system_stub.cpp
index 10acf524d96..b94d6c3078b 100644
--- a/engines/awe/system_stub.cpp
+++ b/engines/awe/system_stub.cpp
@@ -24,6 +24,7 @@
 #include "graphics/paletteman.h"
 #include "graphics/screen.h"
 #include "awe/awe.h"
+#include "awe/metaengine.h"
 #include "awe/system_stub.h"
 #include "awe/util.h"
 
@@ -112,28 +113,6 @@ void ScummVMStub::processEvents() {
 	while (!g_engine->shouldQuit() &&
 			g_system->getEventManager()->pollEvent(ev)) {
 		switch (ev.type) {
-		case Common::EVENT_KEYUP:
-			switch(ev.kbd.keycode) {
-			case Common::KEYCODE_LEFT:
-				_pi.dirMask &= ~PlayerInput::DIR_LEFT;
-				break;
-			case Common::KEYCODE_RIGHT:
-				_pi.dirMask &= ~PlayerInput::DIR_RIGHT;
-				break;
-			case Common::KEYCODE_UP:
-				_pi.dirMask &= ~PlayerInput::DIR_UP;
-				break;
-			case Common::KEYCODE_DOWN:
-				_pi.dirMask &= ~PlayerInput::DIR_DOWN;
-				break;
-			case Common::KEYCODE_SPACE:
-			case Common::KEYCODE_RETURN:
-				_pi.button = false;
-				break;
-			default:
-				break;
-			}
-			break;
 		case Common::EVENT_KEYDOWN:
 			if (ev.kbd.flags & Common::KBD_ALT) {
 				if (ev.kbd.keycode == Common::KEYCODE_x) {
@@ -156,32 +135,59 @@ void ScummVMStub::processEvents() {
 			}
 			_pi.lastChar = ev.kbd.keycode;
 			switch(ev.kbd.keycode) {
-			case Common::KEYCODE_LEFT:
+			case Common::KEYCODE_p:
+				_pi.pause = true;
+				break;
+			default:
+				break;
+			}
+			break;
+		case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+			switch (ev.customType) {
+			case KEYBIND_LEFT:
 				_pi.dirMask |= PlayerInput::DIR_LEFT;
 				break;
-			case Common::KEYCODE_RIGHT:
+			case KEYBIND_RIGHT:
 				_pi.dirMask |= PlayerInput::DIR_RIGHT;
 				break;
-			case Common::KEYCODE_UP:
+			case KEYBIND_UP:
 				_pi.dirMask |= PlayerInput::DIR_UP;
 				break;
-			case Common::KEYCODE_DOWN:
+			case KEYBIND_DOWN:
 				_pi.dirMask |= PlayerInput::DIR_DOWN;
 				break;
-			case Common::KEYCODE_SPACE:
-			case Common::KEYCODE_RETURN:
+			case KEYBIND_SELECT:
 				_pi.button = true;
 				break;
-			case Common::KEYCODE_c:
+			case KEYBIND_CODE:
 				_pi.code = true;
 				break;
-			case Common::KEYCODE_p:
-				_pi.pause = true;
+			default:
+				break;
+			}
+			break;
+		case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
+			switch (ev.customType) {
+			case KEYBIND_LEFT:
+				_pi.dirMask &= ~PlayerInput::DIR_LEFT;
+				break;
+			case KEYBIND_RIGHT:
+				_pi.dirMask &= ~PlayerInput::DIR_RIGHT;
+				break;
+			case KEYBIND_UP:
+				_pi.dirMask &= ~PlayerInput::DIR_UP;
+				break;
+			case KEYBIND_DOWN:
+				_pi.dirMask &= ~PlayerInput::DIR_DOWN;
+				break;
+			case KEYBIND_SELECT:
+				_pi.button = false;
 				break;
 			default:
 				break;
 			}
 			break;
+
 		default:
 			break;
 		}


Commit: 9a4418bd36e3307b75929faa04c9f7d4f6640d94
    https://github.com/scummvm/scummvm/commit/9a4418bd36e3307b75929faa04c9f7d4f6640d94
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Fix initialization for multi-dimensional arrays

Changed paths:
    engines/awe/logic.h


diff --git a/engines/awe/logic.h b/engines/awe/logic.h
index b067115762b..da776f26e30 100644
--- a/engines/awe/logic.h
+++ b/engines/awe/logic.h
@@ -60,8 +60,8 @@ struct Logic {
 	int16 _scriptVar_0xBF = { 0 };
 	int16 _scriptVars[0x100] = { 0 };
 	uint16 _scriptStackCalls[0x40] = { 0 };
-	uint16 _scriptPos[2][0x40] = { 0 };
-	uint8 _scriptPaused[2][0x40] = { 0 };
+	uint16 _scriptPos[2][0x40] = { { 0 } };
+	uint8 _scriptPaused[2][0x40] = { { 0 } };
 	Ptr _scriptPtr;
 	uint8 _stackPtr = 0;
 	bool _scriptHalted = false;


Commit: 56580306032cd05b31331a776b967d2b345b344c
    https://github.com/scummvm/scummvm/commit/56580306032cd05b31331a776b967d2b345b344c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Replacing codebase with rawgl

Changed paths:
  A engines/awe/aifcplayer.cpp
  A engines/awe/aifcplayer.h
  A engines/awe/bitmap.cpp
  A engines/awe/bitmap.h
  A engines/awe/engine.cpp
  A engines/awe/engine.h
  A engines/awe/file.cpp
  A engines/awe/file.h
  A engines/awe/graphics.h
  A engines/awe/graphics_gl.cpp
  A engines/awe/graphics_soft.cpp
  A engines/awe/mixer.cpp
  A engines/awe/mixer.h
  A engines/awe/pak.cpp
  A engines/awe/pak.h
  A engines/awe/resource_3do.cpp
  A engines/awe/resource_3do.h
  A engines/awe/resource_nth.cpp
  A engines/awe/resource_nth.h
  A engines/awe/resource_win31.cpp
  A engines/awe/resource_win31.h
  A engines/awe/scaler.cpp
  A engines/awe/scaler.h
  A engines/awe/screenshot.cpp
  A engines/awe/screenshot.h
  A engines/awe/script.cpp
  A engines/awe/script.h
  A engines/awe/sfxplayer.cpp
  A engines/awe/sfxplayer.h
  A engines/awe/systemstub.h
  A engines/awe/systemstub_sdl.cpp
  A engines/awe/unpack.cpp
  A engines/awe/unpack.h
  R engines/awe/bank.cpp
  R engines/awe/bank.h
  R engines/awe/logic.cpp
  R engines/awe/logic.h
  R engines/awe/serializer.cpp
  R engines/awe/serializer.h
  R engines/awe/system_stub.cpp
  R engines/awe/system_stub.h
    engines/awe/awe.cpp
    engines/awe/awe.h
    engines/awe/intern.h
    engines/awe/module.mk
    engines/awe/resource.cpp
    engines/awe/resource.h
    engines/awe/staticres.cpp
    engines/awe/util.cpp
    engines/awe/util.h
    engines/awe/video.cpp
    engines/awe/video.h


diff --git a/engines/awe/aifcplayer.cpp b/engines/awe/aifcplayer.cpp
new file mode 100644
index 00000000000..b63022225a9
--- /dev/null
+++ b/engines/awe/aifcplayer.cpp
@@ -0,0 +1,139 @@
+/* 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 "awe/aifcplayer.h"
+#include "awe/util.h"
+
+namespace Awe {
+
+static uint32_t READ_IEEE754(const uint8_t *p) {
+	const uint32_t m = READ_BE_UINT32(p + 2);
+	const int exp = 30 - p[1];
+	return (m >> exp);
+}
+
+AifcPlayer::AifcPlayer() {
+}
+
+bool AifcPlayer::play(int mixRate, const char *path, uint32_t startOffset) {
+	_ssndSize = 0;
+	if (_f.open(path)) {
+		_f.seek(startOffset);
+		uint8_t buf[12];
+		_f.read(buf, sizeof(buf));
+		if (memcmp(buf, "FORM", 4) == 0 && memcmp(buf + 8, "AIFC", 4) == 0) {
+			const uint32_t size = READ_BE_UINT32(buf + 4);
+			for (uint32_t offset = 12; offset + 8 < size; ) {
+				_f.seek(startOffset + offset);
+				_f.read(buf, 8);
+				const uint32_t sz = READ_BE_UINT32(buf + 4);
+				if (memcmp(buf, "COMM", 4) == 0) {
+					const int channels = _f.readUint16BE();
+					_f.readUint32BE(); // samples per frame
+					const int bits = _f.readUint16BE();
+					_f.read(buf, 10);
+					const int rate = READ_IEEE754(buf);
+					if (channels != 2) {
+						warning("Unsupported AIFF-C channels %d rate %d (%s)", channels, rate, path);
+						break;
+					}
+					_f.read(buf, 4);
+					if (memcmp(buf, "SDX2", 4) != 0) {
+						warning("Unsupported compression");
+						break;
+					}
+					debug(DBG_SND, "AIFF-C channels %d rate %d bits %d", channels, rate, bits);
+					_rate.reset(rate, mixRate);
+				} else if (memcmp(buf, "SSND", 4) == 0) {
+					_f.readUint32BE(); // block offset
+					_f.readUint32BE(); // block size
+					_ssndOffset = startOffset + offset + 8 + 8;
+					_ssndSize = sz;
+					debug(DBG_SND, "AIFF-C ssnd size %d", _ssndSize);
+					break;
+				} else if (memcmp(buf, "FVER", 4) == 0) {
+					const uint32_t version = _f.readUint32BE();
+					if (version != 0xA2805140) {
+						warning("Unexpected AIFF-C version 0x%x (%s)", version, path);
+					}
+				} else if (memcmp(buf, "INST", 4) == 0) {
+					// unused
+				} else if (memcmp(buf, "MARK", 4) == 0) {
+					const int count = _f.readUint16BE();
+					for (int i = 0; i < count; ++i) {
+						_f.readUint16BE(); // marker_id
+						_f.readUint32BE(); // marker_position
+						const int len = _f.readByte();
+						if (len != 0) {
+							char name[256];
+							_f.read(name, len);
+							name[len] = 0;
+						}
+						// pad ((len + 1) & 1)
+					}
+				} else {
+					warning("Unhandled AIFF-C tag '%02x%02x%02x%02x' size %d offset 0x%x path %s", buf[0], buf[1], buf[2], buf[3], sz, startOffset + offset, path);
+					break;
+				}
+				offset += sz + 8;
+			}
+		}
+	}
+	_pos = 0;
+	_sampleL = _sampleR = 0;
+	return _ssndSize != 0;
+}
+
+void AifcPlayer::stop() {
+	_f.close();
+}
+
+static int16_t decodeSDX2(int16_t prev, int8_t data) {
+	const int sqr = data * ABS(data) * 2;
+	return (data & 1) != 0 ? prev + sqr : sqr;
+}
+
+int8_t AifcPlayer::readSampleData() {
+	if (_pos >= _ssndSize) {
+		_pos = 0;
+		_f.seek(_ssndOffset);
+	}
+	const int8_t data = _f.readByte();
+	++_pos;
+	return data;
+}
+
+void AifcPlayer::decodeSamples() {
+	for (uint32_t pos = _rate.getInt(); pos == _rate.getInt(); _rate.offset += _rate.inc) {
+		_sampleL = decodeSDX2(_sampleL, readSampleData());
+		_sampleR = decodeSDX2(_sampleR, readSampleData());
+	}
+}
+
+void AifcPlayer::readSamples(int16_t *buf, int len) {
+	for (int i = 0; i < len; i += 2) {
+		decodeSamples();
+		*buf++ = _sampleL;
+		*buf++ = _sampleR;
+	}
+}
+
+} // namespace Awe
diff --git a/engines/awe/aifcplayer.h b/engines/awe/aifcplayer.h
new file mode 100644
index 00000000000..182ab5dc1ce
--- /dev/null
+++ b/engines/awe/aifcplayer.h
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AWE_AIFC_PLAYER_H
+#define AWE_AIFC_PLAYER_H
+
+#include "awe/intern.h"
+#include "awe/file.h"
+
+namespace Awe {
+
+struct AifcPlayer {
+
+	File _f;
+	uint32_t _ssndOffset;
+	uint32_t _ssndSize;
+	uint32_t _pos;
+	int16_t _sampleL, _sampleR;
+	Frac _rate;
+
+	AifcPlayer();
+
+	bool play(int mixRate, const char *path, uint32_t offset);
+	void stop();
+
+	int8_t readSampleData();
+	void decodeSamples();
+	void readSamples(int16_t *buf, int len);
+};
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 38690f72183..3bcfa173589 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -24,143 +24,295 @@
 #include "common/stream.h"
 #include "engines/util.h"
 #include "awe/awe.h"
-#include "awe/serializer.h"
 #include "awe/util.h"
 
 namespace Awe {
 
 AweEngine *g_engine;
 
-AweEngine::AweEngine(OSystem *syst, const ADGameDescription *gameDesc)
-		: Engine(syst), _gameDescription(gameDesc),
-		_stub(SystemStub_create()),
-		_res(&_vid),
-		_vid(&_res, _stub),
-		_log(&_res, &_vid, _stub) {
-	g_engine = this;
-}
+#ifdef TODO
+static const char USAGE[] =
+"raw(gl) - Another World Interpreter\n"
+"Usage: %s [OPTIONS]...\n"
+"  --datapath=PATH   Path to data files (default '.')\n"
+"  --language=LANG   Language (fr,us,de,es,it)\n"
+"  --part=NUM        Game part to start from (0-35 or 16001-16009)\n"
+"  --render=NAME     Renderer (original,software,gl)\n"
+"  --window=WxH      Windowed display size (default '640x400')\n"
+"  --fullscreen      Fullscreen display (stretched)\n"
+"  --fullscreen-ar   Fullscreen display (16:10 aspect ratio)\n"
+"  --ega-palette     Use EGA palette with DOS version\n"
+"  --demo3-joy       Use inputs from 'demo3.joy' (DOS demo)\n"
+"  --difficulty=DIFF Difficulty (easy,normal,hard)\n"
+"  --audio=AUDIO     Audio (original,remastered)\n"
+;
 
-AweEngine::~AweEngine() {
-	delete _stub;
-}
+static const struct {
+	const char *name;
+	int lang;
+} LANGUAGES[] = {
+	{ "fr", LANG_FR },
+	{ "us", LANG_US },
+	{ "de", LANG_DE },
+	{ "es", LANG_ES },
+	{ "it", LANG_IT },
+	{ 0, -1 }
+};
 
-Common::Error AweEngine::run() {
-	// Setup mixer
-	if (!_mixer->isReady()) {
-		warning("Sound initialization failed.");
-	}
+static const struct {
+	const char *name;
+	int type;
+} GRAPHICS[] = {
+	{ "original", GRAPHICS_ORIGINAL },
+	{ "software", GRAPHICS_SOFTWARE },
+	{ "gl", GRAPHICS_GL },
+	{ 0,  -1 }
+};
 
-	// Initialize backend
-	initGraphics(320, 200);
+static const struct {
+	const char *name;
+	int difficulty;
+} DIFFICULTIES[] = {
+	{ "easy", DIFFICULTY_EASY },
+	{ "normal", DIFFICULTY_NORMAL },
+	{ "hard", DIFFICULTY_HARD },
+	{ 0,  -1 }
+};
 
-	// Setup
-	_stub->init("Out Of This World");
-	setup();
+bool Graphics::_is1991 = false;
+bool Graphics::_use555 = false;
+bool Video::_useEGA = false;
+Difficulty Script::_difficulty = DIFFICULTY_NORMAL;
+bool Script::_useRemasteredAudio = true;
 
-	// Run the game
-	_log.restartAt(isDemo() ? 0x3e81 : 0x3e80);
-
-	while (!_stub->_pi.quit && !g_engine->shouldQuit()) {
-		_log.setupScripts();
-		_log.inp_updatePlayer();
-		processInput();
-		_log.runScripts();
+static Graphics *createGraphics(int type) {
+	switch (type) {
+	case GRAPHICS_ORIGINAL:
+		Graphics::_is1991 = true;
+		// fall-through
+	case GRAPHICS_SOFTWARE:
+		debug(DBG_INFO, "Using software graphics");
+		return GraphicsSoft_create();
+	case GRAPHICS_GL:
+		debug(DBG_INFO, "Using GL graphics");
+#ifdef USE_GL
+		return GraphicsGL_create();
+#endif
 	}
-
-	finish();
-	_stub->destroy();
-
-	return Common::kNoError;
+	return 0;
 }
 
-void AweEngine::setup() {
-	_vid.init();
-	_res.allocMemBlock();
-	_res.readEntries();
-	_log.init();
+static int getGraphicsType(Resource::DataType type) {
+	switch (type) {
+	case Resource::DT_15TH_EDITION:
+	case Resource::DT_20TH_EDITION:
+	case Resource::DT_3DO:
+		return GRAPHICS_GL;
+	default:
+		return GRAPHICS_ORIGINAL;
+	}
 }
 
-void AweEngine::finish() {
-	// XXX
-	_res.freeMemBlock();
+struct Scaler {
+	char name[32];
+	int factor;
+};
+
+static void parseScaler(char *name, Scaler *s) {
+	char *sep = strchr(name, '@');
+	if (sep) {
+		*sep = 0;
+		strncpy(s->name, name, sizeof(s->name) - 1);
+		s->name[sizeof(s->name) - 1] = 0;
+	}
+	if (sep) {
+		s->factor = atoi(sep + 1);
+	}
 }
 
-void AweEngine::processInput() {
-	if (_stub->_pi.load) {
-		loadGameState(_stateSlot);
-		_stub->_pi.load = false;
+static const int DEFAULT_WINDOW_W = 640;
+static const int DEFAULT_WINDOW_H = 400;
+
+int main(int argc, char *argv[]) {
+	char *dataPath = 0;
+	int part = 16001;
+	Language lang = LANG_FR;
+	int graphicsType = GRAPHICS_GL;
+	DisplayMode dm;
+	dm.mode = DisplayMode::WINDOWED;
+	dm.width = DEFAULT_WINDOW_W;
+	dm.height = DEFAULT_WINDOW_H;
+	dm.opengl = (graphicsType == GRAPHICS_GL);
+	Scaler scaler;
+	scaler.name[0] = 0;
+	scaler.factor = 1;
+	bool defaultGraphics = true;
+	bool demo3JoyInputs = false;
+	if (argc == 2) {
+		// data path as the only command line argument
+		struct stat st;
+		if (stat(argv[1], &st) == 0 && S_ISDIR(st.st_mode)) {
+			dataPath = strdup(argv[1]);
+		}
 	}
-	if (_stub->_pi.save) {
-		saveGameState(_stateSlot, "Quicksave");
-		_stub->_pi.save = false;
+	while (1) {
+		static struct option options[] = {
+			{ "datapath", required_argument, 0, 'd' },
+			{ "language", required_argument, 0, 'l' },
+			{ "part",     required_argument, 0, 'p' },
+			{ "render",   required_argument, 0, 'r' },
+			{ "window",   required_argument, 0, 'w' },
+			{ "fullscreen", no_argument,     0, 'f' },
+			{ "fullscreen-ar", no_argument,  0, 'a' },
+			{ "scaler",   required_argument, 0, 's' },
+			{ "ega-palette", no_argument,    0, 'e' },
+			{ "demo3-joy",  no_argument,     0, 'j' },
+			{ "difficulty", required_argument, 0, 'i' },
+			{ "audio",    required_argument, 0, 'u' },
+			{ "help",       no_argument,     0, 'h' },
+			{ 0, 0, 0, 0 }
+		};
+		int index;
+		const int c = getopt_long(argc, argv, "", options, &index);
+		if (c == -1) {
+			break;
+		}
+		switch (c) {
+		case 'd':
+			dataPath = strdup(optarg);
+			break;
+		case 'l':
+			for (int i = 0; LANGUAGES[i].name; ++i) {
+				if (strcmp(optarg, LANGUAGES[i].name) == 0) {
+					lang = (Language)LANGUAGES[i].lang;
+					break;
+				}
+			}
+			break;
+		case 'p':
+			part = atoi(optarg);
+			break;
+		case 'r':
+			for (int i = 0; GRAPHICS[i].name; ++i) {
+				if (strcmp(optarg, GRAPHICS[i].name) == 0) {
+					graphicsType = GRAPHICS[i].type;
+					dm.opengl = (graphicsType == GRAPHICS_GL);
+					defaultGraphics = false;
+					break;
+				}
+			}
+			break;
+		case 'w':
+			sscanf(optarg, "%dx%d", &dm.width, &dm.height);
+			break;
+		case 'f':
+			dm.mode = DisplayMode::FULLSCREEN;
+			break;
+		case 'a':
+			dm.mode = DisplayMode::FULLSCREEN_AR;
+			break;
+		case 's':
+			parseScaler(optarg, &scaler);
+			break;
+		case 'e':
+			Video::_useEGA = true;
+			break;
+		case 'j':
+			demo3JoyInputs = true;
+			break;
+		case 'i':
+			for (int i = 0; DIFFICULTIES[i].name; ++i) {
+				if (strcmp(optarg, DIFFICULTIES[i].name) == 0) {
+					Script::_difficulty = (Difficulty)DIFFICULTIES[i].difficulty;
+					break;
+				}
+			}
+			break;
+		case 'u':
+			if (strcmp(optarg, "remastered") == 0) {
+				Script::_useRemasteredAudio = true;
+			} else if (strcmp(optarg, "original") == 0) {
+				Script::_useRemasteredAudio = false;
+			}
+			break;
+		case 'h':
+			// fall-through
+		default:
+			printf(USAGE, argv[0]);
+			return 0;
+		}
 	}
-	if (_stub->_pi.fastMode) {
-		_log._fastMode = !_log._fastMode;
-		_stub->_pi.fastMode = false;
+	g_debugMask = DBG_INFO; // | DBG_VIDEO | DBG_SND | DBG_SCRIPT | DBG_BANK | DBG_SER;
+	Engine *e = new Engine(dataPath, part);
+	if (defaultGraphics) {
+		// if not set, use original software graphics for 199x editions and GL for the anniversary and 3DO versions
+		graphicsType = getGraphicsType(e->_res.getDataType());
+		dm.opengl = (graphicsType == GRAPHICS_GL);
 	}
-	if (_stub->_pi.stateSlot != 0) {
-		int8 slot = _stateSlot + _stub->_pi.stateSlot;
-		if (slot >= 0 && slot < 999) {
-			_stateSlot = slot;
-			debugC(kDebugInfo, "Current game state slot is %d", _stateSlot);
+	if (graphicsType != GRAPHICS_GL && e->_res.getDataType() == Resource::DT_3DO) {
+		graphicsType = GRAPHICS_SOFTWARE;
+		Graphics::_use555 = true;
+	}
+	Graphics *graphics = createGraphics(graphicsType);
+	if (e->_res.getDataType() == Resource::DT_20TH_EDITION) {
+		switch (Script::_difficulty) {
+		case DIFFICULTY_EASY:
+			debug(DBG_INFO, "Using easy difficulty");
+			break;
+		case DIFFICULTY_NORMAL:
+			debug(DBG_INFO, "Using normal difficulty");
+			break;
+		case DIFFICULTY_HARD:
+			debug(DBG_INFO, "Using hard difficulty");
+			break;
 		}
-		_stub->_pi.stateSlot = 0;
 	}
-}
-
-Common::Error AweEngine::saveGameStream(Common::WriteStream *stream, bool isAutosave) {
-	// Header
-	stream->writeUint32BE(MKTAG('A', 'W', 'S', 'V'));
-	stream->writeUint16BE(Serializer::CUR_VER);
-	stream->writeUint16BE(0);
-
-	// Contents
-	Serializer s(stream, _res._memPtrStart);
-	_log.saveOrLoad(s);
-	_res.saveOrLoad(s);
-	_vid.saveOrLoad(s);
-	if (stream->err()) {
-		warning("I/O error when saving game state");
-		return Common::kUnknownError;
-	} else {
-		debugC(kDebugInfo, "Saved state to slot %d", _stateSlot);
-		return Common::kNoError;
+	if (e->_res.getDataType() == Resource::DT_15TH_EDITION || e->_res.getDataType() == Resource::DT_20TH_EDITION) {
+		if (Script::_useRemasteredAudio) {
+			debug(DBG_INFO, "Using remastered audio");
+		} else {
+			debug(DBG_INFO, "Using original audio");
+		}
 	}
-}
-
-Common::Error AweEngine::loadGameStream(Common::SeekableReadStream *stream) {
-	uint32 id = stream->readUint32BE();
-	if (id != MKTAG('A', 'W', 'S', 'V')) {
-		warning("Bad savegame format");
-		return Common::kUnknownError;
+	SystemStub *stub = SystemStub_SDL_create();
+	stub->init(e->getGameTitle(lang), &dm);
+	e->setSystemStub(stub, graphics);
+	if (demo3JoyInputs && e->_res.getDataType() == Resource::DT_DOS) {
+		e->_res.readDemo3Joy();
 	}
-
-	uint16 ver = stream->readUint16BE();
-	(void)stream->readUint16BE();
-
-	// Contents
-	Serializer s(stream, _res._memPtrStart, ver);
-	_log.saveOrLoad(s);
-	_res.saveOrLoad(s);
-	_vid.saveOrLoad(s);
-
-	if (stream->err()) {
-		warning("I/O error when loading game state");
-		return Common::kUnknownError;
-	} else {
-		debugC(kDebugInfo, "Loaded state from slot %d", _stateSlot);
-		return Common::kNoError;
+	e->setup(lang, graphicsType, scaler.name, scaler.factor);
+	while (!stub->_pi.quit) {
+		e->run();
 	}
+	e->finish();
+	delete e;
+	stub->fini();
+	delete stub;
+	return 0;
 }
 
-bool AweEngine::hasFeature(EngineFeature f) const {
-	return
-		(f == kSupportsReturnToLauncher);
+#endif
+
+
+AweEngine::AweEngine(OSystem *syst, const ADGameDescription *gameDesc)
+		: Engine(syst), _gameDescription(gameDesc),
+		_random("Awe") {
+	g_engine = this;
 }
 
-bool AweEngine::isDemo() const {
-	return (_gameDescription->flags & ADGF_DEMO) != 0;
+AweEngine::~AweEngine() {
 }
 
+Common::Error AweEngine::run() {
+	// Setup mixer
+	if (!_mixer->isReady()) {
+		warning("Sound initialization failed.");
+	}
+
+	// Initialize backend
+	initGraphics(320, 200);
+
+	return Common::kNoError;
+}
 
 } // namespace Awe
diff --git a/engines/awe/awe.h b/engines/awe/awe.h
index aaf9e614585..a93898aedf7 100644
--- a/engines/awe/awe.h
+++ b/engines/awe/awe.h
@@ -23,42 +23,36 @@
 #define AWE_AWE_H
 
 #include "common/scummsys.h"
+#include "common/random.h"
 #include "engines/engine.h"
 #include "awe/detection.h"
-#include "awe/intern.h"
-#include "awe/logic.h"
-#include "awe/resource.h"
-#include "awe/system_stub.h"
-#include "awe/video.h"
 
 namespace Awe {
 
-class AweEngine : public Engine {
+class AweEngine : public ::Engine {
 private:
 	const ADGameDescription *_gameDescription;
-
-private:
-	void setup();
-	void finish();
-	void processInput();
-
-public:
-	SystemStub *_stub;
-	Logic _log;
-	Resource _res;
-	Video _vid;
-	int _stateSlot = 0;
+	Common::RandomSource _random;
 
 public:
 	AweEngine(OSystem *syst, const ADGameDescription *gameDesc);
 	~AweEngine() override;
 
 	Common::Error run() override;
+#ifdef TODO
 	bool hasFeature(EngineFeature f) const override;
 	bool isDemo() const;
 
 	Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
 	Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
+#endif
+
+	int getRandomNumber(int max) {
+		return _random.getRandomNumber(max);
+	}
+	int getRandomNumber(int min, int max) {
+		return min + _random.getRandomNumber(max - min);
+	}
 };
 
 extern AweEngine *g_engine;
diff --git a/engines/awe/bank.cpp b/engines/awe/bank.cpp
deleted file mode 100644
index 587d98bdb2d..00000000000
--- a/engines/awe/bank.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "common/file.h"
-#include "awe/awe.h"
-#include "awe/bank.h"
-#include "awe/resource.h"
-
-namespace Awe {
-
-Bank::Bank() {
-}
-
-bool Bank::read(const MemEntry *me, uint8 *buf) {
-	bool ret = false;
-	char bankName[10];
-	Common::sprintf_s(bankName, "bank%02x", me->bankNum);
-	Common::File f;
-
-	if (f.open(bankName)) {
-		f.seek(me->bankPos);
-		if (me->packedSize == me->unpackedSize) {
-			f.read(buf, me->packedSize);
-			ret = true;
-		} else {
-			f.read(buf, me->packedSize);
-			_startBuf = buf;
-			_iBuf = buf + me->packedSize - 4;
-			ret = unpack();
-		}
-	} else {
-		error("Bank::read() unable to open '%s'", bankName);
-	}
-
-	return ret;
-}
-
-void Bank::decUnk1(uint8 numChunks, uint8 addCount) {
-	uint16 count = getCode(numChunks) + addCount + 1;
-	debugC(kDebugBank, "Bank::decUnk1(%d, %d) count=%d", numChunks, addCount, count);
-	_unpCtx.datasize -= count;
-	while (count--) {
-		assert(_oBuf >= _iBuf && _oBuf >= _startBuf);
-		*_oBuf = (uint8)getCode(8);
-		--_oBuf;
-	}
-}
-
-void Bank::decUnk2(uint8 numChunks) {
-	uint16 i = getCode(numChunks);
-	uint16 count = _unpCtx.size + 1;
-	debugC(kDebugBank, "Bank::decUnk2(%d) i=%d count=%d", numChunks, i, count);
-	_unpCtx.datasize -= count;
-	while (count--) {
-		assert(_oBuf >= _iBuf && _oBuf >= _startBuf);
-		*_oBuf = *(_oBuf + i);
-		--_oBuf;
-	}
-}
-
-bool Bank::unpack() {
-	_unpCtx.size = 0;
-	_unpCtx.datasize = READ_BE_UINT32(_iBuf); _iBuf -= 4;
-	_oBuf = _startBuf + _unpCtx.datasize - 1;
-	_unpCtx.crc = READ_BE_UINT32(_iBuf); _iBuf -= 4;
-	_unpCtx.chk = READ_BE_UINT32(_iBuf); _iBuf -= 4;
-	_unpCtx.crc ^= _unpCtx.chk;
-	do {
-		if (!nextChunk()) {
-			_unpCtx.size = 1;
-			if (!nextChunk()) {
-				decUnk1(3, 0);
-			} else {
-				decUnk2(8);
-			}
-		} else {
-			uint16 c = getCode(2);
-			if (c == 3) {
-				decUnk1(8, 8);
-			} else {
-				if (c < 2) {
-					_unpCtx.size = c + 2;
-					decUnk2(c + 9);
-				} else {
-					_unpCtx.size = getCode(8);
-					decUnk2(12);
-				}
-			}
-		}
-	} while (_unpCtx.datasize > 0);
-
-	return (_unpCtx.crc == 0);
-}
-
-uint16 Bank::getCode(uint8 numChunks) {
-	uint16 c = 0;
-	while (numChunks--) {
-		c <<= 1;
-		if (nextChunk()) {
-			c |= 1;
-		}			
-	}
-
-	return c;
-}
-
-bool Bank::nextChunk() {
-	bool CF = rcr(false);
-	if (_unpCtx.chk == 0) {
-		assert(_iBuf >= _startBuf);
-		_unpCtx.chk = READ_BE_UINT32(_iBuf); _iBuf -= 4;
-		_unpCtx.crc ^= _unpCtx.chk;
-		CF = rcr(true);
-	}
-
-	return CF;
-}
-
-bool Bank::rcr(bool CF) {
-	bool rCF = (_unpCtx.chk & 1);
-	_unpCtx.chk >>= 1;
-	if (CF) _unpCtx.chk |= 0x80000000;
-
-	return rCF;
-}
-
-} // namespace Awe
diff --git a/engines/awe/bitmap.cpp b/engines/awe/bitmap.cpp
new file mode 100644
index 00000000000..c875d3ea361
--- /dev/null
+++ b/engines/awe/bitmap.cpp
@@ -0,0 +1,92 @@
+/* ScummVM - Graphic Adventure AweEngine
+ *
+ * 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 "awe/bitmap.h"
+#include "awe/util.h"
+
+namespace Awe {
+
+static void clut(const uint8_t *src, const uint8_t *pal, int pitch, int w, int h, int bpp, bool flipY, int colorKey, uint8_t *dst) {
+	int dstPitch = bpp * w;
+	if (flipY) {
+		dst += (h - 1) * bpp * w;
+		dstPitch = -bpp * w;
+	}
+	for (int y = 0; y < h; ++y) {
+		for (int x = 0; x < w; ++x) {
+			const int color = src[x];
+			const int b = pal[color * 4];
+			const int g = pal[color * 4 + 1];
+			const int r = pal[color * 4 + 2];
+			dst[x * bpp] = r;
+			dst[x * bpp + 1] = g;
+			dst[x * bpp + 2] = b;
+			if (bpp == 4) {
+				dst[x * bpp + 3] = (color == 0 || (colorKey == ((r << 16) | (g << 8) | b))) ? 0 : 255;
+			}
+		}
+		src += w;
+		dst += dstPitch;
+	}
+}
+
+uint8_t *decode_bitmap(const uint8_t *src, bool alpha, int colorKey, int *w, int *h) {
+	if (memcmp(src, "BM", 2) != 0) {
+		return 0;
+	}
+	const uint32_t imageOffset = READ_LE_UINT32(src + 0xA);
+	const int width = READ_LE_UINT32(src + 0x12);
+	const int height = READ_LE_UINT32(src + 0x16);
+	const int depth = READ_LE_UINT16(src + 0x1C);
+	const int compression = READ_LE_UINT32(src + 0x1E);
+	if ((depth != 8 && depth != 32) || compression != 0) {
+		warning("Unhandled bitmap depth %d compression %d", depth, compression);
+		return 0;
+	}
+	const int bpp = (!alpha && colorKey < 0) ? 3 : 4;
+	uint8_t *dst = (uint8_t *)malloc(width * height * bpp);
+	if (!dst) {
+		warning("Failed to allocate bitmap buffer, width %d height %d bpp %d", width, height, bpp);
+		return 0;
+	}
+	if (depth == 8) {
+		const uint8_t *palette = src + 14 /* BITMAPFILEHEADER */ + 40 /* BITMAPINFOHEADER */;
+		const bool flipY = true;
+		clut(src + imageOffset, palette, (width + 3) & ~3, width, height, bpp, flipY, colorKey, dst);
+	} else {
+		assert(depth == 32 && bpp == 3);
+		const uint8_t *p = src + imageOffset;
+		for (int y = height - 1; y >= 0; --y) {
+			uint8_t *q = dst + y * width * bpp;
+			for (int x = 0; x < width; ++x) {
+				const uint32_t color = READ_LE_UINT32(p); p += 4;
+				*q++ = (color >> 16) & 255;
+				*q++ = (color >> 8) & 255;
+				*q++ = color & 255;
+			}
+		}
+	}
+	*w = width;
+	*h = height;
+	return dst;
+}
+
+} // namespace Awe
diff --git a/engines/awe/bitmap.h b/engines/awe/bitmap.h
new file mode 100644
index 00000000000..6d7024a36fd
--- /dev/null
+++ b/engines/awe/bitmap.h
@@ -0,0 +1,33 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AWE_BITMAP_H
+#define AWE_BITMAP_H
+
+#include "intern.h"
+
+namespace Awe {
+
+uint8_t *decode_bitmap(const uint8_t *src, bool alpha, int colorKey, int *w, int *h);
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
new file mode 100644
index 00000000000..4668eb735c8
--- /dev/null
+++ b/engines/awe/engine.cpp
@@ -0,0 +1,262 @@
+/* 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 "awe/engine.h"
+#include "awe/file.h"
+#include "awe/graphics.h"
+#include "awe/resource_nth.h"
+#include "awe/systemstub.h"
+#include "awe/util.h"
+
+namespace Awe {
+
+Engine::Engine(Audio::Mixer &mixer, const char *dataDir, int partNum)
+	: _mix(mixer), _graphics(0), _stub(0), _script(&_mix, &_res, &_ply, &_vid),
+	_res(&_vid, dataDir), _ply(&_res), _vid(&_res), _partNum(partNum) {
+	_res.detectVersion();
+}
+
+static const int _restartPos[36 * 2] = {
+	16008,  0, 16001,  0, 16002, 10, 16002, 12, 16002, 14,
+	16003, 20, 16003, 24, 16003, 26, 16004, 30, 16004, 31,
+	16004, 32, 16004, 33, 16004, 34, 16004, 35, 16004, 36,
+	16004, 37, 16004, 38, 16004, 39, 16004, 40, 16004, 41,
+	16004, 42, 16004, 43, 16004, 44, 16004, 45, 16004, 46,
+	16004, 47, 16004, 48, 16004, 49, 16006, 64, 16006, 65,
+	16006, 66, 16006, 67, 16006, 68, 16005, 50, 16006, 60,
+	16007, 0
+};
+
+void Engine::setSystemStub(SystemStub *stub, Graphics *graphics) {
+	_stub = stub;
+	_script._stub = stub;
+	_graphics = graphics;
+}
+
+void Engine::run() {
+	switch (_state) {
+	case kStateLogo3DO:
+		doThreeScreens();
+		scrollText(0, 380, Video::_noteText3DO);
+		playCinepak("Logo.Cine");
+		playCinepak("Spintitle.Cine");
+		break;
+	case kStateTitle3DO:
+		titlePage();
+		break;
+	case kStateEnd3DO:
+		doEndCredits();
+		break;
+	case kStateGame:
+		_script.setupTasks();
+		_script.updateInput();
+		processInput();
+		_script.runTasks();
+#if 0
+		_mix.update();
+#endif
+		if (_res.getDataType() == Resource::DT_3DO) {
+			switch (_res._nextPart) {
+			case 16009:
+				_state = kStateEnd3DO;
+				break;
+			case 16000:
+				_state = kStateTitle3DO;
+				break;
+			}
+		}
+		break;
+	}
+}
+
+void Engine::setup(Language lang, int graphicsType, const char *scalerName, int scalerFactor) {
+	_vid._graphics = _graphics;
+	int w = GFX_W * scalerFactor;
+	int h = GFX_H * scalerFactor;
+	if (_res.getDataType() != Resource::DT_3DO) {
+		_vid._graphics->_fixUpPalette = FIXUP_PALETTE_REDRAW;
+	}
+	_vid.init();
+	if (scalerFactor > 1) {
+		_vid.setScaler(scalerName, scalerFactor);
+	}
+	_res._lang = lang;
+	_res.allocMemBlock();
+	_res.readEntries();
+	_res.dumpEntries();
+	const bool isNth = !Graphics::_is1991 && (_res.getDataType() == Resource::DT_15TH_EDITION || _res.getDataType() == Resource::DT_20TH_EDITION);
+	if (isNth) {
+		// get HD background bitmaps resolution
+		_res._nth->getBitmapSize(&w, &h);
+	}
+	_graphics->init(w, h);
+	if (isNth) {
+		_res.loadFont();
+		_res.loadHeads();
+	} else {
+		_vid.setDefaultFont();
+	}
+	_script.init();
+	MixerType mixerType = kMixerTypeRaw;
+	switch (_res.getDataType()) {
+	case Resource::DT_DOS:
+	case Resource::DT_AMIGA:
+	case Resource::DT_ATARI:
+	case Resource::DT_ATARI_DEMO:
+		mixerType = kMixerTypeRaw;
+		switch (lang) {
+		case LANG_FR:
+			_vid._stringsTable = Video::_stringsTableFr;
+			break;
+		case LANG_US:
+		default:
+			_vid._stringsTable = Video::_stringsTableEng;
+			break;
+		}
+		break;
+	case Resource::DT_WIN31:
+	case Resource::DT_15TH_EDITION:
+	case Resource::DT_20TH_EDITION:
+		mixerType = kMixerTypeWav;
+		break;
+	case Resource::DT_3DO:
+		mixerType = kMixerTypeAiff;
+		break;
+	}
+#ifdef TODO
+	_mix.init(mixerType);
+#endif
+#ifndef BYPASS_PROTECTION
+	switch (_res.getDataType()) {
+	case Resource::DT_DOS:
+		if (!_res._hasPasswordScreen) {
+			break;
+		}
+		/* fall-through */
+	case Resource::DT_AMIGA:
+	case Resource::DT_ATARI:
+	case Resource::DT_WIN31:
+		_partNum = kPartCopyProtection;
+		break;
+	default:
+		break;
+	}
+#endif
+	if (_res.getDataType() == Resource::DT_3DO && _partNum == kPartIntro) {
+		_state = kStateLogo3DO;
+	} else {
+		_state = kStateGame;
+		const int num = _partNum;
+		if (num < 36) {
+			_script.restartAt(_restartPos[num * 2], _restartPos[num * 2 + 1]);
+		} else {
+			_script.restartAt(num);
+		}
+	}
+}
+
+void Engine::finish() {
+	_graphics->fini();
+	_ply.stop();
+	_mix.stopAll();
+	_res.freeMemBlock();
+}
+
+void Engine::processInput() {
+	if (_stub->_pi.fastMode) {
+		_script._fastMode = !_script._fastMode;
+		_stub->_pi.fastMode = false;
+	}
+	if (_stub->_pi.screenshot) {
+		_vid.captureDisplay();
+		_stub->_pi.screenshot = false;
+	}
+}
+
+void Engine::doThreeScreens() {
+	_script.snd_playMusic(1, 0, 0);
+	static const int bitmaps[] = { 67, 68, 69, -1 };
+	for (int i = 0; bitmaps[i] != -1 && !_stub->_pi.quit; ++i) {
+		_res.loadBmp(bitmaps[i]);
+		_vid.updateDisplay(0, _stub);
+		while (!_stub->_pi.quit) {
+			_stub->processEvents();
+			if (_stub->_pi.action) {
+				_stub->_pi.action = false;
+				break;
+			}
+			_stub->sleep(50);
+		}
+	}
+	_state = kStateTitle3DO;
+}
+
+void Engine::doEndCredits() {
+	scrollText(0, 380, Video::_endText3DO);
+	_script.snd_playMusic(0, 0, 0);
+	playCinepak("ootw2.cine");
+	_state = kStateTitle3DO;
+}
+
+void Engine::playCinepak(const char *name) {
+}
+
+void Engine::scrollText(int a, int b, const char *text) {
+}
+
+void Engine::titlePage() {
+	_res.loadBmp(70);
+	static const int kCursorColor = 0;
+	_vid.setPaletteColor(kCursorColor, 255, 0, 0);
+	static const int yPos[] = { 97, 123, 149 };
+	int y = 0;
+	while (!_stub->_pi.quit) {
+		_vid.copyPage(0, 1, 0);
+		_vid.drawRect(1, kCursorColor, 97, yPos[y], 210, yPos[y + 1]);
+		_stub->processEvents();
+		if (_stub->_pi.dirMask & PlayerInput::DIR_DOWN) {
+			_stub->_pi.dirMask &= ~PlayerInput::DIR_DOWN;
+			_partNum = kPartPassword;
+			y = 1;
+		}
+		if (_stub->_pi.dirMask & PlayerInput::DIR_UP) {
+			_stub->_pi.dirMask &= ~PlayerInput::DIR_UP;
+			_partNum = kPartIntro;
+			y = 0;
+		}
+		if (_stub->_pi.action) {
+			_stub->_pi.action = false;
+			_script.restartAt(_partNum);
+			break;
+		}
+		_vid.updateDisplay(1, _stub);
+		_stub->sleep(50);
+	}
+	_state = kStateGame;
+}
+
+void Engine::saveGameState(uint8_t slot, const char *desc) {
+}
+
+void Engine::loadGameState(uint8_t slot) {
+}
+
+} // namespace Awe
diff --git a/engines/awe/engine.h b/engines/awe/engine.h
new file mode 100644
index 00000000000..0e925ca7aa7
--- /dev/null
+++ b/engines/awe/engine.h
@@ -0,0 +1,84 @@
+/* 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 AWE_ENGINE_H
+#define AWE_ENGINE_H
+
+#include "audio/mixer.h"
+#include "awe/intern.h"
+#include "awe/script.h"
+#include "awe/mixer.h"
+#include "awe/sfxplayer.h"
+#include "awe/resource.h"
+#include "awe/video.h"
+
+namespace Awe {
+
+struct Graphics;
+struct SystemStub;
+
+struct Engine {
+
+	enum {
+		kStateLogo3DO,
+		kStateTitle3DO,
+		kStateEnd3DO,
+		kStateGame
+	};
+
+	int _state;
+	Graphics *_graphics;
+	SystemStub *_stub;
+	Script _script;
+	Audio::Mixer &_mix;
+	Resource _res;
+	SfxPlayer _ply;
+	Video _vid;
+	int _partNum;
+
+	Engine(Audio::Mixer &mixer, const char *dataDir, int partNum);
+
+	void setSystemStub(SystemStub *, Graphics *);
+
+	const char *getGameTitle(Language lang) const {
+		return _res.getGameTitle(lang);
+	}
+
+	void run();
+	void setup(Language lang, int graphicsType, const char *scalerName, int scalerFactor);
+	void finish();
+	void processInput();
+
+	// 3DO
+	void doThreeScreens();
+	void doEndCredits();
+	void playCinepak(const char *name);
+	void scrollText(int a, int b, const char *text);
+	void titlePage();
+
+	void saveGameState(uint8_t slot, const char *desc);
+	void loadGameState(uint8_t slot);
+};
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/file.cpp b/engines/awe/file.cpp
new file mode 100644
index 00000000000..8ef7c17f974
--- /dev/null
+++ b/engines/awe/file.cpp
@@ -0,0 +1,238 @@
+/* ScummVM - Graphic Adventure AweEngine
+ *
+ * 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 "awe/file.h"
+#include "awe/util.h"
+
+namespace Awe {
+
+#ifdef DEPRECATED
+struct File_impl {
+	bool _ioErr;
+	File_impl() : _ioErr(false) {
+	}
+	virtual ~File_impl() {
+	}
+	virtual bool open(const char *path, const char *mode) = 0;
+	virtual void close() = 0;
+	virtual uint32_t size() = 0;
+	virtual void seek(int off, int whence) = 0;
+	virtual int read(void *ptr, uint32_t len) = 0;
+	virtual int write(void *ptr, uint32_t len) = 0;
+};
+
+struct stdFile : File_impl {
+	FILE *_fp;
+	stdFile() : _fp(0) {
+	}
+	bool open(const char *path, const char *mode) {
+		_ioErr = false;
+		_fp = fopen(path, mode);
+		return (_fp != 0);
+	}
+	void close() {
+		if (_fp) {
+			fclose(_fp);
+			_fp = 0;
+		}
+	}
+	uint32_t size() {
+		uint32_t sz = 0;
+		if (_fp) {
+			int pos = ftell(_fp);
+			fseek(_fp, 0, SEEK_END);
+			sz = ftell(_fp);
+			fseek(_fp, pos, SEEK_SET);
+		}
+		return sz;
+	}
+	void seek(int off, int whence) {
+		if (_fp) {
+			fseek(_fp, off, whence);
+		}
+	}
+	int read(void *ptr, uint32_t len) {
+		if (_fp) {
+			uint32_t r = fread(ptr, 1, len, _fp);
+			if (r != len) {
+				_ioErr = true;
+			}
+			return r;
+		}
+		return 0;
+	}
+	int write(void *ptr, uint32_t len) {
+		if (_fp) {
+			uint32_t r = fwrite(ptr, 1, len, _fp);
+			if (r != len) {
+				_ioErr = true;
+			}
+			return r;
+		}
+		return 0;
+	}
+};
+
+File::File() {
+	_impl = new stdFile;
+}
+
+File::~File() {
+	_impl->close();
+	delete _impl;
+}
+
+bool File::open(const char *filepath) {
+	_impl->close();
+	return _impl->open(filepath, "rb");
+}
+
+static bool getFilePathNoCase(const char *filename, const char *path, char *out) {
+	bool ret = false;
+	DIR *d = opendir(path);
+	if (d) {
+		dirent *de;
+		while ((de = readdir(d)) != NULL) {
+			if (de->d_name[0] == '.') {
+				continue;
+			}
+			if (strcasecmp(de->d_name, filename) == 0) {
+				sprintf(out, "%s/%s", path, de->d_name);
+				ret = true;
+				break;
+			}
+		}
+		closedir(d);
+	}
+	return ret;
+}
+
+bool File::open(const char *filename, const char *path) {
+	_impl->close();
+	char filepath[MAXPATHLEN];
+	if (getFilePathNoCase(filename, path, filepath)) {
+		return _impl->open(filepath, "rb");
+	}
+	return false;
+}
+
+bool File::openForWriting(const char *filepath) {
+	_impl->close();
+	return _impl->open(filepath, "wb");
+}
+
+void File::close() {
+	_impl->close();
+}
+
+bool File::ioErr() const {
+	return _impl->_ioErr;
+}
+
+uint32_t File::size() {
+	return _impl->size();
+}
+
+void File::seek(int off, int whence) {
+	_impl->seek(off, whence);
+}
+
+int File::read(void *ptr, uint32_t len) {
+	return _impl->read(ptr, len);
+}
+
+uint8_t File::readByte() {
+	uint8_t b;
+	read(&b, 1);
+	return b;
+}
+
+uint16_t File::readUint16LE() {
+	uint8_t lo = readByte();
+	uint8_t hi = readByte();
+	return (hi << 8) | lo;
+}
+
+uint32_t File::readUint32LE() {
+	uint16_t lo = readUint16LE();
+	uint16_t hi = readUint16LE();
+	return (hi << 16) | lo;
+}
+
+uint16_t File::readUint16BE() {
+	uint8_t hi = readByte();
+	uint8_t lo = readByte();
+	return (hi << 8) | lo;
+}
+
+uint32_t File::readUint32BE() {
+	uint16_t hi = readUint16BE();
+	uint16_t lo = readUint16BE();
+	return (hi << 16) | lo;
+}
+
+int File::write(void *ptr, uint32_t len) {
+	return _impl->write(ptr, len);
+}
+
+void File::writeByte(uint8_t b) {
+	write(&b, 1);
+}
+
+void File::writeUint16LE(uint16_t n) {
+	writeByte(n & 0xFF);
+	writeByte(n >> 8);
+}
+
+void File::writeUint32LE(uint32_t n) {
+	writeUint16LE(n & 0xFFFF);
+	writeUint16LE(n >> 16);
+}
+
+void File::writeUint16BE(uint16_t n) {
+	writeByte(n >> 8);
+	writeByte(n & 0xFF);
+}
+
+void File::writeUint32BE(uint32_t n) {
+	writeUint16BE(n >> 16);
+	writeUint16BE(n & 0xFFFF);
+}
+
+void dumpFile(const char *filename, const uint8_t *p, int size) {
+	char path[MAXPATHLEN];
+	snprintf(path, sizeof(path), "DUMP/%s", filename);
+	FILE *fp = fopen(path, "wb");
+	if (fp) {
+		const int wr = fwrite(p, 1, size, fp);
+		if (wr != size) {
+			warning("Failed to write %d bytes (expected %d)", wr, size);
+		}
+		fclose(fp);
+	}
+}
+#endif
+
+void dumpFile(const char *filename, const uint8_t *p, int size) {
+	error("TODO: dumpFile - %s", filename);
+}
+
+} // namespace Awe
diff --git a/engines/awe/file.h b/engines/awe/file.h
new file mode 100644
index 00000000000..792844e5b93
--- /dev/null
+++ b/engines/awe/file.h
@@ -0,0 +1,76 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AWE_FILE_H
+#define AWE_FILE_H
+
+#include "common/file.h"
+
+namespace Awe {
+
+class File : public Common::File {
+public:
+	bool open(const char *filename, const char *path = nullptr) {
+		return Common::File::open(Common::Path(filename));
+	}
+
+	bool ioErr() const {
+		return Common::File::err();
+	}
+};
+
+#ifdef DEPRECATED
+struct File_impl;
+
+struct File {
+	File();
+	~File();
+
+	File_impl *_impl;
+
+	bool open(const char *filepath);
+	bool open(const char *filename, const char *path);
+	bool openForWriting(const char *filepath);
+	void close();
+	bool ioErr() const;
+	uint32_t size();
+	void seek(int off, int whence = SEEK_SET);
+	int read(void *ptr, uint32_t len);
+	uint8_t readByte();
+	uint16_t readUint16LE();
+	uint32_t readUint32LE();
+	uint16_t readUint16BE();
+	uint32_t readUint32BE();
+	int write(void *ptr, uint32_t size);
+	void writeByte(uint8_t b);
+	void writeUint16LE(uint16_t n);
+	void writeUint32LE(uint32_t n);
+	void writeUint16BE(uint16_t n);
+	void writeUint32BE(uint32_t n);
+};
+
+#endif
+
+void dumpFile(const char *filename, const uint8_t *p, int size);
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/graphics.h b/engines/awe/graphics.h
new file mode 100644
index 00000000000..824c000a7ab
--- /dev/null
+++ b/engines/awe/graphics.h
@@ -0,0 +1,98 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AWE_GRAPHICS_H
+#define AWE_GRAPHICS_H
+
+#include "awe/intern.h"
+
+namespace Awe {
+
+enum {
+	FMT_CLUT,
+	FMT_RGB555,
+	FMT_RGB,
+	FMT_RGBA,
+};
+
+enum {
+	FIXUP_PALETTE_NONE,
+	FIXUP_PALETTE_REDRAW, // redraw all primitives on setPal script call
+};
+
+enum {
+	COL_ALPHA = 0x10, // transparent pixel (OR'ed with 0x8)
+	COL_PAGE  = 0x11, // buffer 0 pixel
+	COL_BMP   = 0xFF, // bitmap in buffer 0 pixel
+};
+
+enum {
+	GRAPHICS_ORIGINAL,
+	GRAPHICS_SOFTWARE,
+	GRAPHICS_GL
+};
+
+enum {
+	ALPHA_COLOR_INDEX = 12, // 3DO uses 0x0010 (RGB555) as the blend color, using color #12 matches Amiga/DOS graphics better
+	GFX_W = 320,
+	GFX_H = 200
+};
+
+struct SystemStub;
+
+struct Graphics {
+
+	static const uint8_t _font[];
+	static bool _is1991; // draw graphics as in the original 1991 game release
+	static bool _use555; // use 16bits graphics buffer (for 3DO)
+	static const uint16_t _shapesMaskOffset[];
+	static const int _shapesMaskCount;
+	static const uint8_t _shapesMaskData[];
+
+	int _fixUpPalette;
+	bool _screenshot;
+
+	virtual ~Graphics() {};
+
+	virtual void init(int targetW, int targetH) { _screenshot = false; }
+	virtual void fini() {}
+
+	virtual void setFont(const uint8_t *src, int w, int h) = 0;
+	virtual void setPalette(const Color *colors, int count) = 0;
+	virtual void setSpriteAtlas(const uint8_t *src, int w, int h, int xSize, int ySize) = 0;
+	virtual void drawSprite(int buffer, int num, const Point *pt, uint8_t color) = 0;
+	virtual void drawBitmap(int buffer, const uint8_t *data, int w, int h, int fmt) = 0;
+	virtual void drawPoint(int buffer, uint8_t color, const Point *pt) = 0;
+	virtual void drawQuadStrip(int buffer, uint8_t color, const QuadStrip *qs) = 0;
+	virtual void drawStringChar(int buffer, uint8_t color, char c, const Point *pt) = 0;
+	virtual void clearBuffer(int num, uint8_t color) = 0;
+	virtual void copyBuffer(int dst, int src, int vscroll = 0) = 0;
+	virtual void drawBuffer(int num, SystemStub *) = 0;
+	virtual void drawRect(int num, uint8_t color, const Point *pt, int w, int h) = 0;
+	virtual void drawBitmapOverlay(const uint8_t *data, int w, int h, int fmt, SystemStub *stub) = 0;
+};
+
+Graphics *GraphicsGL_create();
+Graphics *GraphicsSoft_create();
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/graphics_gl.cpp b/engines/awe/graphics_gl.cpp
new file mode 100644
index 00000000000..74d6ab19e6a
--- /dev/null
+++ b/engines/awe/graphics_gl.cpp
@@ -0,0 +1,838 @@
+/* ScummVM - Graphic Adventure AweEngine
+ *
+ * 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 "awe/graphics.h"
+#include "awe/util.h"
+#include "awe/systemstub.h"
+
+namespace Awe {
+
+#ifdef TODO
+static struct {
+	PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
+	PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
+	PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
+	PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
+} _fptr;
+
+static void setupFboFuncs() {
+#ifdef _WIN32
+	_fptr.glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)SDL_GL_GetProcAddress("glBindFramebuffer");
+	_fptr.glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)SDL_GL_GetProcAddress("glGenFramebuffers");
+	_fptr.glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)SDL_GL_GetProcAddress("glFramebufferTexture2D");
+	_fptr.glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)SDL_GL_GetProcAddress("glCheckFramebufferStatus");
+#else
+	_fptr.glBindFramebuffer = glBindFramebuffer;
+	_fptr.glGenFramebuffers = glGenFramebuffers;
+	_fptr.glFramebufferTexture2D = glFramebufferTexture2D;
+	_fptr.glCheckFramebufferStatus = glCheckFramebufferStatus;
+#endif
+}
+
+static GLuint kNoTextureId = (GLuint)-1;
+
+static bool hasExtension(const char *exts, const char *name) {
+	const char *p = strstr(exts, name);
+	if (p) {
+		p += strlen(name);
+		return *p == ' ' || *p == 0;
+	}
+	return false;
+}
+
+static int roundPow2(int sz) {
+	if (sz != 0 && (sz & (sz - 1)) == 0) {
+		return sz;
+	}
+	int textureSize = 1;
+	while (textureSize < sz) {
+		textureSize <<= 1;
+	}
+	return textureSize;
+}
+
+struct Texture {
+	bool _npotTex;
+	GLuint _id;
+	int _w, _h;
+	float _u, _v;
+	uint8_t *_rgbData;
+	const uint8_t *_raw16Data;
+	int _fmt;
+
+	void init();
+	void uploadDataCLUT(const uint8_t *data, int srcPitch, int w, int h, const Color *pal);
+	void uploadDataRGB(const void *data, int srcPitch, int w, int h, int fmt, int type);
+	void draw(int w, int h);
+	void clear();
+	void readRaw16(const uint8_t *src, const Color *pal, int w, int h);
+	void readFont(const uint8_t *src);
+	void readRGB555(const uint16_t *src, int w, int h);
+};
+
+void Texture::init() {
+	_npotTex = false;
+	_id = kNoTextureId;
+	_w = _h = 0;
+	_u = _v = 0.f;
+	_rgbData = 0;
+	_raw16Data = 0;
+	_fmt = -1;
+}
+
+static void convertTextureCLUT(const uint8_t *src, const int srcPitch, int w, int h, uint8_t *dst, int dstPitch, const Color *pal, bool alpha) {
+	for (int y = 0; y < h; ++y) {
+		int offset = 0;
+		for (int x = 0; x < w; ++x) {
+			const uint8_t color = src[x];
+			dst[offset++] = pal[color].r;
+			dst[offset++] = pal[color].g;
+			dst[offset++] = pal[color].b;
+			if (alpha) {
+				if (color == 0) {
+					dst[offset++] = 0;
+				} else {
+					dst[offset++] = 255;
+				}
+			}
+		}
+		dst += dstPitch;
+		src += srcPitch;
+	}
+}
+
+void Texture::uploadDataCLUT(const uint8_t *data, int srcPitch, int w, int h, const Color *pal) {
+	if (w != _w || h != _h) {
+		free(_rgbData);
+		_rgbData = 0;
+	}
+	int depth = 1;
+	int fmt = GL_RGB;
+	int type = GL_UNSIGNED_BYTE;
+	switch (_fmt) {
+	case FMT_CLUT:
+		depth = 3;
+		fmt = GL_RGB;
+		break;
+	case FMT_RGB:
+		depth = 3;
+		fmt = GL_RGB;
+		break;
+	case FMT_RGBA:
+		depth = 4;
+		fmt = GL_RGBA;
+		break;
+	default:
+		return;
+	}
+	const bool alpha = (_fmt == FMT_RGBA);
+	if (!_rgbData) {
+		_w = _npotTex ? w : roundPow2(w);
+		_h = _npotTex ? h : roundPow2(h);
+		_rgbData = (uint8_t *)malloc(_w * _h * depth);
+		if (!_rgbData) {
+			return;
+		}
+		_u = w / (float)_w;
+		_v = h / (float)_h;
+		glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+		glGenTextures(1, &_id);
+		glBindTexture(GL_TEXTURE_2D, _id);
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (fmt == GL_RED) ? GL_NEAREST : GL_LINEAR);
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (fmt == GL_RED) ? GL_NEAREST : GL_LINEAR);
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+		convertTextureCLUT(data, srcPitch, w, h, _rgbData, _w * depth, pal, alpha);
+		glTexImage2D(GL_TEXTURE_2D, 0, fmt, _w, _h, 0, fmt, type, _rgbData);
+	} else {
+		glBindTexture(GL_TEXTURE_2D, _id);
+		convertTextureCLUT(data, srcPitch, w, h, _rgbData, _w * depth, pal, alpha);
+		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _w, _h, fmt, type, _rgbData);
+	}
+}
+
+void Texture::uploadDataRGB(const void *data, int srcPitch, int w, int h, int fmt, int type) {
+	_w = w;
+	_h = h;
+	_u = 1.f;
+	_v = 1.f;
+	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+	glGenTextures(1, &_id);
+	glBindTexture(GL_TEXTURE_2D, _id);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+	glTexImage2D(GL_TEXTURE_2D, 0, fmt, _w, _h, 0, fmt, type, data);
+}
+
+void Texture::draw(int w, int h) {
+	if (_id != kNoTextureId) {
+		glEnable(GL_TEXTURE_2D);
+		glColor4ub(255, 255, 255, 255);
+		glBindTexture(GL_TEXTURE_2D, _id);
+		glBegin(GL_QUADS);
+		glTexCoord2f(0.f, 0.f);
+		glVertex2i(0, 0);
+		glTexCoord2f(_u, 0.f);
+		glVertex2i(w, 0);
+		glTexCoord2f(_u, _v);
+		glVertex2i(w, h);
+		glTexCoord2f(0.f, _v);
+		glVertex2i(0, h);
+		glEnd();
+		glDisable(GL_TEXTURE_2D);
+	}
+}
+
+void Texture::clear() {
+	if (_id != kNoTextureId) {
+		glDeleteTextures(1, &_id);
+		_id = kNoTextureId;
+	}
+	free(_rgbData);
+	_rgbData = 0;
+	_raw16Data = 0;
+}
+
+void Texture::readRaw16(const uint8_t *src, const Color *pal, int w, int h) {
+	_raw16Data = src;
+	uploadDataCLUT(_raw16Data, w, w, h, pal);
+}
+
+void Texture::readFont(const uint8_t *src) {
+	_fmt = FMT_RGBA;
+	const int W = 96 * 8 * 2;
+	const int H = 8;
+	uint8_t *out = (uint8_t *)calloc(1, W * H);
+	if (out) {
+		for (int i = 0; i < 96; ++i) {
+			for (int y = 0; y < 8; ++y) {
+				uint8_t mask = *src++;
+				for (int x = 0; x < 8; ++x) {
+					out[y * W + i * 16 + x] = (mask >> (7 - x)) & 1;
+				}
+			}
+		}
+		Color pal[2];
+		pal[0].r = pal[0].g = pal[0].b = 0;
+		pal[1].r = pal[1].g = pal[1].b = 255;
+		uploadDataCLUT(out, W, W, H, pal);
+		free(out);
+	}
+}
+
+static uint16_t rgb555_to_565(const uint16_t color) {
+	const int r = (color >> 10) & 31;
+	const int g = (color >> 5) & 31;
+	const int b = color & 31;
+	return (r << 11) | (g << 6) | b;
+}
+
+void Texture::readRGB555(const uint16_t *src, int w, int h) {
+	_rgbData = (uint8_t *)malloc(w * h * sizeof(uint16_t));
+	if (!_rgbData) {
+		return;
+	}
+	for (int i = 0; i < w * h; ++i) {
+		((uint16_t *)_rgbData)[i] = rgb555_to_565(src[i]);
+	}
+	uploadDataRGB(_rgbData, w * sizeof(uint16_t), w, h, GL_RGB, GL_UNSIGNED_SHORT_5_6_5);
+}
+
+struct DrawListEntry {
+	static const int NUM_VERTICES = 1024;
+
+	int color;
+	int numVertices;
+	Point vertices[NUM_VERTICES];
+};
+
+struct DrawList {
+	typedef std::vector<DrawListEntry> Entries;
+
+	int fillColor;
+	Entries entries;
+	int yOffset;
+
+	DrawList()
+		: fillColor(0), yOffset(0) {
+	}
+
+	void clear(uint8_t color) {
+		fillColor = color;
+		entries.clear();
+	}
+
+	void append(uint8_t color, int count, const Point *vertices) {
+		if (count <= DrawListEntry::NUM_VERTICES) {
+			DrawListEntry e;
+			e.color = color;
+			e.numVertices = count;
+			memcpy(e.vertices, vertices, count * sizeof(Point));
+			entries.push_back(e);
+		}
+	}
+};
+
+static const int SCREEN_W = 320;
+static const int SCREEN_H = 200;
+
+static const int DEFAULT_FB_W = 1280;
+static const int DEFAULT_FB_H = 800;
+
+static const int NUM_LISTS = 4;
+
+struct GraphicsGL : Graphics {
+	int _w, _h;
+	int _fbW, _fbH;
+	Color _pal[16];
+	Color *_alphaColor;
+	Texture _backgroundTex;
+	Texture _fontTex;
+	Texture _spritesTex;
+	int _spritesSizeX, _spritesSizeY;
+	GLuint _fbPage0;
+	GLuint _pageTex[NUM_LISTS];
+	DrawList _drawLists[NUM_LISTS];
+	struct {
+		int num;
+		Point pos;
+	} _sprite;
+
+	GraphicsGL();
+	virtual ~GraphicsGL() {
+	}
+
+	virtual void init(int targetW, int targetH);
+	virtual void setFont(const uint8_t *src, int w, int h);
+	virtual void setPalette(const Color *colors, int count);
+	virtual void setSpriteAtlas(const uint8_t *src, int w, int h, int xSize, int ySize);
+	virtual void drawSprite(int listNum, int num, const Point *pt, uint8_t color);
+	virtual void drawBitmap(int listNum, const uint8_t *data, int w, int h, int fmt);
+	virtual void drawPoint(int listNum, uint8_t color, const Point *pt);
+	virtual void drawQuadStrip(int listNum, uint8_t color, const QuadStrip *qs);
+	virtual void drawStringChar(int listNum, uint8_t color, char c, const Point *pt);
+	virtual void clearBuffer(int listNum, uint8_t color);
+	virtual void copyBuffer(int dstListNum, int srcListNum, int vscroll = 0);
+	virtual void drawBuffer(int listNum, SystemStub *stub);
+	virtual void drawRect(int num, uint8_t color, const Point *pt, int w, int h);
+	virtual void drawBitmapOverlay(const uint8_t *data, int w, int h, int fmt, SystemStub *stub);
+
+	void initFbo();
+	void drawVerticesFlat(int count, const Point *vertices);
+	void drawVerticesTex(int count, const Point *vertices);
+	void drawVerticesToFb(uint8_t color, int count, const Point *vertices);
+};
+
+GraphicsGL::GraphicsGL() {
+	_fixUpPalette = FIXUP_PALETTE_NONE;
+	memset(_pal, 0, sizeof(_pal));
+	_alphaColor = &_pal[ALPHA_COLOR_INDEX];
+	_spritesSizeX = _spritesSizeY = 0;
+	_sprite.num = -1;
+}
+
+void GraphicsGL::init(int targetW, int targetH) {
+	Graphics::init(targetW, targetH);
+	_fbW = (targetW <= 0) ? DEFAULT_FB_W : targetW;
+	_fbH = (targetH <= 0) ? DEFAULT_FB_H : targetH;
+	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+	glEnable(GL_BLEND);
+	glDisable(GL_DEPTH_TEST);
+	glShadeModel(GL_SMOOTH);
+	const char *exts = (const char *)glGetString(GL_EXTENSIONS);
+	const bool npotTex = hasExtension(exts, "GL_ARB_texture_non_power_of_two");
+	const bool hasFbo = hasExtension(exts, "GL_ARB_framebuffer_object");
+	_backgroundTex.init();
+	_backgroundTex._npotTex = npotTex;
+	_fontTex.init();
+	_fontTex._npotTex = npotTex;
+	_spritesTex.init();
+	_spritesTex._npotTex = npotTex;
+	if (hasFbo) {
+		setupFboFuncs();
+		initFbo();
+		_fptr.glBindFramebuffer(GL_FRAMEBUFFER, 0);
+	} else {
+		error("GL_ARB_framebuffer_object is not supported");
+	}
+}
+
+void GraphicsGL::initFbo() {
+	GLint buffersCount;
+	glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &buffersCount);
+	if (buffersCount < NUM_LISTS) {
+		error("GL_MAX_COLOR_ATTACHMENTS is %d", buffersCount);
+		return;
+	}
+
+	_fptr.glGenFramebuffers(1, &_fbPage0);
+	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
+
+	glGenTextures(NUM_LISTS, _pageTex);
+	for (int i = 0; i < NUM_LISTS; ++i) {
+		glBindTexture(GL_TEXTURE_2D, _pageTex[i]);
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _fbW, _fbH, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
+		glBindTexture(GL_TEXTURE_2D, 0);
+		_fptr.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, _pageTex[i], 0);
+		int status = _fptr.glCheckFramebufferStatus(GL_FRAMEBUFFER);
+		if (status != GL_FRAMEBUFFER_COMPLETE) {
+			error("glCheckFramebufferStatus failed, ret %d", status);
+			return;
+		}
+	}
+
+	glViewport(0, 0, _fbW, _fbH);
+
+	const float r = (float)_fbW / SCREEN_W;
+	glLineWidth(r);
+	glPointSize(r);
+}
+
+void GraphicsGL::setFont(const uint8_t *src, int w, int h) {
+	if (src == 0) {
+		_fontTex.readFont(_font);
+	} else {
+		_fontTex.uploadDataRGB(src, w * 4, w, h, GL_RGBA, GL_UNSIGNED_BYTE);
+	}
+}
+
+void GraphicsGL::setPalette(const Color *colors, int n) {
+	assert(n <= 16);
+	for (int i = 0; i < n; ++i) {
+		_pal[i] = colors[i];
+	}
+	if (_fixUpPalette == FIXUP_PALETTE_REDRAW) {
+		for (int i = 0; i < NUM_LISTS; ++i) {
+			_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
+			glDrawBuffer(GL_COLOR_ATTACHMENT0 + i);
+
+			glMatrixMode(GL_PROJECTION);
+			glLoadIdentity();
+			glOrtho(0, _fbW, 0, _fbH, 0, 1);
+
+			const int color = _drawLists[i].fillColor;
+			if (color != COL_BMP) {
+				assert(color < 16);
+				glClearColor(_pal[color].r / 255.f, _pal[color].g / 255.f, _pal[color].b / 255.f, 1.f);
+				glClear(GL_COLOR_BUFFER_BIT);
+			}
+
+			glScalef((float)_fbW / SCREEN_W, (float)_fbH / SCREEN_H, 1);
+
+			DrawList::Entries::const_iterator it = _drawLists[i].entries.begin();
+			for (; it != _drawLists[i].entries.end(); ++it) {
+				DrawListEntry e = *it;
+				if (e.color < 16) {
+					glColor4ub(_pal[e.color].r, _pal[e.color].g, _pal[e.color].b, 255);
+					drawVerticesFlat(e.numVertices, e.vertices);
+				} else if (e.color == COL_ALPHA) {
+					glColor4ub(_alphaColor->r, _alphaColor->g, _alphaColor->b, 192);
+					drawVerticesFlat(e.numVertices, e.vertices);
+				}
+			}
+
+			glLoadIdentity();
+			glScalef(1., 1., 1.);
+		}
+	}
+}
+
+void GraphicsGL::setSpriteAtlas(const uint8_t *src, int w, int h, int xSize, int ySize) {
+	_spritesTex.uploadDataRGB(src, w * 4, w, h, GL_RGBA, GL_UNSIGNED_BYTE);
+	_spritesSizeX = xSize;
+	_spritesSizeY = ySize;
+}
+
+static void drawTexQuad(const int *pos, const float *uv, GLuint tex) {
+	glEnable(GL_TEXTURE_2D);
+	glBindTexture(GL_TEXTURE_2D, tex);
+	glBegin(GL_QUADS);
+	glTexCoord2f(uv[0], uv[1]);
+	glVertex2i(pos[0], pos[1]);
+	glTexCoord2f(uv[2], uv[1]);
+	glVertex2i(pos[2], pos[1]);
+	glTexCoord2f(uv[2], uv[3]);
+	glVertex2i(pos[2], pos[3]);
+	glTexCoord2f(uv[0], uv[3]);
+	glVertex2i(pos[0], pos[3]);
+	glEnd();
+	glDisable(GL_TEXTURE_2D);
+}
+
+static void drawSpriteHelper(const Point *pt, int num, int xSize, int ySize, int texId) {
+	const int wSize = 18;
+	const int hSize = 18;
+	const int pos[4] = {
+		pt->x, pt->y,
+		pt->x + wSize, pt->y + hSize
+	};
+	int u = num % xSize;
+	int v = num / ySize;
+	const float uv[4] = {
+		u * 1.f / xSize, v * 1.f / ySize,
+		(u + 1) * 1.f / xSize, (v + 1) * 1.f / ySize
+	};
+	glColor4ub(255, 255, 255, 255);
+	drawTexQuad(pos, uv, texId);
+}
+
+void GraphicsGL::drawSprite(int listNum, int num, const Point *pt, uint8_t color) {
+	assert(listNum < NUM_LISTS);
+	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
+	glDrawBuffer(GL_COLOR_ATTACHMENT0 + listNum);
+
+	glViewport(0, 0, _fbW, _fbH);
+
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	glOrtho(0, _fbW, 0, _fbH, 0, 1);
+
+	glScalef((float)_fbW / SCREEN_W, (float)_fbH / SCREEN_H, 1);
+
+	drawSpriteHelper(pt, num, _spritesSizeX, _spritesSizeY, _spritesTex._id);
+
+	glLoadIdentity();
+	glScalef(1., 1., 1.);
+}
+
+void GraphicsGL::drawBitmap(int listNum, const uint8_t *data, int w, int h, int fmt) {
+	_backgroundTex._fmt = fmt;
+	switch (fmt) {
+	case FMT_CLUT:
+		_backgroundTex.readRaw16(data, _pal, w, h);
+		break;
+	case FMT_RGB:
+		_backgroundTex.clear();
+		_backgroundTex.uploadDataRGB(data, w * 3, w, h, GL_RGB, GL_UNSIGNED_BYTE);
+		break;
+	case FMT_RGB555:
+		_backgroundTex.clear();
+		_backgroundTex.readRGB555((const uint16_t *)data, w, h);
+		break;
+	}
+	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
+	glDrawBuffer(GL_COLOR_ATTACHMENT0 + listNum);
+
+	glViewport(0, 0, _fbW, _fbH);
+
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	glOrtho(0, _fbW, 0, _fbH, 0, 1);
+
+	_backgroundTex.draw(_fbW, _fbH);
+
+	_drawLists[listNum].clear(COL_BMP);
+}
+
+void GraphicsGL::drawVerticesToFb(uint8_t color, int count, const Point *vertices) {
+	glScalef((float)_fbW / SCREEN_W, (float)_fbH / SCREEN_H, 1);
+
+	if (color == COL_PAGE) {
+		glEnable(GL_TEXTURE_2D);
+		glBindTexture(GL_TEXTURE_2D, _pageTex[0]);
+		glColor4f(1., 1., 1., 1.);
+		drawVerticesTex(count, vertices);
+		glDisable(GL_TEXTURE_2D);
+	} else {
+		if (color == COL_ALPHA) {
+			glColor4ub(_alphaColor->r, _alphaColor->g, _alphaColor->b, 192);
+		} else {
+			assert(color < 16);
+			glColor4ub(_pal[color].r, _pal[color].g, _pal[color].b, 255);
+		}
+		drawVerticesFlat(count, vertices);
+	}
+
+	glLoadIdentity();
+	glScalef(1., 1., 1.);
+}
+
+void GraphicsGL::drawPoint(int listNum, uint8_t color, const Point *pt) {
+	assert(listNum < NUM_LISTS);
+	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
+	glDrawBuffer(GL_COLOR_ATTACHMENT0 + listNum);
+
+	glViewport(0, 0, _fbW, _fbH);
+
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	glOrtho(0, _fbW, 0, _fbH, 0, 1);
+
+	drawVerticesToFb(color, 1, pt);
+	if (_fixUpPalette != FIXUP_PALETTE_NONE) {
+		_drawLists[listNum].append(color, 1, pt);
+	}
+}
+
+void GraphicsGL::drawQuadStrip(int listNum, uint8_t color, const QuadStrip *qs) {
+	assert(listNum < NUM_LISTS);
+	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
+	glDrawBuffer(GL_COLOR_ATTACHMENT0 + listNum);
+
+	glViewport(0, 0, _fbW, _fbH);
+
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	glOrtho(0, _fbW, 0, _fbH, 0, 1);
+
+	drawVerticesToFb(color, qs->numVertices, qs->vertices);
+	if (_fixUpPalette != FIXUP_PALETTE_NONE) {
+		_drawLists[listNum].append(color, qs->numVertices, qs->vertices);
+	}
+}
+
+void GraphicsGL::drawStringChar(int listNum, uint8_t color, char c, const Point *pt) {
+	assert(listNum < NUM_LISTS);
+	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
+	glDrawBuffer(GL_COLOR_ATTACHMENT0 + listNum);
+
+	glViewport(0, 0, _fbW, _fbH);
+
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	glOrtho(0, _fbW, 0, _fbH, 0, 1);
+
+	glScalef((float)_fbW / SCREEN_W, (float)_fbH / SCREEN_H, 1);
+
+	glColor4ub(_pal[color].r, _pal[color].g, _pal[color].b, 255);
+	if (_fontTex._h == 8) {
+		const int pos[4] = {
+			pt->x, pt->y,
+			pt->x + 8, pt->y + 8
+		};
+		const float uv[4] = {
+			(c - 0x20) * 16.f / _fontTex._w, 0.f,
+			(c - 0x20) * 16.f / _fontTex._w + 1 * 8.f / _fontTex._w, 1.f
+		};
+		drawTexQuad(pos, uv, _fontTex._id);
+	} else {
+		const int pos[4] = {
+			pt->x - 8, pt->y,
+			pt->x, pt->y + 8
+		};
+		float uv[4];
+		uv[0] = (c % 16) * 16 / 256.f;
+		uv[2] = uv[0] + 16 / 256.f;
+		uv[1] = (c / 16) * 16 / 256.f;
+		uv[3] = uv[1] + 16 / 256.f;
+		drawTexQuad(pos, uv, _fontTex._id);
+	}
+
+	glLoadIdentity();
+	glScalef(1., 1., 1.);
+}
+
+void GraphicsGL::drawVerticesFlat(int count, const Point *vertices) {
+	switch (count) {
+	case 1:
+		glBegin(GL_POINTS);
+		glVertex2i(vertices[0].x, vertices[0].y);
+		glEnd();
+		break;
+	case 2:
+		glBegin(GL_LINES);
+		if (vertices[1].x > vertices[0].x) {
+			glVertex2i(vertices[0].x, vertices[0].y);
+			glVertex2i(vertices[1].x + 1, vertices[1].y);
+		} else {
+			glVertex2i(vertices[1].x, vertices[1].y);
+			glVertex2i(vertices[0].x + 1, vertices[0].y);
+		}
+		glEnd();
+		break;
+	default:
+		glBegin(GL_QUAD_STRIP);
+		for (int i = 0; i < count / 2; ++i) {
+			const int j = count - 1 - i;
+			if (vertices[j].x > vertices[i].x) {
+				glVertex2i(vertices[i].x, vertices[i].y);
+				glVertex2i(vertices[j].x + 1, vertices[j].y);
+			} else {
+				glVertex2i(vertices[j].x, vertices[j].y);
+				glVertex2i(vertices[i].x + 1, vertices[i].y);
+			}
+		}
+		glEnd();
+		break;
+	}
+}
+
+void GraphicsGL::drawVerticesTex(int count, const Point *vertices) {
+	if (count < 4) {
+		warning("Invalid vertices count for drawing mode 0x11", count);
+		return;
+	}
+	glBegin(GL_QUAD_STRIP);
+	for (int i = 0; i < count / 2; ++i) {
+		const int j = count - 1 - i;
+		if (vertices[j].x > vertices[i].y) {
+			glTexCoord2f(vertices[i].x / 320., vertices[i].y / 200.);
+			glVertex2i(vertices[i].x, vertices[i].y);
+			glTexCoord2f((vertices[j].x + 1) / 320., vertices[j].y / 200.);
+			glVertex2i((vertices[j].x + 1), vertices[j].y);
+		} else {
+			glTexCoord2f(vertices[j].x / 320., vertices[j].y / 200.);
+			glVertex2i(vertices[j].x, vertices[j].y);
+			glTexCoord2f((vertices[i].x + 1) / 320., vertices[i].y / 200.);
+			glVertex2i((vertices[i].x + 1), vertices[i].y);
+		}
+	}
+	glEnd();
+}
+
+void GraphicsGL::clearBuffer(int listNum, uint8_t color) {
+	assert(listNum < NUM_LISTS);
+	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
+	glDrawBuffer(GL_COLOR_ATTACHMENT0 + listNum);
+
+	glViewport(0, 0, _fbW, _fbH);
+
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	glOrtho(0, _fbW, 0, _fbH, 0, 1);
+
+	assert(color < 16);
+	glClearColor(_pal[color].r / 255.f, _pal[color].g / 255.f, _pal[color].b / 255.f, 1.f);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	_drawLists[listNum].clear(color);
+}
+
+static void drawTextureFb(GLuint tex, int w, int h, int vscroll) {
+	glColor4ub(255, 255, 255, 255);
+	const int pos[] = {
+		0, vscroll,
+		w, h + vscroll
+	};
+	const float uv[] = {
+		0., 0.,
+		1., 1.
+	};
+	drawTexQuad(pos, uv, tex);
+}
+
+void GraphicsGL::copyBuffer(int dstListNum, int srcListNum, int vscroll) {
+	assert(dstListNum < NUM_LISTS && srcListNum < NUM_LISTS);
+
+	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
+	glDrawBuffer(GL_COLOR_ATTACHMENT0 + dstListNum);
+
+	glViewport(0, 0, _fbW, _fbH);
+
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	glOrtho(0, _fbW, 0, _fbH, 0, 1);
+
+	const int yoffset = vscroll * _fbH / (SCREEN_H - 1);
+	drawTextureFb(_pageTex[srcListNum], _fbW, _fbH, yoffset);
+
+	_drawLists[dstListNum] = _drawLists[srcListNum];
+	_drawLists[dstListNum].yOffset = vscroll;
+}
+
+static void dumpPalette(const Color *pal) {
+	static const int SZ = 32;
+	int x2, x1 = 0;
+	for (int i = 0; i < 16; ++i) {
+		x2 = x1 + SZ;
+		glColor4ub(pal[i].r, pal[i].g, pal[i].b, 255);
+		glBegin(GL_QUADS);
+		glVertex2i(x1, 0);
+		glVertex2i(x2, 0);
+		glVertex2i(x2, SZ);
+		glVertex2i(x1, SZ);
+		glEnd();
+		x1 = x2;
+	}
+}
+
+void GraphicsGL::drawBuffer(int listNum, SystemStub *stub) {
+	assert(listNum < NUM_LISTS);
+
+	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, 0);
+
+	float ar[4];
+	stub->prepareScreen(_w, _h, ar);
+
+	glViewport(0, 0, _w, _h);
+
+	glClearColor(0., 0., 0., 1.);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	glMatrixMode(GL_PROJECTION);
+	glLoadIdentity();
+	glOrtho(0, _w, _h, 0, 0, 1);
+
+	glPushMatrix();
+	glTranslatef(ar[0] * _w, ar[1] * _h, 0.);
+	glScalef(ar[2], ar[3], 1.);
+
+	drawTextureFb(_pageTex[listNum], _w, _h, 0);
+	if (0) {
+		glDisable(GL_TEXTURE_2D);
+		dumpPalette(_pal);
+	}
+
+	glPopMatrix();
+	stub->updateScreen();
+}
+
+void GraphicsGL::drawRect(int num, uint8_t color, const Point *pt, int w, int h) {
+
+	// ignore 'num' target framebuffer as this is only used for the title screen with the 3DO version
+	assert(color < 16);
+	glColor4ub(_pal[color].r, _pal[color].g, _pal[color].b, 255);
+
+	glScalef((float)_fbW / SCREEN_W, (float)_fbH / SCREEN_H, 1);
+	const int x1 = pt->x;
+	const int y1 = pt->y;
+	const int x2 = x1 + w - 1;
+	const int y2 = y1 + h - 1;
+	glBegin(GL_LINES);
+	// horizontal
+	glVertex2i(x1, y1);
+	glVertex2i(x2, y1);
+	glVertex2i(x1, y2);
+	glVertex2i(x2, y2);
+	// vertical
+	glVertex2i(x1, y1);
+	glVertex2i(x1, y2);
+	glVertex2i(x2, y1);
+	glVertex2i(x2, y2);
+	glEnd();
+}
+
+void GraphicsGL::drawBitmapOverlay(const uint8_t *data, int w, int h, int fmt, SystemStub *stub) {
+	if (fmt == FMT_RGB555) {
+	}
+}
+
+Graphics *GraphicsGL_create() {
+	return new GraphicsGL();
+}
+
+#endif
+
+} // namespace Awe
diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
new file mode 100644
index 00000000000..5b0a9381607
--- /dev/null
+++ b/engines/awe/graphics_soft.cpp
@@ -0,0 +1,523 @@
+/* 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 "awe/graphics.h"
+#include "awe/util.h"
+#include "awe/screenshot.h"
+#include "awe/systemstub.h"
+
+namespace Awe {
+
+struct GraphicsSoft : public Graphics {
+	typedef void (GraphicsSoft:: *drawLine)(int16_t x1, int16_t x2, int16_t y, uint8_t col);
+
+	uint8_t *_pagePtrs[4];
+	uint8_t *_drawPagePtr;
+	int _u, _v;
+	int _w, _h;
+	int _byteDepth;
+	Color _pal[16];
+	uint16_t *_colorBuffer;
+	int _screenshotNum;
+
+	GraphicsSoft();
+	~GraphicsSoft();
+
+	int xScale(int x) const {
+		return (x * _u) >> 16;
+	}
+	int yScale(int y) const {
+		return (y * _v) >> 16;
+	}
+
+	void setSize(int w, int h);
+	void drawPolygon(uint8_t color, const QuadStrip &qs);
+	void drawChar(uint8_t c, uint16_t x, uint16_t y, uint8_t color);
+	void drawSpriteMask(int x, int y, uint8_t color, const uint8_t *data);
+	void drawPoint(int16_t x, int16_t y, uint8_t color);
+	void drawLineT(int16_t x1, int16_t x2, int16_t y, uint8_t color);
+	void drawLineN(int16_t x1, int16_t x2, int16_t y, uint8_t color);
+	void drawLineP(int16_t x1, int16_t x2, int16_t y, uint8_t color);
+	uint8_t *getPagePtr(uint8_t page);
+	int getPageSize() const {
+		return _w * _h * _byteDepth;
+	}
+	void setWorkPagePtr(uint8_t page);
+
+	virtual void init(int targetW, int targetH);
+
+	virtual void setFont(const uint8_t *src, int w, int h);
+	virtual void setPalette(const Color *colors, int count);
+	virtual void setSpriteAtlas(const uint8_t *src, int w, int h, int xSize, int ySize);
+	virtual void drawSprite(int buffer, int num, const Point *pt, uint8_t color);
+	virtual void drawBitmap(int buffer, const uint8_t *data, int w, int h, int fmt);
+	virtual void drawPoint(int buffer, uint8_t color, const Point *pt);
+	virtual void drawQuadStrip(int buffer, uint8_t color, const QuadStrip *qs);
+	virtual void drawStringChar(int buffer, uint8_t color, char c, const Point *pt);
+	virtual void clearBuffer(int num, uint8_t color);
+	virtual void copyBuffer(int dst, int src, int vscroll = 0);
+	virtual void drawBuffer(int num, SystemStub *stub);
+	virtual void drawRect(int num, uint8_t color, const Point *pt, int w, int h);
+	virtual void drawBitmapOverlay(const uint8_t *data, int w, int h, int fmt, SystemStub *stub);
+};
+
+
+GraphicsSoft::GraphicsSoft() {
+	_fixUpPalette = FIXUP_PALETTE_NONE;
+	memset(_pagePtrs, 0, sizeof(_pagePtrs));
+	_colorBuffer = 0;
+	memset(_pal, 0, sizeof(_pal));
+	_screenshotNum = 1;
+}
+
+GraphicsSoft::~GraphicsSoft() {
+	for (int i = 0; i < 4; ++i) {
+		free(_pagePtrs[i]);
+		_pagePtrs[i] = 0;
+	}
+	free(_colorBuffer);
+}
+
+void GraphicsSoft::setSize(int w, int h) {
+	_u = (w << 16) / GFX_W;
+	_v = (h << 16) / GFX_H;
+	_w = w;
+	_h = h;
+	_byteDepth = _use555 ? 2 : 1;
+	assert(_byteDepth == 1 || _byteDepth == 2);
+	_colorBuffer = (uint16_t *)realloc(_colorBuffer, _w * _h * sizeof(uint16_t));
+	if (!_colorBuffer) {
+		error("Unable to allocate color buffer w %d h %d", _w, _h);
+	}
+	for (int i = 0; i < 4; ++i) {
+		_pagePtrs[i] = (uint8_t *)realloc(_pagePtrs[i], getPageSize());
+		if (!_pagePtrs[i]) {
+			error("Not enough memory to allocate offscreen buffers");
+		}
+		memset(_pagePtrs[i], 0, getPageSize());
+	}
+	setWorkPagePtr(2);
+}
+
+static uint32_t calcStep(const Point &p1, const Point &p2, uint16_t &dy) {
+	dy = p2.y - p1.y;
+	uint16_t delta = (dy <= 1) ? 1 : dy;
+	return ((p2.x - p1.x) * (0x4000 / delta)) << 2;
+}
+
+void GraphicsSoft::drawPolygon(uint8_t color, const QuadStrip &quadStrip) {
+	QuadStrip qs = quadStrip;
+	if (_w != GFX_W || _h != GFX_H) {
+		for (int i = 0; i < qs.numVertices; ++i) {
+			qs.vertices[i].scale(_u, _v);
+		}
+	}
+
+	int i = 0;
+	int j = qs.numVertices - 1;
+
+	int16_t x2 = qs.vertices[i].x;
+	int16_t x1 = qs.vertices[j].x;
+	int16_t hliney = MIN(qs.vertices[i].y, qs.vertices[j].y);
+
+	++i;
+	--j;
+
+	drawLine pdl;
+	switch (color) {
+	default:
+		pdl = &GraphicsSoft::drawLineN;
+		break;
+	case COL_PAGE:
+		pdl = &GraphicsSoft::drawLineP;
+		break;
+	case COL_ALPHA:
+		pdl = &GraphicsSoft::drawLineT;
+		break;
+	}
+
+	uint32_t cpt1 = x1 << 16;
+	uint32_t cpt2 = x2 << 16;
+
+	int numVertices = qs.numVertices;
+	while (1) {
+		numVertices -= 2;
+		if (numVertices == 0) {
+			return;
+		}
+		uint16_t h;
+		uint32_t step1 = calcStep(qs.vertices[j + 1], qs.vertices[j], h);
+		uint32_t step2 = calcStep(qs.vertices[i - 1], qs.vertices[i], h);
+
+		++i;
+		--j;
+
+		cpt1 = (cpt1 & 0xFFFF0000) | 0x7FFF;
+		cpt2 = (cpt2 & 0xFFFF0000) | 0x8000;
+
+		if (h == 0) {
+			cpt1 += step1;
+			cpt2 += step2;
+		} else {
+			while (h--) {
+				if (hliney >= 0) {
+					x1 = cpt1 >> 16;
+					x2 = cpt2 >> 16;
+					if (x1 < _w && x2 >= 0) {
+						if (x1 < 0) x1 = 0;
+						if (x2 >= _w) x2 = _w - 1;
+						(this->*pdl)(x1, x2, hliney, color);
+					}
+				}
+				cpt1 += step1;
+				cpt2 += step2;
+				++hliney;
+				if (hliney >= _h) return;
+			}
+		}
+	}
+}
+
+void GraphicsSoft::drawChar(uint8_t c, uint16_t x, uint16_t y, uint8_t color) {
+	if (x <= GFX_W - 8 && y <= GFX_H - 8) {
+		x = xScale(x);
+		y = yScale(y);
+		const uint8_t *ft = _font + (c - 0x20) * 8;
+		const int offset = (x + y * _w) * _byteDepth;
+		if (_byteDepth == 1) {
+			for (int j = 0; j < 8; ++j) {
+				const uint8_t ch = ft[j];
+				for (int i = 0; i < 8; ++i) {
+					if (ch & (1 << (7 - i))) {
+						_drawPagePtr[offset + j * _w + i] = color;
+					}
+				}
+			}
+		} else if (_byteDepth == 2) {
+			const uint16_t rgbColor = _pal[color].rgb555();
+			for (int j = 0; j < 8; ++j) {
+				const uint8_t ch = ft[j];
+				for (int i = 0; i < 8; ++i) {
+					if (ch & (1 << (7 - i))) {
+						((uint16_t *)(_drawPagePtr + offset))[j * _w + i] = rgbColor;
+					}
+				}
+			}
+		}
+	}
+}
+void GraphicsSoft::drawSpriteMask(int x, int y, uint8_t color, const uint8_t *data) {
+	const int w = *data++;
+	x = xScale(x - w / 2);
+	const int h = *data++;
+	y = yScale(y - h / 2);
+	assert(_byteDepth == 1);
+	for (int j = 0; j < h; ++j) {
+		const int yoffset = y + j;
+		for (int i = 0; i <= w / 16; ++i) {
+			const uint16_t mask = READ_BE_UINT16(data); data += 2;
+			if (yoffset < 0 || yoffset >= _h) {
+				continue;
+			}
+			const int xoffset = x + i * 16;
+			for (int b = 0; b < 16; ++b) {
+				if (xoffset + b < 0 || xoffset + b >= _w) {
+					continue;
+				}
+				if (mask & (1 << (15 - b))) {
+					_drawPagePtr[yoffset * _w + xoffset + b] = color;
+				}
+			}
+		}
+	}
+}
+
+static void blend_rgb555(uint16_t *dst, const uint16_t b) {
+	static const uint16_t RB_MASK = 0x7c1f;
+	static const uint16_t G_MASK = 0x03e0;
+	uint16_t a = *dst;
+	if ((a & 0x8000) == 0) { // use bit 15 to prevent additive blending
+		uint16_t r = 0x8000;
+		r |= (((a & RB_MASK) + (b & RB_MASK)) >> 1) & RB_MASK;
+		r |= (((a & G_MASK) + (b & G_MASK)) >> 1) & G_MASK;
+		*dst = r;
+	}
+}
+
+void GraphicsSoft::drawPoint(int16_t x, int16_t y, uint8_t color) {
+	x = xScale(x);
+	y = yScale(y);
+	const int offset = (y * _w + x) * _byteDepth;
+	if (_byteDepth == 1) {
+		switch (color) {
+		case COL_ALPHA:
+			_drawPagePtr[offset] |= 8;
+			break;
+		case COL_PAGE:
+			_drawPagePtr[offset] = *(_pagePtrs[0] + offset);
+			break;
+		default:
+			_drawPagePtr[offset] = color;
+			break;
+		}
+	} else if (_byteDepth == 2) {
+		switch (color) {
+		case COL_ALPHA:
+			blend_rgb555((uint16_t *)(_drawPagePtr + offset), _pal[ALPHA_COLOR_INDEX].rgb555());
+			break;
+		case COL_PAGE:
+			*(uint16_t *)(_drawPagePtr + offset) = *(uint16_t *)(_pagePtrs[0] + offset);
+			break;
+		default:
+			*(uint16_t *)(_drawPagePtr + offset) = _pal[color].rgb555();
+			break;
+		}
+	}
+}
+
+void GraphicsSoft::drawLineT(int16_t x1, int16_t x2, int16_t y, uint8_t color) {
+	int16_t xmax = MAX(x1, x2);
+	int16_t xmin = MIN(x1, x2);
+	int w = xmax - xmin + 1;
+	const int offset = (y * _w + xmin) * _byteDepth;
+	if (_byteDepth == 1) {
+		for (int i = 0; i < w; ++i) {
+			_drawPagePtr[offset + i] |= 8;
+		}
+	} else if (_byteDepth == 2) {
+		const uint16_t rgbColor = _pal[ALPHA_COLOR_INDEX].rgb555();
+		uint16_t *p = (uint16_t *)(_drawPagePtr + offset);
+		for (int i = 0; i < w; ++i) {
+			blend_rgb555(p + i, rgbColor);
+		}
+	}
+}
+
+void GraphicsSoft::drawLineN(int16_t x1, int16_t x2, int16_t y, uint8_t color) {
+	int16_t xmax = MAX(x1, x2);
+	int16_t xmin = MIN(x1, x2);
+	const int w = xmax - xmin + 1;
+	const int offset = (y * _w + xmin) * _byteDepth;
+	if (_byteDepth == 1) {
+		memset(_drawPagePtr + offset, color, w);
+	} else if (_byteDepth == 2) {
+		const uint16_t rgbColor = _pal[color].rgb555();
+		uint16_t *p = (uint16_t *)(_drawPagePtr + offset);
+		for (int i = 0; i < w; ++i) {
+			p[i] = rgbColor;
+		}
+	}
+}
+
+void GraphicsSoft::drawLineP(int16_t x1, int16_t x2, int16_t y, uint8_t color) {
+	if (_drawPagePtr == _pagePtrs[0]) {
+		return;
+	}
+	int16_t xmax = MAX(x1, x2);
+	int16_t xmin = MIN(x1, x2);
+	const int w = xmax - xmin + 1;
+	const int offset = (y * _w + xmin) * _byteDepth;
+	memcpy(_drawPagePtr + offset, _pagePtrs[0] + offset, w * _byteDepth);
+}
+
+uint8_t *GraphicsSoft::getPagePtr(uint8_t page) {
+	assert(page >= 0 && page < 4);
+	return _pagePtrs[page];
+}
+
+void GraphicsSoft::setWorkPagePtr(uint8_t page) {
+	_drawPagePtr = getPagePtr(page);
+}
+
+void GraphicsSoft::init(int targetW, int targetH) {
+	Graphics::init(targetW, targetH);
+	setSize(targetW, targetH);
+}
+
+void GraphicsSoft::setFont(const uint8_t *src, int w, int h) {
+	if (_is1991) {
+		// no-op for 1991
+	}
+}
+
+void GraphicsSoft::setPalette(const Color *colors, int count) {
+	memcpy(_pal, colors, sizeof(Color) * MIN(count, 16));
+}
+
+void GraphicsSoft::setSpriteAtlas(const uint8_t *src, int w, int h, int xSize, int ySize) {
+	if (_is1991) {
+		// no-op for 1991
+	}
+}
+
+void GraphicsSoft::drawSprite(int buffer, int num, const Point *pt, uint8_t color) {
+	if (_is1991) {
+		if (num < _shapesMaskCount) {
+			setWorkPagePtr(buffer);
+			const uint8_t *data = _shapesMaskData + _shapesMaskOffset[num];
+			drawSpriteMask(pt->x, pt->y, color, data);
+		}
+	}
+}
+
+void GraphicsSoft::drawBitmap(int buffer, const uint8_t *data, int w, int h, int fmt) {
+	switch (_byteDepth) {
+	case 1:
+		if (fmt == FMT_CLUT && _w == w && _h == h) {
+			memcpy(getPagePtr(buffer), data, w * h);
+			return;
+		}
+		break;
+	case 2:
+		if (fmt == FMT_RGB555 && _w == w && _h == h) {
+			memcpy(getPagePtr(buffer), data, getPageSize());
+			return;
+		}
+		break;
+	}
+	warning("GraphicsSoft::drawBitmap() unhandled fmt %d w %d h %d", fmt, w, h);
+}
+
+void GraphicsSoft::drawPoint(int buffer, uint8_t color, const Point *pt) {
+	setWorkPagePtr(buffer);
+	drawPoint(pt->x, pt->y, color);
+}
+
+void GraphicsSoft::drawQuadStrip(int buffer, uint8_t color, const QuadStrip *qs) {
+	setWorkPagePtr(buffer);
+	drawPolygon(color, *qs);
+}
+
+void GraphicsSoft::drawStringChar(int buffer, uint8_t color, char c, const Point *pt) {
+	setWorkPagePtr(buffer);
+	drawChar(c, pt->x, pt->y, color);
+}
+
+void GraphicsSoft::clearBuffer(int num, uint8_t color) {
+	if (_byteDepth == 1) {
+		memset(getPagePtr(num), color, getPageSize());
+	} else if (_byteDepth == 2) {
+		const uint16_t rgbColor = _pal[color].rgb555();
+		uint16_t *p = (uint16_t *)getPagePtr(num);
+		for (int i = 0; i < _w * _h; ++i) {
+			p[i] = rgbColor;
+		}
+	}
+}
+
+void GraphicsSoft::copyBuffer(int dst, int src, int vscroll) {
+	if (vscroll == 0) {
+		memcpy(getPagePtr(dst), getPagePtr(src), getPageSize());
+	} else if (vscroll >= -199 && vscroll <= 199) {
+		const int dy = yScale(vscroll);
+		if (dy < 0) {
+			memcpy(getPagePtr(dst), getPagePtr(src) - dy * _w * _byteDepth, (_h + dy) * _w * _byteDepth);
+		} else {
+			memcpy(getPagePtr(dst) + dy * _w * _byteDepth, getPagePtr(src), (_h - dy) * _w * _byteDepth);
+		}
+	}
+}
+
+static void dumpBuffer555(const uint16_t *src, int w, int h, int num) {
+	char name[32];
+	snprintf(name, sizeof(name), "screenshot-%d.tga", num);
+	saveTGA(name, src, w, h);
+	debug(DBG_INFO, "Written '%s'", name);
+}
+
+static void dumpPalette555(uint16_t *dst, int w, const Color *pal) {
+	static const int SZ = 16;
+	for (int color = 0; color < 16; ++color) {
+		uint16_t *p = dst + (color & 7) * SZ;
+		for (int y = 0; y < SZ; ++y) {
+			for (int x = 0; x < SZ; ++x) {
+				p[x] = pal[color].rgb555();
+			}
+			p += w;
+		}
+		if (color == 7) {
+			dst += SZ * w;
+		}
+	}
+}
+
+void GraphicsSoft::drawBuffer(int num, SystemStub *stub) {
+	int w, h;
+	float ar[4];
+	stub->prepareScreen(w, h, ar);
+	if (_byteDepth == 1) {
+		const uint8_t *src = getPagePtr(num);
+		for (int i = 0; i < _w * _h; ++i) {
+			_colorBuffer[i] = _pal[src[i]].rgb555();
+		}
+		if (0) {
+			dumpPalette555(_colorBuffer, _w, _pal);
+		}
+		stub->setScreenPixels555(_colorBuffer, _w, _h);
+		if (_screenshot) {
+			dumpBuffer555(_colorBuffer, _w, _h, _screenshotNum);
+			++_screenshotNum;
+			_screenshot = false;
+		}
+	} else if (_byteDepth == 2) {
+		const uint16_t *src = (uint16_t *)getPagePtr(num);
+		stub->setScreenPixels555(src, _w, _h);
+		if (_screenshot) {
+			dumpBuffer555(src, _w, _h, _screenshotNum);
+			++_screenshotNum;
+			_screenshot = false;
+		}
+	}
+	stub->updateScreen();
+}
+
+void GraphicsSoft::drawRect(int num, uint8_t color, const Point *pt, int w, int h) {
+	assert(_byteDepth == 2);
+	setWorkPagePtr(num);
+	const uint16_t rgbColor = _pal[color].rgb555();
+	const int x1 = xScale(pt->x);
+	const int y1 = yScale(pt->y);
+	const int x2 = xScale(pt->x + w - 1);
+	const int y2 = yScale(pt->y + h - 1);
+	// horizontal
+	for (int x = x1; x <= x2; ++x) {
+		*(uint16_t *)(_drawPagePtr + (y1 * _w + x) * _byteDepth) = rgbColor;
+		*(uint16_t *)(_drawPagePtr + (y2 * _w + x) * _byteDepth) = rgbColor;
+	}
+	// vertical
+	for (int y = y1; y <= y2; ++y) {
+		*(uint16_t *)(_drawPagePtr + (y * _w + x1) * _byteDepth) = rgbColor;
+		*(uint16_t *)(_drawPagePtr + (y * _w + x2) * _byteDepth) = rgbColor;
+	}
+}
+
+void GraphicsSoft::drawBitmapOverlay(const uint8_t *data, int w, int h, int fmt, SystemStub *stub) {
+	if (fmt == FMT_RGB555) {
+		stub->setScreenPixels555((const uint16_t *)data, w, h);
+		stub->updateScreen();
+	}
+}
+
+Graphics *GraphicsSoft_create() {
+	return new GraphicsSoft();
+}
+
+} // namespace Awe
diff --git a/engines/awe/intern.h b/engines/awe/intern.h
index 65c65ed4d27..b1905892573 100644
--- a/engines/awe/intern.h
+++ b/engines/awe/intern.h
@@ -25,26 +25,159 @@
 #include "common/algorithm.h"
 #include "common/endian.h"
 #include "common/rect.h"
-#include "awe/util.h"
 
 namespace Awe {
 
-using Common::Point;
+#if 0
+#undef ARRAYSIZE
+#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
+
+#undef ABS
+template<typename T>
+inline T ABS(T v) {
+	return (v < 0) ? -v : v;
+}
+
+#undef MIN
+template<typename T>
+inline T MIN(T v1, T v2) {
+	return (v1 < v2) ? v1 : v2;
+}
+
+#undef MAX
+template<typename T>
+inline T MAX(T v1, T v2) {
+	return (v1 > v2) ? v1 : v2;
+}
+
+template<typename T>
+inline void SWAP(T &a, T &b) {
+	T tmp = a;
+	a = b;
+	b = tmp;
+}
+
+inline uint16_t SWAP_UINT16(uint16_t n) {
+	return ((n >> 8) & 255) | ((n & 255) << 8);
+}
+
+inline uint16_t READ_BE_UINT16(const void *ptr) {
+	const uint8_t *b = (const uint8_t *)ptr;
+	return (b[0] << 8) | b[1];
+}
+
+inline uint16_t READ_LE_UINT16(const uint8_t *ptr) {
+	return (ptr[1] << 8) | ptr[0];
+}
+
+inline uint32_t READ_BE_UINT32(const void *ptr) {
+	const uint8_t *b = (const uint8_t *)ptr;
+	return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
+}
+
+inline uint32_t READ_LE_UINT32(const uint8_t *ptr) {
+	return (ptr[3] << 24) | (ptr[2] << 16) | (ptr[1] << 8) | ptr[0];
+}
+
+inline void WRITE_LE_UINT32(uint8_t *ptr, uint32_t value) {
+	for (int i = 0; i < 4; ++i) {
+		ptr[i] = value & 255; value >>= 8;
+	}
+}
+#endif
+
+enum Language {
+	LANG_FR,
+	LANG_US,
+	LANG_DE,
+	LANG_ES,
+	LANG_IT
+};
+
+enum {
+	kPartCopyProtection = 16000,
+	kPartIntro = 16001,
+	kPartWater = 16002,
+	kPartPrison = 16003,
+	kPartCite = 16004,
+	kPartArene = 16005,
+	kPartLuxe = 16006,
+	kPartFinal = 16007,
+	kPartPassword = 16008
+};
+
+enum {
+	kPaulaFreq = 7159092
+};
 
 struct Ptr {
-	uint8 *pc = nullptr;
-	
-	uint8 fetchByte() {
+	uint8_t *pc;
+	bool byteSwap;
+
+	uint8_t fetchByte() {
 		return *pc++;
 	}
-	
-	uint16 fetchWord() {
-		uint16 i = READ_BE_UINT16(pc);
+
+	uint16_t fetchWord() {
+		const uint16_t i = byteSwap ? READ_LE_UINT16(pc) : READ_BE_UINT16(pc);
 		pc += 2;
 		return i;
 	}
 };
 
+struct Point : public Common::Point {
+	Point() : Common::Point() {}
+	Point(int16_t xx, int16_t yy) : Common::Point(xx, yy) {}
+	Point(const Point &p) : Common::Point(p) {}
+
+	void scale(int u, int v) {
+		x = (x * u) >> 16;
+		y = (y * v) >> 16;
+	}
+};
+
+struct QuadStrip {
+	enum {
+		MAX_VERTICES = 70
+	};
+
+	uint8_t numVertices;
+	Point vertices[MAX_VERTICES];
+};
+
+struct Color {
+	uint8_t r;
+	uint8_t g;
+	uint8_t b;
+
+	uint16_t rgb555() const {
+		return ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);
+	}
+};
+
+struct Frac {
+	static const int BITS = 16;
+	static const int MASK = (1 << BITS) - 1;
+	uint32_t inc;
+	uint64_t offset;
+
+	void reset(int n, int d) {
+		inc = (((int64_t)n) << BITS) / d;
+		offset = 0;
+	}
+
+	uint32_t getInt() const {
+		return offset >> BITS;
+	}
+	uint32_t getFrac() const {
+		return offset & MASK;
+	}
+	int interpolate(int sample1, int sample2) const {
+		const int fp = getFrac();
+		return (sample1 * (MASK - fp) + sample2 * fp) >> BITS;
+	}
+};
+
 } // namespace Awe
 
 #endif
diff --git a/engines/awe/logic.cpp b/engines/awe/logic.cpp
deleted file mode 100644
index 37cc780c8fd..00000000000
--- a/engines/awe/logic.cpp
+++ /dev/null
@@ -1,550 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "common/config-manager.h"
-#include "awe/awe.h"
-#include "awe/logic.h"
-#include "awe/resource.h"
-#include "awe/video.h"
-#include "awe/serializer.h"
-#include "awe/system_stub.h"
-
-namespace Awe {
-
-Logic::Logic(Resource *res, Video *vid, SystemStub *stub)
-	: _res(res), _vid(vid), _stub(stub),
-	_copyProtection(ConfMan.getBool("copy_protection")) {
-}
-
-void Logic::init() {
-	memset(_scriptVars, 0, sizeof(_scriptVars));
-	_scriptVars[0x54] = 0x81;
-	_scriptVars[VAR_RANDOM_SEED] = 0;
-	_fastMode = false;
-}
-
-void Logic::op_movConst() {
-	uint8 i = _scriptPtr.fetchByte();
-	int16 n = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "%.4x - op_movConst(0x%02X, %d)",
-		_lastOpcodeOffset, i, n);
-	_scriptVars[i] = n;
-}
-
-void Logic::op_mov() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint8 j = _scriptPtr.fetchByte();	
-	debugC(kDebugLogic, "%.4x - op_mov(0x%02X, 0x%02X)",
-		_lastOpcodeOffset, i, j);
-	_scriptVars[i] = _scriptVars[j];
-}
-
-void Logic::op_add() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint8 j = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "%.4x - op_add(0x%02X, 0x%02X)",
-		_lastOpcodeOffset, i, j);
-	_scriptVars[i] += _scriptVars[j];
-}
-
-void Logic::op_addConst() {
-	uint8 i = _scriptPtr.fetchByte();
-	int16 n = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "%.4x - op_addConst(0x%02X, %d)",
-		_lastOpcodeOffset, i, n);
-	_scriptVars[i] += n;
-}
-
-void Logic::op_call() {
-	uint16 off = _scriptPtr.fetchWord();
-	uint8 sp = _stackPtr;
-	debugC(kDebugLogic, "%.4x - op_call(0x%X)",
-		_lastOpcodeOffset, off);
-	_scriptStackCalls[sp] = _scriptPtr.pc - _res->_segCode;
-	++_stackPtr;
-	_scriptPtr.pc = _res->_segCode + off;
-}
-
-void Logic::op_ret() {
-	debugC(kDebugLogic, "%.4x - op_ret()", _lastOpcodeOffset);
-	--_stackPtr;
-	uint8 sp = _stackPtr;
-	_scriptPtr.pc = _res->_segCode + _scriptStackCalls[sp];
-}
-
-void Logic::op_break() {
-	debugC(kDebugLogic, "%.4x - op_break()", _lastOpcodeOffset);
-	_scriptHalted = true;
-}
-
-void Logic::op_jmp() {
-	uint16 off = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "%.4x - op_jmp(0x%02X)", _lastOpcodeOffset, off);
-	_scriptPtr.pc = _res->_segCode + off;	
-}
-
-void Logic::op_setScriptPos() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint16 n = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "%.4x - op_setScriptPos(0x%X, 0x%X)",
-		_lastOpcodeOffset, i, n);
-	_scriptPos[1][i] = n;
-}
-
-void Logic::op_jnz() {
-	uint8 i = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "%.4x - op_jnz(0x%02X)",
-		_lastOpcodeOffset, i);
-	--_scriptVars[i];
-	if (_scriptVars[i] != 0) {
-		op_jmp();
-	} else {
-		_scriptPtr.fetchWord();
-	}
-}
-
-void Logic::op_condJmp() {
-	if (!_copyProtection && _res->_curPtrsId == 0x3E80 &&
-			_lastOpcodeOffset == 0xCB8) {
-		// (0x0CB8) condJmp(0x80, VAR(41), VAR(30), 0xCD3)
-		*(_scriptPtr.pc + 0x00) = 0x81;
-		*(_scriptPtr.pc + 0x03) = 0x0D;
-		*(_scriptPtr.pc + 0x04) = 0x24;
-		// (0x0D4E) condJmp(0x4, VAR(50), 6, 0xDBC)		
-		*(_scriptPtr.pc + 0x99) = 0x0D;
-		*(_scriptPtr.pc + 0x9A) = 0x5A;
-		debugC(kDebugLogic, "Logic::op_condJmp() bypassing protection");
-	}
-
-	// Patch original interpreter triggers if code is wrong
-	if (_res->_curPtrsId == 0x3e80 && _lastOpcodeOffset == 0xc4b) {
-		byte *script = _scriptPtr.pc;
-		*script = 0x81;
-		WRITE_BE_UINT16(script + 3, 0xcb7);
-		WRITE_BE_UINT16(script + 153, 0xced);
-	}
-
-	uint8 op = _scriptPtr.fetchByte();
-	int16 b = _scriptVars[_scriptPtr.fetchByte()];
-	int16 a = _scriptPtr.fetchByte();
-
-	if (op & 0x80) {
-		a = _scriptVars[a];
-	} else {
-		if (op & 0x40) {
-			a = (a << 8) | _scriptPtr.fetchByte();
-		}
-	}
-
-	debugC(kDebugLogic, "%.4x - op_condJmp(%d, 0x%02X, 0x%02X)",
-		_lastOpcodeOffset, op, b, a);
-	bool expr = false;
-
-	switch (op & 7) {
-	case 0:	// jz
-		expr = (b == a);
-		break;
-	case 1: // jnz
-		expr = (b != a);
-		break;
-	case 2: // jg
-		expr = (b > a);
-		break;
-	case 3: // jge
-		expr = (b >= a);
-		break;
-	case 4: // jl
-		expr = (b < a);
-		break;
-	case 5: // jle
-		expr = (b <= a);
-		break;
-	default:
-		warning("Logic::op_condJmp() invalid condition %d", (op & 7));
-		break;
-	}
-	if (expr) {
-		op_jmp();
-	} else {
-		_scriptPtr.fetchWord();
-	}
-}
-
-void Logic::op_setPalette() {
-	uint16 i = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "%.4x - op_setPalette(%d)", _lastOpcodeOffset, i);
-	_vid->_newPal = i >> 8;
-}
-
-void Logic::op_resetScript() {
-	uint8 j = _scriptPtr.fetchByte();
-	uint8 i = _scriptPtr.fetchByte();
-	int8 n = (i & 0x3F) - j;
-	if (n < 0) {
-		warning("Logic::op_resetScript() ec=0x%X (n < 0)", 0x880);
-		return;
-	}
-	++n;
-	uint8 _al = _scriptPtr.fetchByte();
-
-	debugC(kDebugLogic, "%.4x - op_resetScript(%d, %d, %d)",
-		_lastOpcodeOffset, j, i, _al);
-
-	if (_al == 2) {
-		uint16 *_si = &_scriptPos[1][j];
-		while (n--) {
-			*_si = 0xFFFE;
-			++_si;
-		}
-	} else if (_al < 2) {
-		uint8 *_si = &_scriptPaused[1][j];
-		while (n--) {
-			*_si = _al;
-			++_si;
-		}
-	}
-}
-
-void Logic::op_selectPage() {
-	uint8 i = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "%.4x - op_selectPage(%d)",
-		_lastOpcodeOffset, i);
-	_vid->changePagePtr1(i);
-}
-
-void Logic::op_fillPage() {
-	uint8 screen = _scriptPtr.fetchByte();
-	uint8 color = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "%.4x - op_fillPage(%d, %d)",
-		_lastOpcodeOffset, screen, color);
-	_vid->fillPage(screen, color);
-}
-
-void Logic::op_copyPage() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint8 j = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "%.4x - op_copyPage(%d, %d)",
-		_lastOpcodeOffset, i, j);
-	_vid->copyPage(i, j, _scriptVars[VAR_SCROLL_Y]);
-}
-
-void Logic::op_updateDisplay() {
-	uint8 page = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "%.4x - op_updateDisplay(%d)",
-		_lastOpcodeOffset, page);
-	inp_handleSpecialKeys();
-	if (_res->_curPtrsId == 0x3E80 && _scriptVars[0x67] == 1) {
-		_scriptVar_0xBF = _scriptVars[0xBF];
-		_scriptVars[0xDC] = 0x21;
-	}
-
-	uint32 tstamp = _stub->getTimeStamp();
-
-	if (!_fastMode) {
-		// XXX experimental
-		int32 delay = tstamp - _lastTimestamp;
-		int32 pause = _scriptVars[VAR_PAUSE_SLICES] * 20 - delay;
-		if (pause > 0) {
-			_stub->sleep(pause);
-		}
-	}
-
-	_scriptVars[0xF7] = 0;
-
-	_vid->updateDisplay(page);
-	_lastTimestamp = tstamp;
-}
-
-void Logic::op_halt() {
-	debugC(kDebugLogic, "%.4x - op_halt()", _lastOpcodeOffset);
-	_scriptPtr.pc = _res->_segCode + 0xFFFF;
-	_scriptHalted = true;
-}
-
-void Logic::op_drawString() {
-	uint16 strId = _scriptPtr.fetchWord();
-	uint16 x = _scriptPtr.fetchByte();
-	uint16 y = _scriptPtr.fetchByte();
-	uint16 col = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "%.4x - op_drawString(0x%03X, %d, %d, %d)",
-		_lastOpcodeOffset, strId, x, y, col);
-	_vid->drawString(col, x, y, strId);
-}
-
-void Logic::op_sub() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint8 j = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "%.4x - op_sub(0x%02X, 0x%02X)",
-		_lastOpcodeOffset, i, j);
-	_scriptVars[i] -= _scriptVars[j];
-}
-
-void Logic::op_and() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint16 n = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "%.4x - op_and(0x%02X, %d)",
-		_lastOpcodeOffset, i, n);
-	_scriptVars[i] = (uint16)_scriptVars[i] & n;
-}
-
-void Logic::op_or() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint16 n = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "%.4x - op_or(0x%02X, %d)",
-		_lastOpcodeOffset, i, n);
-	_scriptVars[i] = (uint16)_scriptVars[i] | n;
-}
-
-void Logic::op_shl() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint16 n = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "%.4x - op_shl(0x%02X, %d)",
-		_lastOpcodeOffset, i, n);
-	_scriptVars[i] = (uint16)_scriptVars[i] << n;
-}
-
-void Logic::op_shr() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint16 n = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "%.4x - op_shr(0x%02X, %d)",
-		_lastOpcodeOffset, i, n);
-	_scriptVars[i] = (uint16)_scriptVars[i] >> n;
-}
-
-void Logic::op_soundUnk1() {
-	uint16 b = _scriptPtr.fetchWord();
-	uint16 c = _scriptPtr.fetchWord();
-	uint8 a = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "%.4x - op_soundUnk1(0x%X, 0x%X, %d)",
-		_lastOpcodeOffset, b, c, a);
-	// XXX
-}
-
-void Logic::op_updateMemList() {
-	uint16 num = _scriptPtr.fetchWord();
-	debugC(kDebugLogic, "%.4x - op_updateMemList(%d)",
-		_lastOpcodeOffset, num);
-	_res->update(num);
-}
-
-void Logic::op_soundUnk2() {
-	uint16 b = _scriptPtr.fetchWord();
-	uint16 c = _scriptPtr.fetchWord();
-	uint8 a = _scriptPtr.fetchByte();
-	debugC(kDebugLogic, "%.4x - op_soundUnk2(0x%X, 0x%X, %d)",
-		_lastOpcodeOffset, b, c, a);
-	// XXX
-}
-
-void Logic::restartAt(uint16 ptrId) {
-	// XXX
-	_scriptVars[0xE4] = 0x14;
-	_res->setupPtrs(ptrId);
-	memset((uint8 *)_scriptPos, 0xFF, sizeof(_scriptPos));
-	memset((uint8 *)_scriptPaused, 0, sizeof(_scriptPaused));
-	_scriptPos[0][0] = 0;	
-}
-
-void Logic::setupScripts() {
-	if (_res->_newPtrsId != 0) {
-		restartAt(_res->_newPtrsId);
-		_res->_newPtrsId = 0;
-	}
-	for (int i = 0; i < 0x40; ++i) {
-		_scriptPaused[0][i] = _scriptPaused[1][i];
-		uint16 n = _scriptPos[1][i];
-		if (n != 0xFFFF) {
-			_scriptPos[0][i] = (n == 0xFFFE) ? 0xFFFF : n;
-			_scriptPos[1][i] = 0xFFFF;
-		}
-	}
-}
-
-void Logic::runScripts() {
-	for (int i = 0; i < 0x40 && !g_engine->shouldQuit(); ++i) {
-		if (_scriptPaused[0][i] == 0) {
-			uint16 n = _scriptPos[0][i];
-			if (n != 0xFFFF) {
-				_scriptPtr.pc = _res->_segCode + n;
-				_stackPtr = 0;
-				_scriptHalted = false;
-				debugC(kDebugLogic, "Logic::runScripts() i=0x%02X n=0x%02X *p=0x%02X", i, n, *_scriptPtr.pc);
-				executeScript();
-				_scriptPos[0][i] = _scriptPtr.pc - _res->_segCode;
-				debugC(kDebugLogic, "Logic::runScripts() i=0x%02X pos=0x%X", i, _scriptPos[0][i]);
-				if (_stub->_pi.quit) {
-					break;
-				}
-			}
-		}
-	}
-}
-
-void Logic::executeScript() {
-	while (!_scriptHalted && !g_engine->shouldQuit()) {
-		// Get the next opcode
-		_lastOpcodeOffset = _scriptPtr.pc - _res->_segCode;
-		uint8 opcode = _scriptPtr.fetchByte();
-
-		if (opcode & 0x80) {
-			uint16 off = ((opcode << 8) | _scriptPtr.fetchByte()) * 2;
-			_res->_useSegVideo2 = false;
-			int16 x = _scriptPtr.fetchByte();
-			int16 y = _scriptPtr.fetchByte();
-			int16 h = y - 199;
-			if (h > 0) {
-				y = 199;
-				x += h;
-			}
-			debugC(kDebugVideo, "vid_opcd_0x80 : opcode=0x%X off=0x%X x=%d y=%d", opcode, off, x, y);
-			_vid->setDataBuffer(_res->_segVideo1, off);
-			_vid->drawShape(0xFF, 0x40, Point(x,y));
-		} else if (opcode & 0x40) {
-			int16 x, y;
-			uint16 off = _scriptPtr.fetchWord() * 2;
-			x = _scriptPtr.fetchByte();
-			_res->_useSegVideo2 = false;
-			if (!(opcode & 0x20)) {
-				if (!(opcode & 0x10)) {
-					x = (x << 8) | _scriptPtr.fetchByte();
-				} else {
-					x = _scriptVars[x];
-				}
-			} else {
-				if (opcode & 0x10) {
-					x += 0x100;
-				}
-			}
-			y = _scriptPtr.fetchByte();
-			if (!(opcode & 8)) {
-				if (!(opcode & 4)) {
-					y = (y << 8) | _scriptPtr.fetchByte();
-				} else {
-					y = _scriptVars[y];
-				}
-			}
-			uint16 zoom = _scriptPtr.fetchByte();
-			if (!(opcode & 2)) {
-				if (!(opcode & 1)) {
-					--_scriptPtr.pc;
-					zoom = 0x40;
-				} else {
-					zoom = _scriptVars[zoom];
-				}
-			} else {
-				if (opcode & 1) {
-					_res->_useSegVideo2 = true;
-					--_scriptPtr.pc;
-					zoom = 0x40;
-				}
-			}
-			debugC(kDebugVideo, "vid_opcd_0x40 : off=0x%X x=%d y=%d", off, x, y);
-			_vid->setDataBuffer(_res->_useSegVideo2 ? _res->_segVideo2 : _res->_segVideo1, off);
-			_vid->drawShape(0xFF, zoom, Point(x, y));
-		} else {
-			if (opcode > 0x1A) {
-				error("Logic::executeScript() ec=0x%X invalid opcode=0x%X", 0xFFF, opcode);
-			} else {
-				(this->*OPCODE_TABLE[opcode])();
-			}
-		}
-	}
-}
-
-void Logic::inp_updatePlayer() {
-	_stub->processEvents();
-	if (_res->_curPtrsId == 0x3E89) {
-		char c = _stub->_pi.lastChar;
-		if (c == 8 || /*c == 0xD ||*/ c == 0 || (c >= 'a' && c <= 'z')) {
-			_scriptVars[VAR_LAST_KEYCHAR] = c & ~0x20;
-			_stub->_pi.lastChar = 0;
-		}
-	}
-	int16 lr = 0;
-	int16 m = 0;
-	int16 ud = 0;
-	if (_stub->_pi.dirMask & PlayerInput::DIR_RIGHT) {
-		lr = 1;
-		m |= 1;
-	}
-	if (_stub->_pi.dirMask & PlayerInput::DIR_LEFT) {
-		lr = -1;
-		m |= 2;
-	}
-	if (_stub->_pi.dirMask & PlayerInput::DIR_DOWN) {
-		ud = 1;
-		m |= 4;
-	}
-	_scriptVars[VAR_HERO_POS_UP_DOWN] = ud;
-	if (_stub->_pi.dirMask & PlayerInput::DIR_UP) {
-		_scriptVars[VAR_HERO_POS_UP_DOWN] = -1;
-	}
-	if (_stub->_pi.dirMask & PlayerInput::DIR_UP) { // inpJump
-		ud = -1;
-		m |= 8;
-	}
-	_scriptVars[VAR_HERO_POS_JUMP_DOWN] = ud;
-	_scriptVars[VAR_HERO_POS_LEFT_RIGHT] = lr;
-	_scriptVars[VAR_HERO_POS_MASK] = m;
-	int16 button = 0;
-	if (_stub->_pi.button) { // inpButton
-		button = 1;
-		m |= 0x80;
-	}
-	_scriptVars[VAR_HERO_ACTION] = button;
-	_scriptVars[VAR_HERO_ACTION_POS_MASK] = m;
-}
-
-void Logic::inp_handleSpecialKeys() {
-	if (_stub->_pi.pause) {
-		if (_res->_curPtrsId != 0x3E80 && _res->_curPtrsId != 0x3E81) {
-			_stub->_pi.pause = false;
-			while (!_stub->_pi.pause) {
-				_stub->processEvents();
-				_stub->sleep(200);
-			}
-		}
-		_stub->_pi.pause = false;
-	}
-	if (_stub->_pi.code) {
-		_stub->_pi.code = false;
-		if (_res->_curPtrsId != 0x3E89 && _res->_curPtrsId != 0x3E80) {
-			_res->_newPtrsId = 0x3E89;
-		}
-	}
-	// XXX
-	if (_scriptVars[0xC9] == 1) {
-		warning("Logic::inp_handleSpecialKeys() unhandled case (_scriptVars[0xC9] == 1)");
-	}
-}
-
-void Logic::saveOrLoad(Serializer &ser) {
-	Serializer::Entry entries[] = {
-		SE_ARRAY(_scriptVars, 0x100, Serializer::SES_INT16, VER(1)),
-		SE_ARRAY(_scriptStackCalls, 0x100, Serializer::SES_INT16, VER(1)),
-		SE_ARRAY(_scriptPos, 0x40 * 2, Serializer::SES_INT16, VER(1)),
-		SE_ARRAY(_scriptPaused, 0x40 * 2, Serializer::SES_INT8, VER(1)),
-		SE_END()
-	};
-	ser.saveOrLoadEntries(entries);
-}
-
-} // namespace Awe
diff --git a/engines/awe/logic.h b/engines/awe/logic.h
deleted file mode 100644
index da776f26e30..00000000000
--- a/engines/awe/logic.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AWE_LOGIC_H
-#define AWE_LOGIC_H
-
-#include "awe/intern.h"
-
-namespace Awe {
-
-struct Resource;
-struct Serializer;
-struct SystemStub;
-struct Video;
-
-struct Logic {
-	typedef void (Logic::*OpcodeStub)();
-
-	enum ScriptVars {
-		VAR_RANDOM_SEED          = 0x3C,
-		
-		VAR_LAST_KEYCHAR         = 0xDA,
-
-		VAR_HERO_POS_UP_DOWN     = 0xE5,
-
-		VAR_SCROLL_Y             = 0xF9,
-		VAR_HERO_ACTION          = 0xFA,
-		VAR_HERO_POS_JUMP_DOWN   = 0xFB,
-		VAR_HERO_POS_LEFT_RIGHT  = 0xFC,
-		VAR_HERO_POS_MASK        = 0xFD,
-		VAR_HERO_ACTION_POS_MASK = 0xFE,
-		VAR_PAUSE_SLICES         = 0xFF
-	};
-	
-	static const OpcodeStub OPCODE_TABLE[];
-
-	Resource *_res;
-	Video *_vid;
-	SystemStub *_stub;
-	bool _copyProtection;
-
-	int16 _scriptVar_0xBF = { 0 };
-	int16 _scriptVars[0x100] = { 0 };
-	uint16 _scriptStackCalls[0x40] = { 0 };
-	uint16 _scriptPos[2][0x40] = { { 0 } };
-	uint8 _scriptPaused[2][0x40] = { { 0 } };
-	Ptr _scriptPtr;
-	uint8 _stackPtr = 0;
-	bool _scriptHalted = false;
-	bool _fastMode = false;
-	int _lastOpcodeOffset = 0;
-	uint32 _lastTimestamp = 0;
-
-	Logic(Resource *res, Video *vid, SystemStub *stub);
-	void init();
-	
-	void op_movConst();
-	void op_mov();
-	void op_add();
-	void op_addConst();
-	void op_call();
-	void op_ret();
-	void op_break();
-	void op_jmp();
-	void op_setScriptPos();
-	void op_jnz();
-	void op_condJmp();
-	void op_setPalette();
-	void op_resetScript();
-	void op_selectPage();
-	void op_fillPage();
-	void op_copyPage();
-	void op_updateDisplay();
-	void op_halt();	
-	void op_drawString();
-	void op_sub();
-	void op_and();
-	void op_or();
-	void op_shl();
-	void op_shr();
-	void op_soundUnk1();
-	void op_updateMemList();
-	void op_soundUnk2();
-
-	void restartAt(uint16 ptrId);
-	void setupPtrs(uint16 ptrId);
-	void setupScripts();
-	void runScripts();
-	void executeScript();
-
-	void inp_updatePlayer();
-	void inp_handleSpecialKeys();
-	
-	void saveOrLoad(Serializer &ser);
-};
-
-} // namespace Awe
-
-#endif
diff --git a/engines/awe/mixer.cpp b/engines/awe/mixer.cpp
new file mode 100644
index 00000000000..5c798135855
--- /dev/null
+++ b/engines/awe/mixer.cpp
@@ -0,0 +1,542 @@
+/* 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/>.
+ *
+ */
+
+//define MIX_INIT_FLUIDSYNTH MIX_INIT_MID // renamed with SDL2_mixer >= 2.0.2
+#include "awe/aifcplayer.h"
+#include "awe/mixer.h"
+#include "awe/sfxplayer.h"
+#include "awe/util.h"
+
+namespace Awe {
+
+#ifdef TODO
+enum {
+	TAG_RIFF = 0x46464952,
+	TAG_WAVE = 0x45564157,
+	TAG_fmt = 0x20746D66,
+	TAG_data = 0x61746164
+};
+
+static const bool kAmigaStereoChannels = false; // 0,3:left 1,2:right
+
+static int16_t toS16(int a) {
+	return ((a << 8) | a) - 32768;
+}
+
+static int16_t mixS16(int sample1, int sample2) {
+	const int sample = sample1 + sample2;
+	return sample < -32768 ? -32768 : ((sample > 32767 ? 32767 : sample));
+}
+
+struct MixerChannel {
+	const uint8_t *_data;
+	Frac _pos;
+	uint32_t _len;
+	uint32_t _loopLen, _loopPos;
+	int _volume;
+	void (MixerChannel:: *_mixWav)(int16_t *sample, int count);
+
+	void initRaw(const uint8_t *data, int freq, int volume, int mixingFreq) {
+		_data = data + 8;
+		_pos.reset(freq, mixingFreq);
+
+		const int len = READ_BE_UINT16(data) * 2;
+		_loopLen = READ_BE_UINT16(data + 2) * 2;
+		_loopPos = _loopLen ? len : 0;
+		_len = len;
+
+		_volume = volume;
+	}
+
+	void initWav(const uint8_t *data, int freq, int volume, int mixingFreq, int len, bool bits16, bool stereo, bool loop) {
+		_data = data;
+		_pos.reset(freq, mixingFreq);
+
+		_len = len;
+		_loopLen = loop ? len : 0;
+		_loopPos = 0;
+		_volume = volume;
+		_mixWav = bits16 ? (stereo ? &MixerChannel::mixWav<16, true> : &MixerChannel::mixWav<16, false>) : (stereo ? &MixerChannel::mixWav<8, true> : &MixerChannel::mixWav<8, false>);
+	}
+	void mixRaw(int16_t &sample) {
+		if (_data) {
+			uint32_t pos = _pos.getInt();
+			_pos.offset += _pos.inc;
+			if (_loopLen != 0) {
+				if (pos >= _loopPos + _loopLen) {
+					pos = _loopPos;
+					_pos.offset = (_loopPos << Frac::BITS) + _pos.inc;
+				}
+			} else {
+				if (pos >= _len) {
+					_data = 0;
+					return;
+				}
+			}
+			sample = mixS16(sample, toS16(_data[pos] ^ 0x80) * _volume / 64);
+		}
+	}
+
+	template<int bits, bool stereo>
+	void mixWav(int16_t *samples, int count) {
+		for (int i = 0; i < count; i += 2) {
+			uint32_t pos = _pos.getInt();
+			_pos.offset += _pos.inc;
+			if (pos >= _len) {
+				if (_loopLen != 0) {
+					pos = 0;
+					_pos.offset = _pos.inc;
+				} else {
+					_data = 0;
+					break;
+				}
+			}
+			if (stereo) {
+				pos *= 2;
+			}
+			int valueL;
+			if (bits == 8) { // U8
+				valueL = toS16(_data[pos]) * _volume / 64;
+			} else { // S16
+				valueL = ((int16_t)READ_LE_UINT16(&_data[pos * sizeof(int16_t)])) * _volume / 64;
+			}
+			*samples = mixS16(*samples, valueL);
+			++samples;
+
+			int valueR;
+			if (!stereo) {
+				valueR = valueL;
+			} else {
+				if (bits == 8) { // U8
+					valueR = toS16(_data[pos + 1]) * _volume / 64;
+				} else { // S16
+					valueR = ((int16_t)READ_LE_UINT16(&_data[(pos + 1) * sizeof(int16_t)])) * _volume / 64;
+				}
+			}
+			*samples = mixS16(*samples, valueR);
+			++samples;
+		}
+	}
+};
+
+static const uint8_t *loadWav(const uint8_t *data, int &freq, int &len, bool &bits16, bool &stereo) {
+	uint32_t riffMagic = READ_LE_UINT32(data);
+	if (riffMagic != TAG_RIFF) return 0;
+	uint32_t riffLength = READ_LE_UINT32(data + 4);
+	uint32_t waveMagic = READ_LE_UINT32(data + 8);
+	if (waveMagic != TAG_WAVE) return 0;
+	uint32_t offset = 12;
+	uint32_t chunkMagic, chunkLength = 0;
+	// find fmt chunk
+	do {
+		offset += chunkLength + (chunkLength & 1);
+		if (offset >= riffLength) return 0;
+		chunkMagic = READ_LE_UINT32(data + offset);
+		chunkLength = READ_LE_UINT32(data + offset + 4);
+		offset += 8;
+	} while (chunkMagic != TAG_fmt);
+
+	if (chunkLength < 14) return 0;
+	if (offset + chunkLength >= riffLength) return 0;
+
+	// read format
+	int formatTag = READ_LE_UINT16(data + offset);
+	int channels = READ_LE_UINT16(data + offset + 2);
+	int samplesPerSec = READ_LE_UINT32(data + offset + 4);
+	int bitsPerSample = 0;
+	if (chunkLength >= 16) {
+		bitsPerSample = READ_LE_UINT16(data + offset + 14);
+	} else if (formatTag == 1 && channels != 0) {
+		int blockAlign = READ_LE_UINT16(data + offset + 12);
+		bitsPerSample = (blockAlign * 8) / channels;
+	}
+	// check supported format
+	if ((formatTag != 1) || // PCM
+		(channels != 1 && channels != 2) || // mono or stereo
+		(bitsPerSample != 8 && bitsPerSample != 16)) { // 8bit or 16bit
+		warning("Unsupported wave file");
+		return 0;
+	}
+
+	// find data chunk
+	do {
+		offset += chunkLength + (chunkLength & 1);
+		if (offset >= riffLength) return 0;
+		chunkMagic = READ_LE_UINT32(data + offset);
+		chunkLength = READ_LE_UINT32(data + offset + 4);
+		offset += 8;
+	} while (chunkMagic != TAG_data);
+
+	uint32_t lengthSamples = chunkLength;
+	if (offset + lengthSamples - 4 > riffLength) {
+		lengthSamples = riffLength + 4 - offset;
+	}
+	if (channels == 2) lengthSamples >>= 1;
+	if (bitsPerSample == 16) lengthSamples >>= 1;
+
+	freq = samplesPerSec;
+	len = lengthSamples;
+	bits16 = (bitsPerSample == 16);
+	stereo = (channels == 2);
+
+	return data + offset;
+}
+
+struct Mixer_impl {
+
+	static const int kMixFreq = 44100;
+	static const SDL_AudioFormat kMixFormat = AUDIO_S16SYS;
+	static const int kMixSoundChannels = 2;
+	static const int kMixBufSize = 4096;
+	static const int kMixChannels = 4;
+
+	Mix_Chunk *_sounds[kMixChannels];
+	Mix_Music *_music;
+	MixerChannel _channels[kMixChannels];
+	SfxPlayer *_sfx;
+	std::map<int, Mix_Chunk *> _preloads; // AIFF preloads (3DO)
+
+	void init(MixerType mixerType) {
+		memset(_sounds, 0, sizeof(_sounds));
+		_music = 0;
+		memset(_channels, 0, sizeof(_channels));
+		for (int i = 0; i < kMixChannels; ++i) {
+			_channels[i]._mixWav = &MixerChannel::mixWav<8, false>;
+		}
+		_sfx = 0;
+
+		Mix_Init(MIX_INIT_OGG | MIX_INIT_FLUIDSYNTH);
+		if (Mix_OpenAudio(kMixFreq, kMixFormat, kMixSoundChannels, kMixBufSize) < 0) {
+			warning("Mix_OpenAudio failed: %s", Mix_GetError());
+		}
+		switch (mixerType) {
+		case kMixerTypeRaw:
+			Mix_HookMusic(mixAudio, this);
+			break;
+		case kMixerTypeWav:
+			Mix_SetPostMix(mixAudioWav, this);
+			break;
+		case kMixerTypeAiff:
+			Mix_AllocateChannels(kMixChannels);
+			break;
+		}
+	}
+	void quit() {
+		stopAll();
+		Mix_CloseAudio();
+		Mix_Quit();
+	}
+
+	void update() {
+		for (int i = 0; i < kMixChannels; ++i) {
+			if (_sounds[i] && !Mix_Playing(i)) {
+				freeSound(i);
+			}
+		}
+	}
+
+	void playSoundRaw(uint8_t channel, const uint8_t *data, int freq, uint8_t volume) {
+		SDL_LockAudio();
+		_channels[channel].initRaw(data, freq, volume, kMixFreq);
+		SDL_UnlockAudio();
+	}
+	void playSoundWav(uint8_t channel, const uint8_t *data, int freq, uint8_t volume, bool loop) {
+		int wavFreq, len;
+		bool bits16, stereo;
+		const uint8_t *wavData = loadWav(data, wavFreq, len, bits16, stereo);
+		if (!wavData) return;
+
+		if (wavFreq == 22050 || wavFreq == 44100 || wavFreq == 48000) {
+			freq = (int)(freq * (wavFreq / 9943.0f));
+		}
+
+		SDL_LockAudio();
+		_channels[channel].initWav(wavData, freq, volume, kMixFreq, len, bits16, stereo, loop);
+		SDL_UnlockAudio();
+	}
+	void playSound(uint8_t channel, int volume, Mix_Chunk *chunk, int loops = 0) {
+		stopSound(channel);
+		if (chunk) {
+			Mix_PlayChannel(channel, chunk, loops);
+		}
+		setChannelVolume(channel, volume);
+		_sounds[channel] = chunk;
+	}
+	void stopSound(uint8_t channel) {
+		SDL_LockAudio();
+		_channels[channel]._data = 0;
+		SDL_UnlockAudio();
+		Mix_HaltChannel(channel);
+		freeSound(channel);
+	}
+	void freeSound(int channel) {
+		Mix_FreeChunk(_sounds[channel]);
+		_sounds[channel] = 0;
+	}
+	void setChannelVolume(uint8_t channel, uint8_t volume) {
+		SDL_LockAudio();
+		_channels[channel]._volume = volume;
+		SDL_UnlockAudio();
+		Mix_Volume(channel, volume * MIX_MAX_VOLUME / 63);
+	}
+
+	void playMusic(const char *path, int loops = 0) {
+		stopMusic();
+		_music = Mix_LoadMUS(path);
+		if (_music) {
+			Mix_VolumeMusic(MIX_MAX_VOLUME / 2);
+			Mix_PlayMusic(_music, loops);
+		} else {
+			warning("Failed to load music '%s', %s", path, Mix_GetError());
+		}
+	}
+	void stopMusic() {
+		Mix_HaltMusic();
+		Mix_FreeMusic(_music);
+		_music = 0;
+	}
+
+	static void mixAifcPlayer(void *data, uint8_t *s16buf, int len) {
+		((AifcPlayer *)data)->readSamples((int16_t *)s16buf, len / 2);
+	}
+	void playAifcMusic(AifcPlayer *aifc) {
+		Mix_HookMusic(mixAifcPlayer, aifc);
+	}
+	void stopAifcMusic() {
+		Mix_HookMusic(0, 0);
+	}
+
+	void playSfxMusic(SfxPlayer *sfx) {
+		SDL_LockAudio();
+		_sfx = sfx;
+		_sfx->play(kMixFreq);
+		SDL_UnlockAudio();
+	}
+	void stopSfxMusic() {
+		SDL_LockAudio();
+		if (_sfx) {
+			_sfx->stop();
+			_sfx = 0;
+		}
+		SDL_UnlockAudio();
+	}
+
+	void mixChannels(int16_t *samples, int count) {
+		if (kAmigaStereoChannels) {
+			for (int i = 0; i < count; i += 2) {
+				_channels[0].mixRaw(*samples);
+				_channels[3].mixRaw(*samples);
+				++samples;
+				_channels[1].mixRaw(*samples);
+				_channels[2].mixRaw(*samples);
+				++samples;
+			}
+		} else {
+			for (int i = 0; i < count; i += 2) {
+				for (int j = 0; j < kMixChannels; ++j) {
+					_channels[j].mixRaw(samples[i]);
+				}
+				samples[i + 1] = samples[i];
+			}
+		}
+	}
+
+	static void mixAudio(void *data, uint8_t *s16buf, int len) {
+		memset(s16buf, 0, len);
+		Mixer_impl *mixer = (Mixer_impl *)data;
+		mixer->mixChannels((int16_t *)s16buf, len / sizeof(int16_t));
+		if (mixer->_sfx) {
+			mixer->_sfx->readSamples((int16_t *)s16buf, len / sizeof(int16_t));
+		}
+	}
+
+	void mixChannelsWav(int16_t *samples, int count) {
+		for (int i = 0; i < kMixChannels; ++i) {
+			if (_channels[i]._data) {
+				(_channels[i].*_channels[i]._mixWav)(samples, count);
+			}
+		}
+	}
+
+	static void mixAudioWav(void *data, uint8_t *s16buf, int len) {
+		Mixer_impl *mixer = (Mixer_impl *)data;
+		mixer->mixChannelsWav((int16_t *)s16buf, len / sizeof(int16_t));
+	}
+
+	void stopAll() {
+		for (int i = 0; i < kMixChannels; ++i) {
+			stopSound(i);
+		}
+		stopMusic();
+		stopSfxMusic();
+		for (std::map<int, Mix_Chunk *>::iterator it = _preloads.begin(); it != _preloads.end(); ++it) {
+			debug(DBG_SND, "Flush preload %d", it->first);
+			Mix_FreeChunk(it->second);
+		}
+		_preloads.clear();
+	}
+
+	void preloadSoundAiff(int num, const uint8_t *data) {
+		if (_preloads.find(num) != _preloads.end()) {
+			warning("AIFF sound %d is already preloaded", num);
+		} else {
+			const uint32_t size = READ_BE_UINT32(data + 4) + 8;
+			SDL_RWops *rw = SDL_RWFromConstMem(data, size);
+			Mix_Chunk *chunk = Mix_LoadWAV_RW(rw, 1);
+			_preloads[num] = chunk;
+		}
+	}
+
+	void playSoundAiff(int channel, int num, int volume) {
+		if (_preloads.find(num) == _preloads.end()) {
+			warning("AIFF sound %d is not preloaded", num);
+		} else {
+			Mix_Chunk *chunk = _preloads[num];
+			Mix_PlayChannel(channel, chunk, 0);
+			Mix_Volume(channel, volume * MIX_MAX_VOLUME / 63);
+		}
+	}
+};
+
+Mixer::Mixer(SfxPlayer *sfx)
+	: _aifc(0), _sfx(sfx) {
+}
+
+void Mixer::init(MixerType mixerType) {
+	_impl = new Mixer_impl();
+	_impl->init(mixerType);
+}
+
+void Mixer::quit() {
+	stopAll();
+	if (_impl) {
+		_impl->quit();
+		delete _impl;
+	}
+	delete _aifc;
+}
+
+void Mixer::update() {
+	if (_impl) {
+		_impl->update();
+	}
+}
+
+void Mixer::playSoundRaw(uint8_t channel, const uint8_t *data, uint16_t freq, uint8_t volume) {
+	debug(DBG_SND, "Mixer::playChannel(%d, %d, %d)", channel, freq, volume);
+	if (_impl) {
+		return _impl->playSoundRaw(channel, data, freq, volume);
+	}
+}
+
+void Mixer::playSoundWav(uint8_t channel, const uint8_t *data, uint16_t freq, uint8_t volume, uint8_t loop) {
+	debug(DBG_SND, "Mixer::playSoundWav(%d, %d, %d)", channel, volume, loop);
+	if (_impl) {
+		return _impl->playSoundWav(channel, data, freq, volume, loop);
+	}
+}
+
+void Mixer::stopSound(uint8_t channel) {
+	debug(DBG_SND, "Mixer::stopChannel(%d)", channel);
+	if (_impl) {
+		return _impl->stopSound(channel);
+	}
+}
+
+void Mixer::setChannelVolume(uint8_t channel, uint8_t volume) {
+	debug(DBG_SND, "Mixer::setChannelVolume(%d, %d)", channel, volume);
+	if (_impl) {
+		return _impl->setChannelVolume(channel, volume);
+	}
+}
+
+void Mixer::playMusic(const char *path, uint8_t loop) {
+	debug(DBG_SND, "Mixer::playMusic(%s, %d)", path, loop);
+	if (_impl) {
+		return _impl->playMusic(path, (loop != 0) ? -1 : 0);
+	}
+}
+
+void Mixer::stopMusic() {
+	debug(DBG_SND, "Mixer::stopMusic()");
+	if (_impl) {
+		return _impl->stopMusic();
+	}
+}
+
+void Mixer::playAifcMusic(const char *path, uint32_t offset) {
+	debug(DBG_SND, "Mixer::playAifcMusic(%s)", path);
+	if (!_aifc) {
+		_aifc = new AifcPlayer();
+	}
+	if (_impl) {
+		_impl->stopAifcMusic();
+		if (_aifc->play(Mixer_impl::kMixFreq, path, offset)) {
+			_impl->playAifcMusic(_aifc);
+		}
+	}
+}
+
+void Mixer::stopAifcMusic() {
+	debug(DBG_SND, "Mixer::stopAifcMusic()");
+	if (_impl && _aifc) {
+		_aifc->stop();
+		_impl->stopAifcMusic();
+	}
+}
+
+void Mixer::playSfxMusic(int num) {
+	debug(DBG_SND, "Mixer::playSfxMusic(%d)", num);
+	if (_impl && _sfx) {
+		return _impl->playSfxMusic(_sfx);
+	}
+}
+
+void Mixer::stopSfxMusic() {
+	debug(DBG_SND, "Mixer::stopSfxMusic()");
+	if (_impl && _sfx) {
+		return _impl->stopSfxMusic();
+	}
+}
+
+void Mixer::stopAll() {
+	debug(DBG_SND, "Mixer::stopAll()");
+	if (_impl) {
+		return _impl->stopAll();
+	}
+}
+
+void Mixer::preloadSoundAiff(uint8_t num, const uint8_t *data) {
+	debug(DBG_SND, "Mixer::preloadSoundAiff(num:%d, data:%p)", num, data);
+	if (_impl) {
+		return _impl->preloadSoundAiff(num, data);
+	}
+}
+
+void Mixer::playSoundAiff(uint8_t channel, uint8_t num, uint8_t volume) {
+	debug(DBG_SND, "Mixer::playSoundAiff()");
+	if (_impl) {
+		return _impl->playSoundAiff(channel, num, volume);
+	}
+}
+#endif
+
+} // namespace Awe
diff --git a/engines/awe/mixer.h b/engines/awe/mixer.h
new file mode 100644
index 00000000000..eb28000e67c
--- /dev/null
+++ b/engines/awe/mixer.h
@@ -0,0 +1,68 @@
+/* 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 AWE_MIXER_H
+#define AWE_MIXER_H
+
+#include "awe/intern.h"
+
+namespace Awe {
+
+enum MixerType {
+	kMixerTypeRaw,
+	kMixerTypeWav,
+	kMixerTypeAiff
+};
+
+#ifdef TODO
+struct AifcPlayer;
+struct SfxPlayer;
+struct Mixer_impl;
+
+struct Mixer {
+	AifcPlayer *_aifc;
+	SfxPlayer *_sfx;
+	Mixer_impl *_impl;
+
+	Mixer(SfxPlayer *sfx);
+	void init(MixerType mixerType);
+	void quit();
+	void update();
+
+	void playSoundRaw(uint8_t channel, const uint8_t *data, uint16_t freq, uint8_t volume);
+	void playSoundWav(uint8_t channel, const uint8_t *data, uint16_t freq, uint8_t volume, uint8_t loop);
+	void stopSound(uint8_t channel);
+	void setChannelVolume(uint8_t channel, uint8_t volume);
+	void playMusic(const char *path, uint8_t loop);
+	void stopMusic();
+	void playAifcMusic(const char *path, uint32_t offset);
+	void stopAifcMusic();
+	void playSfxMusic(int num);
+	void stopSfxMusic();
+	void stopAll();
+	void preloadSoundAiff(uint8_t num, const uint8_t *data);
+	void playSoundAiff(uint8_t channel, uint8_t num, uint8_t volume);
+};
+#endif
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/module.mk b/engines/awe/module.mk
index fd062dfe6da..46b98f96fb4 100644
--- a/engines/awe/module.mk
+++ b/engines/awe/module.mk
@@ -3,12 +3,27 @@ MODULE := engines/awe
 MODULE_OBJS = \
 	metaengine.o \
 	awe.o \
-	bank.o \
-	logic.o \
+	aifcplayer.o \
+	bitmap.o \
+	detection.o \
+	engine.o \
+	file.o \
+	graphics_gl.o \
+	graphics_soft.o \
+	metaengine.o \
+	mixer.o \
+	pak.o \
 	resource.o \
-	serializer.o \
+	resource_3do.o \
+	resource_nth.o \
+	resource_win31.o \
+	scaler.o \
+	screenshot.o \
+	script.o \
+	sfxplayer.o \
 	staticres.o \
-	system_stub.o \
+	systemstub_sdl.o \
+	unpack.o \
 	util.o \
 	video.o
 
diff --git a/engines/awe/pak.cpp b/engines/awe/pak.cpp
new file mode 100644
index 00000000000..0f9995b9604
--- /dev/null
+++ b/engines/awe/pak.cpp
@@ -0,0 +1,150 @@
+/* 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 "awe/pak.h"
+#include "awe/util.h"
+
+namespace Awe {
+
+// static const uint32_t XOR_KEY1 = 0x31111612;
+static const uint32_t XOR_KEY2 = 0x22683297;
+static const uint32_t CHECKSUM = 0x20202020;
+
+static uint8_t *decode_toodc(uint8_t *p, int count) {
+	uint32_t key = XOR_KEY2;
+	uint32_t acc = 0;
+	for (int i = 0; i < count; ++i) {
+		uint8_t *q = p + i * 4;
+		const uint32_t data = READ_LE_UINT32(q) ^ key;
+		uint32_t r = (q[2] + q[1] + q[0]) ^ q[3];
+		r += acc;
+		key += r;
+		acc += 0x4D;
+		WRITE_LE_UINT32(q, data);
+	}
+	return p + 4;
+}
+
+const char *Pak::FILENAME = "Pak01.pak";
+
+Pak::Pak()
+	: _entries(0), _entriesCount(0) {
+}
+
+Pak::~Pak() {
+	close();
+}
+
+void Pak::open(const char *dataPath) {
+	_f.open(FILENAME, dataPath);
+}
+
+void Pak::close() {
+	free(_entries);
+	_entries = 0;
+	_entriesCount = 0;
+}
+
+static int comparePakEntry(const void *a, const void *b) {
+	return scumm_stricmp(((PakEntry *)a)->name, ((PakEntry *)b)->name);
+}
+
+void Pak::readEntries() {
+	uint8_t header[12];
+
+	memset(header, 0, sizeof(header));
+	_f.read(header, sizeof(header));
+	if (_f.ioErr() || memcmp(header, "PACK", 4) != 0) {
+		return;
+	}
+	const uint32_t entriesOffset = READ_LE_UINT32(header + 4);
+	_f.seek(entriesOffset);
+	const uint32_t entriesSize = READ_LE_UINT32(header + 8);
+	_entriesCount = entriesSize / 0x40;
+	debug(DBG_PAK, "Pak::readEntries() entries count %d", _entriesCount);
+	_entries = (PakEntry *)calloc(_entriesCount, sizeof(PakEntry));
+	if (!_entries) {
+		_entriesCount = 0;
+		return;
+	}
+	for (int i = 0; i < _entriesCount; ++i) {
+		uint8_t buf[0x40];
+		_f.read(buf, sizeof(buf));
+		if (_f.ioErr()) {
+			break;
+		}
+		const char *name = (const char *)buf;
+		if (strncmp(name, "dlx/", 4) != 0) {
+			continue;
+		}
+		PakEntry *e = &_entries[i];
+		Common::strcpy_s(e->name, name + 4);
+		e->offset = READ_LE_UINT32(buf + 0x38);
+		e->size = READ_LE_UINT32(buf + 0x3C);
+		debug(DBG_PAK, "Pak::readEntries() buf '%s' size %d", e->name, e->size);
+	}
+	qsort(_entries, _entriesCount, sizeof(PakEntry), comparePakEntry);
+	// the original executable descrambles the (ke)y.txt file and check the last 4 bytes.
+	// this has been disabled in later re-releases and a key is bundled in the data files
+	if (0) {
+		uint8_t buf[128];
+		const PakEntry *e = find("check.txt");
+		if (e && e->size <= sizeof(buf)) {
+			uint32_t size = 0;
+			loadData(e, buf, &size);
+			assert(size >= 4);
+			const uint32_t num = READ_LE_UINT32(buf + size - 4);
+			assert(num == CHECKSUM);
+		}
+	}
+}
+
+const PakEntry *Pak::find(const char *name) {
+	debug(DBG_PAK, "Pak::find() '%s'", name);
+	PakEntry tmp;
+	Common::strcpy_s(tmp.name, name);
+	return (const PakEntry *)bsearch(&tmp, _entries, _entriesCount, sizeof(PakEntry), comparePakEntry);
+}
+
+void Pak::loadData(const PakEntry *e, uint8_t *buf, uint32_t *size) {
+	debug(DBG_PAK, "Pak::loadData() %d bytes from 0x%x", e->size, e->offset);
+	_f.seek(e->offset);
+	if (_f.ioErr()) {
+		*size = 0;
+		return;
+	}
+	_f.read(buf, e->size);
+	if (e->size > 5 && memcmp(buf, "TooDC", 5) == 0) {
+		const int dataSize = e->size - 6;
+		debug(DBG_PAK, "Pak::loadData() encoded TooDC data, size %d", dataSize);
+		if ((dataSize & 3) != 0) {
+			// descrambler operates on uint32_t
+			warning("Unexpected size %d for encoded TooDC data '%s'", dataSize, e->name);
+		}
+		*size = dataSize - 4;
+		decode_toodc(buf + 6, (dataSize + 3) / 4);
+		memmove(buf, buf + 10, dataSize - 4);
+	} else {
+		*size = e->size;
+	}
+}
+
+} // namespace Awe
diff --git a/engines/awe/bank.h b/engines/awe/pak.h
similarity index 69%
rename from engines/awe/bank.h
rename to engines/awe/pak.h
index ab51d7fe77f..234dffbc788 100644
--- a/engines/awe/bank.h
+++ b/engines/awe/pak.h
@@ -19,35 +19,36 @@
  *
  */
 
-#ifndef AWE_BANK_H
-#define AWE_BANK_H
+#ifndef AWE_PAK_H
+#define AWE_PAK_H
 
 #include "awe/intern.h"
+#include "awe/file.h"
 
 namespace Awe {
 
-struct MemEntry;
-
-struct UnpackContext {
-	uint16 size;
-	uint32 crc;
-	uint32 chk;
-	int32 datasize;
+struct PakEntry {
+	char name[32];
+	uint32_t offset;
+	uint32_t size;
 };
 
-struct Bank {
-	UnpackContext _unpCtx;
-	uint8 *_iBuf, *_oBuf, *_startBuf;
+struct Pak {
+	static const char *FILENAME;
+
+	File _f;
+	PakEntry *_entries;
+	int _entriesCount;
+
+	Pak();
+	~Pak();
 
-	Bank();
+	void open(const char *dataPath);
+	void close();
 
-	bool read(const MemEntry *me, uint8 *buf);
-	void decUnk1(uint8 numChunks, uint8 addCount);
-	void decUnk2(uint8 numChunks);
-	bool unpack();
-	uint16 getCode(uint8 numChunks);
-	bool nextChunk();
-	bool rcr(bool CF);
+	void readEntries();
+	const PakEntry *find(const char *name);
+	void loadData(const PakEntry *e, uint8_t *buf, uint32_t *size);
 };
 
 } // namespace Awe
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 67996e30cc9..eb19b3de106 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -19,265 +19,710 @@
  *
  */
 
-#include "common/file.h"
-#include "awe/awe.h"
 #include "awe/resource.h"
-#include "awe/bank.h"
-#include "awe/serializer.h"
+#include "awe/file.h"
+#include "awe/pak.h"
+#include "awe/resource_nth.h"
+#include "awe/resource_win31.h"
+#include "awe/resource_3do.h"
+#include "awe/unpack.h"
+#include "awe/util.h"
 #include "awe/video.h"
 
 namespace Awe {
 
-Resource::Resource(Video *vid) : _vid(vid) {
+static const char *atariDemo = "aw.tos";
+
+Resource::Resource(Video *vid, const char *dataDir)
+	: _vid(vid), _dataDir(dataDir), _currentPart(0), _nextPart(0), _dataType(DT_DOS), _nth(0), _win31(0), _3do(0) {
+	_bankPrefix = "bank";
+	_hasPasswordScreen = true;
+	memset(_memList, 0, sizeof(_memList));
+	_numMemList = 0;
+	if (!_dataDir) {
+		_dataDir = ".";
+	}
+	_lang = LANG_FR;
+	_amigaMemList = 0;
+	memset(&_demo3Joy, 0, sizeof(_demo3Joy));
+}
+
+Resource::~Resource() {
+	free(_demo3Joy.bufPtr);
+	delete _nth;
+	delete _win31;
+	delete _3do;
 }
 
-void Resource::readBank(const MemEntry *me, uint8 *dstBuf) {
-	uint16 n = me - _memList;
-	debugC(kDebugBank, "Resource::readBank(%d)", n);
-#ifdef USE_UNPACKED
-	char bankEntryName[64];
-	sprintf(bankEntryName, "ootw-%02X-%d.dump", n, me->type);
+bool Resource::readBank(const MemEntry *me, uint8_t *dstBuf) {
+	bool ret = false;
+	char name[10];
+	snprintf(name, sizeof(name), "%s%02x", _bankPrefix, me->bankNum);
 	File f;
-	if (!f.open(bankEntryName, _dataDir)) {
-		error("Resource::readBank() unable to open '%s' file\n", bankEntryName);
+	if (f.open(name, _dataDir) || (_dataType == DT_ATARI_DEMO && f.open(atariDemo, _dataDir))) {
+		f.seek(me->bankPos);
+		const size_t count = f.read(dstBuf, me->packedSize);
+		ret = (count == me->packedSize);
+		if (ret && me->packedSize != me->unpackedSize) {
+			ret = bytekiller_unpack(dstBuf, me->unpackedSize, dstBuf, me->packedSize);
+		}
 	}
-	f.read(dstBuf, me->unpackedSize);
-#else
-	Bank bk;
-	if (!bk.read(me, dstBuf)) {
-		error("Resource::readBank() unable to unpack entry %d\n", n);
+	return ret;
+}
+
+static bool check15th(File &f, const char *dataDir) {
+	char path[MAXPATHLEN];
+	snprintf(path, sizeof(path), "%s/Data", dataDir);
+	return f.open(Pak::FILENAME, path);
+}
+
+static bool check20th(File &f, const char *dataDir) {
+	char path[MAXPATHLEN];
+	snprintf(path, sizeof(path), "%s/game/DAT", dataDir);
+	return f.open("FILE017.DAT", path);
+}
+
+static bool check3DO(File &f, const char *dataDir) {
+	const char *ext = strrchr(dataDir, '.');
+	if (ext && scumm_stricmp(ext, ".iso") == 0) {
+		return f.open(dataDir);
 	}
-#endif
+	char path[MAXPATHLEN];
+	snprintf(path, sizeof(path), "%s/GameData", dataDir);
+	return f.open("File340", path);
 }
 
-void Resource::readEntries() {	
-	Common::File f;
-	if (!f.open("memlist.bin")) {
-		error("Resource::readEntries() unable to open 'memlist.bin' file\n");
+static const AmigaMemEntry *detectAmigaAtari(File &f, const char *dataDir) {
+	static const struct {
+		uint32_t bank01Size;
+		const AmigaMemEntry *entries;
+	} _files[] = {
+		{ 244674, Resource::_memListAmigaFR },
+		{ 244868, Resource::_memListAmigaEN },
+		{ 227142, Resource::_memListAtariEN },
+		{ 0, 0 }
+	};
+	if (f.open("bank01", dataDir)) {
+		const uint32_t size = f.size();
+		for (int i = 0; _files[i].entries; ++i) {
+			if (_files[i].bank01Size == size) {
+				return _files[i].entries;
+			}
+		}
 	}
-	_numMemList = 0;
-	MemEntry *me = _memList;
-	while (1) {
-		assert(_numMemList < ARRAYSIZE(_memList));
-		me->valid = f.readByte();
-		me->type = f.readByte();
-		me->bufPtr = 0; f.readUint16BE();
-		me->unk4 = f.readUint16BE();
-		me->rankNum = f.readByte();
-		me->bankNum = f.readByte();
-		me->bankPos = f.readUint32BE();
-		me->unkC = f.readUint16BE();
-		me->packedSize = f.readUint16BE();
-		me->unk10 = f.readUint16BE();
-		me->unpackedSize = f.readUint16BE();
-		if (me->valid == 0xFF) {
-			break;
+	return 0;
+}
+
+void Resource::detectVersion() {
+	File f;
+	if (check15th(f, _dataDir)) {
+		_dataType = DT_15TH_EDITION;
+		debug(DBG_INFO, "Using 15th anniversary edition data files");
+	} else if (check20th(f, _dataDir)) {
+		_dataType = DT_20TH_EDITION;
+		debug(DBG_INFO, "Using 20th anniversary edition data files");
+	} else if (f.open("memlist.bin", _dataDir)) {
+		_dataType = DT_DOS;
+		debug(DBG_INFO, "Using DOS data files");
+	} else if ((_amigaMemList = detectAmigaAtari(f, _dataDir)) != 0) {
+		if (_amigaMemList == _memListAtariEN) {
+			_dataType = DT_ATARI;
+			debug(DBG_INFO, "Using Atari data files");
+		} else {
+			_dataType = DT_AMIGA;
+			debug(DBG_INFO, "Using Amiga data files");
+		}
+	} else if (f.open(ResourceWin31::FILENAME, _dataDir)) {
+		_dataType = DT_WIN31;
+		debug(DBG_INFO, "Using Win31 data files");
+	} else if (check3DO(f, _dataDir)) {
+		_dataType = DT_3DO;
+		debug(DBG_INFO, "Using 3DO data files");
+	} else if (f.open(atariDemo, _dataDir) && f.size() == 96513) {
+		_dataType = DT_ATARI_DEMO;
+		debug(DBG_INFO, "Using Atari demo file");
+	} else {
+		error("No data files found in '%s'", _dataDir);
+	}
+}
+
+static const char *kGameTitleEU = "Another World";
+static const char *kGameTitleUS = "Out Of This World";
+static const char *kGameTitle15thEdition = "Another World 15th anniversary edition";
+static const char *kGameTitle20thEdition = "Another World 20th anniversary edition";
+
+const char *Resource::getGameTitle(Language lang) const {
+	switch (_dataType) {
+	case DT_15TH_EDITION:
+		return kGameTitle15thEdition;
+	case DT_20TH_EDITION:
+		return kGameTitle20thEdition;
+	case DT_3DO:
+		return kGameTitleUS;
+	case DT_DOS:
+		if (lang == LANG_US) {
+			return kGameTitleUS;
+		}
+		/* fall-through */
+	default:
+		break;
+	}
+	return kGameTitleEU;
+}
+
+void Resource::readEntries() {
+	switch (_dataType) {
+	case DT_15TH_EDITION:
+		_numMemList = ENTRIES_COUNT;
+		_nth = ResourceNth::create(15, _dataDir);
+		if (_nth && _nth->init()) {
+			return;
+		}
+		break;
+	case DT_20TH_EDITION:
+		_numMemList = ENTRIES_COUNT_20TH;
+		_nth = ResourceNth::create(20, _dataDir);
+		if (_nth && _nth->init()) {
+			return;
+		}
+		break;
+	case DT_AMIGA:
+	case DT_ATARI:
+		assert(_amigaMemList);
+		readEntriesAmiga(_amigaMemList, ENTRIES_COUNT);
+		return;
+	case DT_DOS:
+	{
+		_hasPasswordScreen = false; // DOS demo versions do not have the resources
+		File f;
+		if (f.open("demo01", _dataDir)) {
+			_bankPrefix = "demo";
+		}
+		if (f.open("memlist.bin", _dataDir)) {
+			MemEntry *me = _memList;
+			while (1) {
+				assert(_numMemList < ARRAYSIZE(_memList));
+				me->status = f.readByte();
+				me->type = f.readByte();
+				me->bufPtr = 0; f.readUint32BE();
+				me->rankNum = f.readByte();
+				me->bankNum = f.readByte();
+				me->bankPos = f.readUint32BE();
+				me->packedSize = f.readUint32BE();
+				me->unpackedSize = f.readUint32BE();
+				if (me->status == 0xFF) {
+					const int num = _memListParts[8][1]; // 16008 bytecode
+					assert(num < _numMemList);
+					char bank[16];
+					snprintf(bank, sizeof(bank), "%s%02x", _bankPrefix, _memList[num].bankNum);
+					_hasPasswordScreen = f.open(bank, _dataDir);
+					return;
+				}
+				++_numMemList;
+				++me;
+			}
+		}
+	}
+	break;
+	case DT_WIN31:
+		_numMemList = ENTRIES_COUNT;
+		_win31 = new ResourceWin31(_dataDir);
+		if (_win31->readEntries()) {
+			return;
+		}
+		break;
+	case DT_3DO:
+		_numMemList = ENTRIES_COUNT;
+		_3do = new Resource3do(_dataDir);
+		if (_3do->readEntries()) {
+			return;
+		}
+		break;
+	case DT_ATARI_DEMO:
+	{
+		File f;
+		if (f.open(atariDemo, _dataDir)) {
+			static const struct {
+				uint8_t type;
+				uint8_t num;
+				uint32_t offset;
+				uint16_t size;
+			} data[] = {
+				{ RT_SHAPE, 0x19, 0x50f0, 65146 },
+				{ RT_PALETTE, 0x17, 0x14f6a, 2048 },
+				{ RT_BYTECODE, 0x18, 0x1576a, 8368 }
+			};
+			_numMemList = ENTRIES_COUNT;
+			for (int i = 0; i < 3; ++i) {
+				MemEntry *entry = &_memList[data[i].num];
+				entry->type = data[i].type;
+				entry->bankNum = 15;
+				entry->bankPos = data[i].offset;
+				entry->packedSize = entry->unpackedSize = data[i].size;
+			}
+			return;
+		}
+	}
+	break;
+	}
+	error("No data files found in '%s'", _dataDir);
+}
+
+void Resource::readEntriesAmiga(const AmigaMemEntry *entries, int count) {
+	_numMemList = count;
+	for (int i = 0; i < count; ++i) {
+		_memList[i].type = entries[i].type;
+		_memList[i].bankNum = entries[i].bank;
+		_memList[i].bankPos = entries[i].offset;
+		_memList[i].packedSize = entries[i].packedSize;
+		_memList[i].unpackedSize = entries[i].unpackedSize;
+	}
+	_memList[count].status = 0xFF;
+}
+
+void Resource::dumpEntries() {
+	static const bool kDump = false;
+	if (kDump && (_dataType == DT_DOS || _dataType == DT_AMIGA || _dataType == DT_ATARI)) {
+		for (int i = 0; i < _numMemList; ++i) {
+			if (_memList[i].unpackedSize == 0) {
+				continue;
+			}
+			if (_memList[i].bankNum == 5 && (_dataType == DT_AMIGA || _dataType == DT_ATARI)) {
+				continue;
+			}
+			uint8_t *p = (uint8_t *)malloc(_memList[i].unpackedSize);
+			if (p) {
+				if (readBank(&_memList[i], p)) {
+					char name[16];
+					snprintf(name, sizeof(name), "data_%02x_%d", i, _memList[i].type);
+					dumpFile(name, p, _memList[i].unpackedSize);
+				}
+				free(p);
+			}
 		}
-		++_numMemList;
-		++me;
 	}
 }
 
 void Resource::load() {
 	while (1) {
-		MemEntry *it = _memList;
 		MemEntry *me = 0;
 
 		// get resource with max rankNum
-		uint8 maxNum = 0;
-		uint16 i = _numMemList;
-		while (i--) {
-			if (it->valid == 2 && maxNum <= it->rankNum) {
+		uint8_t maxNum = 0;
+		for (int i = 0; i < _numMemList; ++i) {
+			MemEntry *it = &_memList[i];
+			if (it->status == STATUS_TOLOAD && maxNum <= it->rankNum) {
 				maxNum = it->rankNum;
 				me = it;
 			}
-			++it;
 		}
 		if (me == 0) {
 			break; // no entry found
 		}
 
-		uint8 *memPtr = 0;
-		// XXX if (_audio_no_sound != 0 && _audio_use_roland != 0 && me->type < 2) {
-		// XXX		me->valid = 0;
-		// XXX		continue;
-		// XXX }
-		if (me->type == 2) {
+		const int resourceNum = me - _memList;
+
+		uint8_t *memPtr = 0;
+		if (me->type == RT_BITMAP) {
 			memPtr = _vidCurPtr;
 		} else {
 			memPtr = _scriptCurPtr;
-			if (me->unpackedSize > _vidBakPtr - _scriptCurPtr) {
-				warning("Resource::load() not enough memory");
-				me->valid = 0;
+			const uint32_t avail = uint32_t(_vidCurPtr - _scriptCurPtr);
+			if (me->unpackedSize > avail) {
+				warning("Resource::load() not enough memory, available=%d", avail);
+				me->status = STATUS_NULL;
 				continue;
 			}
 		}
 		if (me->bankNum == 0) {
 			warning("Resource::load() ec=0x%X (me->bankNum == 0)", 0xF00);
-			me->valid = 0;
+			me->status = STATUS_NULL;
 		} else {
-			debugC(kDebugBank, "Resource::load() bufPos=%X size=%X type=%X pos=%X bankNum=%X", memPtr - _memPtrStart, me->packedSize, me->type, me->bankPos, me->bankNum);
-			readBank(me, memPtr);
-			if(me->type == 2) {
-				_vid->copyPagePtr(_vidCurPtr);
-				me->valid = 0;
+			debug(DBG_BANK, "Resource::load() bufPos=0x%X size=%d type=%d pos=0x%X bankNum=%d", memPtr - _memPtrStart, me->packedSize, me->type, me->bankPos, me->bankNum);
+			if (readBank(me, memPtr)) {
+				if (me->type == RT_BITMAP) {
+					_vid->copyBitmapPtr(_vidCurPtr, me->unpackedSize);
+					me->status = STATUS_NULL;
+				} else {
+					me->bufPtr = memPtr;
+					me->status = STATUS_LOADED;
+					_scriptCurPtr += me->unpackedSize;
+				}
 			} else {
-				me->bufPtr = memPtr;
-				me->valid = 1;
-				_scriptCurPtr += me->unpackedSize;
+				if (_dataType == DT_DOS && me->bankNum == 12 && me->type == RT_BANK) {
+					// DOS demo version does not have the bank for this resource
+					// this should be safe to ignore as the resource does not appear to be used by the game code
+					me->status = STATUS_NULL;
+					continue;
+				}
+				error("Unable to read resource %d from bank %d", resourceNum, me->bankNum);
 			}
 		}
 	}
 }
 
 void Resource::invalidateRes() {
-	// XXX call ds:sound_stub_1_ptr
-	MemEntry *me = _memList;
-	uint16 i = _numMemList;
-	while (i--) {
+	for (int i = 0; i < _numMemList; ++i) {
+		MemEntry *me = &_memList[i];
 		if (me->type <= 2 || me->type > 6) {
-			me->valid = 0;
+			me->status = STATUS_NULL;
 		}
-		++me;
 	}
 	_scriptCurPtr = _scriptBakPtr;
+	_vid->_currentPal = 0xFF;
 }
 
 void Resource::invalidateAll() {
-	MemEntry *me = _memList;
-	uint16 i = _numMemList;
-	while (i--) {
-		me->valid = 0;
-		++me;
+	for (int i = 0; i < _numMemList; ++i) {
+		_memList[i].status = STATUS_NULL;
 	}
 	_scriptCurPtr = _memPtrStart;
+	_vid->_currentPal = 0xFF;
 }
 
-void Resource::update(uint16 num) {
-	if (num == 0) {
-		invalidateRes();
-	} else {
-		if (num > _numMemList) {
-			_newPtrsId = num;
-		} else {
-			if (false) { // XXX (_audio_use_pro_or_adlib == 1 || _audio_use_spk == 1) {
-				for (const uint16 *ml = MEMLIST_AUDIO; *ml != 0xFFFF; ++ml) {
-					if (*ml == num)
-						return;
-				}
+static const uint8_t *getSoundsList3DO(int num) {
+	static const uint8_t intro7[] = {
+		0x33, 0xFF
+	};
+	static const uint8_t water7[] = {
+		0x08, 0x10, 0x2D, 0x30, 0x31, 0x32, 0x35, 0x39, 0x3A, 0x3C,
+		0x3D, 0x3E, 0x4A, 0x4B, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
+		0x54, 0xFF
+	};
+	static const uint8_t pri1[] = {
+		0x52, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D,
+		0x5E, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+		0x69, 0x70, 0x71, 0x72, 0x73, 0xFF
+	};
+	static const uint8_t cite1[] = {
+		0x02, 0x03, 0x52, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B,
+		0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x63, 0x66, 0x6A, 0x6B, 0x6C,
+		0x6D, 0x6E, 0x6F, 0x70, 0x72, 0x74, 0x75, 0x77, 0x78, 0x79,
+		0x7A, 0x7B, 0x7C, 0x88, 0xFF
+	};
+	static const uint8_t arene2[] = {
+		0x52, 0x57, 0x58, 0x59, 0x5B, 0x84, 0x8B, 0x8C, 0x8E, 0xFF
+	};
+	static const uint8_t luxe2[] = {
+		0x30, 0x52, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C,
+		0x5D, 0x5E, 0x5F, 0x60, 0x66, 0x67, 0x6B, 0x6C, 0x70, 0x74,
+		0x75, 0x79, 0x7A, 0x8D, 0xFF
+	};
+	static const uint8_t final3[] = {
+		0x08, 0x0E, 0x0F, 0x57, 0xFF
+	};
+	switch (num) {
+	case 2001: return intro7;
+	case 2002: return water7;
+	case 2003: return pri1;
+	case 2004: return cite1;
+	case 2005: return arene2;
+	case 2006: return luxe2;
+	case 2007: return final3;
+	}
+	return 0;
+}
+
+static const int _memListBmp[] = {
+	145, 144, 73, 72, 70, 69, 68, 67, -1
+};
+
+void Resource::update(uint16_t num, PreloadSoundProc preloadSound, void *data) {
+	if (num > 16000) {
+		_nextPart = num;
+		return;
+	}
+	switch (_dataType) {
+	case DT_15TH_EDITION:
+	case DT_20TH_EDITION:
+		if (num >= 3000) {
+			loadBmp(num);
+			break;
+		} else if (num >= 2000) {
+			break;
+		}
+		/* fall-through */
+	case DT_WIN31:
+		if (num == 71 || num == 83) {
+			loadBmp(num);
+			break;
+		}
+		for (int i = 0; _memListBmp[i] != -1; ++i) {
+			if (num == _memListBmp[i]) {
+				loadBmp(num);
+				return;
 			}
-			MemEntry *me = &_memList[num];
-			if (me->valid == 0) {
-				me->valid = 2;
-				load();
+		}
+		break;
+	case DT_3DO:
+		if (num >= 2000) { // preload sounds
+			const uint8_t *soundsList = getSoundsList3DO(num);
+			for (int i = 0; soundsList[i] != 255; ++i) {
+				const int soundNum = soundsList[i];
+				loadDat(soundNum);
+				if (_memList[soundNum].status == STATUS_LOADED) {
+					preloadSound(data, soundNum, _memList[soundNum].bufPtr);
+				}
 			}
+		} else if (num >= 200) {
+			loadBmp(num);
+		}
+		break;
+	case DT_AMIGA:
+	case DT_ATARI:
+	case DT_ATARI_DEMO:
+	case DT_DOS:
+		MemEntry *me = &_memList[num];
+		if (me->status == STATUS_NULL) {
+			me->status = STATUS_TOLOAD;
+			load();
+		}
+		break;
+	}
+}
+
+void Resource::loadBmp(int num) {
+	uint32_t size = 0;
+	uint8_t *p = 0;
+	switch (_dataType) {
+	case DT_15TH_EDITION:
+	case DT_20TH_EDITION:
+		p = _nth->loadBmp(num);
+		break;
+	case DT_WIN31:
+		p = _win31->loadFile(num, 0, &size);
+		break;
+	case DT_3DO:
+		p = _3do->loadFile(num, 0, &size);
+		break;
+	default:
+		break;
+	}
+	if (p) {
+		_vid->copyBitmapPtr(p, size);
+		free(p);
+	}
+}
+
+uint8_t *Resource::loadDat(int num) {
+	assert(num < _numMemList);
+	if (_memList[num].status == STATUS_LOADED) {
+		return _memList[num].bufPtr;
+	}
+	uint32_t size = 0;
+	uint8_t *p = 0;
+	switch (_dataType) {
+	case DT_15TH_EDITION:
+	case DT_20TH_EDITION:
+		p = _nth->loadDat(num, _scriptCurPtr, &size);
+		break;
+	case DT_WIN31:
+		p = _win31->loadFile(num, _scriptCurPtr, &size);
+		break;
+	case DT_3DO:
+		p = _3do->loadFile(num, _scriptCurPtr, &size);
+		break;
+	default:
+		break;
+	}
+	if (p) {
+		_scriptCurPtr += size;
+		_memList[num].bufPtr = p;
+		_memList[num].status = STATUS_LOADED;
+	}
+	return p;
+}
+
+void Resource::loadFont() {
+	if (_nth) {
+		uint8_t *p = _nth->load("font.bmp");
+		if (p) {
+			_vid->setFont(p);
+			free(p);
+		}
+	}
+}
+
+void Resource::loadHeads() {
+	if (_nth) {
+		uint8_t *p = _nth->load("heads.bmp");
+		if (p) {
+			_vid->setHeads(p);
+			free(p);
 		}
 	}
 }
 
-void Resource::setupPtrs(uint16 ptrId) {
-	if (ptrId != _curPtrsId) {
-		uint8 ipal = 0;
-		uint8 icod = 0;
-		uint8 ivd1 = 0;
-		uint8 ivd2 = 0;
+uint8_t *Resource::loadWav(int num) {
+	if (_memList[num].status == STATUS_LOADED) {
+		return _memList[num].bufPtr;
+	}
+	uint32_t size = 0;
+	uint8_t *p = 0;
+	switch (_dataType) {
+	case DT_15TH_EDITION:
+	case DT_20TH_EDITION:
+		p = _nth->loadWav(num, _scriptCurPtr, &size);
+		break;
+	case DT_WIN31:
+		p = _win31->loadFile(num, _scriptCurPtr, &size);
+		break;
+	default:
+		break;
+	}
+	if (p && size != 0) {
+		_scriptCurPtr += size;
+		_memList[num].bufPtr = p;
+		_memList[num].status = STATUS_LOADED;
+	}
+	return p;
+}
 
-		static const auto &parts = g_engine->isDemo() ?
-			MEM_LIST_DEMO_PARTS : MEM_LIST_PARTS;
+const char *Resource::getString(int num) {
+	switch (_dataType) {
+	case DT_15TH_EDITION:
+	case DT_20TH_EDITION:
+		return _nth->getString(_lang, num);
+	case DT_WIN31:
+		return _win31->getString(num);
+	default:
+		break;
+	}
+	return 0;
+}
 
-		if (ptrId >= 0x3E80 && ptrId <= 0x3E89) {
-			uint16 part = ptrId - 0x3E80;
-			ipal = MEM_LIST_PARTS[part][0];
-			icod = MEM_LIST_PARTS[part][1];
-			ivd1 = MEM_LIST_PARTS[part][2];
-			ivd2 = MEM_LIST_PARTS[part][3];
+const char *Resource::getMusicPath(int num, char *buf, int bufSize, uint32_t *offset) {
+	const char *name = 0;
+	switch (_dataType) {
+	case DT_15TH_EDITION:
+	case DT_20TH_EDITION:
+		name = _nth->getMusicName(num);
+		break;
+	case DT_WIN31:
+		name = _win31->getMusicName(num);
+		break;
+	case DT_3DO:
+		assert(offset);
+		name = _3do->getMusicName(num, offset);
+		if (*offset != 0) {
+			return _dataDir; // playing music from .ISO
+		}
+		break;
+	default:
+		break;
+	}
+	if (name) {
+		snprintf(buf, bufSize, "%s/%s", _dataDir, name);
+		return buf;
+	}
+	return 0;
+}
 
-			if (g_engine->isDemo() && ptrId == 0x3e82) {
+const uint8_t Resource::_memListParts[][4] = {
+	{ 0x14, 0x15, 0x16, 0x00 }, // 16000 - protection screens
+	{ 0x17, 0x18, 0x19, 0x00 }, // 16001 - introduction
+	{ 0x1A, 0x1B, 0x1C, 0x11 }, // 16002 - water
+	{ 0x1D, 0x1E, 0x1F, 0x11 }, // 16003 - jail
+	{ 0x20, 0x21, 0x22, 0x11 }, // 16004 - 'cite'
+	{ 0x23, 0x24, 0x25, 0x00 }, // 16005 - 'arene'
+	{ 0x26, 0x27, 0x28, 0x11 }, // 16006 - 'luxe'
+	{ 0x29, 0x2A, 0x2B, 0x11 }, // 16007 - 'final'
+	{ 0x7D, 0x7E, 0x7F, 0x00 }, // 16008 - password screen
+	{ 0x7D, 0x7E, 0x7F, 0x00 }  // 16009 - password screen
+};
+
+void Resource::setupPart(int ptrId) {
+	int firstPart = kPartCopyProtection;
+	switch (_dataType) {
+	case DT_15TH_EDITION:
+	case DT_20TH_EDITION:
+	case DT_3DO:
+		firstPart = kPartIntro;
+		/* fall-through */
+	case DT_WIN31:
+		if (ptrId >= firstPart && ptrId <= 16009) {
+			invalidateAll();
+			uint8_t **segments[4] = { &_segVideoPal, &_segCode, &_segVideo1, &_segVideo2 };
+			for (int i = 0; i < 4; ++i) {
+				const int num = _memListParts[ptrId - 16000][i];
+				if (num != 0) {
+					if (_dataType == DT_20TH_EDITION && 0) {
+						// HD assets
+						_nth->preloadDat(ptrId - 16000, i, num);
+					}
+					*segments[i] = loadDat(num);
+				}
 			}
+			_currentPart = ptrId;
 		} else {
-			error("Resource::setupPtrs() ec=0x%X invalid ptrId", 0xF07);
+			error("Resource::setupPart() ec=0x%X invalid part", 0xF07);
 		}
-		invalidateAll();
-		_memList[ipal].valid = 2;
-		_memList[icod].valid = 2;
-		_memList[ivd1].valid = 2;
-		if (ivd2 != 0) {
-			_memList[ivd2].valid = 2;
-		}
-		load();
-		_segVideoPal = _memList[ipal].bufPtr;
-		_segCode = _memList[icod].bufPtr;
-		_segVideo1 = _memList[ivd1].bufPtr;
-		if (ivd2 != 0) {
-			_segVideo2 = _memList[ivd2].bufPtr;
+		_scriptBakPtr = _scriptCurPtr;
+		break;
+	case DT_AMIGA:
+	case DT_ATARI:
+	case DT_ATARI_DEMO:
+	case DT_DOS:
+		if (ptrId != _currentPart) {
+			uint8_t ipal = 0;
+			uint8_t icod = 0;
+			uint8_t ivd1 = 0;
+			uint8_t ivd2 = 0;
+			if (ptrId >= 16000 && ptrId <= 16009) {
+				uint16_t part = ptrId - 16000;
+				ipal = _memListParts[part][0];
+				icod = _memListParts[part][1];
+				ivd1 = _memListParts[part][2];
+				ivd2 = _memListParts[part][3];
+			} else {
+				error("Resource::setupPart() ec=0x%X invalid part", 0xF07);
+			}
+			invalidateAll();
+			_memList[ipal].status = STATUS_TOLOAD;
+			_memList[icod].status = STATUS_TOLOAD;
+			_memList[ivd1].status = STATUS_TOLOAD;
+			if (ivd2 != 0) {
+				_memList[ivd2].status = STATUS_TOLOAD;
+			}
+			load();
+			_segVideoPal = _memList[ipal].bufPtr;
+			_segCode = _memList[icod].bufPtr;
+			_segVideo1 = _memList[ivd1].bufPtr;
+			if (ivd2 != 0) {
+				_segVideo2 = _memList[ivd2].bufPtr;
+			}
+			_currentPart = ptrId;
 		}
-		_curPtrsId = ptrId;
+		_scriptBakPtr = _scriptCurPtr;
+		break;
 	}
-	_scriptBakPtr = _scriptCurPtr;	
 }
 
 void Resource::allocMemBlock() {
-	_memPtrStart = (uint8 *)malloc(MEM_BLOCK_SIZE);
+	_memPtrStart = (uint8_t *)malloc(MEM_BLOCK_SIZE);
 	_scriptBakPtr = _scriptCurPtr = _memPtrStart;
-	_vidBakPtr = _vidCurPtr = _memPtrStart + MEM_BLOCK_SIZE - 0x800 * 16;
+	_vidCurPtr = _memPtrStart + MEM_BLOCK_SIZE - (320 * 200 / 2); // 4bpp bitmap
 	_useSegVideo2 = false;
 }
 
 void Resource::freeMemBlock() {
 	free(_memPtrStart);
+	_memPtrStart = 0;
 }
 
-void Resource::saveOrLoad(Serializer &ser) {
-	uint8 loadedList[64];
-	if (ser._mode == Serializer::SM_SAVE) {
-		memset(loadedList, 0, sizeof(loadedList));
-		uint8 *p = loadedList;
-		uint8 *q = _memPtrStart;
-		while (1) {
-			MemEntry *it = _memList;
-			MemEntry *me = 0;
-			uint16 num = _numMemList;
-			while (num--) {
-				if (it->valid == 1 && it->bufPtr == q) {
-					me = it;
-				}
-				++it;
-			}
-			if (me == 0) {
-				break;
-			} else {
-				assert(p < loadedList + 64);
-				*p++ = me - _memList;
-				q += me->unpackedSize;
-			}
+void Resource::readDemo3Joy() {
+	static const char *filename = "demo3.joy";
+	File f;
+	if (f.open(filename, _dataDir)) {
+		const uint32_t fileSize = f.size();
+		_demo3Joy.bufPtr = (uint8_t *)malloc(fileSize);
+		if (_demo3Joy.bufPtr) {
+			_demo3Joy.bufSize = f.read(_demo3Joy.bufPtr, fileSize);
+			_demo3Joy.bufPos = -1;
 		}
+	} else {
+		warning("Unable to open '%s'", filename);
 	}
-	Serializer::Entry entries[] = {
-		SE_ARRAY(loadedList, 64, Serializer::SES_INT8, VER(1)),
-		SE_INT(&_curPtrsId, Serializer::SES_INT16, VER(1)),
-		SE_PTR(&_scriptBakPtr, VER(1)),
-		SE_PTR(&_scriptCurPtr, VER(1)),
-		SE_PTR(&_vidBakPtr, VER(1)),
-		SE_PTR(&_vidCurPtr, VER(1)),
-		SE_INT(&_useSegVideo2, Serializer::SES_INT8, VER(1)),
-		SE_PTR(&_segVideoPal, VER(1)),
-		SE_PTR(&_segCode, VER(1)),
-		SE_PTR(&_segVideo1, VER(1)),
-		SE_PTR(&_segVideo2, VER(1)),
-		SE_END()		
-	};
-	ser.saveOrLoadEntries(entries);
-	if (ser._mode == Serializer::SM_LOAD) {
-		uint8 *p = loadedList;
-		uint8 *q = _memPtrStart;
-		while (*p) {
-			MemEntry *me = &_memList[*p++];
-			readBank(me, q);
-			me->bufPtr = q;
-			me->valid = 1;
-			q += me->unpackedSize;
-		}
-	}	
 }
 
 } // namespace Awe
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index ca3b1bcef70..9ec4e6381cb 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -27,68 +27,150 @@
 namespace Awe {
 
 struct MemEntry {
-	uint8 valid = 0;			// 0x0
-	uint8 type = 0;				// 0x1, Resource::ResType
-	uint8 *bufPtr = nullptr;	// 0x2
-	uint16 unk4 = 0;			// 0x4, unused ?
-	uint8 rankNum = 0;			// 0x6
-	uint8 bankNum = 0;			// 0x7
-	uint32 bankPos = 0;			// 0x8 0xA
-	uint16 unkC = 0;			// 0xC, unused ?
-	uint16 packedSize = 0;		// 0xE
-	uint16 unk10 = 0;			// 0x10, unused ?
-	uint16 unpackedSize = 0;	// 0x12
+	uint8_t status;        // 0x0
+	uint8_t type;          // 0x1, Resource::ResType
+	uint8_t *bufPtr;       // 0x2
+	uint8_t rankNum;       // 0x6
+	uint8_t bankNum;       // 0x7
+	uint32_t bankPos;      // 0x8
+	uint32_t packedSize;   // 0xC
+	uint32_t unpackedSize; // 0x12
 };
 
-struct Serializer;
+struct AmigaMemEntry {
+	uint8_t type;
+	uint8_t bank;
+	uint32_t offset;
+	uint32_t packedSize;
+	uint32_t unpackedSize;
+};
+
+struct DemoJoy {
+	uint8_t keymask;
+	uint8_t counter;
+
+	uint8_t *bufPtr;
+	int bufPos, bufSize;
+
+	bool start() {
+		if (bufSize > 0) {
+			keymask = bufPtr[0];
+			counter = bufPtr[1];
+			bufPos = 2;
+			return true;
+		}
+		return false;
+	}
+
+	uint8_t update() {
+		if (bufPos >= 0 && bufPos < bufSize) {
+			if (counter == 0) {
+				keymask = bufPtr[bufPos++];
+				counter = bufPtr[bufPos++];
+			} else {
+				--counter;
+			}
+			return keymask;
+		}
+		return 0;
+	}
+};
+
+struct ResourceNth;
+struct ResourceWin31;
+struct Resource3do;
 struct Video;
 
+typedef void (*PreloadSoundProc)(void *userdata, int num, const uint8_t *data);
+
 struct Resource {
+
 	enum ResType {
-		RT_SOUND  = 0,
-		RT_MUSIC  = 1,
-		RT_VIDBUF = 2, // full screen video buffer, size=0x7D00
-		RT_PAL    = 3, // palette (1024=vga + 1024=ega), size=2048
-		RT_SCRIPT = 4,
-		RT_VBMP   = 5
+		RT_SOUND = 0,
+		RT_MUSIC = 1,
+		RT_BITMAP = 2, // full screen 4bpp video buffer, size=200*320/2
+		RT_PALETTE = 3, // palette (1024=vga + 1024=ega), size=2048
+		RT_BYTECODE = 4,
+		RT_SHAPE = 5,
+		RT_BANK = 6, // common part shapes (bank2.mat)
 	};
-	
+
+	enum DataType {
+		DT_DOS,
+		DT_AMIGA,
+		DT_ATARI,
+		DT_15TH_EDITION,
+		DT_20TH_EDITION,
+		DT_WIN31,
+		DT_3DO,
+		DT_ATARI_DEMO, // ST Action Issue44 Disk28
+	};
+
+	enum {
+		MEM_BLOCK_SIZE = 1 * 1024 * 1024,
+		ENTRIES_COUNT = 146,
+		ENTRIES_COUNT_20TH = 178,
+	};
+
 	enum {
-		MEM_BLOCK_SIZE = 600 * 1024
+		STATUS_NULL,
+		STATUS_LOADED,
+		STATUS_TOLOAD,
 	};
-	
-	static const uint16 MEMLIST_AUDIO[];
-	static const uint16 MEM_LIST_PARTS[][4];
-	static const uint16 MEM_LIST_DEMO_PARTS[][4];
-
-	Video *_vid = nullptr;
-	MemEntry _memList[150];
-	uint16 _numMemList = 0;
-	uint16 _curPtrsId = 0, _newPtrsId = 0;
-	uint8 *_memPtrStart = nullptr,
-		*_scriptBakPtr = nullptr,
-		*_scriptCurPtr = nullptr,
-		*_vidBakPtr = nullptr,
-		*_vidCurPtr = nullptr;
-	bool _useSegVideo2 = false;
-	uint8 *_segVideoPal = nullptr;
-	uint8 *_segCode = nullptr;
-	uint8 *_segVideo1 = nullptr;
-	uint8 *_segVideo2 = nullptr;
-
-	Resource(Video *vid);
-	
-	void readBank(const MemEntry *me, uint8 *dstBuf);
+
+	static const AmigaMemEntry _memListAmigaFR[ENTRIES_COUNT];
+	static const AmigaMemEntry _memListAmigaEN[ENTRIES_COUNT];
+	static const AmigaMemEntry _memListAtariEN[ENTRIES_COUNT];
+	static const uint8_t _memListParts[][4];
+
+	Video *_vid;
+	const char *_dataDir;
+	MemEntry _memList[ENTRIES_COUNT_20TH];
+	uint16_t _numMemList;
+	uint16_t _currentPart, _nextPart;
+	uint8_t *_memPtrStart, *_scriptBakPtr, *_scriptCurPtr, *_vidCurPtr;
+	bool _useSegVideo2;
+	uint8_t *_segVideoPal;
+	uint8_t *_segCode;
+	uint8_t *_segVideo1;
+	uint8_t *_segVideo2;
+	const char *_bankPrefix;
+	bool _hasPasswordScreen;
+	DataType _dataType;
+	ResourceNth *_nth;
+	ResourceWin31 *_win31;
+	Resource3do *_3do;
+	Language _lang;
+	const AmigaMemEntry *_amigaMemList;
+	DemoJoy _demo3Joy;
+
+	Resource(Video *vid, const char *dataDir);
+	~Resource();
+
+	DataType getDataType() const {
+		return _dataType;
+	}
+	void detectVersion();
+	const char *getGameTitle(Language lang) const;
+	bool readBank(const MemEntry *me, uint8_t *dstBuf);
 	void readEntries();
+	void readEntriesAmiga(const AmigaMemEntry *entries, int count);
+	void dumpEntries();
 	void load();
 	void invalidateAll();
-	void invalidateRes();	
-	void update(uint16 num);
-	void setupPtrs(uint16 ptrId);
+	void invalidateRes();
+	void update(uint16_t num, PreloadSoundProc, void *);
+	void loadBmp(int num);
+	uint8_t *loadDat(int num);
+	void loadFont();
+	void loadHeads();
+	uint8_t *loadWav(int num);
+	const char *getString(int num);
+	const char *getMusicPath(int num, char *buf, int bufSize, uint32_t *offset = 0);
+	void setupPart(int part);
 	void allocMemBlock();
 	void freeMemBlock();
-	
-	void saveOrLoad(Serializer &ser);
+	void readDemo3Joy();
 };
 
 } // namespace Awe
diff --git a/engines/awe/resource_3do.cpp b/engines/awe/resource_3do.cpp
new file mode 100644
index 00000000000..6bb29ce3e73
--- /dev/null
+++ b/engines/awe/resource_3do.cpp
@@ -0,0 +1,338 @@
+/* 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 "awe/resource_3do.h"
+#include "awe/util.h"
+
+namespace Awe {
+
+static const int ISO_BLOCK_SIZE = 2048;
+
+struct OperaIsoEntry {
+	char name[16];
+	uint32_t offset;
+	uint32_t size;
+};
+
+static int compareOperaIsoEntry(const void *a, const void *b) {
+	const OperaIsoEntry *entry1 = (const OperaIsoEntry *)a;
+	const OperaIsoEntry *entry2 = (const OperaIsoEntry *)b;
+	return strcmp(entry1->name, entry2->name);
+}
+
+static int compareOperaIsoEntryName(const void *name, const void *p) {
+	const OperaIsoEntry *entry = (const OperaIsoEntry *)p;
+	return strcmp((const char *)name, entry->name);
+}
+
+struct OperaIso {
+	File _f;
+	OperaIsoEntry *_entries;
+	int _entriesCount;
+
+	OperaIso(const char *filePath)
+		: _entries(0), _entriesCount(0) {
+		_f.open(filePath);
+	}
+	~OperaIso() {
+		free(_entries);
+	}
+	void readToc() {
+		uint8_t buf[128];
+		const int count = _f.read(buf, sizeof(buf));
+		if (count != sizeof(buf)) {
+			warning("Failed to read %d bytes", count);
+			return;
+		}
+		if (buf[0] != 1 || memcmp(buf + 40, "CD-ROM", 6) != 0) {
+			warning("Unexpected Opera ISO signature");
+			return;
+		}
+		const int block = READ_BE_UINT32(buf + 100);
+		readTocEntry(block);
+		qsort(_entries, _entriesCount, sizeof(OperaIsoEntry), compareOperaIsoEntry);
+	}
+	void readTocEntry(int block) {
+		uint32_t attr = 0;
+		do {
+			_f.seek(block * ISO_BLOCK_SIZE + 20, SEEK_SET);
+			do {
+				uint8_t buf[72];
+				_f.read(buf, sizeof(buf));
+				attr = READ_BE_UINT32(buf);
+				const char *name = (const char *)buf + 32;
+				const uint32_t count = READ_BE_UINT32(buf + 64);
+				const uint32_t offset = READ_BE_UINT32(buf + 68);
+				_f.seek(count * 4, SEEK_CUR);
+				switch (attr & 255) {
+				case 2:
+					_entries = (OperaIsoEntry *)realloc(_entries, (_entriesCount + 1) * sizeof(OperaIsoEntry));
+					if (_entries) {
+						OperaIsoEntry *e = &_entries[_entriesCount];
+						strncpy(e->name, name, sizeof(e->name) - 1);
+						e->name[sizeof(e->name) - 1] = 0;
+						e->offset = offset * ISO_BLOCK_SIZE;
+						e->size = READ_BE_UINT32(buf + 16);
+						++_entriesCount;
+					}
+					break;
+				case 7:
+					if (strcmp(name, "GameData") == 0) {
+						readTocEntry(offset);
+					}
+					break;
+				}
+			} while (attr != 0 && attr < 256);
+			++block;
+		} while ((attr >> 24) == 0x40);
+	}
+	const OperaIsoEntry *find(const char *name) const {
+		return (const OperaIsoEntry *)bsearch(name, _entries, _entriesCount, sizeof(OperaIsoEntry), compareOperaIsoEntryName);
+	}
+};
+
+static int decodeLzss(const uint8_t *src, uint32_t len, uint8_t *dst) {
+	uint32_t rd = 0, wr = 0;
+	while (rd < len) {
+		const uint8_t code = src[rd++];
+		for (int j = 0; j < 8 && rd < len; ++j) {
+			if (code & (1 << j)) {
+				dst[wr++] = src[rd++];
+			} else {
+				const uint16_t offset = 0xF000 | src[rd] | ((src[rd + 1] & 0xF) << 8);
+				const int llen = (src[rd + 1] >> 4) + 3;
+				rd += 2;
+				for (int i = 0; i < llen; ++i) {
+					dst[wr] = dst[wr + (int16_t)offset];
+					++wr;
+				}
+			}
+		}
+	}
+	return wr;
+}
+
+static void decodeCcb16(int ccbWidth, int ccbHeight, File *f, uint32_t dataSize, uint16_t *dst) {
+	for (int y = 0; y < ccbHeight; ++y) {
+		const int scanlineSize = 4 * (f->readUint16BE() + 2);
+		int scanlineLen = 2;
+		int w = ccbWidth;
+		while (w > 0) {
+			uint8_t code = f->readByte();
+			++scanlineLen;
+			const int count = (code & 63) + 1;
+			code >>= 6;
+			if (code == 0) {
+				break;
+			}
+			switch (code) {
+			case 1:
+				for (int i = 0; i < count; ++i) {
+					*dst++ = f->readUint16BE();
+				}
+				scanlineLen += count * 2;
+				break;
+			case 2:
+				memset(dst, 0, count * sizeof(uint16_t));
+				dst += count;
+				break;
+			case 3:
+			{
+				const uint16_t color = f->readUint16BE();
+				for (int i = 0; i < count; ++i) {
+					*dst++ = color;
+				}
+				scanlineLen += 2;
+			}
+			break;
+			}
+			w -= count;
+		}
+		assert(w >= 0);
+		if (w > 0) {
+			dst += w;
+		}
+		const int align = scanlineSize - scanlineLen;
+		if (align != 0) {
+			f->seek(align, SEEK_CUR);
+		}
+	}
+}
+
+static const uint8_t _ccb_bppTable[8] = {
+		0, 1, 2, 4, 6, 8, 16, 0
+};
+
+static uint16_t *decodeShapeCcb(File *f, int dataSize, int *w, int *h) {
+	const uint32_t flags = f->readUint32BE();
+	f->seek(4, SEEK_CUR);
+	const uint32_t celData = f->readUint32BE();
+	f->seek(40, SEEK_CUR);
+	const uint32_t pre0 = f->readUint32BE();
+	const uint32_t pre1 = f->readUint32BE();
+	assert(celData == 0x30);
+	assert(flags & (1 << 9));
+	const int bpp = _ccb_bppTable[pre0 & 7];
+	assert(bpp == 16);
+	const uint32_t width = (pre1 & 0x3FF) + 1;
+	const uint32_t height = ((pre0 >> 6) & 0x3FF) + 1;
+	uint16_t *buffer = (uint16_t *)malloc(width * height * sizeof(uint16_t));
+	if (buffer) {
+		decodeCcb16(width, height, f, dataSize - 60, buffer);
+		*w = width;
+		*h = height;
+	}
+	return buffer;
+}
+
+Resource3do::Resource3do(const char *dataPath)
+	: _dataPath(dataPath) {
+
+	Common::FSNode f(dataPath);
+
+	if (f.exists()) {
+		_iso = new OperaIso(dataPath);
+	} else {
+		_iso = 0;
+	}
+}
+
+Resource3do::~Resource3do() {
+	delete _iso;
+}
+
+bool Resource3do::readEntries() {
+	if (_iso) {
+		_iso->readToc();
+		return _iso->_entriesCount != 0;
+	}
+	return true;
+}
+
+uint8_t *Resource3do::loadFile(int num, uint8_t *dst, uint32_t *size) {
+	uint8_t *in = dst;
+	if (_iso) {
+		char name[16];
+		snprintf(name, sizeof(name), "File%d", num);
+		const OperaIsoEntry *e = _iso->find(name);
+		if (e) {
+			if (!dst) {
+				dst = (uint8_t *)malloc(e->size);
+				if (!dst) {
+					warning("Unable to allocate %d bytes", e->size);
+					return 0;
+				}
+			}
+			*size = e->size;
+			_iso->_f.seek(e->offset);
+			_iso->_f.read(dst, e->size);
+		} else {
+			warning("Failed to load '%s'", name);
+			return 0;
+		}
+	} else {
+		char path[MAXPATHLEN];
+		snprintf(path, sizeof(path), "%s/GameData/File%d", _dataPath, num);
+		File f;
+		if (f.open(path)) {
+			const int sz = f.size();
+			if (!dst) {
+				dst = (uint8_t *)malloc(sz);
+				if (!dst) {
+					warning("Unable to allocate %d bytes", sz);
+					return 0;
+				}
+			}
+			*size = sz;
+			f.read(dst, sz);
+		} else {
+			warning("Failed to load '%s'", path);
+			return 0;
+		}
+	}
+	if (dst && memcmp(dst, "\x00\xf4\x01\x00", 4) == 0) {
+		static const int SZ = 64000 * 2;
+		uint8_t *tmp = (uint8_t *)calloc(1, SZ);
+		if (!tmp) {
+			warning("Unable to allocate %d bytes", SZ);
+			if (in != dst) free(dst);
+			return 0;
+		}
+		const int decodedSize = decodeLzss(dst + 4, *size - 4, tmp);
+		if (in != dst) free(dst);
+		if (decodedSize != SZ) {
+			warning("Unexpected LZSS decoded size %d", decodedSize);
+			return 0;
+		}
+		*size = decodedSize;
+		return tmp;
+	}
+	return dst;
+}
+
+uint16_t *Resource3do::loadShape555(const char *name, int *w, int *h) {
+	if (_iso) {
+		const OperaIsoEntry *e = _iso->find(name);
+		if (e) {
+			_iso->_f.seek(e->offset);
+			return decodeShapeCcb(&_iso->_f, e->size, w, h);
+		}
+	} else {
+		char path[MAXPATHLEN];
+		snprintf(path, sizeof(path), "%s/GameData/%s", _dataPath, name);
+		File f;
+		if (f.open(path)) {
+			const uint32_t dataSize = f.size();
+			return decodeShapeCcb(&f, dataSize, w, h);
+		}
+	}
+	return 0;
+}
+
+const char *Resource3do::getMusicName(int num, uint32_t *offset) {
+	*offset = 0;
+	if (_iso) {
+		char name[16];
+		snprintf(name, sizeof(name), "song%d", num);
+		const OperaIsoEntry *e = _iso->find(name);
+		if (e) {
+			*offset = e->offset;
+		}
+		return 0;
+	}
+	snprintf(_musicPath, sizeof(_musicPath), "GameData/song%d", num);
+	return _musicPath;
+}
+
+const char *Resource3do::getCpak(const char *name, uint32_t *offset) {
+	*offset = 0;
+	if (_iso) {
+		const OperaIsoEntry *e = _iso->find(name);
+		if (e) {
+			*offset = e->offset;
+		}
+		return 0;
+	}
+	snprintf(_cpakPath, sizeof(_cpakPath), "GameData/%s", name);
+	return _cpakPath;
+}
+
+} // namespace Awe
diff --git a/engines/awe/resource_3do.h b/engines/awe/resource_3do.h
new file mode 100644
index 00000000000..9677a2880e3
--- /dev/null
+++ b/engines/awe/resource_3do.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AWE_RESOURCE_3DO_H
+#define AWE_RESOURCE_3DO_H
+
+#include "awe/intern.h"
+#include "awe/file.h"
+
+namespace Awe {
+
+struct OperaIso;
+
+struct Resource3do {
+
+	const char *_dataPath;
+	char _musicPath[32];
+	char _cpakPath[64];
+	OperaIso *_iso;
+
+	Resource3do(const char *dataPath);
+	~Resource3do();
+
+	bool readEntries();
+
+	uint8_t *loadFile(int num, uint8_t *dst, uint32_t *size);
+	uint16_t *loadShape555(const char *name, int *w, int *h);
+	const char *getMusicName(int num, uint32_t *offset);
+	const char *getCpak(const char *name, uint32_t *offset);
+};
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/resource_nth.cpp b/engines/awe/resource_nth.cpp
new file mode 100644
index 00000000000..e36ae371140
--- /dev/null
+++ b/engines/awe/resource_nth.cpp
@@ -0,0 +1,589 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/fs.h"
+#include "awe/pak.h"
+#include "awe/resource_nth.h"
+#include "awe/util.h"
+#include "awe/script.h"
+#include "awe/awe.h"
+
+namespace Awe {
+
+static char *loadTextFile(File &f, const int size) {
+	char *buf = (char *)malloc(size + 1);
+	if (buf) {
+		const int count = f.read(buf, size);
+		if (count != size) {
+			warning("Failed to read %d bytes (%d expected)", count, size);
+			free(buf);
+			return 0;
+		}
+		buf[count] = 0;
+	}
+	return buf;
+}
+
+struct Resource15th : ResourceNth {
+	Pak _pak;
+	char _dataPath[MAXPATHLEN];
+	char _menuPath[MAXPATHLEN];
+	char *_textBuf;
+	const char *_stringsTable[157];
+	bool _hasRemasteredMusic;
+
+	Resource15th(const char *dataPath) {
+		snprintf(_dataPath, sizeof(_dataPath), "%s/Music/AW/RmSnd", dataPath);
+
+		_hasRemasteredMusic = Common::FSNode(_dataPath).isDirectory();
+		snprintf(_dataPath, sizeof(_dataPath), "%s/Data", dataPath);
+		snprintf(_menuPath, sizeof(_menuPath), "%s/Menu", dataPath);
+		_textBuf = 0;
+		memset(_stringsTable, 0, sizeof(_stringsTable));
+	}
+
+	virtual ~Resource15th() {
+		free(_textBuf);
+	}
+
+	virtual bool init() {
+		_pak.open(_dataPath);
+		_pak.readEntries();
+		return _pak._entriesCount != 0;
+	}
+
+	virtual uint8_t *load(const char *name) {
+		uint8_t *buf = 0;
+		const PakEntry *e = _pak.find(name);
+		if (e) {
+			buf = (uint8_t *)malloc(e->size);
+			if (buf) {
+				uint32_t size;
+				_pak.loadData(e, buf, &size);
+			}
+		} else {
+			warning("Unable to load '%s'", name);
+		}
+		return buf;
+	}
+
+	virtual uint8_t *loadBmp(int num) {
+		char name[16];
+		if (num >= 3000) {
+			snprintf(name, sizeof(name), "e%04d.bmp", num);
+		} else {
+			snprintf(name, sizeof(name), "file%03d.bmp", num);
+		}
+		return load(name);
+	}
+
+	virtual uint8_t *loadDat(int num, uint8_t *dst, uint32_t *size) {
+		char name[16];
+		snprintf(name, sizeof(name), "file%03d.dat", num);
+		const PakEntry *e = _pak.find(name);
+		if (e) {
+			_pak.loadData(e, dst, size);
+			return dst;
+		} else {
+			warning("Unable to load '%s'", name);
+		}
+		return 0;
+	}
+
+	virtual uint8_t *loadWav(int num, uint8_t *dst, uint32_t *size) {
+		char name[32];
+		const PakEntry *e = 0;
+		if (Script::_useRemasteredAudio) {
+			snprintf(name, sizeof(name), "rmsnd/file%03d.wav", num);
+			e = _pak.find(name);
+		}
+		if (!e) {
+			snprintf(name, sizeof(name), "file%03db.wav", num);
+			e = _pak.find(name);
+			if (!e) {
+				snprintf(name, sizeof(name), "file%03d.wav", num);
+				e = _pak.find(name);
+			}
+		}
+		if (e) {
+			uint8_t *p = (uint8_t *)malloc(e->size);
+			if (p) {
+				_pak.loadData(e, p, size);
+				*size = 0;
+				return p;
+			}
+			warning("Failed to allocate %d bytes", e->size);
+		} else {
+			warning("Unable to load '%s'", name);
+		}
+		return 0;
+	}
+
+	void loadStrings(Language lang) {
+		if (!_textBuf) {
+			const char *name = 0;
+			switch (lang) {
+			case LANG_FR:
+				name = "Francais.Txt";
+				break;
+			case LANG_US:
+				name = "English.Txt";
+				break;
+			case LANG_DE:
+				name = "German.Txt";
+				break;
+			case LANG_ES:
+				name = "Espanol.txt";
+				break;
+			case LANG_IT:
+				name = "Italian.Txt";
+				break;
+			default:
+				return;
+			}
+			char path[MAXPATHLEN];
+			snprintf(path, sizeof(path), "%s/lang_%s", _menuPath, name);
+			File f;
+			if (f.open(path)) {
+				const int size = f.size();
+				_textBuf = loadTextFile(f, size);
+				if (_textBuf) {
+					char *p = _textBuf;
+					while (true) {
+						char *end = strchr(p, '\r');
+						if (!end) {
+							break;
+						}
+						*end++ = 0;
+						if (*end == '\n') {
+							*end++ = 0;
+						}
+						const int len = end - p;
+						int strNum = -1;
+						if (len > 3 && sscanf(p, "%03d", &strNum) == 1) {
+							p += 3;
+							while (*p == ' ' || *p == '\t') {
+								++p;
+							}
+							if ((uint32_t)strNum < ARRAYSIZE(_stringsTable)) {
+								_stringsTable[strNum] = p;
+							}
+						}
+						p = end;
+					}
+				}
+			}
+		}
+	}
+
+	virtual const char *getString(Language lang, int num) {
+		loadStrings(lang);
+		if ((uint32_t)num < ARRAYSIZE(_stringsTable)) {
+			return _stringsTable[num];
+		}
+		return 0;
+	}
+
+	virtual const char *getMusicName(int num) {
+		const char *path = 0;
+		switch (num) {
+		case 7:
+			if (_hasRemasteredMusic && Script::_useRemasteredAudio) {
+				path = "Music/AW/RmSnd/Intro2004.wav";
+			} else {
+				path = "Music/AW/Intro2004.wav";
+			}
+			break;
+		case 138:
+			if (_hasRemasteredMusic && Script::_useRemasteredAudio) {
+				path = "Music/AW/RmSnd/End2004.wav";
+			} else {
+				path = "Music/AW/End2004.wav";
+			}
+			break;
+		}
+		return path;
+	}
+
+	virtual void getBitmapSize(int *w, int *h) {
+		*w = 1280;
+		*h = 800;
+	}
+};
+
+static uint8_t *inflateGzip(const char *filepath) {
+	File f;
+	if (!f.open(filepath)) {
+		warning("Unable to open '%s'", filepath);
+		return 0;
+	}
+	const uint16_t sig = f.readUint16LE();
+	if (sig != 0x8B1F) {
+		warning("Unexpected file signature 0x%x for '%s'", sig, filepath);
+		return 0;
+	}
+	f.seek(-4, SEEK_END);
+	const uint32_t dataSize = f.readUint32LE();
+	uint8_t *out = (uint8_t *)malloc(dataSize);
+	if (!out) {
+		warning("Failed to allocate %d bytes", dataSize);
+		return 0;
+	}
+	f.seek(0);
+
+#ifdef TODO
+	z_stream str;
+	memset(&str, 0, sizeof(str));
+	int err = inflateInit2(&str, MAX_WBITS + 16);
+	if (err == Z_OK) {
+		Bytef buf[1 << MAX_WBITS];
+		str.next_in = buf;
+		str.avail_in = 0;
+		str.next_out = out;
+		str.avail_out = dataSize;
+		while (err == Z_OK && str.avail_out != 0) {
+			if (str.avail_in == 0 && !f.ioErr()) {
+				str.next_in = buf;
+				str.avail_in = f.read(buf, sizeof(buf));
+			}
+			err = inflate(&str, Z_NO_FLUSH);
+		}
+		inflateEnd(&str);
+		if (err == Z_STREAM_END) {
+			return out;
+		}
+	}
+	free(out);
+#else
+	error("TODO: inflateGzip");
+#endif
+	return 0;
+}
+
+struct Resource20th : ResourceNth {
+	const char *_dataPath;
+	char *_textBuf;
+	const char *_stringsTable[192];
+	char _musicName[64];
+	uint8_t _musicType;
+	char _datName[32];
+	const char *_bitmapSize;
+
+	Resource20th(const char *dataPath)
+		: _dataPath(dataPath), _textBuf(0) {
+		memset(_stringsTable, 0, sizeof(_stringsTable));
+		_musicType = 0;
+		_datName[0] = 0;
+		//srand(time(NULL));
+	}
+
+	virtual ~Resource20th() {
+		free(_textBuf);
+	}
+
+	virtual bool init() {
+		static const char *dirs[] = { "BGZ", "DAT", "WGZ", 0 };
+		for (int i = 0; dirs[i]; ++i) {
+			char path[MAXPATHLEN];
+			snprintf(path, sizeof(path), "%s/game/%s", _dataPath, dirs[i]);
+			Common::FSNode f(path);
+
+			if (f.exists() && !f.isDirectory()) {
+				warning("'%s' is not a directory", path);
+				return false;
+			}
+		}
+		static const char *bmps[] = {
+			"1728x1080",
+			"1280x800",
+			"1152x720",
+			"960x600",
+			"864x540",
+			"768x480",
+			"480x300",
+			"320x200",
+			0
+		};
+		_bitmapSize = 0;
+		for (int i = 0; bmps[i]; ++i) {
+			char path[MAXPATHLEN];
+			snprintf(path, sizeof(path), "%s/game/BGZ/data%s", _dataPath, bmps[i]);
+			Common::FSNode f(path);
+
+			if (f.isDirectory()) {
+				_bitmapSize = bmps[i];
+				break;
+			}
+		}
+		return true;
+	}
+
+	virtual uint8_t *load(const char *name) {
+		if (strcmp(name, "font.bmp") == 0) {
+			char path[MAXPATHLEN];
+			snprintf(path, sizeof(path), "%s/game/BGZ/Font.bgz", _dataPath);
+			return inflateGzip(path);
+		} else if (strcmp(name, "heads.bmp") == 0) {
+			char path[MAXPATHLEN];
+			snprintf(path, sizeof(path), "%s/game/BGZ/Heads.bgz", _dataPath);
+			return inflateGzip(path);
+		}
+		return 0;
+	}
+
+	virtual uint8_t *loadBmp(int num) {
+		char path[MAXPATHLEN];
+		if (num >= 3000 && _bitmapSize) {
+			snprintf(path, sizeof(path), "%s/game/BGZ/data%s/%s_e%04d.bgz", _dataPath, _bitmapSize, _bitmapSize, num);
+		} else {
+			snprintf(path, sizeof(path), "%s/game/BGZ/file%03d.bgz", _dataPath, num);
+		}
+		return inflateGzip(path);
+	}
+
+	void preloadDat(int part, int type, int num) {
+		static const char *names[] = {
+			"INTRO", "EAU", "PRI", "CITE", "arene", "LUXE", "FINAL", 0
+		};
+		static const char *exts[] = {
+			"pal", "mac", "mat", 0
+		};
+		if (part > 0 && part < 8) {
+			if (type == 3) {
+				assert(num == 0x11);
+				Common::strcpy_s(_datName, "BANK2.MAT");
+			} else {
+				snprintf(_datName, sizeof(_datName), "%s2011.%s", names[part - 1], exts[type]);
+			}
+			debug(DBG_RESOURCE, "Loading '%s'", _datName);
+		} else {
+			_datName[0] = 0;
+		}
+	}
+
+	virtual uint8_t *loadDat(int num, uint8_t *dst, uint32_t *size) {
+		bool datOpen = false;
+		char path[MAXPATHLEN];
+		snprintf(path, sizeof(path), "%s/game/DAT", _dataPath);
+		File f;
+		if (_datName[0]) {
+			datOpen = f.open(_datName, path);
+		}
+		if (!datOpen) {
+			snprintf(_datName, sizeof(_datName), "FILE%03d.DAT", num);
+			datOpen = f.open(_datName, path);
+		}
+		if (datOpen) {
+			const uint32_t dataSize = f.size();
+			const uint32_t count = f.read(dst, dataSize);
+			if (count != dataSize) {
+				warning("Failed to read %d bytes (expected %d)", dataSize, count);
+			}
+			*size = dataSize;
+		} else {
+			warning("Unable to open '%s/%s'", path, _datName);
+			dst = 0;
+		}
+		_datName[0] = 0;
+		return dst;
+	}
+
+	virtual uint8_t *loadWav(int num, uint8_t *dst, uint32_t *size) {
+		char path[MAXPATHLEN];
+		if (!Script::_useRemasteredAudio) {
+			snprintf(path, sizeof(path), "%s/game/WGZ/original/file%03d.wgz", _dataPath, num);
+			struct stat s;
+			if (stat(path, &s) != 0) {
+				snprintf(path, sizeof(path), "%s/game/WGZ/original/file%03dB.wgz", _dataPath, num);
+			}
+			*size = 0;
+			return inflateGzip(path);
+		}
+		switch (num) {
+		case 81:
+		{
+			const int r = g_engine->getRandomNumber(1, 3);
+			snprintf(path, sizeof(path), "%s/game/WGZ/file081-EX-%d.wgz", _dataPath, r);
+		}
+		break;
+		case 85:
+		{
+			const int r = g_engine->getRandomNumber(1, 2);
+			const char *snd = "IN";
+			if (_musicType == 1) {
+				snd = "EX";
+			}
+			snprintf(path, sizeof(path), "%s/game/WGZ/file085-%s-%d.wgz", _dataPath, snd, r);
+		}
+		break;
+		case 96:
+		{
+			const int r = g_engine->getRandomNumber(1, 3);
+			const char *snd = "GR";
+			if (_musicType == 1) {
+				snd = "EX";
+			} else if (_musicType == 2) {
+				snd = "IN";
+			}
+			snprintf(path, sizeof(path), "%s/game/WGZ/file096-%s-%d.wgz", _dataPath, snd, r);
+		}
+		break;
+		case 163:
+		{
+			const char *snd = "GR";
+			if (_musicType == 1) {
+				snd = "EX";
+			} else if (_musicType == 2) {
+				snd = "IN";
+			}
+			snprintf(path, sizeof(path), "%s/game/WGZ/file163-%s-1.wgz", _dataPath, snd);
+		}
+		break;
+		default:
+		{
+			snprintf(path, sizeof(path), "%s/game/WGZ/file%03d.wgz", _dataPath, num);
+			struct stat s;
+			if (stat(path, &s) != 0) {
+				snprintf(path, sizeof(path), "%s/game/WGZ/file%03dB.wgz", _dataPath, num);
+			}
+		}
+		break;
+		}
+		*size = 0;
+		return inflateGzip(path);
+	}
+
+	void loadStrings(Language lang) {
+		if (!_textBuf) {
+			const char *name = 0;
+			switch (lang) {
+			case LANG_FR:
+				name = "FR";
+				break;
+			case LANG_US:
+				name = "EN";
+				break;
+			case LANG_DE:
+				name = "DE";
+				break;
+			case LANG_ES:
+				name = "ES";
+				break;
+			case LANG_IT:
+				name = "IT";
+				break;
+			default:
+				return;
+			}
+			char path[MAXPATHLEN];
+			static const char *fmt[] = {
+				"%s/game/TXT/%s.txt",
+				"%s/game/TXT/Linux/%s.txt",
+				0
+			};
+			bool isOpen = false;
+			File f;
+			for (int i = 0; fmt[i] && !isOpen; ++i) {
+				snprintf(path, sizeof(path), fmt[i], _dataPath, name);
+				isOpen = f.open(path);
+			}
+			if (isOpen) {
+				const int size = f.size();
+				_textBuf = loadTextFile(f, size);
+				if (_textBuf) {
+					int count = 0;
+					for (char *p = _textBuf; count < (int)ARRAYSIZE(_stringsTable); ) {
+						_stringsTable[count++] = p;
+						char *end = strchr(p, '\n');
+						if (!end) {
+							break;
+						}
+						*end++ = 0;
+						p = end;
+					}
+				}
+			}
+		}
+	}
+	virtual const char *getString(Language lang, int num) {
+		loadStrings(lang);
+		if ((uint32_t)num < ARRAYSIZE(_stringsTable)) {
+			return _stringsTable[num];
+		}
+		return 0;
+	}
+
+	virtual const char *getMusicName(int num) {
+		if (num >= 5000 && Script::_useRemasteredAudio) {
+			snprintf(_musicName, sizeof(_musicName), "game/OGG/amb%d.ogg", num);
+			switch (num) {
+			case 5005:
+				_musicType = 1;
+				break;
+			case 5006:
+				_musicType = 3;
+				break;
+			default:
+				_musicType = 2;
+				break;
+			}
+		} else {
+			switch (num) {
+			case 7:
+				if (Script::_useRemasteredAudio) {
+					Common::strcpy_s(_musicName, "game/OGG/Intro_20th.ogg");
+				} else {
+					Common::strcpy_s(_musicName, "game/OGG/original/intro.ogg");
+				}
+				break;
+			case 138:
+				if (!Script::_useRemasteredAudio) {
+					Common::strcpy_s(_musicName, "game/OGG/original/ending.ogg");
+					break;
+				}
+				/* fall-through */
+			default:
+				return 0;
+			}
+		}
+		return _musicName;
+	}
+
+	virtual void getBitmapSize(int *w, int *h) {
+		if (_bitmapSize && sscanf(_bitmapSize, "%dx%d", w, h) == 2) {
+			return;
+		}
+		*w = 0;
+		*h = 0;
+	}
+};
+
+ResourceNth *ResourceNth::create(int edition, const char *dataPath) {
+	switch (edition) {
+	case 15:
+		return new Resource15th(dataPath);
+	case 20:
+		return new Resource20th(dataPath);
+	}
+	return 0;
+}
+
+} // namespace Awe
diff --git a/engines/awe/resource_nth.h b/engines/awe/resource_nth.h
new file mode 100644
index 00000000000..7ea783f1489
--- /dev/null
+++ b/engines/awe/resource_nth.h
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AWE_RESOURCE_NTH_H
+#define AWE_RESOURCE_NTH_H
+
+#include "awe/intern.h"
+
+namespace Awe {
+
+struct ResourceNth {
+	virtual ~ResourceNth() {
+	}
+
+	virtual bool init() = 0;
+	virtual uint8_t *load(const char *name) = 0;
+	virtual uint8_t *loadBmp(int num) = 0;
+	virtual void preloadDat(int part, int type, int num) {
+	}
+	virtual uint8_t *loadDat(int num, uint8_t *dst, uint32_t *size) = 0;
+	virtual uint8_t *loadWav(int num, uint8_t *dst, uint32_t *size) = 0;
+	virtual const char *getString(Language lang, int num) = 0;
+	virtual const char *getMusicName(int num) = 0;
+	virtual void getBitmapSize(int *w, int *h) = 0;
+
+	static ResourceNth *create(int edition, const char *dataPath);
+};
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/resource_win31.cpp b/engines/awe/resource_win31.cpp
new file mode 100644
index 00000000000..3595588c0e3
--- /dev/null
+++ b/engines/awe/resource_win31.cpp
@@ -0,0 +1,351 @@
+/* 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 "awe/resource_win31.h"
+#include "awe/util.h"
+
+namespace Awe {
+
+static const uint8_t _shuffleTable[256] = {
+	0xB2, 0x91, 0x49, 0xEE, 0x8C, 0xBC, 0x16, 0x0D, 0x07, 0x87, 0xCD, 0xB6, 0x4C, 0x44, 0x22, 0xB3,
+	0xAE, 0x96, 0xDF, 0x18, 0x7B, 0x28, 0x17, 0x9A, 0x74, 0x3C, 0x2E, 0x59, 0x69, 0x56, 0x38, 0x82,
+	0x7F, 0x25, 0x41, 0xC6, 0xE8, 0x8A, 0x86, 0x7A, 0xB5, 0x8B, 0xA7, 0xB1, 0x2C, 0x53, 0xF0, 0x3B,
+	0x20, 0xCB, 0x6F, 0x9E, 0xD9, 0x05, 0x54, 0x08, 0x4F, 0xFE, 0x32, 0x31, 0xF9, 0x50, 0xBD, 0x37,
+	0x45, 0xDA, 0x46, 0x33, 0x01, 0xC5, 0x27, 0xEC, 0xE5, 0x14, 0x98, 0x70, 0xB0, 0xF8, 0x93, 0xC9,
+	0xAC, 0xEB, 0xE4, 0xE1, 0xE6, 0xF7, 0xAF, 0x76, 0x0E, 0x63, 0x80, 0x83, 0x1E, 0x57, 0x47, 0x9F,
+	0xC2, 0x42, 0xA5, 0xFF, 0x5B, 0xBF, 0x12, 0xFA, 0x61, 0x5E, 0x5D, 0xC8, 0x21, 0xA8, 0xB9, 0x5A,
+	0x9D, 0x30, 0xD5, 0x09, 0xB7, 0x0B, 0x2F, 0xED, 0x6E, 0xA2, 0x5F, 0x6C, 0xA0, 0x95, 0x00, 0x55,
+	0x75, 0x7D, 0x89, 0x97, 0x6A, 0xFB, 0x1A, 0x58, 0xDE, 0x8D, 0x4E, 0xE3, 0x4B, 0x3D, 0x15, 0x67,
+	0x11, 0x5C, 0x1C, 0x71, 0x73, 0x1B, 0xD3, 0x13, 0xE7, 0x77, 0x4D, 0xD6, 0x9C, 0x1D, 0x1F, 0xEF,
+	0xBB, 0x66, 0x99, 0xF6, 0x3F, 0x02, 0x7E, 0xCF, 0x2B, 0x35, 0x88, 0xBA, 0xA4, 0x40, 0x19, 0x23,
+	0xC1, 0xD4, 0xD7, 0x43, 0x52, 0x34, 0xE9, 0xDC, 0x60, 0x24, 0x94, 0x6B, 0x81, 0x03, 0xC0, 0x39,
+	0xBE, 0x90, 0x65, 0xFD, 0xE0, 0x2D, 0x7C, 0xEA, 0x04, 0xA6, 0xDB, 0xF3, 0xCE, 0xB4, 0xA9, 0xAA,
+	0xAD, 0x64, 0xF2, 0x72, 0xD2, 0x84, 0x8E, 0xD1, 0x26, 0xA3, 0xCA, 0x4A, 0x48, 0x06, 0x0F, 0x36,
+	0x85, 0xD0, 0x51, 0x6D, 0xC4, 0x3E, 0x92, 0xF1, 0xC7, 0x62, 0x79, 0xA1, 0x9B, 0x68, 0xF5, 0xE2,
+	0xAB, 0x0C, 0xCC, 0x78, 0xFC, 0x2A, 0xD8, 0x3A, 0xDD, 0x8F, 0x10, 0x29, 0xF4, 0x0A, 0xB8, 0xC3
+};
+
+static uint16_t decode(uint8_t *p, int size, uint16_t key) {
+	for (int i = 0; i < size; ++i) {
+		const uint8_t dl = 1 + (key >> 8);
+		const uint8_t al = _shuffleTable[dl];
+		const uint8_t dh = al ^ (key & 255);
+		p[i] ^= al;
+		key = (dh << 8) | dl;
+	}
+	return key;
+}
+
+struct Bitstream {
+	File *_f;
+	int _size;
+	uint16_t _bits;
+	int _len;
+
+	Bitstream()
+		: _f(0), _size(0), _bits(0), _len(0) {
+	}
+
+	void reset(File *f, int size) {
+		_f = f;
+		_size = size;
+		_bits = 0;
+		_len = 0;
+	}
+
+	uint8_t readByte() {
+		if (_len < 8) {
+			_bits <<= 8;
+			assert(_size > 0);
+			--_size;
+			_bits |= _f->readByte();
+			_len += 8;
+		}
+		_len -= 8;
+		return (_bits >> _len) & 255;
+	}
+	int readBit() {
+		if (_len == 0) {
+			assert(_size > 0);
+			--_size;
+			_bits = _f->readByte();
+			_len = 8;
+		}
+		--_len;
+		return (_bits & (1 << _len)) != 0 ? 1 : 0;
+	}
+};
+
+struct LzHuffman {
+
+	enum {
+		kCharsCount = 314,
+		kTableSize = kCharsCount * 2 - 1,
+		kHuffmanRoot = kTableSize - 1,
+		kMaxFreq = 0x8000
+	};
+
+	Bitstream _stream;
+	int _child[kTableSize];
+	int _freq[628];
+	int _parent[943];
+	unsigned char _historyBuffer[4096];
+
+	LzHuffman() {
+		memset(_child, 0, sizeof(_child));
+		memset(_freq, 0, sizeof(_freq));
+		memset(_parent, 0, sizeof(_parent));
+	}
+
+	void resetHuffTables() {
+		for (int i = 0; i < kCharsCount; ++i) {
+			_freq[i] = 1;
+			_child[i] = kTableSize + i;
+			_parent[kTableSize + i] = i;
+		}
+		for (int i = 0, j = kCharsCount; j <= kHuffmanRoot; i += 2, ++j) {
+			_freq[j] = _freq[i] + _freq[i + 1];
+			_child[j] = i;
+			_parent[i] = _parent[i + 1] = j;
+		}
+		_freq[kTableSize] = 0xFFFF;
+		_parent[kHuffmanRoot] = 0;
+	}
+	int getHuffCode() {
+		static const int base[] = { 0, 1, 4, 12, 24, 48 };
+		static const int count[] = { 0, 2, 5, 9, 12, 15 };
+		static const int length[] = { 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5 };
+		int index = _stream.readByte();
+		const int len = length[index >> 4];
+		const int code = base[len] + (index - count[len] * 16) / (1 << (5 - len));
+		for (int i = 0; i <= len; ++i) {
+			index = (index << 1) | _stream.readBit();
+		}
+		return (index & 63) | (code << 6);
+	}
+	int decodeChar() {
+		int i = _child[kHuffmanRoot];
+		while (i < kTableSize) {
+			i += _stream.readBit();
+			i = _child[i];
+		}
+		i -= kTableSize;
+		update(i);
+		return i;
+	}
+	void update(int num) {
+		if (_freq[kHuffmanRoot] == kMaxFreq) {
+			for (int j = 0, i = 0; j < kTableSize; ++j) {
+				if (_child[j] >= kTableSize) {
+					_freq[i] = (_freq[j] + 1) >> 1;
+					_child[i] = _child[j];
+					++i;
+				}
+			}
+			for (int j = 0, i = kCharsCount; i < kTableSize; j += 2, ++i) {
+				const int f = _freq[i] = _freq[j] + _freq[j + 1];
+				int index = i - 1;
+				while (_freq[index] > f) {
+					--index;
+				}
+				++index;
+				const int copySize = (i - index) * sizeof(int);
+				memmove(_freq + index + 1, _freq + index, copySize);
+				_freq[index] = f;
+				memmove(_child + index + 1, _child + index, copySize);
+				_child[index] = j;
+			}
+			for (int i = 0; i < kTableSize; ++i) {
+				const int j = _child[i];
+				if (j >= kTableSize) {
+					_parent[j] = i;
+				} else {
+					_parent[j] = _parent[j + 1] = i;
+				}
+			}
+		}
+		int p = _parent[kTableSize + num];
+		do {
+			++_freq[p];
+			const int i = _freq[p];
+			int index = p + 1;
+			if (_freq[index] < i) {
+				while (_freq[++index] < i) {
+				}
+				--index;
+				_freq[p] = _freq[index];
+				_freq[index] = i;
+				const int k = _child[p];
+				_parent[k] = index;
+				if (k < kTableSize) {
+					_parent[k + 1] = index;
+				}
+				const int j = _child[index];
+				_child[index] = k;
+				_parent[j] = p;
+				if (j < kTableSize) {
+					_parent[j + 1] = p;
+				}
+				_child[p] = j;
+				p = index;
+			}
+			p = _parent[p];
+		} while (p != 0);
+	}
+	bool decode(uint8_t *out, int uncompressedSize) {
+		resetHuffTables();
+		memset(_historyBuffer, ' ', sizeof(_historyBuffer));
+		int offset = 4078;
+		int currentSize = 0;
+		while (currentSize < uncompressedSize) {
+			int chr = decodeChar();
+			if (chr < 256) {
+				*out++ = chr & 255;
+				_historyBuffer[offset++] = chr;
+				offset &= 0xFFF;
+				++currentSize;
+			} else {
+				const int baseOffset = (offset - getHuffCode() - 1) & 0xFFF;
+				const int size = chr - 253;
+				for (int i = 0; i < size; ++i) {
+					chr = _historyBuffer[(baseOffset + i) & 0xFFF];
+					*out++ = chr & 255;
+					_historyBuffer[offset++] = chr;
+					offset &= 0xFFF;
+					++currentSize;
+				}
+			}
+		}
+		return currentSize == uncompressedSize;
+	}
+
+	bool decompressEntry(File &f, const Win31BankEntry *e, uint8_t *out) {
+		f.seek(e->offset);
+		_stream.reset(&f, e->packedSize);
+		return decode(out, e->size);
+	}
+};
+
+const char *ResourceWin31::FILENAME = "BANK";
+
+ResourceWin31::ResourceWin31(const char *dataPath)
+	: _dataPath(dataPath), _entries(0), _entriesCount(0) {
+	_f.open(FILENAME, dataPath);
+	_textBuf = 0;
+	memset(_stringsTable, 0, sizeof(_stringsTable));
+}
+
+ResourceWin31::~ResourceWin31() {
+	free(_entries);
+	free(_textBuf);
+}
+
+bool ResourceWin31::readEntries() {
+	uint8_t buf[32];
+	const int count = _f.read(buf, sizeof(buf));
+	if (count == 32 && memcmp(buf, "NL\00\00", 4) == 0) {
+		_entriesCount = READ_LE_UINT16(buf + 4);
+		debug(DBG_RESOURCE, "Read %d entries in win31 '%s'", _entriesCount, FILENAME);
+		_entries = (Win31BankEntry *)calloc(_entriesCount, sizeof(Win31BankEntry));
+		if (_entries) {
+			uint16_t key = READ_LE_UINT16(buf + 0x14);
+			for (int i = 0; i < _entriesCount; ++i) {
+				_f.read(buf, sizeof(buf));
+				key = decode(buf, sizeof(buf), key);
+				Win31BankEntry *e = &_entries[i];
+				memcpy(e->name, buf, 16);
+				const uint16_t flags = READ_LE_UINT16(buf + 16);
+				e->type = buf[19];
+				e->size = READ_LE_UINT32(buf + 20);
+				e->offset = READ_LE_UINT32(buf + 24);
+				e->packedSize = READ_LE_UINT32(buf + 28);
+				debug(DBG_RESOURCE, "Res #%03d '%s' type %d size %d (%d) offset 0x%x", i, e->name, e->type, e->size, e->packedSize, e->offset);
+				assert(e->size == 0 || flags == 0x80);
+			}
+			readStrings();
+		}
+	}
+	return _entries != 0;
+}
+
+uint8_t *ResourceWin31::loadFile(int num, uint8_t *dst, uint32_t *size) {
+	if (num > 0 && num < _entriesCount) {
+		Win31BankEntry *e = &_entries[num];
+		*size = e->size;
+		if (!dst) {
+			dst = (uint8_t *)malloc(e->size);
+			if (!dst) {
+				warning("Unable to allocate %d bytes", e->size);
+				return 0;
+			}
+		}
+		// check for unpacked data
+		char name[32];
+		snprintf(name, sizeof(name), "%03d_%s", num, e->name);
+		File f;
+		if (f.open(name, _dataPath) && f.size() == e->size) {
+			f.read(dst, e->size);
+			return dst;
+		}
+		LzHuffman lzHuf;
+		if (lzHuf.decompressEntry(_f, e, dst)) {
+			return dst;
+		}
+	}
+	warning("Unable to load resource #%d", num);
+	return 0;
+}
+
+void ResourceWin31::readStrings() {
+	uint32_t len, offset = 0;
+	_textBuf = loadFile(148, 0, &len);
+	while (1) {
+		const uint32_t sep = READ_LE_UINT32(_textBuf + offset); offset += 4;
+		const uint16_t num = sep >> 16;
+		if (num == 0xFFFF) {
+			break;
+		}
+		if (num < ARRAYSIZE(_stringsTable) && _stringsTable[num] == 0) {
+			_stringsTable[num] = (const char *)_textBuf + offset;
+		}
+		while (offset < len && _textBuf[offset++] != 0);
+		// strings are not always '\0' terminated
+		if (_textBuf[offset + 1] != 0) {
+			--offset;
+		}
+	}
+}
+
+const char *ResourceWin31::getString(int num) const {
+	return _stringsTable[num];
+}
+
+const char *ResourceWin31::getMusicName(int num) const {
+	switch (num) {
+	case 7:
+		return "y.mid";
+	case 138:
+		return "X.mid";
+	}
+	return 0;
+}
+
+} // namespace Awe
diff --git a/engines/awe/system_stub.h b/engines/awe/resource_win31.h
similarity index 55%
rename from engines/awe/system_stub.h
rename to engines/awe/resource_win31.h
index 529622853f6..b83fd03f743 100644
--- a/engines/awe/system_stub.h
+++ b/engines/awe/resource_win31.h
@@ -19,50 +19,42 @@
  *
  */
 
-#ifndef AWE_SYSTEM_STUB_H
-#define AWE_SYSTEM_STUB_H
+#ifndef AWE_RESOURCE_WIN31_H
+#define AWE_RESOURCE_WIN31_H
 
 #include "awe/intern.h"
+#include "awe/file.h"
 
 namespace Awe {
 
-struct PlayerInput {
-	enum {
-		DIR_LEFT  = 1 << 0,
-		DIR_RIGHT = 1 << 1,
-		DIR_UP    = 1 << 2,
-		DIR_DOWN  = 1 << 3
-	};
-
-	uint8 dirMask;
-	bool button;
-	bool code;
-	bool pause;
-	bool quit;
-	char lastChar;
-	bool save, load;
-	bool fastMode;
-	int8 stateSlot;
+struct Win31BankEntry {
+	char name[16];
+	uint8_t type;
+	uint32_t offset;
+	uint32_t size;
+	uint32_t packedSize;
 };
 
-struct SystemStub {
-	PlayerInput _pi;
-
-	virtual ~SystemStub() {}
+struct ResourceWin31 {
+	static const char *FILENAME;
 
-	virtual void init(const char *title) = 0;
-	virtual void destroy() = 0;
+	File _f;
+	const char *_dataPath;
+	Win31BankEntry *_entries;
+	int _entriesCount;
+	uint8_t *_textBuf;
+	const char *_stringsTable[614];
 
-	virtual void setPalette(uint8 s, uint8 n, const uint8 *buf) = 0;
-	virtual void copyRect(uint16 x, uint16 y, uint16 w, uint16 h, const uint8 *buf, uint32 pitch) = 0;
+	ResourceWin31(const char *dataPath);
+	~ResourceWin31();
 
-	virtual void processEvents() = 0;
-	virtual void sleep(uint32 duration) = 0;
-	virtual uint32 getTimeStamp() = 0;
+	bool readEntries();
+	uint8_t *loadFile(int num, uint8_t *dst, uint32_t *size);
+	void readStrings();
+	const char *getString(int num) const;
+	const char *getMusicName(int num) const;
 };
 
-extern SystemStub *SystemStub_create();
-
 } // namespace Awe
 
 #endif
diff --git a/engines/awe/scaler.cpp b/engines/awe/scaler.cpp
new file mode 100644
index 00000000000..5f22a50a52e
--- /dev/null
+++ b/engines/awe/scaler.cpp
@@ -0,0 +1,30 @@
+/* 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 "awe/scaler.h"
+
+namespace Awe {
+
+const Scaler *findScaler(const char *name) {
+	return 0;
+}
+
+} // namespace Awe
diff --git a/engines/awe/scaler.h b/engines/awe/scaler.h
new file mode 100644
index 00000000000..da6be0b532a
--- /dev/null
+++ b/engines/awe/scaler.h
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AWE_SCALER_H
+#define AWE_SCALER_H
+
+#include "awe/intern.h"
+
+namespace Awe {
+
+typedef void (*ScaleProc)(int factor, int byteDepth, uint8_t *dst, int dstPitch, const uint8_t *src, int srcPitch, int w, int h);
+
+#define SCALER_TAG 1
+
+struct Scaler {
+	uint32_t tag;
+	const char *name;
+	int factorMin, factorMax;
+	int bpp;
+	ScaleProc scale;
+};
+
+const Scaler *findScaler(const char *name);
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/screenshot.cpp b/engines/awe/screenshot.cpp
new file mode 100644
index 00000000000..eb922d6667d
--- /dev/null
+++ b/engines/awe/screenshot.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 "awe/screenshot.h"
+#include "awe/file.h"
+
+namespace Awe {
+
+static void TO_LE16(uint8_t *dst, uint16_t value) {
+	for (int i = 0; i < 2; ++i) {
+		dst[i] = value & 255;
+		value >>= 8;
+	}
+}
+
+#define kTgaImageTypeUncompressedTrueColor 2
+#define kTgaImageTypeRunLengthEncodedTrueColor 10
+#define kTgaDirectionTop (1 << 5)
+
+static const int TGA_HEADER_SIZE = 18;
+
+void saveTGA(const char *filename, const uint16_t *rgb555, int w, int h) {
+	static const uint8_t kImageType = kTgaImageTypeRunLengthEncodedTrueColor;
+	uint8_t buffer[TGA_HEADER_SIZE];
+	buffer[0] = 0; // ID Length
+	buffer[1] = 0; // ColorMap Type
+	buffer[2] = kImageType;
+	TO_LE16(buffer + 3, 0); // ColorMap Start
+	TO_LE16(buffer + 5, 0); // ColorMap Length
+	buffer[7] = 0;  // ColorMap Bits
+	TO_LE16(buffer + 8, 0); // X-origin
+	TO_LE16(buffer + 10, 0); // Y-origin
+	TO_LE16(buffer + 12, w); // Image Width
+	TO_LE16(buffer + 14, h); // Image Height
+	buffer[16] = 16; // Pixel Depth
+	buffer[17] = kTgaDirectionTop;  // Descriptor
+
+	Common::DumpFile f;
+	if (f.open(filename)) {
+		f.write(buffer, sizeof(buffer));
+		if (kImageType == kTgaImageTypeUncompressedTrueColor) {
+			for (int i = 0; i < w * h; ++i) {
+				const uint16_t color = *rgb555++;
+				f.writeByte(color & 255);
+				f.writeByte(color >> 8);
+			}
+		} else {
+			assert(kImageType == kTgaImageTypeRunLengthEncodedTrueColor);
+			uint16_t prevColor = *rgb555++;
+			int count = 0;
+			for (int i = 1; i < w * h; ++i) {
+				const uint16_t color = *rgb555++;
+				if (prevColor == color && count < 127) {
+					++count;
+					continue;
+				}
+				f.writeByte(count | 0x80);
+				f.writeByte(prevColor & 255);
+				f.writeByte(prevColor >> 8);
+				count = 0;
+				prevColor = color;
+			}
+			if (count != 0) {
+				f.writeByte(count | 0x80);
+				f.writeByte(prevColor & 255);
+				f.writeByte(prevColor >> 8);
+			}
+		}
+	}
+}
+
+static void fwriteUint16LE(Common::WriteStream *fp, uint16_t n) {
+	fp->writeUint16LE(n);
+}
+
+static void fwriteUint32LE(Common::WriteStream *fp, uint32_t n) {
+	fp->writeUint32LE(n);
+}
+
+static const uint16_t TAG_BM = 0x4D42;
+
+void saveBMP(const char *filename, const uint8_t *bits, const uint8_t *pal, int w, int h) {
+#ifdef TODO
+	FILE *fp = fopen(filename, "wb");
+	if (fp) {
+		int alignWidth = (w + 3) & ~3;
+		int imageSize = alignWidth * h;
+
+		// Write file header
+		fwriteUint16LE(fp, TAG_BM);
+		fwriteUint32LE(fp, 14 + 40 + 4 * 256 + imageSize);
+		fwriteUint16LE(fp, 0); // reserved1
+		fwriteUint16LE(fp, 0); // reserved2
+		fwriteUint32LE(fp, 14 + 40 + 4 * 256);
+
+		// Write info header
+		fwriteUint32LE(fp, 40);
+		fwriteUint32LE(fp, w);
+		fwriteUint32LE(fp, h);
+		fwriteUint16LE(fp, 1); // planes
+		fwriteUint16LE(fp, 8); // bit_count
+		fwriteUint32LE(fp, 0); // compression
+		fwriteUint32LE(fp, imageSize); // size_image
+		fwriteUint32LE(fp, 0); // x_pels_per_meter
+		fwriteUint32LE(fp, 0); // y_pels_per_meter
+		fwriteUint32LE(fp, 0); // num_colors_used
+		fwriteUint32LE(fp, 0); // num_colors_important
+
+		// Write palette data
+		for (int i = 0; i < 256; ++i) {
+			fp->writeByte(pal[2], fp);
+			fp->writeByte(pal[1], fp);
+			fp->writeByte(pal[0], fp);
+			fp->writeByte(0, fp);
+			pal += 3;
+		}
+
+		// Write bitmap data
+		const int pitch = w;
+		bits += h * pitch;
+		for (int i = 0; i < h; ++i) {
+			bits -= pitch;
+			fwrite(bits, w, 1, fp);
+			int pad = alignWidth - w;
+			while (pad--) {
+				fp->writeByte(0, fp);
+			}
+		}
+
+		fclose(fp);
+	}
+#else
+	error("TODO: saveBMP");
+#endif
+}
+
+} // namespace Awe
diff --git a/engines/awe/screenshot.h b/engines/awe/screenshot.h
new file mode 100644
index 00000000000..e40ff782be6
--- /dev/null
+++ b/engines/awe/screenshot.h
@@ -0,0 +1,34 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AWE_SCREENSHOT_H
+#define AWE_SCREENSHOT_H
+
+#include "common/scummsys.h"
+
+namespace Awe {
+
+void saveTGA(const char *filename, const uint16_t *rgb, int w, int h);
+void saveBMP(const char *filename, const uint8_t *bits, const uint8_t *pal, int w, int h);
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
new file mode 100644
index 00000000000..65d6eef3793
--- /dev/null
+++ b/engines/awe/script.cpp
@@ -0,0 +1,919 @@
+/* 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 "awe/graphics.h"
+#include "awe/script.h"
+#include "awe/mixer.h"
+#include "awe/resource.h"
+#include "awe/video.h"
+#include "awe/sfxplayer.h"
+#include "awe/systemstub.h"
+#include "awe/util.h"
+
+namespace Awe {
+
+Script::Script(Audio::Mixer *mix, Resource *res, SfxPlayer *ply, Video *vid)
+	: _mix(mix), _res(res), _ply(ply), _vid(vid), _stub(0) {
+}
+
+void Script::init() {
+	memset(_scriptVars, 0, sizeof(_scriptVars));
+	_fastMode = false;
+	_ply->_syncVar = &_scriptVars[VAR_MUSIC_SYNC];
+	_scriptPtr.byteSwap = _is3DO = (_res->getDataType() == Resource::DT_3DO);
+	if (_is3DO) {
+		_scriptVars[0xDB] = 1;
+		_scriptVars[0xE2] = 1;
+		_scriptVars[0xF2] = 6000;
+	} else if (_res->getDataType() != Resource::DT_15TH_EDITION && _res->getDataType() != Resource::DT_20TH_EDITION) {
+		_scriptVars[VAR_RANDOM_SEED] = 0; // time(0);
+#ifdef BYPASS_PROTECTION
+		// these 3 variables are set by the game code
+		_scriptVars[0xBC] = 0x10;
+		_scriptVars[0xC6] = 0x80;
+		_scriptVars[0xF2] = (_res->getDataType() == Resource::DT_AMIGA || _res->getDataType() == Resource::DT_ATARI) ? 6000 : 4000;
+		// these 2 variables are set by the engine executable
+		_scriptVars[0xDC] = 33;
+#endif
+		if (_res->getDataType() == Resource::DT_DOS || _res->getDataType() == Resource::DT_WIN31) {
+			_scriptVars[0xE4] = 20;
+		}
+	}
+}
+
+void Script::op_movConst() {
+	uint8_t i = _scriptPtr.fetchByte();
+	int16_t n = _scriptPtr.fetchWord();
+	debug(DBG_SCRIPT, "Script::op_movConst(0x%02X, %d)", i, n);
+	_scriptVars[i] = n;
+}
+
+void Script::op_mov() {
+	uint8_t i = _scriptPtr.fetchByte();
+	uint8_t j = _scriptPtr.fetchByte();
+	debug(DBG_SCRIPT, "Script::op_mov(0x%02X, 0x%02X)", i, j);
+	_scriptVars[i] = _scriptVars[j];
+}
+
+void Script::op_add() {
+	uint8_t i = _scriptPtr.fetchByte();
+	uint8_t j = _scriptPtr.fetchByte();
+	debug(DBG_SCRIPT, "Script::op_add(0x%02X, 0x%02X)", i, j);
+	_scriptVars[i] += _scriptVars[j];
+}
+
+void Script::op_addConst() {
+	if (_res->getDataType() == Resource::DT_DOS || _res->getDataType() == Resource::DT_AMIGA || _res->getDataType() == Resource::DT_ATARI) {
+		if (_res->_currentPart == 16006 && _scriptPtr.pc == _res->_segCode + 0x6D48) {
+			warning("Script::op_addConst() workaround for infinite looping gun sound");
+			// The script 0x27 slot 0x17 doesn't stop the gun sound from looping.
+			// This is a bug in the original game code, confirmed by Eric Chahi and
+			// addressed with the anniversary editions.
+			// For older releases (DOS, Amiga), we play the 'stop' sound like it is
+			// done in other part of the game code.
+			//
+			//  6D43: jmp(0x6CE5)
+			//  6D46: break
+			//  6D47: VAR(0x06) -= 50
+			//
+			snd_playSound(0x5B, 1, 64, 1);
+		}
+	}
+	uint8_t i = _scriptPtr.fetchByte();
+	int16_t n = _scriptPtr.fetchWord();
+	debug(DBG_SCRIPT, "Script::op_addConst(0x%02X, %d)", i, n);
+	_scriptVars[i] += n;
+}
+
+void Script::op_call() {
+	uint16_t off = _scriptPtr.fetchWord();
+	debug(DBG_SCRIPT, "Script::op_call(0x%X)", off);
+	if (_stackPtr == 0x40) {
+		error("Script::op_call() ec=0x%X stack overflow", 0x8F);
+	}
+	_scriptStackCalls[_stackPtr] = _scriptPtr.pc - _res->_segCode;
+	++_stackPtr;
+	_scriptPtr.pc = _res->_segCode + off;
+}
+
+void Script::op_ret() {
+	debug(DBG_SCRIPT, "Script::op_ret()");
+	if (_stackPtr == 0) {
+		error("Script::op_ret() ec=0x%X stack underflow", 0x8F);
+	}
+	--_stackPtr;
+	_scriptPtr.pc = _res->_segCode + _scriptStackCalls[_stackPtr];
+}
+
+void Script::op_yieldTask() {
+	debug(DBG_SCRIPT, "Script::op_yieldTask()");
+	_scriptPaused = true;
+}
+
+void Script::op_jmp() {
+	uint16_t off = _scriptPtr.fetchWord();
+	debug(DBG_SCRIPT, "Script::op_jmp(0x%02X)", off);
+	_scriptPtr.pc = _res->_segCode + off;
+}
+
+void Script::op_installTask() {
+	uint8_t i = _scriptPtr.fetchByte();
+	uint16_t n = _scriptPtr.fetchWord();
+	debug(DBG_SCRIPT, "Script::op_installTask(0x%X, 0x%X)", i, n);
+	assert(i < 0x40);
+	_scriptTasks[1][i] = n;
+}
+
+void Script::op_jmpIfVar() {
+	uint8_t i = _scriptPtr.fetchByte();
+	debug(DBG_SCRIPT, "Script::op_jmpIfVar(0x%02X)", i);
+	--_scriptVars[i];
+	if (_scriptVars[i] != 0) {
+		op_jmp();
+	} else {
+		_scriptPtr.fetchWord();
+	}
+}
+
+void Script::op_condJmp() {
+	uint8_t op = _scriptPtr.fetchByte();
+	const uint8_t var = _scriptPtr.fetchByte();
+	int16_t b = _scriptVars[var];
+	int16_t a;
+	if (op & 0x80) {
+		a = _scriptVars[_scriptPtr.fetchByte()];
+	} else if (op & 0x40) {
+		a = _scriptPtr.fetchWord();
+	} else {
+		a = _scriptPtr.fetchByte();
+	}
+	debug(DBG_SCRIPT, "Script::op_condJmp(%d, 0x%02X, 0x%02X) var=0x%02X", op, b, a, var);
+	bool expr = false;
+	switch (op & 7) {
+	case 0:
+		expr = (b == a);
+#ifdef BYPASS_PROTECTION
+		if (_res->_currentPart == kPartCopyProtection) {
+			//
+			// 0CB8: jmpIf(VAR(0x29) == VAR(0x1E), @0CD3)
+			// ...
+			//
+			if (var == 0x29 && (op & 0x80) != 0) {
+				// 4 symbols
+				_scriptVars[0x29] = _scriptVars[0x1E];
+				_scriptVars[0x2A] = _scriptVars[0x1F];
+				_scriptVars[0x2B] = _scriptVars[0x20];
+				_scriptVars[0x2C] = _scriptVars[0x21];
+				// counters
+				_scriptVars[0x32] = 6;
+				_scriptVars[0x64] = 20;
+				warning("Script::op_condJmp() bypassing protection");
+				expr = true;
+			}
+		}
+#endif
+		break;
+	case 1:
+		expr = (b != a);
+		break;
+	case 2:
+		expr = (b > a);
+		break;
+	case 3:
+		expr = (b >= a);
+		break;
+	case 4:
+		expr = (b < a);
+		break;
+	case 5:
+		expr = (b <= a);
+		break;
+	default:
+		warning("Script::op_condJmp() invalid condition %d", (op & 7));
+		break;
+	}
+	if (expr) {
+		op_jmp();
+		if (!_is3DO && var == VAR_SCREEN_NUM && _screenNum != _scriptVars[VAR_SCREEN_NUM]) {
+			fixUpPalette_changeScreen(_res->_currentPart, _scriptVars[VAR_SCREEN_NUM]);
+			_screenNum = _scriptVars[VAR_SCREEN_NUM];
+		}
+	} else {
+		_scriptPtr.fetchWord();
+	}
+}
+
+void Script::op_setPalette() {
+	uint16_t i = _scriptPtr.fetchWord();
+	debug(DBG_SCRIPT, "Script::op_changePalette(%d)", i);
+	const int num = i >> 8;
+	if (_vid->_graphics->_fixUpPalette == FIXUP_PALETTE_REDRAW) {
+		if (_res->_currentPart == 16001) {
+			if (num == 10 || num == 16) {
+				return;
+			}
+		}
+		_vid->_nextPal = num;
+	} else {
+		_vid->_nextPal = num;
+	}
+}
+
+void Script::op_changeTasksState() {
+	uint8_t start = _scriptPtr.fetchByte();
+	uint8_t end = _scriptPtr.fetchByte();
+	if (end < start) {
+		warning("Script::op_changeTasksState() ec=0x%X (end < start)", 0x880);
+		return;
+	}
+	uint8_t state = _scriptPtr.fetchByte();
+
+	debug(DBG_SCRIPT, "Script::op_changeTasksState(%d, %d, %d)", start, end, state);
+
+	if (state == 2) {
+		for (; start <= end; ++start) {
+			_scriptTasks[1][start] = 0xFFFE;
+		}
+	} else if (state < 2) {
+		for (; start <= end; ++start) {
+			_scriptStates[1][start] = state;
+		}
+	}
+}
+
+void Script::op_selectPage() {
+	uint8_t i = _scriptPtr.fetchByte();
+	debug(DBG_SCRIPT, "Script::op_selectPage(%d)", i);
+	_vid->setWorkPagePtr(i);
+}
+
+void Script::op_fillPage() {
+	uint8_t i = _scriptPtr.fetchByte();
+	uint8_t color = _scriptPtr.fetchByte();
+	debug(DBG_SCRIPT, "Script::op_fillPage(%d, %d)", i, color);
+	_vid->fillPage(i, color);
+}
+
+void Script::op_copyPage() {
+	uint8_t i = _scriptPtr.fetchByte();
+	uint8_t j = _scriptPtr.fetchByte();
+	debug(DBG_SCRIPT, "Script::op_copyPage(%d, %d)", i, j);
+	_vid->copyPage(i, j, _scriptVars[VAR_SCROLL_Y]);
+}
+
+void Script::op_updateDisplay() {
+	uint8_t page = _scriptPtr.fetchByte();
+	debug(DBG_SCRIPT, "Script::op_updateDisplay(%d)", page);
+	inp_handleSpecialKeys();
+
+#ifndef BYPASS_PROTECTION
+	// entered protection symbols match the expected values
+	if (_res->_currentPart == kPartCopyProtection && _scriptVars[0x67] == 1) {
+		_scriptVars[0xDC] = 33;
+	}
+#endif
+
+	const int frameHz = _is3DO ? 60 : 50;
+	if (!_fastMode && _scriptVars[VAR_PAUSE_SLICES] != 0) {
+		const int delay = _stub->getTimeStamp() - _timeStamp;
+		const int pause = _scriptVars[VAR_PAUSE_SLICES] * 1000 / frameHz - delay;
+		if (pause > 0) {
+			_stub->sleep(pause);
+		}
+	}
+	_timeStamp = _stub->getTimeStamp();
+	if (_is3DO) {
+		_scriptVars[0xF7] = (_timeStamp - _startTime) * frameHz / 1000;
+	} else {
+		_scriptVars[0xF7] = 0;
+	}
+
+	_vid->_displayHead = !((_res->_currentPart == 16004 && _screenNum == 37) || (_res->_currentPart == 16006 && _screenNum == 202));
+	_vid->updateDisplay(page, _stub);
+}
+
+void Script::op_removeTask() {
+	debug(DBG_SCRIPT, "Script::op_removeTask()");
+	_scriptPtr.pc = _res->_segCode + 0xFFFF;
+	_scriptPaused = true;
+}
+
+void Script::op_drawString() {
+	uint16_t strId = _scriptPtr.fetchWord();
+	uint16_t x = _scriptPtr.fetchByte();
+	uint16_t y = _scriptPtr.fetchByte();
+	uint16_t col = _scriptPtr.fetchByte();
+	debug(DBG_SCRIPT, "Script::op_drawString(0x%03X, %d, %d, %d)", strId, x, y, col);
+	_vid->drawString(col, x, y, strId);
+}
+
+void Script::op_sub() {
+	uint8_t i = _scriptPtr.fetchByte();
+	uint8_t j = _scriptPtr.fetchByte();
+	debug(DBG_SCRIPT, "Script::op_sub(0x%02X, 0x%02X)", i, j);
+	_scriptVars[i] -= _scriptVars[j];
+}
+
+void Script::op_and() {
+	uint8_t i = _scriptPtr.fetchByte();
+	uint16_t n = _scriptPtr.fetchWord();
+	debug(DBG_SCRIPT, "Script::op_and(0x%02X, %d)", i, n);
+	_scriptVars[i] = (uint16_t)_scriptVars[i] & n;
+}
+
+void Script::op_or() {
+	uint8_t i = _scriptPtr.fetchByte();
+	uint16_t n = _scriptPtr.fetchWord();
+	debug(DBG_SCRIPT, "Script::op_or(0x%02X, %d)", i, n);
+	_scriptVars[i] = (uint16_t)_scriptVars[i] | n;
+}
+
+void Script::op_shl() {
+	uint8_t i = _scriptPtr.fetchByte();
+	uint16_t n = _scriptPtr.fetchWord();
+	debug(DBG_SCRIPT, "Script::op_shl(0x%02X, %d)", i, n);
+	_scriptVars[i] = (uint16_t)_scriptVars[i] << n;
+}
+
+void Script::op_shr() {
+	uint8_t i = _scriptPtr.fetchByte();
+	uint16_t n = _scriptPtr.fetchWord();
+	debug(DBG_SCRIPT, "Script::op_shr(0x%02X, %d)", i, n);
+	_scriptVars[i] = (uint16_t)_scriptVars[i] >> n;
+}
+
+void Script::op_playSound() {
+	uint16_t resNum = _scriptPtr.fetchWord();
+	uint8_t freq = _scriptPtr.fetchByte();
+	uint8_t vol = _scriptPtr.fetchByte();
+	uint8_t channel = _scriptPtr.fetchByte();
+	debug(DBG_SCRIPT, "Script::op_playSound(0x%X, %d, %d, %d)", resNum, freq, vol, channel);
+	snd_playSound(resNum, freq, vol, channel);
+}
+
+static void preloadSoundCb(void *userdata, int soundNum, const uint8_t *data) {
+	((Script *)userdata)->snd_preloadSound(soundNum, data);
+}
+
+void Script::op_updateResources() {
+	uint16_t num = _scriptPtr.fetchWord();
+	debug(DBG_SCRIPT, "Script::op_updateResources(%d)", num);
+	if (num == 0) {
+		_ply->stop();
+		_mix->stopAll();
+		_res->invalidateRes();
+	} else {
+		_res->update(num, preloadSoundCb, this);
+	}
+}
+
+void Script::op_playMusic() {
+	uint16_t resNum = _scriptPtr.fetchWord();
+	uint16_t delay = _scriptPtr.fetchWord();
+	uint8_t pos = _scriptPtr.fetchByte();
+	debug(DBG_SCRIPT, "Script::op_playMusic(0x%X, %d, %d)", resNum, delay, pos);
+	snd_playMusic(resNum, delay, pos);
+}
+
+void Script::restartAt(int part, int pos) {
+	_ply->stop();
+	_mix->stopAll();
+	if (_res->getDataType() == Resource::DT_20TH_EDITION) {
+		_scriptVars[0xBF] = _difficulty; // difficulty (0 to 2)
+		// _scriptVars[0xDB] = 1; // preload sounds (resnum >= 2000)
+		_scriptVars[0xDE] = _useRemasteredAudio ? 1 : 0; // playback remastered sounds (resnum >= 146)
+	}
+	if (_res->getDataType() == Resource::DT_DOS && part == kPartCopyProtection) {
+		// VAR(0x54) indicates if the "Out of this World" title screen should be presented
+		//
+		//   0084: jmpIf(VAR(0x54) < 128, @00C4)
+		//   ..
+		//   008D: setPalette(num=0)
+		//   0090: updateResources(res=18)
+		//   ...
+		//   00C4: setPalette(num=23)
+		//   00CA: updateResources(res=71)
+
+		// Use "Another World" title screen if language is set to French
+		const bool awTitleScreen = (_vid->_stringsTable == Video::_stringsTableFr);
+		_scriptVars[0x54] = awTitleScreen ? 0x1 : 0x81;
+	}
+	_res->setupPart(part);
+	memset(_scriptTasks, 0xFF, sizeof(_scriptTasks));
+	memset(_scriptStates, 0, sizeof(_scriptStates));
+	_scriptTasks[0][0] = 0;
+	_screenNum = -1;
+	if (pos >= 0) {
+		_scriptVars[0] = pos;
+	}
+	_startTime = _timeStamp = _stub->getTimeStamp();
+	if (part == kPartWater) {
+		if (_res->_demo3Joy.start()) {
+			memset(_scriptVars, 0, sizeof(_scriptVars));
+		}
+	}
+}
+
+void Script::setupTasks() {
+	if (_res->_nextPart != 0) {
+		restartAt(_res->_nextPart);
+		_res->_nextPart = 0;
+	}
+	for (int i = 0; i < 0x40; ++i) {
+		_scriptStates[0][i] = _scriptStates[1][i];
+		uint16_t n = _scriptTasks[1][i];
+		if (n != 0xFFFF) {
+			_scriptTasks[0][i] = (n == 0xFFFE) ? 0xFFFF : n;
+			_scriptTasks[1][i] = 0xFFFF;
+		}
+	}
+}
+
+void Script::runTasks() {
+	for (int i = 0; i < 0x40 && !_stub->_pi.quit; ++i) {
+		if (_scriptStates[0][i] == 0) {
+			uint16_t n = _scriptTasks[0][i];
+			if (n != 0xFFFF) {
+				_scriptPtr.pc = _res->_segCode + n;
+				_stackPtr = 0;
+				_scriptPaused = false;
+				debug(DBG_SCRIPT, "Script::runTasks() i=0x%02X n=0x%02X", i, n);
+				executeTask();
+				_scriptTasks[0][i] = _scriptPtr.pc - _res->_segCode;
+				debug(DBG_SCRIPT, "Script::runTasks() i=0x%02X pos=0x%X", i, _scriptTasks[0][i]);
+			}
+		}
+	}
+}
+
+void Script::executeTask() {
+	while (!_scriptPaused) {
+		uint8_t opcode = _scriptPtr.fetchByte();
+		if (opcode & 0x80) {
+			const uint16_t off = ((opcode << 8) | _scriptPtr.fetchByte()) << 1;
+			_res->_useSegVideo2 = false;
+			Point pt;
+			pt.x = _scriptPtr.fetchByte();
+			pt.y = _scriptPtr.fetchByte();
+			int16_t h = pt.y - 199;
+			if (h > 0) {
+				pt.y = 199;
+				pt.x += h;
+			}
+			debug(DBG_VIDEO, "vid_opcd_0x80 : opcode=0x%X off=0x%X x=%d y=%d", opcode, off, pt.x, pt.y);
+			_vid->setDataBuffer(_res->_segVideo1, off);
+			if (_is3DO) {
+				_vid->drawShape3DO(0xFF, 64, &pt);
+			} else {
+				_vid->drawShape(0xFF, 64, &pt);
+			}
+		} else if (opcode & 0x40) {
+			Point pt;
+			const uint8_t offsetHi = _scriptPtr.fetchByte();
+			const uint16_t off = ((offsetHi << 8) | _scriptPtr.fetchByte()) << 1;
+			pt.x = _scriptPtr.fetchByte();
+			_res->_useSegVideo2 = false;
+			if (!(opcode & 0x20)) {
+				if (!(opcode & 0x10)) {
+					pt.x = (pt.x << 8) | _scriptPtr.fetchByte();
+				} else {
+					pt.x = _scriptVars[pt.x];
+				}
+			} else {
+				if (opcode & 0x10) {
+					pt.x += 0x100;
+				}
+			}
+			pt.y = _scriptPtr.fetchByte();
+			if (!(opcode & 8)) {
+				if (!(opcode & 4)) {
+					pt.y = (pt.y << 8) | _scriptPtr.fetchByte();
+				} else {
+					pt.y = _scriptVars[pt.y];
+				}
+			}
+			uint16_t zoom = 64;
+			if (!(opcode & 2)) {
+				if (opcode & 1) {
+					zoom = _scriptVars[_scriptPtr.fetchByte()];
+				}
+			} else {
+				if (opcode & 1) {
+					_res->_useSegVideo2 = true;
+				} else {
+					zoom = _scriptPtr.fetchByte();
+				}
+			}
+			debug(DBG_VIDEO, "vid_opcd_0x40 : off=0x%X x=%d y=%d", off, pt.x, pt.y);
+			_vid->setDataBuffer(_res->_useSegVideo2 ? _res->_segVideo2 : _res->_segVideo1, off);
+			if (_is3DO) {
+				_vid->drawShape3DO(0xFF, zoom, &pt);
+			} else {
+				_vid->drawShape(0xFF, zoom, &pt);
+			}
+		} else {
+			if (_is3DO) {
+				switch (opcode) {
+				case 11:
+				{
+					const int num = _scriptPtr.fetchByte();
+					debug(DBG_SCRIPT, "Script::op11() setPalette %d", num);
+					_vid->changePal(num);
+				}
+				continue;
+				case 22:
+				{
+					const int var = _scriptPtr.fetchByte();
+					const int shift = _scriptPtr.fetchByte();
+					debug(DBG_SCRIPT, "Script::op22() VAR(0x%02X) <<= %d", var, shift);
+					_scriptVars[var] = (uint16_t)_scriptVars[var] << shift;
+				}
+				continue;
+				case 23:
+				{
+					const int var = _scriptPtr.fetchByte();
+					const int shift = _scriptPtr.fetchByte();
+					debug(DBG_SCRIPT, "Script::op23() VAR(0x%02X) >>= %d", var, shift);
+					_scriptVars[var] = (uint16_t)_scriptVars[var] >> shift;
+				}
+				continue;
+				case 26:
+				{
+					const int num = _scriptPtr.fetchByte();
+					debug(DBG_SCRIPT, "Script::op26() playMusic %d", num);
+					snd_playMusic(num, 0, 0);
+				}
+				continue;
+				case 27:
+				{
+					const int num = _scriptPtr.fetchWord();
+					const int x = _scriptVars[_scriptPtr.fetchByte()];
+					const int y = _scriptVars[_scriptPtr.fetchByte()];
+					const int color = _scriptPtr.fetchByte();
+					_vid->drawString(color, x, y, num);
+				}
+				continue;
+				case 28:
+				{
+					const uint8_t var = _scriptPtr.fetchByte();
+					debug(DBG_SCRIPT, "Script::op28() jmpIf(VAR(0x%02X) == 0)");
+					if (_scriptVars[var] == 0) {
+						op_jmp();
+					} else {
+						_scriptPtr.fetchWord();
+					}
+				}
+				continue;
+				case 29:
+				{
+					const uint8_t var = _scriptPtr.fetchByte();
+					debug(DBG_SCRIPT, "Script::op29() jmpIf(VAR(0x%02X) != 0)");
+					if (_scriptVars[var] != 0) {
+						op_jmp();
+					} else {
+						_scriptPtr.fetchWord();
+					}
+				}
+				continue;
+				case 30:
+				{
+					::debug("Time = %d", _scriptVars[0xF7]);
+				}
+				continue;
+				}
+			}
+			if (opcode > 0x1A) {
+				error("Script::executeTask() ec=0x%X invalid opcode=0x%X", 0xFFF, opcode);
+			} else {
+				(this->*_opTable[opcode])();
+			}
+		}
+	}
+}
+
+void Script::updateInput() {
+	_stub->processEvents();
+	if (_res->_currentPart == kPartPassword) {
+		char c = _stub->_pi.lastChar;
+		if (c == 8 || /*c == 0xD ||*/ c == 0 || (c >= 'a' && c <= 'z')) {
+			_scriptVars[VAR_LAST_KEYCHAR] = c & ~0x20;
+			_stub->_pi.lastChar = 0;
+		}
+	}
+	int16_t lr = 0;
+	int16_t m = 0;
+	int16_t ud = 0;
+	int16_t jd = 0;
+	if (_stub->_pi.dirMask & PlayerInput::DIR_RIGHT) {
+		lr = 1;
+		m |= 1;
+	}
+	if (_stub->_pi.dirMask & PlayerInput::DIR_LEFT) {
+		lr = -1;
+		m |= 2;
+	}
+	if (_stub->_pi.dirMask & PlayerInput::DIR_DOWN) {
+		ud = jd = 1;
+		m |= 4; // crouch
+	}
+	if (_is3DO) { // This could be enabled to any later version than Amiga, Atari and DOS demo
+		if (_stub->_pi.dirMask & PlayerInput::DIR_UP) {
+			ud = -1;
+		}
+		if (_stub->_pi.jump) {
+			jd = -1;
+			m |= 8; // jump
+		}
+	} else {
+		if (_stub->_pi.dirMask & PlayerInput::DIR_UP) {
+			ud = jd = -1;
+			m |= 8; // jump
+		}
+	}
+	if (!(_res->getDataType() == Resource::DT_AMIGA || _res->getDataType() == Resource::DT_ATARI)) {
+		_scriptVars[VAR_HERO_POS_UP_DOWN] = ud;
+	}
+	_scriptVars[VAR_HERO_POS_JUMP_DOWN] = jd;
+	_scriptVars[VAR_HERO_POS_LEFT_RIGHT] = lr;
+	_scriptVars[VAR_HERO_POS_MASK] = m;
+	int16_t action = 0;
+	if (_stub->_pi.action) {
+		action = 1;
+		m |= 0x80;
+	}
+	_scriptVars[VAR_HERO_ACTION] = action;
+	_scriptVars[VAR_HERO_ACTION_POS_MASK] = m;
+	if (_res->_currentPart == kPartWater) {
+		const uint8_t mask = _res->_demo3Joy.update();
+		if (mask != 0) {
+			_scriptVars[VAR_HERO_ACTION_POS_MASK] = mask;
+			_scriptVars[VAR_HERO_POS_MASK] = mask & 15;
+			_scriptVars[VAR_HERO_POS_LEFT_RIGHT] = 0;
+			if (mask & 1) {
+				_scriptVars[VAR_HERO_POS_LEFT_RIGHT] = 1;
+			}
+			if (mask & 2) {
+				_scriptVars[VAR_HERO_POS_LEFT_RIGHT] = -1;
+			}
+			_scriptVars[VAR_HERO_POS_JUMP_DOWN] = 0;
+			if (mask & 4) {
+				_scriptVars[VAR_HERO_POS_JUMP_DOWN] = 1;
+			}
+			if (mask & 8) {
+				_scriptVars[VAR_HERO_POS_JUMP_DOWN] = -1;
+			}
+			_scriptVars[VAR_HERO_ACTION] = (mask >> 7);
+		}
+	}
+}
+
+void Script::inp_handleSpecialKeys() {
+	if (_stub->_pi.pause) {
+		if (_res->_currentPart != kPartCopyProtection && _res->_currentPart != kPartIntro) {
+			_stub->_pi.pause = false;
+			if (_is3DO) {
+				_vid->drawBitmap3DO("PauseShape", _stub);
+			}
+			while (!_stub->_pi.pause && !_stub->_pi.quit) {
+				_stub->processEvents();
+				_stub->sleep(50);
+			}
+		}
+		_stub->_pi.pause = false;
+	}
+	if (_stub->_pi.back) {
+		_stub->_pi.back = false;
+		if (_is3DO) {
+			static const char *names[] = { "EndShape1", "EndShape2" };
+			int current = 0;
+			_vid->drawBitmap3DO(names[current], _stub);
+			while (!_stub->_pi.quit) {
+				_stub->processEvents();
+				_stub->sleep(50);
+				if (_stub->_pi.dirMask & PlayerInput::DIR_LEFT) {
+					_stub->_pi.dirMask &= ~PlayerInput::DIR_LEFT;
+					if (current != 0) {
+						current = 0;
+						_vid->drawBitmap3DO(names[current], _stub);
+					}
+				}
+				if (_stub->_pi.dirMask & PlayerInput::DIR_RIGHT) {
+					_stub->_pi.dirMask &= ~PlayerInput::DIR_RIGHT;
+					if (current != 1) {
+						current = 1;
+						_vid->drawBitmap3DO(names[current], _stub);
+					}
+				}
+				if (_stub->_pi.action) {
+					_stub->_pi.action = false;
+					if (current == 0) {
+						_res->_nextPart = 16000;
+					}
+					break;
+				}
+			}
+		}
+	}
+	if (_stub->_pi.code) {
+		_stub->_pi.code = false;
+		if (_res->_hasPasswordScreen) {
+			if (_res->_currentPart != kPartPassword && _res->_currentPart != kPartCopyProtection) {
+				_res->_nextPart = kPartPassword;
+			}
+		}
+	}
+}
+
+static uint8_t getWavLooping(uint16_t resNum) {
+	switch (resNum) {
+	case 1:
+	case 3:
+	case 8:
+	case 16:
+	case 89:
+	case 97:
+	case 102:
+	case 104:
+	case 106:
+	case 132:
+	case 139: return 1;
+	}
+	return 0;
+}
+
+static int getSoundFreq(uint8_t period) {
+	return kPaulaFreq / (Script::_periodTable[period] * 2);
+}
+
+void Script::snd_playSound(uint16_t resNum, uint8_t freq, uint8_t vol, uint8_t channel) {
+	debug(DBG_SND, "snd_playSound(0x%X, %d, %d, %d)", resNum, freq, vol, channel);
+	if (vol == 0) {
+#ifdef TODO
+		_mix->stopSound(channel);
+#else
+		::error("TODO: snd_playSound");
+#endif
+		return;
+	}
+	if (vol > 63) {
+		vol = 63;
+	}
+	if (freq > 39) {
+		freq = 39;
+	}
+	channel &= 3;
+	switch (_res->getDataType()) {
+	case Resource::DT_20TH_EDITION:
+		if (freq != 0) {
+			--freq;
+		}
+		/* fall-through */
+	case Resource::DT_15TH_EDITION:
+		if (freq >= 32) {
+			// Anniversary editions do not have the 170 period
+			//
+			//  [31] dos=19886 20th=19886 amiga=19886 (period 180)
+			//  [32] dos=21056 20th=22372 amiga=21056 (period 170)
+			//  [33] dos=22372 20th=23704 amiga=22372 (period 160)
+			++freq;
+		}
+		/* fall-through */
+	case Resource::DT_WIN31:
+	{
+#ifdef TODO
+		uint8_t *buf = _res->loadWav(resNum);
+		if (buf) {
+			_mix->playSoundWav(channel, buf, getSoundFreq(freq), vol, getWavLooping(resNum));
+		}
+#else
+		::error("TODO: play wav");
+#endif
+	}
+	break;
+	case Resource::DT_3DO:
+#ifdef TODO
+		_mix->playSoundAiff(channel, resNum, vol);
+#else
+		::error("TODO: play aiff");
+#endif
+		break;
+	case Resource::DT_AMIGA:
+	case Resource::DT_ATARI:
+	case Resource::DT_ATARI_DEMO:
+	case Resource::DT_DOS:
+	{
+#ifdef TODO
+		MemEntry *me = &_res->_memList[resNum];
+		if (me->status == Resource::STATUS_LOADED) {
+			_mix->playSoundRaw(channel, me->bufPtr, getSoundFreq(freq), vol);
+		}
+#else
+		::error("TODO: play sound raw");
+#endif
+	}
+	break;
+	}
+}
+
+void Script::snd_playMusic(uint16_t resNum, uint16_t delay, uint8_t pos) {
+#ifdef TODO
+	debug(DBG_SND, "snd_playMusic(0x%X, %d, %d)", resNum, delay, pos);
+	uint8_t loop = 0;
+	switch (_res->getDataType()) {
+	case Resource::DT_20TH_EDITION:
+		if (resNum == 5000) {
+			_mix->stopMusic();
+			break;
+		}
+		if (resNum >= 5001 && resNum <= 5010) {
+			loop = 1;
+		}
+		/* fall-through */
+	case Resource::DT_15TH_EDITION:
+	case Resource::DT_WIN31:
+		if (resNum != 0) {
+			char path[MAXPATHLEN];
+			const char *p = _res->getMusicPath(resNum, path, sizeof(path));
+			if (p) {
+				_mix->playMusic(p, loop);
+			}
+		}
+		break;
+	case Resource::DT_3DO:
+		if (resNum == 0) {
+			_mix->stopAifcMusic();
+		} else {
+			uint32_t offset = 0;
+			char path[MAXPATHLEN];
+			const char *p = _res->getMusicPath(resNum, path, sizeof(path), &offset);
+			if (p) {
+				_mix->playAifcMusic(p, offset);
+			}
+		}
+		break;
+	default: // DT_AMIGA, DT_ATARI, DT_DOS
+		if (resNum != 0) {
+			_ply->loadSfxModule(resNum, delay, pos);
+			_ply->start();
+			_mix->playSfxMusic(resNum);
+		} else if (delay != 0) {
+			_ply->setEventsDelay(delay);
+		} else {
+			_mix->stopSfxMusic();
+		}
+		break;
+	}
+#else
+	::error("TODO: snd_playMusic");
+#endif
+}
+
+void Script::snd_preloadSound(uint16_t resNum, const uint8_t *data) {
+#ifdef TODO
+	if (_res->getDataType() == Resource::DT_3DO) {
+		_mix->preloadSoundAiff(resNum, data);
+	}
+#else
+	::error("TODO: snd_preloadSound");
+#endif
+}
+
+void Script::fixUpPalette_changeScreen(int part, int screen) {
+	int pal = -1;
+	switch (part) {
+	case 16004:
+		if (screen == 0x47) { // bitmap resource #68
+			pal = 8;
+		}
+		break;
+	case 16006:
+		if (screen == 0x4A) { // bitmap resources #144, #145
+			pal = 1;
+		}
+		break;
+	}
+	if (pal != -1) {
+		debug(DBG_SCRIPT, "Setting palette %d for part %d screen %d", pal, part, screen);
+		_vid->changePal(pal);
+	}
+}
+
+} // namespace Awe
diff --git a/engines/awe/script.h b/engines/awe/script.h
new file mode 100644
index 00000000000..dec4bad4fa0
--- /dev/null
+++ b/engines/awe/script.h
@@ -0,0 +1,137 @@
+/* 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 AWE_SCRIPT_H
+#define AWE_SCRIPT_H
+
+#include "audio/mixer.h"
+#include "awe/intern.h"
+
+namespace Awe {
+
+struct Mixer;
+struct Resource;
+struct SfxPlayer;
+struct SystemStub;
+struct Video;
+
+enum Difficulty {
+	DIFFICULTY_EASY = 0,
+	DIFFICULTY_NORMAL = 1,
+	DIFFICULTY_HARD = 2
+};
+
+struct Script {
+	typedef void (Script:: *OpcodeStub)();
+
+	enum ScriptVars {
+		VAR_RANDOM_SEED = 0x3C,
+
+		VAR_SCREEN_NUM = 0x67,
+
+		VAR_LAST_KEYCHAR = 0xDA,
+
+		VAR_HERO_POS_UP_DOWN = 0xE5,
+
+		VAR_MUSIC_SYNC = 0xF4,
+
+		VAR_SCROLL_Y = 0xF9,
+		VAR_HERO_ACTION = 0xFA,
+		VAR_HERO_POS_JUMP_DOWN = 0xFB,
+		VAR_HERO_POS_LEFT_RIGHT = 0xFC,
+		VAR_HERO_POS_MASK = 0xFD,
+		VAR_HERO_ACTION_POS_MASK = 0xFE,
+		VAR_PAUSE_SLICES = 0xFF
+	};
+
+	static const OpcodeStub _opTable[];
+	static const uint16_t _periodTable[];
+	static Difficulty _difficulty;
+	static bool _useRemasteredAudio;
+
+	Audio::Mixer *_mix;
+	Resource *_res;
+	SfxPlayer *_ply;
+	Video *_vid;
+	SystemStub *_stub;
+
+	int16_t _scriptVars[256];
+	uint16_t _scriptStackCalls[64];
+	uint16_t _scriptTasks[2][64];
+	uint8_t _scriptStates[2][64];
+	Ptr _scriptPtr;
+	uint8_t _stackPtr;
+	bool _scriptPaused;
+	bool _fastMode;
+	int _screenNum;
+	bool _is3DO;
+	uint32_t _startTime, _timeStamp;
+
+	Script(Audio::Mixer *mix, Resource *res, SfxPlayer *ply, Video *vid);
+	void init();
+
+	void op_movConst();
+	void op_mov();
+	void op_add();
+	void op_addConst();
+	void op_call();
+	void op_ret();
+	void op_yieldTask();
+	void op_jmp();
+	void op_installTask();
+	void op_jmpIfVar();
+	void op_condJmp();
+	void op_setPalette();
+	void op_changeTasksState();
+	void op_selectPage();
+	void op_fillPage();
+	void op_copyPage();
+	void op_updateDisplay();
+	void op_removeTask();
+	void op_drawString();
+	void op_sub();
+	void op_and();
+	void op_or();
+	void op_shl();
+	void op_shr();
+	void op_playSound();
+	void op_updateResources();
+	void op_playMusic();
+
+	void restartAt(int part, int pos = -1);
+	void setupPart(int num);
+	void setupTasks();
+	void runTasks();
+	void executeTask();
+
+	void updateInput();
+	void inp_handleSpecialKeys();
+
+	void snd_playSound(uint16_t resNum, uint8_t freq, uint8_t vol, uint8_t channel);
+	void snd_playMusic(uint16_t resNum, uint16_t delay, uint8_t pos);
+	void snd_preloadSound(uint16_t resNum, const uint8_t *data);
+
+	void fixUpPalette_changeScreen(int part, int screen);
+};
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/serializer.cpp b/engines/awe/serializer.cpp
deleted file mode 100644
index ccf0d6648ed..00000000000
--- a/engines/awe/serializer.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "awe/serializer.h"
-#include "awe/util.h"
-
-namespace Awe {
-
-Serializer::Serializer(Common::WriteStream *stream, uint8 *ptrBlock, uint16 saveVer)
-	: _stream(stream), _mode(SM_SAVE), _ptrBlock(ptrBlock), _saveVer(saveVer) {
-}
-
-Serializer::Serializer(Common::SeekableReadStream *stream, uint8 *ptrBlock, uint16 saveVer)
-	: _stream(stream), _mode(SM_LOAD), _ptrBlock(ptrBlock), _saveVer(saveVer) {
-}
-
-void Serializer::saveOrLoadEntries(Entry *entry) {
-	switch (_mode) {
-	case SM_SAVE:
-		saveEntries(entry);
-		break;
-	case SM_LOAD:
-		loadEntries(entry);
-		break;	
-	}
-}
-
-void Serializer::saveEntries(Entry *entry) {
-	Common::WriteStream *stream =
-		dynamic_cast<Common::WriteStream *>(_stream);
-
-	for (; entry->type != SET_END; ++entry) {
-		if (entry->maxVer == CUR_VER) {
-			switch (entry->type) {
-			case SET_INT:
-				saveInt(entry->size, entry->data);
-				break;
-			case SET_ARRAY:
-				if (entry->size == Serializer::SES_INT8) {
-					stream->write(entry->data, entry->n);
-				} else {
-					uint8 *p = (uint8 *)entry->data;
-					for (int i = 0; i < entry->n; ++i) {
-						saveInt(entry->size, p);
-						p += entry->size;
-					}
-				}
-				break;
-			case SET_PTR:
-				stream->writeUint32BE(*(uint8 **)(entry->data) - _ptrBlock);
-				break;
-			case SET_END:
-				break;
-			}
-		}
-	}
-}
-
-void Serializer::loadEntries(Entry *entry) {
-	Common::SeekableReadStream *stream =
-		dynamic_cast<Common::SeekableReadStream *>(_stream);
-
-	for (; entry->type != SET_END; ++entry) {
-		if (_saveVer >= entry->minVer && _saveVer <= entry->maxVer) {
-			switch (entry->type) {
-			case SET_INT:
-				loadInt(entry->size, entry->data);
-				break;
-			case SET_ARRAY:
-				if (entry->size == Serializer::SES_INT8) {
-					stream->read(entry->data, entry->n);
-				} else {
-					uint8 *p = (uint8 *)entry->data;
-					for (int i = 0; i < entry->n; ++i) {
-						loadInt(entry->size, p);
-						p += entry->size;
-					}
-				}
-				break;
-			case SET_PTR:
-				*(uint8 **)(entry->data) = _ptrBlock + stream->readUint32BE();
-				break;
-			case SET_END:
-				break;				
-			}
-		}
-	}
-}
-
-void Serializer::saveInt(uint8 es, void *p) {
-	Common::WriteStream *stream =
-		dynamic_cast<Common::WriteStream *>(_stream);
-
-	switch (es) {
-	case SES_INT8:
-		stream->writeByte(*(uint8 *)p);
-		break;
-	case SES_INT16:
-		stream->writeUint16BE(*(uint16 *)p);
-		break;
-	case SES_INT32:
-		stream->writeUint32BE(*(uint32 *)p);
-		break;
-	}
-}
-
-void Serializer::loadInt(uint8 es, void *p) {
-	Common::SeekableReadStream *stream =
-		dynamic_cast<Common::SeekableReadStream *>(_stream);
-
-	switch (es) {
-	case SES_INT8:
-		*(uint8 *)p = stream->readByte();
-		break;
-	case SES_INT16:
-		*(uint16 *)p = stream->readUint16BE();
-		break;
-	case SES_INT32:
-		*(uint32 *)p = stream->readUint32BE();
-		break;
-	}
-}
-
-} // namespace Awe
diff --git a/engines/awe/serializer.h b/engines/awe/serializer.h
deleted file mode 100644
index 5ab1be8c515..00000000000
--- a/engines/awe/serializer.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AWE_SERIALIZER_H
-#define AWE_SERIALIZER_H
-
-#include "common/stream.h"
-#include "awe/intern.h"
-
-namespace Awe {
-
-#define VER(x) x
-
-#define SE_INT(i,sz,ver)     { Serializer::SET_INT, sz, 1, i, ver, Serializer::CUR_VER }
-#define SE_ARRAY(a,n,sz,ver) { Serializer::SET_ARRAY, sz, n, a, ver, Serializer::CUR_VER }
-#define SE_PTR(p,ver)        { Serializer::SET_PTR, 0, 0, p, ver, Serializer::CUR_VER }
-#define SE_END()             { Serializer::SET_END, 0, 0, 0, 0, 0 }
-
-struct File;
-
-struct Serializer {
-	enum {
-		CUR_VER = 1
-	};
-
-	enum EntryType {
-		SET_INT,
-		SET_ARRAY,
-		SET_PTR,
-		SET_END
-	};
-
-	enum {
-		SES_INT8  = 1,
-		SES_INT16 = 2,
-		SES_INT32 = 4
-	};
-
-	enum Mode {
-		SM_SAVE,
-		SM_LOAD
-	};
-
-	struct Entry {
-		EntryType type;
-		uint8 size;
-		uint16 n;
-		void *data;
-		uint16 minVer;
-		uint16 maxVer;
-	};
-
-	Common::Stream *_stream;
-	Mode _mode;
-	uint8 *_ptrBlock;
-	uint16 _saveVer;
-
-	Serializer(Common::WriteStream *stream,
-		uint8 *ptrBlock, uint16 saveVer = CUR_VER);
-	Serializer(Common::SeekableReadStream *stream,
-		uint8 *ptrBlock, uint16 saveVer = CUR_VER);
-
-	void saveOrLoadEntries(Entry *entry);
-
-	void saveEntries(Entry *entry);
-	void loadEntries(Entry *entry);
-
-	void saveInt(uint8 es, void *p);
-	void loadInt(uint8 es, void *p);
-};
-
-} // namespace Awe
-
-#endif
diff --git a/engines/awe/sfxplayer.cpp b/engines/awe/sfxplayer.cpp
new file mode 100644
index 00000000000..514ee385303
--- /dev/null
+++ b/engines/awe/sfxplayer.cpp
@@ -0,0 +1,245 @@
+/* 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 "awe/sfxplayer.h"
+#include "awe/mixer.h"
+#include "awe/resource.h"
+#include "awe/systemstub.h"
+#include "awe/util.h"
+
+namespace Awe {
+
+SfxPlayer::SfxPlayer(Resource *res)
+	: _res(res), _delay(0) {
+	_playing = false;
+}
+
+void SfxPlayer::setEventsDelay(uint16_t delay) {
+	debug(DBG_SND, "SfxPlayer::setEventsDelay(%d)", delay);
+	_delay = delay;
+}
+
+void SfxPlayer::loadSfxModule(uint16_t resNum, uint16_t delay, uint8_t pos) {
+	debug(DBG_SND, "SfxPlayer::loadSfxModule(0x%X, %d, %d)", resNum, delay, pos);
+	MemEntry *me = &_res->_memList[resNum];
+	if (me->status == Resource::STATUS_LOADED && me->type == Resource::RT_MUSIC) {
+		memset(&_sfxMod, 0, sizeof(SfxModule));
+		_sfxMod.curOrder = pos;
+		_sfxMod.numOrder = me->bufPtr[0x3F];
+		debug(DBG_SND, "SfxPlayer::loadSfxModule() curOrder = 0x%X numOrder = 0x%X", _sfxMod.curOrder, _sfxMod.numOrder);
+		_sfxMod.orderTable = me->bufPtr + 0x40;
+		if (delay == 0) {
+			_delay = READ_BE_UINT16(me->bufPtr);
+		} else {
+			_delay = delay;
+		}
+		_sfxMod.data = me->bufPtr + 0xC0;
+		debug(DBG_SND, "SfxPlayer::loadSfxModule() eventDelay = %d ms", _delay);
+		prepareInstruments(me->bufPtr + 2);
+	} else {
+		warning("SfxPlayer::loadSfxModule() ec=0x%X", 0xF8);
+	}
+}
+
+void SfxPlayer::prepareInstruments(const uint8_t *p) {
+	memset(_sfxMod.samples, 0, sizeof(_sfxMod.samples));
+	for (int i = 0; i < 15; ++i) {
+		SfxInstrument *ins = &_sfxMod.samples[i];
+		uint16_t resNum = READ_BE_UINT16(p); p += 2;
+		if (resNum != 0) {
+			ins->volume = READ_BE_UINT16(p);
+			MemEntry *me = &_res->_memList[resNum];
+			if (me->status == Resource::STATUS_LOADED && me->type == Resource::RT_SOUND) {
+				ins->data = me->bufPtr;
+				debug(DBG_SND, "Loaded instrument 0x%X n=%d volume=%d", resNum, i, ins->volume);
+			} else {
+				error("Error loading instrument 0x%X", resNum);
+			}
+		}
+		p += 2; // skip volume
+	}
+}
+
+void SfxPlayer::play(int rate) {
+	_playing = true;
+	_rate = rate;
+	_samplesLeft = 0;
+	memset(_channels, 0, sizeof(_channels));
+}
+
+static int16_t toS16(int a) {
+	if (a <= -128) {
+		return -32768;
+	} else if (a >= 127) {
+		return 32767;
+	} else {
+		const uint8_t u8 = (a ^ 0x80);
+		return ((u8 << 8) | u8) - 32768;
+	}
+}
+
+static void mixChannel(int16_t &s, SfxChannel *ch) {
+	if (ch->sampleLen == 0) {
+		return;
+	}
+	int pos1 = ch->pos.offset >> Frac::BITS;
+	ch->pos.offset += ch->pos.inc;
+	int pos2 = pos1 + 1;
+	if (ch->sampleLoopLen != 0) {
+		if (pos1 >= ch->sampleLoopPos + ch->sampleLoopLen - 1) {
+			pos2 = ch->sampleLoopPos;
+			ch->pos.offset = pos2 << Frac::BITS;
+		}
+	} else {
+		if (pos1 >= ch->sampleLen - 1) {
+			ch->sampleLen = 0;
+			return;
+		}
+	}
+	int sample = ch->pos.interpolate((int8_t)ch->sampleData[pos1], (int8_t)ch->sampleData[pos2]);
+	sample = s + toS16(sample * ch->volume / 64);
+	s = (sample < -32768 ? -32768 : (sample > 32767 ? 32767 : sample));
+}
+
+void SfxPlayer::mixSamples(int16_t *buf, int len) {
+	while (len != 0) {
+		if (_samplesLeft == 0) {
+			handleEvents();
+			const int samplesPerTick = _rate * (_delay * 60 * 1000 / kPaulaFreq) / 1000;
+			_samplesLeft = samplesPerTick;
+		}
+		int count = _samplesLeft;
+		if (count > len) {
+			count = len;
+		}
+		_samplesLeft -= count;
+		len -= count;
+		for (int i = 0; i < count; ++i) {
+			mixChannel(*buf, &_channels[0]);
+			mixChannel(*buf, &_channels[3]);
+			++buf;
+			mixChannel(*buf, &_channels[1]);
+			mixChannel(*buf, &_channels[2]);
+			++buf;
+		}
+	}
+}
+
+void SfxPlayer::readSamples(int16_t *buf, int len) {
+	if (_delay != 0) {
+		mixSamples(buf, len / 2);
+	}
+}
+
+void SfxPlayer::start() {
+	debug(DBG_SND, "SfxPlayer::start()");
+	_sfxMod.curPos = 0;
+}
+
+void SfxPlayer::stop() {
+	debug(DBG_SND, "SfxPlayer::stop()");
+	_playing = false;
+}
+
+void SfxPlayer::handleEvents() {
+	uint8_t order = _sfxMod.orderTable[_sfxMod.curOrder];
+	const uint8_t *patternData = _sfxMod.data + _sfxMod.curPos + order * 1024;
+	for (uint8_t ch = 0; ch < 4; ++ch) {
+		handlePattern(ch, patternData);
+		patternData += 4;
+	}
+	_sfxMod.curPos += 4 * 4;
+	debug(DBG_SND, "SfxPlayer::handleEvents() order = 0x%X curPos = 0x%X", order, _sfxMod.curPos);
+	if (_sfxMod.curPos >= 1024) {
+		_sfxMod.curPos = 0;
+		order = _sfxMod.curOrder + 1;
+		if (order == _sfxMod.numOrder) {
+			_playing = false;
+		}
+		_sfxMod.curOrder = order;
+	}
+}
+
+void SfxPlayer::handlePattern(uint8_t channel, const uint8_t *data) {
+	SfxPattern pat;
+	memset(&pat, 0, sizeof(SfxPattern));
+	pat.note_1 = READ_BE_UINT16(data + 0);
+	pat.note_2 = READ_BE_UINT16(data + 2);
+	if (pat.note_1 != 0xFFFD) {
+		uint16_t sample = (pat.note_2 & 0xF000) >> 12;
+		if (sample != 0) {
+			uint8_t *ptr = _sfxMod.samples[sample - 1].data;
+			if (ptr != 0) {
+				debug(DBG_SND, "SfxPlayer::handlePattern() preparing sample %d", sample);
+				pat.sampleVolume = _sfxMod.samples[sample - 1].volume;
+				pat.sampleStart = 8;
+				pat.sampleBuffer = ptr;
+				pat.sampleLen = READ_BE_UINT16(ptr) * 2;
+				uint16_t loopLen = READ_BE_UINT16(ptr + 2) * 2;
+				if (loopLen != 0) {
+					pat.loopPos = pat.sampleLen;
+					pat.loopLen = loopLen;
+				} else {
+					pat.loopPos = 0;
+					pat.loopLen = 0;
+				}
+				int16_t m = pat.sampleVolume;
+				uint8_t effect = (pat.note_2 & 0x0F00) >> 8;
+				if (effect == 5) { // volume up
+					uint8_t volume = (pat.note_2 & 0xFF);
+					m += volume;
+					if (m > 0x3F) {
+						m = 0x3F;
+					}
+				} else if (effect == 6) { // volume down
+					uint8_t volume = (pat.note_2 & 0xFF);
+					m -= volume;
+					if (m < 0) {
+						m = 0;
+					}
+				}
+				_channels[channel].volume = m;
+				pat.sampleVolume = m;
+			}
+		}
+	}
+	if (pat.note_1 == 0xFFFD) {
+		debug(DBG_SND, "SfxPlayer::handlePattern() _syncVar = 0x%X", pat.note_2);
+		*_syncVar = pat.note_2;
+	} else if (pat.note_1 == 0xFFFE) {
+		_channels[channel].sampleLen = 0;
+	} else if (pat.note_1 != 0 && pat.sampleBuffer != 0) {
+		assert(pat.note_1 >= 0x37 && pat.note_1 < 0x1000);
+		// convert Amiga period value to hz
+		const int freq = kPaulaFreq / (pat.note_1 * 2);
+		debug(DBG_SND, "SfxPlayer::handlePattern() adding sample freq = 0x%X", freq);
+		SfxChannel *ch = &_channels[channel];
+		ch->sampleData = pat.sampleBuffer + pat.sampleStart;
+		ch->sampleLen = pat.sampleLen;
+		ch->sampleLoopPos = pat.loopPos;
+		ch->sampleLoopLen = pat.loopLen;
+		ch->volume = pat.sampleVolume;
+		ch->pos.offset = 0;
+		ch->pos.inc = (freq << Frac::BITS) / _rate;
+	}
+}
+
+} // namespace Awe
diff --git a/engines/awe/sfxplayer.h b/engines/awe/sfxplayer.h
new file mode 100644
index 00000000000..89c5693c330
--- /dev/null
+++ b/engines/awe/sfxplayer.h
@@ -0,0 +1,97 @@
+/* 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 AWE_SFXPLAYER_H
+#define AWE_SFXPLAYER_H
+
+#include "awe/intern.h"
+
+namespace Awe {
+
+struct SfxInstrument {
+	uint8_t *data;
+	uint16_t volume;
+};
+
+struct SfxModule {
+	const uint8_t *data;
+	uint16_t curPos;
+	uint8_t curOrder;
+	uint8_t numOrder;
+	uint8_t *orderTable;
+	SfxInstrument samples[15];
+};
+
+struct SfxPattern {
+	uint16_t note_1;
+	uint16_t note_2;
+	uint16_t sampleStart;
+	uint8_t *sampleBuffer;
+	uint16_t sampleLen;
+	uint16_t loopPos;
+	uint16_t loopLen;
+	uint16_t sampleVolume;
+};
+
+struct SfxChannel {
+	uint8_t *sampleData;
+	uint16_t sampleLen;
+	uint16_t sampleLoopPos;
+	uint16_t sampleLoopLen;
+	uint16_t volume;
+	Frac pos;
+};
+
+struct Resource;
+
+struct SfxPlayer {
+	enum {
+		NUM_CHANNELS = 4
+	};
+
+	Resource *_res;
+
+	uint16_t _delay;
+	uint16_t _resNum;
+	SfxModule _sfxMod;
+	int16_t *_syncVar;
+	bool _playing;
+	int _rate;
+	int _samplesLeft;
+	SfxChannel _channels[NUM_CHANNELS];
+
+	SfxPlayer(Resource *res);
+
+	void setEventsDelay(uint16_t delay);
+	void loadSfxModule(uint16_t resNum, uint16_t delay, uint8_t pos);
+	void prepareInstruments(const uint8_t *p);
+	void play(int rate);
+	void mixSamples(int16_t *buf, int len);
+	void readSamples(int16_t *buf, int len);
+	void start();
+	void stop();
+	void handleEvents();
+	void handlePattern(uint8_t channel, const uint8_t *patternData);
+};
+
+} // namespace Awe
+
+#endif
diff --git a/engines/awe/staticres.cpp b/engines/awe/staticres.cpp
index 7d6da114249..fe6ba4e58cb 100644
--- a/engines/awe/staticres.cpp
+++ b/engines/awe/staticres.cpp
@@ -19,80 +19,58 @@
  *
  */
 
-#include "awe/logic.h"
+#include "awe/graphics.h"
+#include "awe/script.h"
 #include "awe/resource.h"
 #include "awe/video.h"
 
 namespace Awe {
 
-const Logic::OpcodeStub Logic::OPCODE_TABLE[] = {
+const Script::OpcodeStub Script::_opTable[] = {
 	/* 0x00 */
-	&Logic::op_movConst,
-	&Logic::op_mov,
-	&Logic::op_add,
-	&Logic::op_addConst,
+	&Script::op_movConst,
+	&Script::op_mov,
+	&Script::op_add,
+	&Script::op_addConst,
 	/* 0x04 */
-	&Logic::op_call,
-	&Logic::op_ret,
-	&Logic::op_break,
-	&Logic::op_jmp,
+	&Script::op_call,
+	&Script::op_ret,
+	&Script::op_yieldTask,
+	&Script::op_jmp,
 	/* 0x08 */
-	&Logic::op_setScriptPos,
-	&Logic::op_jnz,
-	&Logic::op_condJmp,
-	&Logic::op_setPalette,
+	&Script::op_installTask,
+	&Script::op_jmpIfVar,
+	&Script::op_condJmp,
+	&Script::op_setPalette,
 	/* 0x0C */
-	&Logic::op_resetScript,
-	&Logic::op_selectPage,
-	&Logic::op_fillPage,
-	&Logic::op_copyPage,
+	&Script::op_changeTasksState,
+	&Script::op_selectPage,
+	&Script::op_fillPage,
+	&Script::op_copyPage,
 	/* 0x10 */
-	&Logic::op_updateDisplay,
-	&Logic::op_halt,
-	&Logic::op_drawString,
-	&Logic::op_sub,
+	&Script::op_updateDisplay,
+	&Script::op_removeTask,
+	&Script::op_drawString,
+	&Script::op_sub,
 	/* 0x14 */
-	&Logic::op_and,
-	&Logic::op_or,
-	&Logic::op_shl,
-	&Logic::op_shr,
+	&Script::op_and,
+	&Script::op_or,
+	&Script::op_shl,
+	&Script::op_shr,
 	/* 0x18 */
-	&Logic::op_soundUnk1,
-	&Logic::op_updateMemList,
-	&Logic::op_soundUnk2
+	&Script::op_playSound,
+	&Script::op_updateResources,
+	&Script::op_playMusic
 };
 
-const uint16 Resource::MEMLIST_AUDIO[] = { 
-	8, 0x10, 0x61, 0x66, 0xFFFF
+const uint16_t Script::_periodTable[] = {
+	1076, 1016,  960,  906,  856,  808,  762,  720,  678,  640,
+	 604,  570,  538,  508,  480,  453,  428,  404,  381,  360,
+	 339,  320,  302,  285,  269,  254,  240,  226,  214,  202,
+	 190,  180,  170,  160,  151,  143,  135,  127,  120,  113
 };
 
-const uint16 Resource::MEM_LIST_PARTS[][4] = {
-	{ 0x14, 0x15, 0x16, 0x00 }, // protection screens
-	{ 0x17, 0x18, 0x19, 0x00 }, // introduction
-	{ 0x1A, 0x1B, 0x1C, 0x11 },
-	{ 0x1D, 0x1E, 0x1F, 0x11 },
-	{ 0x20, 0x21, 0x22, 0x11 },
-	{ 0x23, 0x24, 0x25, 0x00 },
-	{ 0x26, 0x27, 0x28, 0x11 },
-	{ 0x29, 0x2A, 0x2B, 0x11 },
-	{ 0x7D, 0x7E, 0x7F, 0x00 },
-	{ 0x7D, 0x7E, 0x7F, 0x00 }  // password screen
-};
-
-const uint16 Resource::MEM_LIST_DEMO_PARTS[][4] = {
-	{ 0x14, 0x15, 0x16, 0x00 }, // Protection: unused in demo
-	{ 0x17, 0x18, 0x19, 0x00 }, // Introduction: start
-	{ 0x1A, 0x1B, 0x1C, 0x00 },
-	{ 0x1D, 0x1E, 0x1F, 0x11 },
-	{ 0x20, 0x21, 0x22, 0x11 },
-	{ 0x23, 0x24, 0x25, 0x00 },
-	{ 0x26, 0x27, 0x28, 0x11 },
-	{ 0x29, 0x2A, 0x2B, 0x00 },
-	{ 0x7D, 0x7E, 0x7F, 0x00 },
-	{ 0x7D, 0x7E, 0x7F, 0x00 }
-};
-
-const uint8 Video::FONT[] = {
+const uint8_t Graphics::_font[] = {
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00,
 	0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x7E, 0x24, 0x24, 0x7E, 0x24, 0x00,
 	0x08, 0x3E, 0x48, 0x3C, 0x12, 0x7C, 0x10, 0x00, 0x42, 0xA4, 0x48, 0x10, 0x24, 0x4A, 0x84, 0x00,
@@ -143,7 +121,7 @@ const uint8 Video::FONT[] = {
 	0x38, 0x44, 0x82, 0x82, 0x44, 0x28, 0xEE, 0x00, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA
 };
 
-const StrEntry Video::STRINGS_TABLE_ENG[] = {
+const StrEntry Video::_stringsTableFr[] = {
 	{ 0x001, "P E A N U T  3000" },
 	{ 0x002, "Copyright  } 1990 Peanut Computer, Inc.\nAll rights reserved.\n\nCDOS Version 5.01" },
 	{ 0x003, "2" },
@@ -172,26 +150,26 @@ const StrEntry Video::STRINGS_TABLE_ENG[] = {
 	{ 0x01B, "ON" },
 	{ 0x01C, "-" },
 	{ 0x021, "|" },
-	{ 0x022, "--- Theoretical study ---" },
-	{ 0x023, " THE EXPERIMENT WILL BEGIN IN    SECONDS" },
-	{ 0x024, "  20" },
-	{ 0x025, "  19" },
-	{ 0x026, "  18" },
-	{ 0x027, "  4" },
-	{ 0x028, "  3" },
-	{ 0x029, "  2" },
-	{ 0x02A, "  1" },
-	{ 0x02B, "  0" },
+	{ 0x022, "--- Etude theorique ---" },
+	{ 0x023, " L'EXPERIENCE DEBUTERA DANS    SECONDES." },
+	{ 0x024, "20" },
+	{ 0x025, "19" },
+	{ 0x026, "18" },
+	{ 0x027, "4" },
+	{ 0x028, "3" },
+	{ 0x029, "2" },
+	{ 0x02A, "1" },
+	{ 0x02B, "0" },
 	{ 0x02C, "L E T ' S   G O" },
-	{ 0x031, "- Phase 0:\nINJECTION of particles\ninto synchrotron" },
-	{ 0x032, "- Phase 1:\nParticle ACCELERATION." },
-	{ 0x033, "- Phase 2:\nEJECTION of particles\non the shield." },
-	{ 0x034, "A  N  A  L  Y  S  I  S" },
-	{ 0x035, "- RESULT:\nProbability of creating:\n ANTIMATTER: 91.V %\n NEUTRINO 27:  0.04 %\n NEUTRINO 424: 18 %\n" },
-	{ 0x036, "   Practical verification Y/N ?" },
-	{ 0x037, "SURE ?" },
-	{ 0x038, "MODIFICATION OF PARAMETERS\nRELATING TO PARTICLE\nACCELERATOR (SYNCHROTRON)." },
-	{ 0x039, "       RUN EXPERIMENT ?" },
+	{ 0x031, "- Phase 0:\nINJECTION des particules\ndans le synchrotron" },
+	{ 0x032, "- Phase 1:\nACCELERATION des particules." },
+	{ 0x033, "- Phase 2:\nEJECTION des particules\nsur le bouclier." },
+	{ 0x034, "A  N  A  L  Y  S  E" },
+	{ 0x035, "- RESULTAT:\nProbabilites de creer de:\n ANTI-MATIERE: 91.V %\n NEUTRINO 27:  0.04 %\n NEUTRINO 424: 18 %\n" },
+	{ 0x036, "Verification par la pratique O/N ?" },
+	{ 0x037, "SUR ?" },
+	{ 0x038, "MODIFICATION DES PARAMETRES\nRELATIFS A L'ACCELERATEUR\nDE PARTICULES (SYNCHROTRON)." },
+	{ 0x039, "SIMULATION DE L'EXPERIENCE ?" },
 	{ 0x03C, "t---t" },
 	{ 0x03D, "000 ~" },
 	{ 0x03E, ".20x14dd" },
@@ -207,8 +185,8 @@ const StrEntry Video::STRINGS_TABLE_ENG[] = {
 	{ 0x048, "{{{{" },
 	{ 0x049, "Delphine Software" },
 	{ 0x04A, "By Eric Chahi" },
-	{ 0x04B, "  5" },
-	{ 0x04C, "  17" },
+	{ 0x04B, "5" },
+	{ 0x04C, "17" },
 	{ 0x12C, "0" },
 	{ 0x12D, "1" },
 	{ 0x12E, "2" },
@@ -225,15 +203,15 @@ const StrEntry Video::STRINGS_TABLE_ENG[] = {
 	{ 0x139, "D" },
 	{ 0x13A, "E" },
 	{ 0x13B, "F" },
-	{ 0x13C, "        ACCESS CODE:" },
-	{ 0x13D, "PRESS BUTTON OR RETURN TO CONTINUE" },
-	{ 0x13E, "   ENTER ACCESS CODE" },
-	{ 0x13F, "   INVALID PASSWORD !" },
+	{ 0x13C, "       CODE D'ACCES:" },
+	{ 0x13D, "PRESSEZ LE BOUTON POUR CONTINUER" },
+	{ 0x13E, "   ENTRER LE CODE D'ACCES" },
+	{ 0x13F, "MOT DE PASSE INVALIDE !" },
 	{ 0x140, "ANNULER" },
-	{ 0x141, "      INSERT DISK ?\n\n\n\n\n\n\n\n\nPRESS ANY KEY TO CONTINUE" },
-	{ 0x142, " SELECT SYMBOLS CORRESPONDING TO\n THE POSITION\n ON THE CODE WHEEL" },
-	{ 0x143, "    LOADING..." },
-	{ 0x144, "              ERROR" },
+	{ 0x141, "     INSEREZ LA DISQUETTE ?\n\n\n\n\n\n\n\n\nPRESSEZ UNE TOUCHE POUR CONTINUER" },
+	{ 0x142, "SELECTIONNER LES SYMBOLES CORRESPONDANTS\nA LA POSITION\nDE LA ROUE DE PROTECTION" },
+	{ 0x143, "CHARGEMENT..." },
+	{ 0x144, "             ERREUR" },
 	{ 0x15E, "LDKD" },
 	{ 0x15F, "HTDC" },
 	{ 0x160, "CLLD" },
@@ -257,37 +235,37 @@ const StrEntry Video::STRINGS_TABLE_ENG[] = {
 	{ 0x172, "TFBB" },
 	{ 0x173, "TXHF" },
 	{ 0x174, "JHJL" },
-	{ 0x181, " BY" },
+	{ 0x181, "PAR" },
 	{ 0x182, "ERIC CHAHI" },
-	{ 0x183, "         MUSIC AND SOUND EFFECTS" },
-	{ 0x184, " " },
+	{ 0x183, "          MUSIQUES ET BRUITAGES" },
+	{ 0x184, "DE" },
 	{ 0x185, "JEAN-FRANCOIS FREITAS" },
-	{ 0x186, "IBM PC VERSION" },
-	{ 0x187, "      BY" },
+	{ 0x186, "VERSION IBM PC" },
+	{ 0x187, "      PAR" },
 	{ 0x188, " DANIEL MORAIS" },
-	{ 0x18B, "       THEN PRESS FIRE" },
-	{ 0x18C, " PUT THE PADDLE ON THE UPPER LEFT CORNER" },
-	{ 0x18D, "PUT THE PADDLE IN CENTRAL POSITION" },
-	{ 0x18E, "PUT THE PADDLE ON THE LOWER RIGHT CORNER" },
-	{ 0x258, "      Designed by ..... Eric Chahi" },
-	{ 0x259, "    Programmed by...... Eric Chahi" },
-	{ 0x25A, "      Artwork ......... Eric Chahi" },
-	{ 0x25B, "Music by ........ Jean-francois Freitas" },
-	{ 0x25C, "            Sound effects" },
+	{ 0x18B, "PUIS PRESSER LE BOUTON" },
+	{ 0x18C, "POSITIONNER LE JOYSTICK EN HAUT A GAUCHE" },
+	{ 0x18D, " POSITIONNER LE JOYSTICK AU CENTRE" },
+	{ 0x18E, " POSITIONNER LE JOYSTICK EN BAS A DROITE" },
+	{ 0x258, "       Conception ..... Eric Chahi" },
+	{ 0x259, "    Programmation ..... Eric Chahi" },
+	{ 0x25A, "     Graphismes ....... Eric Chahi" },
+	{ 0x25B, "Musique de ...... Jean-francois Freitas" },
+	{ 0x25C, "              Bruitages" },
 	{ 0x25D, "        Jean-Francois Freitas\n             Eric Chahi" },
-	{ 0x263, "              Thanks To" },
+	{ 0x263, "               Merci a" },
 	{ 0x264, "           Jesus Martinez\n\n          Daniel Morais\n\n        Frederic Savoir\n\n      Cecile Chahi\n\n    Philippe Delamarre\n\n  Philippe Ulrich\n\nSebastien Berthet\n\nPierre Gousseau" },
-	{ 0x265, "Now Go Out Of This World" },
-	{ 0x190, "Good evening professor." },
-	{ 0x191, "I see you have driven here in your\nFerrari." },
+	{ 0x265, "Now Go Back To Another Earth" },
+	{ 0x190, "Bonsoir professeur." },
+	{ 0x191, "Je vois que Monsieur a pris\nsa Ferrari." },
 	{ 0x192, "IDENTIFICATION" },
 	{ 0x193, "Monsieur est en parfaite sante." },
-	{ 0x194, "Y\n" },
+	{ 0x194, "O" },
 	{ 0x193, "AU BOULOT !!!\n" },
-	{ 0xFFFF, "" }
+	{ 0xFFFF, 0 }
 };
 
-const StrEntry Video::STRINGS_TABLE_DEMO[] = {
+const StrEntry Video::_stringsTableEng[] = {
 	{ 0x001, "P E A N U T  3000" },
 	{ 0x002, "Copyright  } 1990 Peanut Computer, Inc.\nAll rights reserved.\n\nCDOS Version 5.01" },
 	{ 0x003, "2" },
@@ -369,14 +347,38 @@ const StrEntry Video::STRINGS_TABLE_DEMO[] = {
 	{ 0x139, "D" },
 	{ 0x13A, "E" },
 	{ 0x13B, "F" },
+	{ 0x13C, "        ACCESS CODE:" },
 	{ 0x13D, "PRESS BUTTON OR RETURN TO CONTINUE" },
 	{ 0x13E, "   ENTER ACCESS CODE" },
 	{ 0x13F, "   INVALID PASSWORD !" },
 	{ 0x140, "ANNULER" },
-	{ 0x141, "          INSERT DISK ?" },
+	{ 0x141, "      INSERT DISK ?\n\n\n\n\n\n\n\n\nPRESS ANY KEY TO CONTINUE" },
 	{ 0x142, " SELECT SYMBOLS CORRESPONDING TO\n THE POSITION\n ON THE CODE WHEEL" },
 	{ 0x143, "    LOADING..." },
 	{ 0x144, "              ERROR" },
+	{ 0x15E, "LDKD" },
+	{ 0x15F, "HTDC" },
+	{ 0x160, "CLLD" },
+	{ 0x161, "FXLC" },
+	{ 0x162, "KRFK" },
+	{ 0x163, "XDDJ" },
+	{ 0x164, "LBKG" },
+	{ 0x165, "KLFB" },
+	{ 0x166, "TTCT" },
+	{ 0x167, "DDRX" },
+	{ 0x168, "TBHK" },
+	{ 0x169, "BRTD" },
+	{ 0x16A, "CKJL" },
+	{ 0x16B, "LFCK" },
+	{ 0x16C, "BFLX" },
+	{ 0x16D, "XJRT" },
+	{ 0x16E, "HRTB" },
+	{ 0x16F, "HBHK" },
+	{ 0x170, "JCGB" },
+	{ 0x171, "HHFL" },
+	{ 0x172, "TFBB" },
+	{ 0x173, "TXHF" },
+	{ 0x174, "JHJL" },
 	{ 0x181, " BY" },
 	{ 0x182, "ERIC CHAHI" },
 	{ 0x183, "         MUSIC AND SOUND EFFECTS" },
@@ -389,13 +391,6 @@ const StrEntry Video::STRINGS_TABLE_DEMO[] = {
 	{ 0x18C, " PUT THE PADDLE ON THE UPPER LEFT CORNER" },
 	{ 0x18D, "PUT THE PADDLE IN CENTRAL POSITION" },
 	{ 0x18E, "PUT THE PADDLE ON THE LOWER RIGHT CORNER" },
-	{ 0x1F4, "Over Two Years in the Making" },
-	{ 0x1F5, "   A New, State\nof the Art, Polygon\n  Graphics System" },
-	{ 0x1F6, "   Comes to the\nComputer With Full\n Screen Graphics" },
-	{ 0x1F7, "While conducting a nuclear fission\nexperiment at your local\nparticle accelerator ..." },
-	{ 0x1F8, "Nature decides to put a little\n    extra spin on the ball" },
-	{ 0x1F9, "And sends you ..." },
-	{ 0x1FA, "     Out of this World\nA Cinematic Action Adventure\n Coming soon to a computer\n      screen near you\n from Interplay Productions\n   coming soon to the IBM" },
 	{ 0x258, "      Designed by ..... Eric Chahi" },
 	{ 0x259, "    Programmed by...... Eric Chahi" },
 	{ 0x25A, "      Artwork ......... Eric Chahi" },
@@ -411,6 +406,1963 @@ const StrEntry Video::STRINGS_TABLE_DEMO[] = {
 	{ 0x193, "Monsieur est en parfaite sante." },
 	{ 0x194, "Y\n" },
 	{ 0x193, "AU BOULOT !!!\n" },
+	{ 0xFFFF, 0 }
+};
+
+const StrEntry Video::_stringsTableDemo[] = {
+	{ 0x1F4, "Over Two Years in the Making" },
+	{ 0x1F5, "   A New, State\nof the Art, Polygon\n  Graphics System" },
+	{ 0x1F6, "   Comes to the\nComputer With Full\n Screen Graphics" },
+	{ 0x1F7, "While conducting a nuclear fission\nexperiment at your local\nparticle accelerator ..." },
+	{ 0x1F8, "Nature decides to put a little\n    extra spin on the ball" },
+	{ 0x1F9, "And sends you ..." },
+	{ 0x1FA, "     Out of this World\nA Cinematic Action Adventure\n from Interplay Productions\n                    \n       By Eric CHAHI      \n\n  IBM version : D.MORAIS\n" },
+	{ 0xFFFF, 0 }
+};
+
+const uint16_t Video::_stringsId15th[] = {
+	0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, 0x008, 0x00A, 0x00B, 0x00C, 0x00D, 0x00E, 0x00F, 0x010, 0x011,
+	0x012, 0x013, 0x014, 0x015, 0x016, 0x017, 0x018, 0x019, 0x01A, 0x01B, 0x01C, 0x021, 0x022, 0x023, 0x024, 0x025,
+	0x026, 0x027, 0x028, 0x029, 0x02A, 0x02B, 0x02C, 0x031, 0x032, 0x033, 0x034, 0x035, 0x036, 0x037, 0x038, 0x039,
+	0x03C, 0x03D, 0x03E, 0x03F, 0x040, 0x041, 0x042, 0x043, 0x044, 0x045, 0x046, 0x047, 0x048, 0x04B, 0x04C, 0x12C,
+	0x12D, 0x12E, 0x12F, 0x130, 0x131, 0x132, 0x133, 0x134, 0x135, 0x136, 0x137, 0x138, 0x139, 0x13C, 0x13D, 0x13E,
+	0x13F, 0x140, 0x141, 0x142, 0x143, 0x144, 0x258, 0x259, 0x25A, 0x25B, 0x25C, 0x25D, 0x25E, 0x25F, 0x260, 0x261,
+	0x263, 0x264, 0x265, 0x181, 0x182, 0x183, 0x184, 0x185, 0x186, 0x187, 0x188, 0x190, 0x191, 0x192, 0x193, 0x194,
+	0x193, 0x1F4, 0x1F5, 0x1F6, 0x1F7, 0x1F8, 0x1F9, 0x1FA, 0x384, 0x385, 0x386, 0x387, 0x15E, 0x17C, 0x17D, 0x15F,
+	0x17A, 0x17B, 0x160, 0x164, 0x163, 0x177, 0x175, 0x161, 0x176, 0x162, 0x179, 0x165, 0x178, 0x166, 0x167, 0x168,
+	0x16C, 0x16D, 0x16E, 0x16F, 0x170, 0x169, 0x172, 0x17F, 0x173, 0x17E, 0x174, 0x16A, 0x16B
+};
+
+const char *Video::_stringsTable15th[] = {
+	"P E A N U T  3000",
+	"Copyright  } 1990 Peanut Computer, Inc.\nAll rights reserved.\n\nCDOS Version 5.01",
+	"2",
+	"3",
+	".",
+	"A",
+	"@",
+	"PEANUT 3000",
+	"R",
+	"U",
+	"N",
+	"P",
+	"R",
+	"O",
+	"J",
+	"E",
+	"C",
+	"T",
+	"Shield 9A.5f Ok",
+	"Flux % 5.0177 Ok",
+	"CDI Vector ok",
+	" %%%ddd ok",
+	"Race-Track ok",
+	"SYNCHROTRON",
+	"E: 23%\ng: .005\n\nRK: 77.2L\n\nopt: g+\n\n Shield:\n1: OFF\n2: ON\n3: ON\n\nP~: 1\n",
+	"ON",
+	"-",
+	"|",
+	"--- Theoretical study ---",
+	" THE EXPERIMENT WILL BEGIN IN    SECONDS",
+	"  20",
+	"  19",
+	"  18",
+	"  4",
+	"  3",
+	"  2",
+	"  1",
+	"  0",
+	"L E T ' S   G O",
+	"- Phase 0:\nINJECTION of particles\ninto synchrotron",
+	"- Phase 1:\nParticle ACCELERATION.",
+	"- Phase 2:\nEJECTION of particles\non the shield.",
+	"A  N  A  L  Y  S  I  S",
+	"- RESULT:\nProbability of creating:\n ANTIMATTER: 91.V %\n NEUTRINO 27:  0.04 %\n NEUTRINO 424: 18 %\n",
+	"   Practical verification Y/N ?",
+	"SUR ?",
+	"MODIFICATION OF PARAMETERS\nRELATING TO PARTICLE\nACCELERATOR (SYNCHROTRON).",
+	"       RUN EXPERIMENT ?",
+	"t---t",
+	"000 ~",
+	".20x14dd",
+	"gj5r5r",
+	"tilgor 25%",
+	"12% 33% checked",
+	"D=4.2158005584",
+	"d=10.00001",
+	"+",
+	"*",
+	"% 304",
+	"gurgle 21",
+	"{{{{",
+	"  5",
+	"  17",
+	"   N C B F G H",
+	"   T A K R P X",
+	"N",
+	"C",
+	"B",
+	"F",
+	"G",
+	"H",
+	"T",
+	"A",
+	"K",
+	"R",
+	"X",
+	"P",
+	"        ACCESS CODE:",
+	"    PRESS BUTTON TO CONTINUE",
+	"   ENTER ACCESS CODE",
+	"   PASSWORD INVALID!",
+	"ANNULER",
+	"Burp !",
+	"I want to believe",
+	"    LOADING...",
+	"              ERROR",
+	"      Designed, program & artwork\n            by Eric Chahi",
+	"            ",
+	"     Music by J.F Freitas, Elmobo",
+	"     PC Port (www.ManaGames.com):\n     ManuTOO (aka Emmanuel Rivoire)\n ",
+	"            Sound effects:",
+	"  Jean-Francois Freitas, Eric Chahi\n\n  Additional Gfx: Bertrand Dupuy (menu)",
+	"         -----",
+	"    ----------",
+	"             \n\n",
+	"            \n\n          ",
+	"              Thanks To",
+	"           Jesus Martinez\n\n          Daniel Morais\n\n        Pierre Gousseau\n\n      Cecile Chahi\n\n    Philippe Delamarre\n\n  Frederic Sardain\n\nSebastien Berthet",
+	"Now Go Back To Another Earth",
+	" BY",
+	"ERIC CHAHI",
+	"         MUSIC AND SOUND EFFECTS",
+	"",
+	"JEAN-FRANCOIS FREITAS",
+	" GBA VERSION",
+	"      BY",
+	"CYRIL COGORDAN",
+	"Good evening professor.",
+	"I see you have driven here in your\nFerrari.",
+	"IDENTIFICATION",
+	"Monsieur est en parfaite sante.",
+	"Y",
+	"AU BOULOT !!!\n",
+	"Over Two Years in the Making",
+	"   A New, State\nof the Art, Polygon\n  Graphics System",
+	"   Comes to the\nComputer With Full\n Screen Graphics",
+	"While conducting a nuclear fission\nexperiment at your local\nparticle accelerator ...",
+	"Nature decides to put a little\n    extra spin on the ball",
+	"And sends you ...",
+	"     Another World\nA Cinematic Action Adventure\n Coming soon to a computer\n      screen near you\n from ??????? Productions\n   ",
+	"P A U S E",
+	"CONTINUE",
+	"EXIT",
+	"*",
+	"KBAB",
+	"KNNN",
+	"KFBN",
+	"HPBC",
+	"XACN",
+	"KNTC",
+	"CKKB",
+	"KNAG",
+	"XBBT",
+	"BGAF",
+	"RNTA",
+	"FXKC",
+	"RABH",
+	"ARFA",
+	"FRPX",
+	"AKFN",
+	"GKHH",
+	"PPCP",
+	"BBRX",
+	"PNHA",
+	"NFKX",
+	"XTRP",
+	"HRPN",
+	"HNHA",
+	"TCGN",
+	"NRPB",
+	"PFNN",
+	"CRGN",
+	"PXHF",
+	"XXKF",
+	"THTK",
+	"CATK",
+	"KFCA",
+};
+
+const char *Video::_str0x194AtariDemo = "Je signale que Monsieur\na tout de meme 40 minutes\net 21 secondes de retard.";
+
+const StrEntry Video::_stringsTable3DO[] = {
+	{ 1, "Copyright } 1997 Cortland Computer, Inc.\nAll rights reserved.\n\nGS/OS Version 7.03\nII Infinitum!" },
+	{ 2, "Copyright } 1997 Peanut Computer, Inc.\nAll rights reserved.\n\nOS/BH Version 7.03" },
+	{ 3, "2" },
+	{ 4, "3" },
+	{ 5, "." },
+	{ 6, "A" },
+	{ 7, "@" },
+	{ 10, "R" },
+	{ 11, "U" },
+	{ 12, "N" },
+	{ 13, "P" },
+	{ 14, "R" },
+	{ 15, "O" },
+	{ 16, "J" },
+	{ 17, "E" },
+	{ 18, "C" },
+	{ 19, "T" },
+	{ 20, "Shield 9A.5f Ok" },
+	{ 21, "Flux % 5.0177 Ok" },
+	{ 22, "CDI Vector ok" },
+	{ 23, " %%%ddd ok" },
+	{ 24, "Race-Track ok" },
+	{ 25, "SYNCHROTRON" },
+	{ 26, "E: 23%\ng: .005\n\nRK: 77.2L\n\nopt: g+\n\n Shield:\n1: OFF\n2: ON\n3: ON\n\nP~: 1\n" },
+	{ 27, "ON" },
+	{ 28, "-" },
+	{ 33, "|" },
+	{ 34, "--- Theoretical study ---" },
+	{ 35, " THE EXPERIMENT WILL BEGIN IN    SECONDS" },
+	{ 36, "  20" },
+	{ 37, "  19" },
+	{ 38, "  18" },
+	{ 39, "  4" },
+	{ 40, "  3" },
+	{ 41, "  2" },
+	{ 42, "  1" },
+	{ 43, "  0" },
+	{ 49, "- Phase 1:\nINJECTION of particles\ninto synchrotron" },
+	{ 50, "- Phase 2:\nParticle ACCELERATION." },
+	{ 51, "- Phase 3:\nEJECTION of particles\non the shield." },
+	{ 52, "   A N A L Y S I S" },
+	{ 53, "- RESULT:\nProbability of creating:\n ANTIMATTER  : 91.20 %\n NEUTRINO 27 :  0.04 %\n NEUTRINO 424: 18.02 %\n" },
+	{ 54, "   Practical verification Y/N ?" },
+	{ 55, "SURE ?" },
+	{ 56, "MODIFICATION OF PARAMETERS\nRELATING TO PARTICLE\nACCELERATOR (SYNCHROTRON)." },
+	{ 57, "       RUN EXPERIMENT ?" },
+	{ 60, "t---t" },
+	{ 61, "000 ~" },
+	{ 62, ".20x14dd" },
+	{ 63, "gj5r5r" },
+	{ 64, "tilgor 25%" },
+	{ 65, "12% 33% checked" },
+	{ 66, "D=4.2158005584" },
+	{ 67, "d=10.00001" },
+	{ 68, "+" },
+	{ 69, "*" },
+	{ 70, "% 304" },
+	{ 71, "gurgle 21" },
+	{ 72, "{{{{" },
+	{ 75, "  5" },
+	{ 76, "  17" },
+	{ 300, "   B C D F G H" },
+	{ 301, "   J K L R T X" },
+	{ 302, "B" },
+	{ 303, "C" },
+	{ 304, "D" },
+	{ 305, "F" },
+	{ 306, "G" },
+	{ 307, "H" },
+	{ 308, "J" },
+	{ 309, "K" },
+	{ 310, "L" },
+	{ 311, "R" },
+	{ 312, "X" },
+	{ 313, "T" },
+	{ 316, "        ACCESS CODE:" },
+	{ 317, "  PRESS BUTTON TO CONTINUE" },
+	{ 318, "    PRESS BUTTON TO CONTINUE" },
+	{ 319, "   PASSWORD INVALID!" },
+	{ 320, "INVALID" },
+	{ 350, "LDKD" },
+	{ 351, "HTDC" },
+	{ 352, "CLLD" },
+	{ 353, "FXLC" },
+	{ 354, "KRFK" },
+	{ 355, "XDDJ" },
+	{ 356, "LBKG" },
+	{ 357, "KLFB" },
+	{ 358, "TTCT" },
+	{ 359, "DDRX" },
+	{ 360, "TBHK" },
+	{ 361, "BRTD" },
+	{ 362, "CKJL" },
+	{ 363, "LFCK" },
+	{ 364, "BFLX" },
+	{ 365, "XJRT" },
+	{ 366, "HRTB" },


Commit: a3c989904bd12436c5d76837333af435131bdae1
    https://github.com/scummvm/scummvm/commit/a3c989904bd12436c5d76837333af435131bdae1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Added main run method logic

Changed paths:
    engines/awe/awe.cpp
    engines/awe/graphics.h
    engines/awe/unpack.cpp


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 3bcfa173589..fc8b34d7936 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -24,40 +24,19 @@
 #include "common/stream.h"
 #include "engines/util.h"
 #include "awe/awe.h"
+#include "awe/engine.h"
+#include "awe/graphics.h"
+#include "awe/resource.h"
+#include "awe/scaler.h"
+#include "awe/script.h"
+#include "awe/systemstub.h"
 #include "awe/util.h"
+#include "awe/video.h"
 
 namespace Awe {
 
 AweEngine *g_engine;
 
-#ifdef TODO
-static const char USAGE[] =
-"raw(gl) - Another World Interpreter\n"
-"Usage: %s [OPTIONS]...\n"
-"  --datapath=PATH   Path to data files (default '.')\n"
-"  --language=LANG   Language (fr,us,de,es,it)\n"
-"  --part=NUM        Game part to start from (0-35 or 16001-16009)\n"
-"  --render=NAME     Renderer (original,software,gl)\n"
-"  --window=WxH      Windowed display size (default '640x400')\n"
-"  --fullscreen      Fullscreen display (stretched)\n"
-"  --fullscreen-ar   Fullscreen display (16:10 aspect ratio)\n"
-"  --ega-palette     Use EGA palette with DOS version\n"
-"  --demo3-joy       Use inputs from 'demo3.joy' (DOS demo)\n"
-"  --difficulty=DIFF Difficulty (easy,normal,hard)\n"
-"  --audio=AUDIO     Audio (original,remastered)\n"
-;
-
-static const struct {
-	const char *name;
-	int lang;
-} LANGUAGES[] = {
-	{ "fr", LANG_FR },
-	{ "us", LANG_US },
-	{ "de", LANG_DE },
-	{ "es", LANG_ES },
-	{ "it", LANG_IT },
-	{ 0, -1 }
-};
 
 static const struct {
 	const char *name;
@@ -102,6 +81,7 @@ static Graphics *createGraphics(int type) {
 	return 0;
 }
 
+
 static int getGraphicsType(Resource::DataType type) {
 	switch (type) {
 	case Resource::DT_15TH_EDITION:
@@ -113,26 +93,40 @@ static int getGraphicsType(Resource::DataType type) {
 	}
 }
 
-struct Scaler {
-	char name[32];
-	int factor;
-};
-
-static void parseScaler(char *name, Scaler *s) {
-	char *sep = strchr(name, '@');
-	if (sep) {
-		*sep = 0;
-		strncpy(s->name, name, sizeof(s->name) - 1);
-		s->name[sizeof(s->name) - 1] = 0;
-	}
-	if (sep) {
-		s->factor = atoi(sep + 1);
-	}
-}
-
 static const int DEFAULT_WINDOW_W = 640;
 static const int DEFAULT_WINDOW_H = 400;
 
+
+#ifdef TODO
+static const char USAGE[] =
+"raw(gl) - Another World Interpreter\n"
+"Usage: %s [OPTIONS]...\n"
+"  --datapath=PATH   Path to data files (default '.')\n"
+"  --language=LANG   Language (fr,us,de,es,it)\n"
+"  --part=NUM        Game part to start from (0-35 or 16001-16009)\n"
+"  --render=NAME     Renderer (original,software,gl)\n"
+"  --window=WxH      Windowed display size (default '640x400')\n"
+"  --fullscreen      Fullscreen display (stretched)\n"
+"  --fullscreen-ar   Fullscreen display (16:10 aspect ratio)\n"
+"  --ega-palette     Use EGA palette with DOS version\n"
+"  --demo3-joy       Use inputs from 'demo3.joy' (DOS demo)\n"
+"  --difficulty=DIFF Difficulty (easy,normal,hard)\n"
+"  --audio=AUDIO     Audio (original,remastered)\n"
+;
+
+static const struct {
+	const char *name;
+	int lang;
+} LANGUAGES[] = {
+	{ "fr", LANG_FR },
+	{ "us", LANG_US },
+	{ "de", LANG_DE },
+	{ "es", LANG_ES },
+	{ "it", LANG_IT },
+	{ 0, -1 }
+};
+
+
 int main(int argc, char *argv[]) {
 	char *dataPath = 0;
 	int part = 16001;
@@ -309,8 +303,71 @@ Common::Error AweEngine::run() {
 		warning("Sound initialization failed.");
 	}
 
+	char *dataPath = 0;
+	int part = 16001;
+	Language lang = LANG_FR;
+	int graphicsType = GRAPHICS_GL;
+
+	DisplayMode dm;
+	dm.mode = DisplayMode::WINDOWED;
+	dm.width = DEFAULT_WINDOW_W;
+	dm.height = DEFAULT_WINDOW_H;
+	dm.opengl = (graphicsType == GRAPHICS_GL);
+
+	bool defaultGraphics = true;
+	bool demo3JoyInputs = false;
+
 	// Initialize backend
-	initGraphics(320, 200);
+	initGraphics(dm.width, dm.height);
+
+	Awe::Engine *e = new Awe::Engine(*_mixer, dataPath, part);
+	if (defaultGraphics) {
+		// if not set, use original software graphics for 199x editions and GL for the anniversary and 3DO versions
+		graphicsType = getGraphicsType(e->_res.getDataType());
+		dm.opengl = (graphicsType == GRAPHICS_GL);
+	}
+	if (graphicsType != GRAPHICS_GL && e->_res.getDataType() == Resource::DT_3DO) {
+		graphicsType = GRAPHICS_SOFTWARE;
+		Graphics::_use555 = true;
+	}
+	Graphics *graphics = createGraphics(graphicsType);
+	if (e->_res.getDataType() == Resource::DT_20TH_EDITION) {
+		switch (Script::_difficulty) {
+		case DIFFICULTY_EASY:
+			debug(DBG_INFO, "Using easy difficulty");
+			break;
+		case DIFFICULTY_NORMAL:
+			debug(DBG_INFO, "Using normal difficulty");
+			break;
+		case DIFFICULTY_HARD:
+			debug(DBG_INFO, "Using hard difficulty");
+			break;
+		}
+	}
+	if (e->_res.getDataType() == Resource::DT_15TH_EDITION || e->_res.getDataType() == Resource::DT_20TH_EDITION) {
+		if (Script::_useRemasteredAudio) {
+			debug(DBG_INFO, "Using remastered audio");
+		} else {
+			debug(DBG_INFO, "Using original audio");
+		}
+	}
+
+	SystemStub *stub = SystemStub_SDL_create();
+	stub->init(e->getGameTitle(lang), &dm);
+	e->setSystemStub(stub, graphics);
+	if (demo3JoyInputs && e->_res.getDataType() == Resource::DT_DOS) {
+		e->_res.readDemo3Joy();
+	}
+	e->setup(lang, graphicsType, nullptr, 1);
+
+	while (!stub->_pi.quit) {
+		e->run();
+	}
+
+	e->finish();
+	delete e;
+	stub->fini();
+	delete stub;
 
 	return Common::kNoError;
 }
diff --git a/engines/awe/graphics.h b/engines/awe/graphics.h
index 824c000a7ab..8e34f530247 100644
--- a/engines/awe/graphics.h
+++ b/engines/awe/graphics.h
@@ -90,7 +90,6 @@ struct Graphics {
 	virtual void drawBitmapOverlay(const uint8_t *data, int w, int h, int fmt, SystemStub *stub) = 0;
 };
 
-Graphics *GraphicsGL_create();
 Graphics *GraphicsSoft_create();
 
 } // namespace Awe
diff --git a/engines/awe/unpack.cpp b/engines/awe/unpack.cpp
index 07826ae8ab6..c1be8ae0176 100644
--- a/engines/awe/unpack.cpp
+++ b/engines/awe/unpack.cpp
@@ -1,11 +1,28 @@
-
-/*
- * Another World engine rewrite
- * Copyright (C) 2004-2005 Gregory Montoir (cyx at users.sourceforge.net)
+/* 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 "unpack.h"
-#include "util.h"
+#include "awe/unpack.h"
+#include "awe/util.h"
+
+namespace Awe {
 
 struct UnpackCtx {
 	int size;
@@ -104,3 +121,5 @@ bool bytekiller_unpack(uint8_t *dst, int dstSize, const uint8_t *src, int srcSiz
 	assert(uc.size == 0);
 	return uc.crc == 0;
 }
+
+} // namespace Awe


Commit: d504a5d486b298d6604dbe2343493516389caae7
    https://github.com/scummvm/scummvm/commit/d504a5d486b298d6604dbe2343493516389caae7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Change Language enum to use Common::Language

Changed paths:
    engines/awe/awe.cpp
    engines/awe/engine.cpp
    engines/awe/intern.h
    engines/awe/resource.cpp
    engines/awe/resource_nth.cpp


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index fc8b34d7936..cb4a61142bf 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -114,23 +114,12 @@ static const char USAGE[] =
 "  --audio=AUDIO     Audio (original,remastered)\n"
 ;
 
-static const struct {
-	const char *name;
-	int lang;
-} LANGUAGES[] = {
-	{ "fr", LANG_FR },
-	{ "us", LANG_US },
-	{ "de", LANG_DE },
-	{ "es", LANG_ES },
-	{ "it", LANG_IT },
-	{ 0, -1 }
-};
 
 
 int main(int argc, char *argv[]) {
 	char *dataPath = 0;
 	int part = 16001;
-	Language lang = LANG_FR;
+	Language lang = Common::FR_FRA;
 	int graphicsType = GRAPHICS_GL;
 	DisplayMode dm;
 	dm.mode = DisplayMode::WINDOWED;
@@ -305,8 +294,8 @@ Common::Error AweEngine::run() {
 
 	char *dataPath = 0;
 	int part = 16001;
-	Language lang = LANG_FR;
-	int graphicsType = GRAPHICS_GL;
+	Language lang = _gameDescription->language;
+	int graphicsType = GRAPHICS_SOFTWARE;
 
 	DisplayMode dm;
 	dm.mode = DisplayMode::WINDOWED;
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index 4668eb735c8..84359373a2a 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -123,10 +123,10 @@ void Engine::setup(Language lang, int graphicsType, const char *scalerName, int
 	case Resource::DT_ATARI_DEMO:
 		mixerType = kMixerTypeRaw;
 		switch (lang) {
-		case LANG_FR:
+		case Common::FR_FRA:
 			_vid._stringsTable = Video::_stringsTableFr;
 			break;
-		case LANG_US:
+		case Common::EN_ANY:
 		default:
 			_vid._stringsTable = Video::_stringsTableEng;
 			break;
diff --git a/engines/awe/intern.h b/engines/awe/intern.h
index b1905892573..39107ad8096 100644
--- a/engines/awe/intern.h
+++ b/engines/awe/intern.h
@@ -24,10 +24,13 @@
 
 #include "common/algorithm.h"
 #include "common/endian.h"
+#include "common/language.h"
 #include "common/rect.h"
 
 namespace Awe {
 
+using Common::Language;
+
 #if 0
 #undef ARRAYSIZE
 #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
@@ -86,14 +89,6 @@ inline void WRITE_LE_UINT32(uint8_t *ptr, uint32_t value) {
 }
 #endif
 
-enum Language {
-	LANG_FR,
-	LANG_US,
-	LANG_DE,
-	LANG_ES,
-	LANG_IT
-};
-
 enum {
 	kPartCopyProtection = 16000,
 	kPartIntro = 16001,
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index eb19b3de106..b9140cd14d8 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -42,7 +42,7 @@ Resource::Resource(Video *vid, const char *dataDir)
 	if (!_dataDir) {
 		_dataDir = ".";
 	}
-	_lang = LANG_FR;
+	_lang = Common::FR_FRA;
 	_amigaMemList = 0;
 	memset(&_demo3Joy, 0, sizeof(_demo3Joy));
 }
@@ -160,7 +160,7 @@ const char *Resource::getGameTitle(Language lang) const {
 	case DT_3DO:
 		return kGameTitleUS;
 	case DT_DOS:
-		if (lang == LANG_US) {
+		if (lang == Common::EN_ANY) {
 			return kGameTitleUS;
 		}
 		/* fall-through */
diff --git a/engines/awe/resource_nth.cpp b/engines/awe/resource_nth.cpp
index e36ae371140..94dbf74c84b 100644
--- a/engines/awe/resource_nth.cpp
+++ b/engines/awe/resource_nth.cpp
@@ -141,19 +141,19 @@ struct Resource15th : ResourceNth {
 		if (!_textBuf) {
 			const char *name = 0;
 			switch (lang) {
-			case LANG_FR:
+			case Common::FR_FRA:
 				name = "Francais.Txt";
 				break;
-			case LANG_US:
+			case Common::EN_ANY:
 				name = "English.Txt";
 				break;
-			case LANG_DE:
+			case Common::DE_DEU:
 				name = "German.Txt";
 				break;
-			case LANG_ES:
+			case Common::ES_ESP:
 				name = "Espanol.txt";
 				break;
-			case LANG_IT:
+			case Common::IT_ITA:
 				name = "Italian.Txt";
 				break;
 			default:
@@ -475,19 +475,19 @@ struct Resource20th : ResourceNth {
 		if (!_textBuf) {
 			const char *name = 0;
 			switch (lang) {
-			case LANG_FR:
+			case Common::FR_FRA:
 				name = "FR";
 				break;
-			case LANG_US:
+			case Common::EN_ANY:
 				name = "EN";
 				break;
-			case LANG_DE:
+			case Common::DE_DEU:
 				name = "DE";
 				break;
-			case LANG_ES:
+			case Common::ES_ESP:
 				name = "ES";
 				break;
-			case LANG_IT:
+			case Common::IT_ITA:
 				name = "IT";
 				break;
 			default:


Commit: 6aea75765f292b595dc22c0a97d471bd2dcf43e3
    https://github.com/scummvm/scummvm/commit/6aea75765f292b595dc22c0a97d471bd2dcf43e3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Initializing structure fields

Changed paths:
    engines/awe/aifcplayer.h
    engines/awe/engine.h
    engines/awe/graphics.h
    engines/awe/intern.h
    engines/awe/pak.h
    engines/awe/resource.h
    engines/awe/resource_3do.h
    engines/awe/resource_win31.h
    engines/awe/script.h
    engines/awe/sfxplayer.h
    engines/awe/systemstub.h
    engines/awe/systemstub_sdl.cpp
    engines/awe/video.h


diff --git a/engines/awe/aifcplayer.h b/engines/awe/aifcplayer.h
index 182ab5dc1ce..9e856399856 100644
--- a/engines/awe/aifcplayer.h
+++ b/engines/awe/aifcplayer.h
@@ -28,12 +28,11 @@
 namespace Awe {
 
 struct AifcPlayer {
-
 	File _f;
-	uint32_t _ssndOffset;
-	uint32_t _ssndSize;
-	uint32_t _pos;
-	int16_t _sampleL, _sampleR;
+	uint32_t _ssndOffset = 0;
+	uint32_t _ssndSize = 0;
+	uint32_t _pos = 0;
+	int16_t _sampleL = 0, _sampleR = 0;
 	Frac _rate;
 
 	AifcPlayer();
diff --git a/engines/awe/engine.h b/engines/awe/engine.h
index 0e925ca7aa7..a9cc85eebc1 100644
--- a/engines/awe/engine.h
+++ b/engines/awe/engine.h
@@ -37,7 +37,6 @@ struct Graphics;
 struct SystemStub;
 
 struct Engine {
-
 	enum {
 		kStateLogo3DO,
 		kStateTitle3DO,
@@ -45,15 +44,15 @@ struct Engine {
 		kStateGame
 	};
 
-	int _state;
-	Graphics *_graphics;
-	SystemStub *_stub;
+	int _state = 0;
+	Graphics *_graphics = nullptr;
+	SystemStub *_stub = nullptr;
 	Script _script;
 	Audio::Mixer &_mix;
 	Resource _res;
 	SfxPlayer _ply;
 	Video _vid;
-	int _partNum;
+	int _partNum = 0;
 
 	Engine(Audio::Mixer &mixer, const char *dataDir, int partNum);
 
diff --git a/engines/awe/graphics.h b/engines/awe/graphics.h
index 8e34f530247..5bb2208d049 100644
--- a/engines/awe/graphics.h
+++ b/engines/awe/graphics.h
@@ -59,7 +59,6 @@ enum {
 struct SystemStub;
 
 struct Graphics {
-
 	static const uint8_t _font[];
 	static bool _is1991; // draw graphics as in the original 1991 game release
 	static bool _use555; // use 16bits graphics buffer (for 3DO)
@@ -67,8 +66,8 @@ struct Graphics {
 	static const int _shapesMaskCount;
 	static const uint8_t _shapesMaskData[];
 
-	int _fixUpPalette;
-	bool _screenshot;
+	int _fixUpPalette = 0;
+	bool _screenshot = false;
 
 	virtual ~Graphics() {};
 
diff --git a/engines/awe/intern.h b/engines/awe/intern.h
index 39107ad8096..4b09e34acc9 100644
--- a/engines/awe/intern.h
+++ b/engines/awe/intern.h
@@ -31,64 +31,6 @@ namespace Awe {
 
 using Common::Language;
 
-#if 0
-#undef ARRAYSIZE
-#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
-
-#undef ABS
-template<typename T>
-inline T ABS(T v) {
-	return (v < 0) ? -v : v;
-}
-
-#undef MIN
-template<typename T>
-inline T MIN(T v1, T v2) {
-	return (v1 < v2) ? v1 : v2;
-}
-
-#undef MAX
-template<typename T>
-inline T MAX(T v1, T v2) {
-	return (v1 > v2) ? v1 : v2;
-}
-
-template<typename T>
-inline void SWAP(T &a, T &b) {
-	T tmp = a;
-	a = b;
-	b = tmp;
-}
-
-inline uint16_t SWAP_UINT16(uint16_t n) {
-	return ((n >> 8) & 255) | ((n & 255) << 8);
-}
-
-inline uint16_t READ_BE_UINT16(const void *ptr) {
-	const uint8_t *b = (const uint8_t *)ptr;
-	return (b[0] << 8) | b[1];
-}
-
-inline uint16_t READ_LE_UINT16(const uint8_t *ptr) {
-	return (ptr[1] << 8) | ptr[0];
-}
-
-inline uint32_t READ_BE_UINT32(const void *ptr) {
-	const uint8_t *b = (const uint8_t *)ptr;
-	return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
-}
-
-inline uint32_t READ_LE_UINT32(const uint8_t *ptr) {
-	return (ptr[3] << 24) | (ptr[2] << 16) | (ptr[1] << 8) | ptr[0];
-}
-
-inline void WRITE_LE_UINT32(uint8_t *ptr, uint32_t value) {
-	for (int i = 0; i < 4; ++i) {
-		ptr[i] = value & 255; value >>= 8;
-	}
-}
-#endif
-
 enum {
 	kPartCopyProtection = 16000,
 	kPartIntro = 16001,
@@ -106,8 +48,8 @@ enum {
 };
 
 struct Ptr {
-	uint8_t *pc;
-	bool byteSwap;
+	uint8_t *pc = nullptr;
+	bool byteSwap = false;
 
 	uint8_t fetchByte() {
 		return *pc++;
@@ -136,14 +78,14 @@ struct QuadStrip {
 		MAX_VERTICES = 70
 	};
 
-	uint8_t numVertices;
+	uint8_t numVertices = 0;
 	Point vertices[MAX_VERTICES];
 };
 
 struct Color {
-	uint8_t r;
-	uint8_t g;
-	uint8_t b;
+	uint8_t r = 0;
+	uint8_t g = 0;
+	uint8_t b = 0;
 
 	uint16_t rgb555() const {
 		return ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);
@@ -153,8 +95,8 @@ struct Color {
 struct Frac {
 	static const int BITS = 16;
 	static const int MASK = (1 << BITS) - 1;
-	uint32_t inc;
-	uint64_t offset;
+	uint32_t inc = 0;
+	uint64_t offset = 0;
 
 	void reset(int n, int d) {
 		inc = (((int64_t)n) << BITS) / d;
diff --git a/engines/awe/pak.h b/engines/awe/pak.h
index 234dffbc788..38bb63bb2d5 100644
--- a/engines/awe/pak.h
+++ b/engines/awe/pak.h
@@ -28,17 +28,17 @@
 namespace Awe {
 
 struct PakEntry {
-	char name[32];
-	uint32_t offset;
-	uint32_t size;
+	char name[32] = { '\0' };
+	uint32_t offset = 0;
+	uint32_t size = 0;
 };
 
 struct Pak {
 	static const char *FILENAME;
 
 	File _f;
-	PakEntry *_entries;
-	int _entriesCount;
+	PakEntry *_entries = nullptr;
+	int _entriesCount = 0;
 
 	Pak();
 	~Pak();
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index 9ec4e6381cb..5a5a76e2e0c 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -27,14 +27,14 @@
 namespace Awe {
 
 struct MemEntry {
-	uint8_t status;        // 0x0
-	uint8_t type;          // 0x1, Resource::ResType
-	uint8_t *bufPtr;       // 0x2
-	uint8_t rankNum;       // 0x6
-	uint8_t bankNum;       // 0x7
-	uint32_t bankPos;      // 0x8
-	uint32_t packedSize;   // 0xC
-	uint32_t unpackedSize; // 0x12
+	uint8_t status = 0;        // 0x0
+	uint8_t type = 0;          // 0x1, Resource::ResType
+	uint8_t *bufPtr = nullptr; // 0x2
+	uint8_t rankNum = 0;       // 0x6
+	uint8_t bankNum = 0;       // 0x7
+	uint32_t bankPos = 0;      // 0x8
+	uint32_t packedSize = 0;   // 0xC
+	uint32_t unpackedSize = 0; // 0x12
 };
 
 struct AmigaMemEntry {
@@ -46,11 +46,11 @@ struct AmigaMemEntry {
 };
 
 struct DemoJoy {
-	uint8_t keymask;
-	uint8_t counter;
+	uint8_t keymask = 0;
+	uint8_t counter = 0;
 
-	uint8_t *bufPtr;
-	int bufPos, bufSize;
+	uint8_t *bufPtr = nullptr;
+	int bufPos = 0, bufSize = 0;
 
 	bool start() {
 		if (bufSize > 0) {
@@ -84,7 +84,6 @@ struct Video;
 typedef void (*PreloadSoundProc)(void *userdata, int num, const uint8_t *data);
 
 struct Resource {
-
 	enum ResType {
 		RT_SOUND = 0,
 		RT_MUSIC = 1,
diff --git a/engines/awe/resource_3do.h b/engines/awe/resource_3do.h
index 9677a2880e3..5000e407c63 100644
--- a/engines/awe/resource_3do.h
+++ b/engines/awe/resource_3do.h
@@ -30,10 +30,9 @@ namespace Awe {
 struct OperaIso;
 
 struct Resource3do {
-
 	const char *_dataPath;
-	char _musicPath[32];
-	char _cpakPath[64];
+	char _musicPath[32] = { '\0' };
+	char _cpakPath[64] = { '\0' };
 	OperaIso *_iso;
 
 	Resource3do(const char *dataPath);
diff --git a/engines/awe/resource_win31.h b/engines/awe/resource_win31.h
index b83fd03f743..9bb4a09196c 100644
--- a/engines/awe/resource_win31.h
+++ b/engines/awe/resource_win31.h
@@ -28,11 +28,11 @@
 namespace Awe {
 
 struct Win31BankEntry {
-	char name[16];
-	uint8_t type;
-	uint32_t offset;
-	uint32_t size;
-	uint32_t packedSize;
+	char name[16] = { '\0' };
+	uint8_t type = 0;
+	uint32_t offset = 0;
+	uint32_t size = 0;
+	uint32_t packedSize = 0;
 };
 
 struct ResourceWin31 {
@@ -40,10 +40,10 @@ struct ResourceWin31 {
 
 	File _f;
 	const char *_dataPath;
-	Win31BankEntry *_entries;
-	int _entriesCount;
-	uint8_t *_textBuf;
-	const char *_stringsTable[614];
+	Win31BankEntry *_entries = nullptr;
+	int _entriesCount = 0;
+	uint8_t *_textBuf = nullptr;
+	const char *_stringsTable[614] = { nullptr };
 
 	ResourceWin31(const char *dataPath);
 	~ResourceWin31();
diff --git a/engines/awe/script.h b/engines/awe/script.h
index dec4bad4fa0..f644e4d8b78 100644
--- a/engines/awe/script.h
+++ b/engines/awe/script.h
@@ -71,19 +71,19 @@ struct Script {
 	Resource *_res;
 	SfxPlayer *_ply;
 	Video *_vid;
-	SystemStub *_stub;
+	SystemStub *_stub = nullptr;
 
-	int16_t _scriptVars[256];
-	uint16_t _scriptStackCalls[64];
-	uint16_t _scriptTasks[2][64];
-	uint8_t _scriptStates[2][64];
+	int16_t _scriptVars[256] = { 0 };
+	uint16_t _scriptStackCalls[64] = { 0 };
+	uint16_t _scriptTasks[2][64] = { { 0 } };
+	uint8_t _scriptStates[2][64] = { { 0 } };
 	Ptr _scriptPtr;
-	uint8_t _stackPtr;
-	bool _scriptPaused;
-	bool _fastMode;
-	int _screenNum;
-	bool _is3DO;
-	uint32_t _startTime, _timeStamp;
+	uint8_t _stackPtr = 0;
+	bool _scriptPaused = false;
+	bool _fastMode = false;
+	int _screenNum = 0;
+	bool _is3DO = false;
+	uint32_t _startTime = 0, _timeStamp = 0;
 
 	Script(Audio::Mixer *mix, Resource *res, SfxPlayer *ply, Video *vid);
 	void init();
diff --git a/engines/awe/sfxplayer.h b/engines/awe/sfxplayer.h
index 89c5693c330..e45910f329a 100644
--- a/engines/awe/sfxplayer.h
+++ b/engines/awe/sfxplayer.h
@@ -27,36 +27,36 @@
 namespace Awe {
 
 struct SfxInstrument {
-	uint8_t *data;
-	uint16_t volume;
+	uint8_t *data = nullptr;
+	uint16_t volume = 0;
 };
 
 struct SfxModule {
-	const uint8_t *data;
-	uint16_t curPos;
-	uint8_t curOrder;
-	uint8_t numOrder;
-	uint8_t *orderTable;
+	const uint8_t *data = nullptr;
+	uint16_t curPos = 0;
+	uint8_t curOrder = 0;
+	uint8_t numOrder = 0;
+	uint8_t *orderTable = nullptr;
 	SfxInstrument samples[15];
 };
 
 struct SfxPattern {
-	uint16_t note_1;
-	uint16_t note_2;
-	uint16_t sampleStart;
-	uint8_t *sampleBuffer;
-	uint16_t sampleLen;
-	uint16_t loopPos;
-	uint16_t loopLen;
-	uint16_t sampleVolume;
+	uint16_t note_1 = 0;
+	uint16_t note_2 = 0;
+	uint16_t sampleStart = 0;
+	uint8_t *sampleBuffer = nullptr;
+	uint16_t sampleLen = 0;
+	uint16_t loopPos = 0;
+	uint16_t loopLen = 0;
+	uint16_t sampleVolume = 0;
 };
 
 struct SfxChannel {
-	uint8_t *sampleData;
-	uint16_t sampleLen;
-	uint16_t sampleLoopPos;
-	uint16_t sampleLoopLen;
-	uint16_t volume;
+	uint8_t *sampleData = nullptr;
+	uint16_t sampleLen = 0;
+	uint16_t sampleLoopPos = 0;
+	uint16_t sampleLoopLen = 0;
+	uint16_t volume = 0;
 	Frac pos;
 };
 
diff --git a/engines/awe/systemstub.h b/engines/awe/systemstub.h
index 8b055de3663..a35ab19a9d3 100644
--- a/engines/awe/systemstub.h
+++ b/engines/awe/systemstub.h
@@ -34,16 +34,16 @@ struct PlayerInput {
 		DIR_DOWN = 1 << 3
 	};
 
-	uint8_t dirMask;
-	bool action; // run,shoot
-	bool jump;
-	bool code;
-	bool pause;
-	bool quit;
-	bool back;
-	char lastChar;
-	bool fastMode;
-	bool screenshot;
+	uint8_t dirMask = 0;
+	bool action = false; // run,shoot
+	bool jump = false;
+	bool code = false;
+	bool pause = false;
+	bool quit = false;
+	bool back = false;
+	char lastChar = '\0';
+	bool fastMode = false;
+	bool screenshot = false;
 };
 
 struct DisplayMode {
@@ -52,8 +52,8 @@ struct DisplayMode {
 		FULLSCREEN,    // stretch
 		FULLSCREEN_AR, // 16:10 aspect ratio
 	} mode;
-	int width, height; // window dimensions
-	bool opengl;       // GL renderer
+	int width = 0, height = 0; // window dimensions
+	bool opengl = false;       // GL renderer
 };
 
 struct SystemStub {
@@ -62,11 +62,8 @@ struct SystemStub {
 	PlayerInput _pi;
 	DisplayMode _dm;
 
-	SystemStub() {
-		memset(&_pi, 0, sizeof(_pi));
-	}
-	virtual ~SystemStub() {
-	}
+	SystemStub() {}
+	virtual ~SystemStub() {}
 
 	virtual void init(const char *title, const DisplayMode *dm) = 0;
 	virtual void fini() = 0;
diff --git a/engines/awe/systemstub_sdl.cpp b/engines/awe/systemstub_sdl.cpp
index 945889230d7..eb26d9f6ab0 100644
--- a/engines/awe/systemstub_sdl.cpp
+++ b/engines/awe/systemstub_sdl.cpp
@@ -27,13 +27,12 @@
 namespace Awe {
 
 struct SystemStub_SDL : SystemStub {
-
 	static const int kJoystickIndex = 0;
 	static const int kJoystickCommitValue = 16384;
 	static const float kAspectRatio;
 
-	int _w, _h;
-	float _aspectRatio[4];
+	int _w = 0, _h = 0;
+	float _aspectRatio[4] = { 0.0 };
 #ifdef TODO
 	SDL_Window *_window;
 	SDL_Renderer *_renderer;
@@ -43,7 +42,7 @@ struct SystemStub_SDL : SystemStub {
 	SDL_Joystick *_joystick;
 	SDL_GameController *_controller;
 #endif
-	int _screenshot;
+	int _screenshot = 0;
 
 	SystemStub_SDL();
 	virtual ~SystemStub_SDL() {
diff --git a/engines/awe/video.h b/engines/awe/video.h
index 5abf6626635..d854d6f6436 100644
--- a/engines/awe/video.h
+++ b/engines/awe/video.h
@@ -27,8 +27,8 @@
 namespace Awe {
 
 struct StrEntry {
-	uint16_t id;
-	const char *str;
+	uint16_t id = 0;
+	const char *str = nullptr;
 };
 
 struct Graphics;
@@ -37,7 +37,6 @@ struct Scaler;
 struct SystemStub;
 
 struct Video {
-
 	enum {
 		BITMAP_W = 320,
 		BITMAP_H = 200
@@ -58,20 +57,20 @@ struct Video {
 	static bool _useEGA;
 
 	Resource *_res;
-	Graphics *_graphics;
-	bool _hasHeadSprites;
-	bool _displayHead;
+	Graphics *_graphics = nullptr;
+	bool _hasHeadSprites = false;
+	bool _displayHead = false;
 
-	uint8_t _nextPal, _currentPal;
-	uint8_t _buffers[3];
+	uint8_t _nextPal = 0, _currentPal = 0;
+	uint8_t _buffers[3] = { 0 };
 	Ptr _pData;
-	uint8_t *_dataBuf;
-	const StrEntry *_stringsTable;
-	uint8_t _tempBitmap[BITMAP_W * BITMAP_H];
-	uint16_t _bitmap555[BITMAP_W * BITMAP_H];
-	const Scaler *_scaler;
-	int _scalerFactor;
-	uint8_t *_scalerBuffer;
+	uint8_t *_dataBuf = nullptr;
+	const StrEntry *_stringsTable = nullptr;
+	uint8_t _tempBitmap[BITMAP_W * BITMAP_H] = { 0 };
+	uint16_t _bitmap555[BITMAP_W * BITMAP_H] = { 0 };
+	const Scaler *_scaler = nullptr;
+	int _scalerFactor = 0;
+	uint8_t *_scalerBuffer = nullptr;
 
 	Video(Resource *res);
 	~Video();


Commit: e03a3fedab96e416aa677de1d0af1c312f5a1437
    https://github.com/scummvm/scummvm/commit/e03a3fedab96e416aa677de1d0af1c312f5a1437
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Start of dataDir params removal

Changed paths:
    engines/awe/awe.cpp
    engines/awe/engine.cpp
    engines/awe/engine.h
    engines/awe/resource.cpp
    engines/awe/resource.h


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index cb4a61142bf..7fcfdf57f9d 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -292,7 +292,6 @@ Common::Error AweEngine::run() {
 		warning("Sound initialization failed.");
 	}
 
-	char *dataPath = 0;
 	int part = 16001;
 	Language lang = _gameDescription->language;
 	int graphicsType = GRAPHICS_SOFTWARE;
@@ -309,7 +308,7 @@ Common::Error AweEngine::run() {
 	// Initialize backend
 	initGraphics(dm.width, dm.height);
 
-	Awe::Engine *e = new Awe::Engine(*_mixer, dataPath, part);
+	Awe::Engine *e = new Awe::Engine(*_mixer, part);
 	if (defaultGraphics) {
 		// if not set, use original software graphics for 199x editions and GL for the anniversary and 3DO versions
 		graphicsType = getGraphicsType(e->_res.getDataType());
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index 84359373a2a..78c519cc72a 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -28,9 +28,10 @@
 
 namespace Awe {
 
-Engine::Engine(Audio::Mixer &mixer, const char *dataDir, int partNum)
-	: _mix(mixer), _graphics(0), _stub(0), _script(&_mix, &_res, &_ply, &_vid),
-	_res(&_vid, dataDir), _ply(&_res), _vid(&_res), _partNum(partNum) {
+Engine::Engine(Audio::Mixer &mixer, int partNum) : _mix(mixer),
+	_script(&_mix, &_res, &_ply, &_vid),
+	_res(&_vid), _ply(&_res), _vid(&_res),
+	_partNum(partNum) {
 	_res.detectVersion();
 }
 
diff --git a/engines/awe/engine.h b/engines/awe/engine.h
index a9cc85eebc1..1be33f40e63 100644
--- a/engines/awe/engine.h
+++ b/engines/awe/engine.h
@@ -52,9 +52,9 @@ struct Engine {
 	Resource _res;
 	SfxPlayer _ply;
 	Video _vid;
-	int _partNum = 0;
+	int _partNum;
 
-	Engine(Audio::Mixer &mixer, const char *dataDir, int partNum);
+	Engine(Audio::Mixer &mixer, int partNum);
 
 	void setSystemStub(SystemStub *, Graphics *);
 
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index b9140cd14d8..491d3ded253 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -33,15 +33,11 @@ namespace Awe {
 
 static const char *atariDemo = "aw.tos";
 
-Resource::Resource(Video *vid, const char *dataDir)
-	: _vid(vid), _dataDir(dataDir), _currentPart(0), _nextPart(0), _dataType(DT_DOS), _nth(0), _win31(0), _3do(0) {
+Resource::Resource(Video *vid) : _vid(vid) {
 	_bankPrefix = "bank";
 	_hasPasswordScreen = true;
 	memset(_memList, 0, sizeof(_memList));
 	_numMemList = 0;
-	if (!_dataDir) {
-		_dataDir = ".";
-	}
 	_lang = Common::FR_FRA;
 	_amigaMemList = 0;
 	memset(&_demo3Joy, 0, sizeof(_demo3Joy));
@@ -59,7 +55,7 @@ bool Resource::readBank(const MemEntry *me, uint8_t *dstBuf) {
 	char name[10];
 	snprintf(name, sizeof(name), "%s%02x", _bankPrefix, me->bankNum);
 	File f;
-	if (f.open(name, _dataDir) || (_dataType == DT_ATARI_DEMO && f.open(atariDemo, _dataDir))) {
+	if (f.open(name) || (_dataType == DT_ATARI_DEMO && f.open(atariDemo))) {
 		f.seek(me->bankPos);
 		const size_t count = f.read(dstBuf, me->packedSize);
 		ret = (count == me->packedSize);
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index 5a5a76e2e0c..e7c2ccad446 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -123,27 +123,30 @@ struct Resource {
 	static const uint8_t _memListParts[][4];
 
 	Video *_vid;
-	const char *_dataDir;
 	MemEntry _memList[ENTRIES_COUNT_20TH];
-	uint16_t _numMemList;
-	uint16_t _currentPart, _nextPart;
-	uint8_t *_memPtrStart, *_scriptBakPtr, *_scriptCurPtr, *_vidCurPtr;
-	bool _useSegVideo2;
-	uint8_t *_segVideoPal;
-	uint8_t *_segCode;
-	uint8_t *_segVideo1;
-	uint8_t *_segVideo2;
-	const char *_bankPrefix;
-	bool _hasPasswordScreen;
+	uint16_t _numMemList = 0;
+	uint16_t _currentPart = 0, _nextPart = 0;
+	uint8_t *_memPtrStart = nullptr,
+		*_scriptBakPtr = nullptr,
+		*_scriptCurPtr = nullptr,
+		*_vidCurPtr = nullptr;
+	bool _useSegVideo2 = false;
+	uint8_t *_segVideoPal = nullptr;
+	uint8_t *_segCode = nullptr;
+	uint8_t *_segVideo1 = nullptr;
+	uint8_t *_segVideo2 = nullptr;
+	const char *_bankPrefix = "bank";
+	bool _hasPasswordScreen = true;
 	DataType _dataType;
-	ResourceNth *_nth;
-	ResourceWin31 *_win31;
-	Resource3do *_3do;
-	Language _lang;
+	ResourceNth *_nth = nullptr;
+	ResourceWin31 *_win31 = nullptr;
+	Resource3do *_3do = nullptr;
+	Language _lang = Language::EN_ANY;
 	const AmigaMemEntry *_amigaMemList;
 	DemoJoy _demo3Joy;
+	const char *const _dataDir = ".";
 
-	Resource(Video *vid, const char *dataDir);
+	Resource(Video *vid);
 	~Resource();
 
 	DataType getDataType() const {


Commit: 56f8bb0d0707814311e304158ef92ec31cc3d32b
    https://github.com/scummvm/scummvm/commit/56f8bb0d0707814311e304158ef92ec31cc3d32b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Shifting game data type to detection table

Changed paths:
    engines/awe/awe.cpp
    engines/awe/awe.h
    engines/awe/detection.h
    engines/awe/detection_tables.h
    engines/awe/engine.cpp
    engines/awe/engine.h
    engines/awe/metaengine.cpp
    engines/awe/metaengine.h
    engines/awe/resource.cpp
    engines/awe/resource.h
    engines/awe/script.cpp
    engines/awe/video.cpp


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 7fcfdf57f9d..f51e3b1f442 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -82,11 +82,11 @@ static Graphics *createGraphics(int type) {
 }
 
 
-static int getGraphicsType(Resource::DataType type) {
+static int getGraphicsType(DataType type) {
 	switch (type) {
-	case Resource::DT_15TH_EDITION:
-	case Resource::DT_20TH_EDITION:
-	case Resource::DT_3DO:
+	case DT_15TH_EDITION:
+	case DT_20TH_EDITION:
+	case DT_3DO:
 		return GRAPHICS_GL;
 	default:
 		return GRAPHICS_ORIGINAL;
@@ -232,12 +232,12 @@ int main(int argc, char *argv[]) {
 		graphicsType = getGraphicsType(e->_res.getDataType());
 		dm.opengl = (graphicsType == GRAPHICS_GL);
 	}
-	if (graphicsType != GRAPHICS_GL && e->_res.getDataType() == Resource::DT_3DO) {
+	if (graphicsType != GRAPHICS_GL && e->_res.getDataType() == DT_3DO) {
 		graphicsType = GRAPHICS_SOFTWARE;
 		Graphics::_use555 = true;
 	}
 	Graphics *graphics = createGraphics(graphicsType);
-	if (e->_res.getDataType() == Resource::DT_20TH_EDITION) {
+	if (e->_res.getDataType() == DT_20TH_EDITION) {
 		switch (Script::_difficulty) {
 		case DIFFICULTY_EASY:
 			debug(DBG_INFO, "Using easy difficulty");
@@ -250,7 +250,7 @@ int main(int argc, char *argv[]) {
 			break;
 		}
 	}
-	if (e->_res.getDataType() == Resource::DT_15TH_EDITION || e->_res.getDataType() == Resource::DT_20TH_EDITION) {
+	if (e->_res.getDataType() == DT_15TH_EDITION || e->_res.getDataType() == DT_20TH_EDITION) {
 		if (Script::_useRemasteredAudio) {
 			debug(DBG_INFO, "Using remastered audio");
 		} else {
@@ -260,7 +260,7 @@ int main(int argc, char *argv[]) {
 	SystemStub *stub = SystemStub_SDL_create();
 	stub->init(e->getGameTitle(lang), &dm);
 	e->setSystemStub(stub, graphics);
-	if (demo3JoyInputs && e->_res.getDataType() == Resource::DT_DOS) {
+	if (demo3JoyInputs && e->_res.getDataType() == DT_DOS) {
 		e->_res.readDemo3Joy();
 	}
 	e->setup(lang, graphicsType, scaler.name, scaler.factor);
@@ -277,7 +277,7 @@ int main(int argc, char *argv[]) {
 #endif
 
 
-AweEngine::AweEngine(OSystem *syst, const ADGameDescription *gameDesc)
+AweEngine::AweEngine(OSystem *syst, const Awe::AweGameDescription *gameDesc)
 		: Engine(syst), _gameDescription(gameDesc),
 		_random("Awe") {
 	g_engine = this;
@@ -293,7 +293,8 @@ Common::Error AweEngine::run() {
 	}
 
 	int part = 16001;
-	Language lang = _gameDescription->language;
+	const Language lang = getLanguage();
+	const DataType dataType = getDataType();
 	int graphicsType = GRAPHICS_SOFTWARE;
 
 	DisplayMode dm;
@@ -308,18 +309,18 @@ Common::Error AweEngine::run() {
 	// Initialize backend
 	initGraphics(dm.width, dm.height);
 
-	Awe::Engine *e = new Awe::Engine(*_mixer, part);
+	Awe::Engine *e = new Awe::Engine(*_mixer, dataType, part);
 	if (defaultGraphics) {
 		// if not set, use original software graphics for 199x editions and GL for the anniversary and 3DO versions
 		graphicsType = getGraphicsType(e->_res.getDataType());
 		dm.opengl = (graphicsType == GRAPHICS_GL);
 	}
-	if (graphicsType != GRAPHICS_GL && e->_res.getDataType() == Resource::DT_3DO) {
+	if (graphicsType != GRAPHICS_GL && e->_res.getDataType() == DT_3DO) {
 		graphicsType = GRAPHICS_SOFTWARE;
 		Graphics::_use555 = true;
 	}
 	Graphics *graphics = createGraphics(graphicsType);
-	if (e->_res.getDataType() == Resource::DT_20TH_EDITION) {
+	if (e->_res.getDataType() == DT_20TH_EDITION) {
 		switch (Script::_difficulty) {
 		case DIFFICULTY_EASY:
 			debug(DBG_INFO, "Using easy difficulty");
@@ -332,7 +333,7 @@ Common::Error AweEngine::run() {
 			break;
 		}
 	}
-	if (e->_res.getDataType() == Resource::DT_15TH_EDITION || e->_res.getDataType() == Resource::DT_20TH_EDITION) {
+	if (e->_res.getDataType() == DT_15TH_EDITION || e->_res.getDataType() == DT_20TH_EDITION) {
 		if (Script::_useRemasteredAudio) {
 			debug(DBG_INFO, "Using remastered audio");
 		} else {
@@ -343,7 +344,7 @@ Common::Error AweEngine::run() {
 	SystemStub *stub = SystemStub_SDL_create();
 	stub->init(e->getGameTitle(lang), &dm);
 	e->setSystemStub(stub, graphics);
-	if (demo3JoyInputs && e->_res.getDataType() == Resource::DT_DOS) {
+	if (demo3JoyInputs && e->_res.getDataType() == DT_DOS) {
 		e->_res.readDemo3Joy();
 	}
 	e->setup(lang, graphicsType, nullptr, 1);
@@ -360,4 +361,12 @@ Common::Error AweEngine::run() {
 	return Common::kNoError;
 }
 
+DataType AweEngine::getDataType() const {
+	return (DataType)_gameDescription->_gameType;
+}
+
+Common::Language AweEngine::getLanguage() const {
+	return _gameDescription->desc.language;
+}
+
 } // namespace Awe
diff --git a/engines/awe/awe.h b/engines/awe/awe.h
index a93898aedf7..ce761078003 100644
--- a/engines/awe/awe.h
+++ b/engines/awe/awe.h
@@ -31,11 +31,11 @@ namespace Awe {
 
 class AweEngine : public ::Engine {
 private:
-	const ADGameDescription *_gameDescription;
+	const AweGameDescription *_gameDescription;
 	Common::RandomSource _random;
 
 public:
-	AweEngine(OSystem *syst, const ADGameDescription *gameDesc);
+	AweEngine(OSystem *syst, const AweGameDescription *gameDesc);
 	~AweEngine() override;
 
 	Common::Error run() override;
@@ -53,6 +53,9 @@ public:
 	int getRandomNumber(int min, int max) {
 		return min + _random.getRandomNumber(max - min);
 	}
+
+	DataType getDataType() const;
+	Common::Language getLanguage() const;
 };
 
 extern AweEngine *g_engine;
diff --git a/engines/awe/detection.h b/engines/awe/detection.h
index bcbbb722cb1..763e9d7ee37 100644
--- a/engines/awe/detection.h
+++ b/engines/awe/detection.h
@@ -33,15 +33,34 @@ enum AweDebugChannels {
 	kDebugInfo = 1 << 3
 };
 
+enum DataType {
+	DT_DOS,
+	DT_AMIGA,
+	DT_ATARI,
+	DT_15TH_EDITION,
+	DT_20TH_EDITION,
+	DT_WIN31,
+	DT_3DO,
+	DT_ATARI_DEMO, // ST Action Issue44 Disk28
+};
+
+struct AweGameDescription {
+	AD_GAME_DESCRIPTION_HELPERS(desc);
+
+	ADGameDescription desc;
+
+	int _gameType;
+};
+
 extern const PlainGameDescriptor aweGames[];
 
-extern const ADGameDescription gameDescriptions[];
+extern const AweGameDescription gameDescriptions[];
 
 #define GAMEOPTION_COPY_PROTECTION		GUIO_GAMEOPTIONS1
 
 } // namespace Awe
 
-class AweMetaEngineDetection : public AdvancedMetaEngineDetection<ADGameDescription> {
+class AweMetaEngineDetection : public AdvancedMetaEngineDetection<Awe::AweGameDescription> {
 	static const DebugChannelDef debugFlagList[];
 
 public:
diff --git a/engines/awe/detection_tables.h b/engines/awe/detection_tables.h
index b3e7ae2dfb1..1e07e860b07 100644
--- a/engines/awe/detection_tables.h
+++ b/engines/awe/detection_tables.h
@@ -26,40 +26,43 @@ const PlainGameDescriptor aweGames[] = {
 	{ 0, 0 }
 };
 
-const ADGameDescription gameDescriptions[] = {
+const AweGameDescription gameDescriptions[] = {
 	{
-		"anotherworld",
-		nullptr,
-		AD_ENTRY1s("memlist.bin", "f2bf61fe20c98108b2256e96d57d3fe0", 2940),
-		Common::EN_ANY,
-		Common::kPlatformDOS,
-		ADGF_UNSTABLE,
-		GUIO1(GAMEOPTION_COPY_PROTECTION)
+		{
+			"anotherworld",
+			nullptr,
+			AD_ENTRY1s("memlist.bin", "f2bf61fe20c98108b2256e96d57d3fe0", 2940),
+			Common::EN_ANY,
+			Common::kPlatformDOS,
+			ADGF_UNSTABLE,
+			GUIO1(GAMEOPTION_COPY_PROTECTION)
+		},
+		DT_DOS
 	},
 	{
-		"anotherworld",
-		"Demo",
-		AD_ENTRY1s("memlist.bin", "11e0cc58aeb47ad1dfc1c4dae8dcd9ee", 2940),
-		Common::EN_ANY,
-		Common::kPlatformDOS,
-		ADGF_DEMO | ADGF_UNSTABLE,
-		GUIO1(GAMEOPTION_COPY_PROTECTION)
+		{
+			"anotherworld",
+			"Demo",
+			AD_ENTRY1s("memlist.bin", "11e0cc58aeb47ad1dfc1c4dae8dcd9ee", 2940),
+			Common::EN_ANY,
+			Common::kPlatformDOS,
+			ADGF_DEMO | ADGF_UNSTABLE,
+			GUIO1(GAMEOPTION_COPY_PROTECTION)
+		},
+		DT_DOS
 	},
-
-#if 0
-	// Unsupported Windows release that doesn't have a memlist.bin
-	// Need to investigate further.. maybe an embedded resource?
 	{
-		"anotherworld",
-		nullptr,
-		AD_ENTRY1s("bank", "30fb99cb4cbd812273d0b54b7b4a18ca", 987462),
-		Common::EN_ANY,
-		Common::kPlatformWindows,
-		ADGF_UNSTABLE,
-		GUIO1(GUIO_NONE)
+		{
+			"anotherworld",
+			nullptr,
+			AD_ENTRY1s("bank", "30fb99cb4cbd812273d0b54b7b4a18ca", 987462),
+			Common::EN_ANY,
+			Common::kPlatformWindows,
+			ADGF_UNSTABLE,
+			GUIO1(GUIO_NONE)
+		},
 	},
-#endif
-	AD_TABLE_END_MARKER
+	{ AD_TABLE_END_MARKER, 0 }
 };
 
 } // End of namespace Awe
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index 78c519cc72a..dbb7376301f 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -28,10 +28,10 @@
 
 namespace Awe {
 
-Engine::Engine(Audio::Mixer &mixer, int partNum) : _mix(mixer),
-	_script(&_mix, &_res, &_ply, &_vid),
-	_res(&_vid), _ply(&_res), _vid(&_res),
-	_partNum(partNum) {
+Engine::Engine(Audio::Mixer &mixer, DataType dataType, int partNum) :
+		_mix(mixer), _script(&_mix, &_res, &_ply, &_vid),
+		_res(&_vid, dataType), _ply(&_res), _vid(&_res),
+		_partNum(partNum) {
 	_res.detectVersion();
 }
 
@@ -74,7 +74,7 @@ void Engine::run() {
 #if 0
 		_mix.update();
 #endif
-		if (_res.getDataType() == Resource::DT_3DO) {
+		if (_res.getDataType() == DT_3DO) {
 			switch (_res._nextPart) {
 			case 16009:
 				_state = kStateEnd3DO;
@@ -92,7 +92,7 @@ void Engine::setup(Language lang, int graphicsType, const char *scalerName, int
 	_vid._graphics = _graphics;
 	int w = GFX_W * scalerFactor;
 	int h = GFX_H * scalerFactor;
-	if (_res.getDataType() != Resource::DT_3DO) {
+	if (_res.getDataType() != DT_3DO) {
 		_vid._graphics->_fixUpPalette = FIXUP_PALETTE_REDRAW;
 	}
 	_vid.init();
@@ -103,7 +103,7 @@ void Engine::setup(Language lang, int graphicsType, const char *scalerName, int
 	_res.allocMemBlock();
 	_res.readEntries();
 	_res.dumpEntries();
-	const bool isNth = !Graphics::_is1991 && (_res.getDataType() == Resource::DT_15TH_EDITION || _res.getDataType() == Resource::DT_20TH_EDITION);
+	const bool isNth = !Graphics::_is1991 && (_res.getDataType() == DT_15TH_EDITION || _res.getDataType() == DT_20TH_EDITION);
 	if (isNth) {
 		// get HD background bitmaps resolution
 		_res._nth->getBitmapSize(&w, &h);
@@ -118,10 +118,10 @@ void Engine::setup(Language lang, int graphicsType, const char *scalerName, int
 	_script.init();
 	MixerType mixerType = kMixerTypeRaw;
 	switch (_res.getDataType()) {
-	case Resource::DT_DOS:
-	case Resource::DT_AMIGA:
-	case Resource::DT_ATARI:
-	case Resource::DT_ATARI_DEMO:
+	case DT_DOS:
+	case DT_AMIGA:
+	case DT_ATARI:
+	case DT_ATARI_DEMO:
 		mixerType = kMixerTypeRaw;
 		switch (lang) {
 		case Common::FR_FRA:
@@ -133,12 +133,12 @@ void Engine::setup(Language lang, int graphicsType, const char *scalerName, int
 			break;
 		}
 		break;
-	case Resource::DT_WIN31:
-	case Resource::DT_15TH_EDITION:
-	case Resource::DT_20TH_EDITION:
+	case DT_WIN31:
+	case DT_15TH_EDITION:
+	case DT_20TH_EDITION:
 		mixerType = kMixerTypeWav;
 		break;
-	case Resource::DT_3DO:
+	case DT_3DO:
 		mixerType = kMixerTypeAiff;
 		break;
 	}
@@ -147,21 +147,21 @@ void Engine::setup(Language lang, int graphicsType, const char *scalerName, int
 #endif
 #ifndef BYPASS_PROTECTION
 	switch (_res.getDataType()) {
-	case Resource::DT_DOS:
+	case DT_DOS:
 		if (!_res._hasPasswordScreen) {
 			break;
 		}
 		/* fall-through */
-	case Resource::DT_AMIGA:
-	case Resource::DT_ATARI:
-	case Resource::DT_WIN31:
+	case DT_AMIGA:
+	case DT_ATARI:
+	case DT_WIN31:
 		_partNum = kPartCopyProtection;
 		break;
 	default:
 		break;
 	}
 #endif
-	if (_res.getDataType() == Resource::DT_3DO && _partNum == kPartIntro) {
+	if (_res.getDataType() == DT_3DO && _partNum == kPartIntro) {
 		_state = kStateLogo3DO;
 	} else {
 		_state = kStateGame;
diff --git a/engines/awe/engine.h b/engines/awe/engine.h
index 1be33f40e63..cdd85c2851c 100644
--- a/engines/awe/engine.h
+++ b/engines/awe/engine.h
@@ -54,7 +54,7 @@ struct Engine {
 	Video _vid;
 	int _partNum;
 
-	Engine(Audio::Mixer &mixer, int partNum);
+	Engine(Audio::Mixer &mixer, DataType dataType, int partNum);
 
 	void setSystemStub(SystemStub *, Graphics *);
 
diff --git a/engines/awe/metaengine.cpp b/engines/awe/metaengine.cpp
index f31b9b4cdf4..38f930f5489 100644
--- a/engines/awe/metaengine.cpp
+++ b/engines/awe/metaengine.cpp
@@ -73,8 +73,8 @@ const ADExtraGuiOptionsMap *AweMetaEngine::getAdvancedExtraGuiOptions() const {
 	return Awe::optionsList;
 }
 
-Common::Error AweMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
-	*engine = new Awe::AweEngine(syst, desc);
+Common::Error AweMetaEngine::createInstance(OSystem *syst, Engine **engine, const Awe::AweGameDescription *desc) const {
+	*engine = new Awe::AweEngine(syst, (Awe::AweGameDescription *)desc);
 	return Common::kNoError;
 }
 
diff --git a/engines/awe/metaengine.h b/engines/awe/metaengine.h
index 455304069cd..a846934872f 100644
--- a/engines/awe/metaengine.h
+++ b/engines/awe/metaengine.h
@@ -22,6 +22,7 @@
 #ifndef AWE_METAENGINE_H
 #define AWE_METAENGINE_H
 
+#include "awe/detection.h"
 #include "engines/advancedDetector.h"
 
 namespace Awe {
@@ -38,11 +39,11 @@ enum KeybindingAction {
 
 } // namespace Awe
 
-class AweMetaEngine : public AdvancedMetaEngine<ADGameDescription> {
+class AweMetaEngine : public AdvancedMetaEngine<Awe::AweGameDescription> {
 public:
 	const char *getName() const override;
 
-	Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
+	Common::Error createInstance(OSystem *syst, Engine **engine, const Awe::AweGameDescription *desc) const override;
 
 	/**
 	 * Determine whether the engine supports the specified MetaEngine feature.
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 491d3ded253..3e7ff9f47ca 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -33,14 +33,13 @@ namespace Awe {
 
 static const char *atariDemo = "aw.tos";
 
-Resource::Resource(Video *vid) : _vid(vid) {
+Resource::Resource(Video *vid, DataType dataType) :
+		_vid(vid), _dataType(dataType) {
 	_bankPrefix = "bank";
 	_hasPasswordScreen = true;
-	memset(_memList, 0, sizeof(_memList));
 	_numMemList = 0;
-	_lang = Common::FR_FRA;
+	_lang = Common::EN_ANY;
 	_amigaMemList = 0;
-	memset(&_demo3Joy, 0, sizeof(_demo3Joy));
 }
 
 Resource::~Resource() {
@@ -66,29 +65,9 @@ bool Resource::readBank(const MemEntry *me, uint8_t *dstBuf) {
 	return ret;
 }
 
-static bool check15th(File &f, const char *dataDir) {
-	char path[MAXPATHLEN];
-	snprintf(path, sizeof(path), "%s/Data", dataDir);
-	return f.open(Pak::FILENAME, path);
-}
-
-static bool check20th(File &f, const char *dataDir) {
-	char path[MAXPATHLEN];
-	snprintf(path, sizeof(path), "%s/game/DAT", dataDir);
-	return f.open("FILE017.DAT", path);
-}
-
-static bool check3DO(File &f, const char *dataDir) {
-	const char *ext = strrchr(dataDir, '.');
-	if (ext && scumm_stricmp(ext, ".iso") == 0) {
-		return f.open(dataDir);
-	}
-	char path[MAXPATHLEN];
-	snprintf(path, sizeof(path), "%s/GameData", dataDir);
-	return f.open("File340", path);
-}
+static const AmigaMemEntry *detectAmigaAtari() {
+	Common::File f;
 
-static const AmigaMemEntry *detectAmigaAtari(File &f, const char *dataDir) {
 	static const struct {
 		uint32_t bank01Size;
 		const AmigaMemEntry *entries;
@@ -98,7 +77,7 @@ static const AmigaMemEntry *detectAmigaAtari(File &f, const char *dataDir) {
 		{ 227142, Resource::_memListAtariEN },
 		{ 0, 0 }
 	};
-	if (f.open("bank01", dataDir)) {
+	if (f.open("bank01")) {
 		const uint32_t size = f.size();
 		for (int i = 0; _files[i].entries; ++i) {
 			if (_files[i].bank01Size == size) {
@@ -106,39 +85,13 @@ static const AmigaMemEntry *detectAmigaAtari(File &f, const char *dataDir) {
 			}
 		}
 	}
-	return 0;
+
+	return nullptr;
 }
 
 void Resource::detectVersion() {
-	File f;
-	if (check15th(f, _dataDir)) {
-		_dataType = DT_15TH_EDITION;
-		debug(DBG_INFO, "Using 15th anniversary edition data files");
-	} else if (check20th(f, _dataDir)) {
-		_dataType = DT_20TH_EDITION;
-		debug(DBG_INFO, "Using 20th anniversary edition data files");
-	} else if (f.open("memlist.bin", _dataDir)) {
-		_dataType = DT_DOS;
-		debug(DBG_INFO, "Using DOS data files");
-	} else if ((_amigaMemList = detectAmigaAtari(f, _dataDir)) != 0) {
-		if (_amigaMemList == _memListAtariEN) {
-			_dataType = DT_ATARI;
-			debug(DBG_INFO, "Using Atari data files");
-		} else {
-			_dataType = DT_AMIGA;
-			debug(DBG_INFO, "Using Amiga data files");
-		}
-	} else if (f.open(ResourceWin31::FILENAME, _dataDir)) {
-		_dataType = DT_WIN31;
-		debug(DBG_INFO, "Using Win31 data files");
-	} else if (check3DO(f, _dataDir)) {
-		_dataType = DT_3DO;
-		debug(DBG_INFO, "Using 3DO data files");
-	} else if (f.open(atariDemo, _dataDir) && f.size() == 96513) {
-		_dataType = DT_ATARI_DEMO;
-		debug(DBG_INFO, "Using Atari demo file");
-	} else {
-		error("No data files found in '%s'", _dataDir);
+	if (_dataType == DT_ATARI) {
+		_amigaMemList = detectAmigaAtari();
 	}
 }
 
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index e7c2ccad446..62b90349a45 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -22,6 +22,7 @@
 #ifndef AWE_RESOURCE_H
 #define AWE_RESOURCE_H
 
+#include "awe/detection.h"
 #include "awe/intern.h"
 
 namespace Awe {
@@ -94,17 +95,6 @@ struct Resource {
 		RT_BANK = 6, // common part shapes (bank2.mat)
 	};
 
-	enum DataType {
-		DT_DOS,
-		DT_AMIGA,
-		DT_ATARI,
-		DT_15TH_EDITION,
-		DT_20TH_EDITION,
-		DT_WIN31,
-		DT_3DO,
-		DT_ATARI_DEMO, // ST Action Issue44 Disk28
-	};
-
 	enum {
 		MEM_BLOCK_SIZE = 1 * 1024 * 1024,
 		ENTRIES_COUNT = 146,
@@ -123,6 +113,7 @@ struct Resource {
 	static const uint8_t _memListParts[][4];
 
 	Video *_vid;
+	DataType _dataType;
 	MemEntry _memList[ENTRIES_COUNT_20TH];
 	uint16_t _numMemList = 0;
 	uint16_t _currentPart = 0, _nextPart = 0;
@@ -137,7 +128,6 @@ struct Resource {
 	uint8_t *_segVideo2 = nullptr;
 	const char *_bankPrefix = "bank";
 	bool _hasPasswordScreen = true;
-	DataType _dataType;
 	ResourceNth *_nth = nullptr;
 	ResourceWin31 *_win31 = nullptr;
 	Resource3do *_3do = nullptr;
@@ -146,7 +136,7 @@ struct Resource {
 	DemoJoy _demo3Joy;
 	const char *const _dataDir = ".";
 
-	Resource(Video *vid);
+	Resource(Video *vid, DataType dataType);
 	~Resource();
 
 	DataType getDataType() const {
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index 65d6eef3793..9c99f83ee88 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -38,22 +38,22 @@ void Script::init() {
 	memset(_scriptVars, 0, sizeof(_scriptVars));
 	_fastMode = false;
 	_ply->_syncVar = &_scriptVars[VAR_MUSIC_SYNC];
-	_scriptPtr.byteSwap = _is3DO = (_res->getDataType() == Resource::DT_3DO);
+	_scriptPtr.byteSwap = _is3DO = (_res->getDataType() == DT_3DO);
 	if (_is3DO) {
 		_scriptVars[0xDB] = 1;
 		_scriptVars[0xE2] = 1;
 		_scriptVars[0xF2] = 6000;
-	} else if (_res->getDataType() != Resource::DT_15TH_EDITION && _res->getDataType() != Resource::DT_20TH_EDITION) {
+	} else if (_res->getDataType() != DT_15TH_EDITION && _res->getDataType() != DT_20TH_EDITION) {
 		_scriptVars[VAR_RANDOM_SEED] = 0; // time(0);
 #ifdef BYPASS_PROTECTION
 		// these 3 variables are set by the game code
 		_scriptVars[0xBC] = 0x10;
 		_scriptVars[0xC6] = 0x80;
-		_scriptVars[0xF2] = (_res->getDataType() == Resource::DT_AMIGA || _res->getDataType() == Resource::DT_ATARI) ? 6000 : 4000;
+		_scriptVars[0xF2] = (_res->getDataType() == DT_AMIGA || _res->getDataType() == DT_ATARI) ? 6000 : 4000;
 		// these 2 variables are set by the engine executable
 		_scriptVars[0xDC] = 33;
 #endif
-		if (_res->getDataType() == Resource::DT_DOS || _res->getDataType() == Resource::DT_WIN31) {
+		if (_res->getDataType() == DT_DOS || _res->getDataType() == DT_WIN31) {
 			_scriptVars[0xE4] = 20;
 		}
 	}
@@ -81,7 +81,7 @@ void Script::op_add() {
 }
 
 void Script::op_addConst() {
-	if (_res->getDataType() == Resource::DT_DOS || _res->getDataType() == Resource::DT_AMIGA || _res->getDataType() == Resource::DT_ATARI) {
+	if (_res->getDataType() == DT_DOS || _res->getDataType() == DT_AMIGA || _res->getDataType() == DT_ATARI) {
 		if (_res->_currentPart == 16006 && _scriptPtr.pc == _res->_segCode + 0x6D48) {
 			warning("Script::op_addConst() workaround for infinite looping gun sound");
 			// The script 0x27 slot 0x17 doesn't stop the gun sound from looping.
@@ -396,12 +396,12 @@ void Script::op_playMusic() {
 void Script::restartAt(int part, int pos) {
 	_ply->stop();
 	_mix->stopAll();
-	if (_res->getDataType() == Resource::DT_20TH_EDITION) {
+	if (_res->getDataType() == DT_20TH_EDITION) {
 		_scriptVars[0xBF] = _difficulty; // difficulty (0 to 2)
 		// _scriptVars[0xDB] = 1; // preload sounds (resnum >= 2000)
 		_scriptVars[0xDE] = _useRemasteredAudio ? 1 : 0; // playback remastered sounds (resnum >= 146)
 	}
-	if (_res->getDataType() == Resource::DT_DOS && part == kPartCopyProtection) {
+	if (_res->getDataType() == DT_DOS && part == kPartCopyProtection) {
 		// VAR(0x54) indicates if the "Out of this World" title screen should be presented
 		//
 		//   0084: jmpIf(VAR(0x54) < 128, @00C4)
@@ -648,7 +648,7 @@ void Script::updateInput() {
 			m |= 8; // jump
 		}
 	}
-	if (!(_res->getDataType() == Resource::DT_AMIGA || _res->getDataType() == Resource::DT_ATARI)) {
+	if (!(_res->getDataType() == DT_AMIGA || _res->getDataType() == DT_ATARI)) {
 		_scriptVars[VAR_HERO_POS_UP_DOWN] = ud;
 	}
 	_scriptVars[VAR_HERO_POS_JUMP_DOWN] = jd;
@@ -781,12 +781,12 @@ void Script::snd_playSound(uint16_t resNum, uint8_t freq, uint8_t vol, uint8_t c
 	}
 	channel &= 3;
 	switch (_res->getDataType()) {
-	case Resource::DT_20TH_EDITION:
+	case DT_20TH_EDITION:
 		if (freq != 0) {
 			--freq;
 		}
 		/* fall-through */
-	case Resource::DT_15TH_EDITION:
+	case DT_15TH_EDITION:
 		if (freq >= 32) {
 			// Anniversary editions do not have the 170 period
 			//
@@ -796,7 +796,7 @@ void Script::snd_playSound(uint16_t resNum, uint8_t freq, uint8_t vol, uint8_t c
 			++freq;
 		}
 		/* fall-through */
-	case Resource::DT_WIN31:
+	case DT_WIN31:
 	{
 #ifdef TODO
 		uint8_t *buf = _res->loadWav(resNum);
@@ -808,17 +808,17 @@ void Script::snd_playSound(uint16_t resNum, uint8_t freq, uint8_t vol, uint8_t c
 #endif
 	}
 	break;
-	case Resource::DT_3DO:
+	case DT_3DO:
 #ifdef TODO
 		_mix->playSoundAiff(channel, resNum, vol);
 #else
 		::error("TODO: play aiff");
 #endif
 		break;
-	case Resource::DT_AMIGA:
-	case Resource::DT_ATARI:
-	case Resource::DT_ATARI_DEMO:
-	case Resource::DT_DOS:
+	case DT_AMIGA:
+	case DT_ATARI:
+	case DT_ATARI_DEMO:
+	case DT_DOS:
 	{
 #ifdef TODO
 		MemEntry *me = &_res->_memList[resNum];
@@ -838,7 +838,7 @@ void Script::snd_playMusic(uint16_t resNum, uint16_t delay, uint8_t pos) {
 	debug(DBG_SND, "snd_playMusic(0x%X, %d, %d)", resNum, delay, pos);
 	uint8_t loop = 0;
 	switch (_res->getDataType()) {
-	case Resource::DT_20TH_EDITION:
+	case DT_20TH_EDITION:
 		if (resNum == 5000) {
 			_mix->stopMusic();
 			break;
@@ -847,8 +847,8 @@ void Script::snd_playMusic(uint16_t resNum, uint16_t delay, uint8_t pos) {
 			loop = 1;
 		}
 		/* fall-through */
-	case Resource::DT_15TH_EDITION:
-	case Resource::DT_WIN31:
+	case DT_15TH_EDITION:
+	case DT_WIN31:
 		if (resNum != 0) {
 			char path[MAXPATHLEN];
 			const char *p = _res->getMusicPath(resNum, path, sizeof(path));
@@ -857,7 +857,7 @@ void Script::snd_playMusic(uint16_t resNum, uint16_t delay, uint8_t pos) {
 			}
 		}
 		break;
-	case Resource::DT_3DO:
+	case DT_3DO:
 		if (resNum == 0) {
 			_mix->stopAifcMusic();
 		} else {
@@ -888,7 +888,7 @@ void Script::snd_playMusic(uint16_t resNum, uint16_t delay, uint8_t pos) {
 
 void Script::snd_preloadSound(uint16_t resNum, const uint8_t *data) {
 #ifdef TODO
-	if (_res->getDataType() == Resource::DT_3DO) {
+	if (_res->getDataType() == DT_3DO) {
 		_mix->preloadSoundAiff(resNum, data);
 	}
 #else
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index a141d7957f2..81f41ba471f 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -43,7 +43,7 @@ void Video::init() {
 	_buffers[2] = getPagePtr(1);
 	_buffers[1] = getPagePtr(2);
 	setWorkPagePtr(0xFE);
-	_pData.byteSwap = (_res->getDataType() == Resource::DT_3DO);
+	_pData.byteSwap = (_res->getDataType() == DT_3DO);
 	_scaler = 0;
 	_scalerBuffer = 0;
 }
@@ -53,7 +53,7 @@ void Video::setScaler(const char *name, int factor) {
 	if (!_scaler) {
 		warning("Scaler '%s' not found", name);
 	} else {
-		const int byteDepth = (_res->getDataType() == Resource::DT_3DO) ? 2 : 1;
+		const int byteDepth = (_res->getDataType() == DT_3DO) ? 2 : 1;
 		if ((_scaler->bpp & (byteDepth * 8)) == 0) {
 			warning("Scaler '%s' does not support %d bits per pixel", name, (byteDepth << 8));
 			_scaler = 0;
@@ -329,7 +329,7 @@ static const char *findString(const StrEntry *stringsTable, int id) {
 void Video::drawString(uint8_t color, uint16_t x, uint16_t y, uint16_t strId) {
 	bool escapedChars = false;
 	const char *str = 0;
-	if (_res->getDataType() == Resource::DT_15TH_EDITION || _res->getDataType() == Resource::DT_20TH_EDITION) {
+	if (_res->getDataType() == DT_15TH_EDITION || _res->getDataType() == DT_20TH_EDITION) {
 		for (int i = 0; i < NTH_EDITION_STRINGS_COUNT; ++i) {
 			if (Video::_stringsId15th[i] == strId) {
 				str = _res->getString(i);
@@ -341,15 +341,15 @@ void Video::drawString(uint8_t color, uint16_t x, uint16_t y, uint16_t strId) {
 				break;
 			}
 		}
-	} else if (_res->getDataType() == Resource::DT_WIN31) {
+	} else if (_res->getDataType() == DT_WIN31) {
 		str = _res->getString(strId);
-	} else if (_res->getDataType() == Resource::DT_3DO) {
+	} else if (_res->getDataType() == DT_3DO) {
 		str = findString(_stringsTable3DO, strId);
-	} else if (_res->getDataType() == Resource::DT_ATARI_DEMO && strId == 0x194) {
+	} else if (_res->getDataType() == DT_ATARI_DEMO && strId == 0x194) {
 		str = _str0x194AtariDemo;
 	} else {
 		str = findString(_stringsTable, strId);
-		if (!str && _res->getDataType() == Resource::DT_DOS) {
+		if (!str && _res->getDataType() == DT_DOS) {
 			str = findString(_stringsTableDemo, strId);
 		}
 	}
@@ -493,16 +493,16 @@ void Video::scaleBitmap(const uint8_t *src, int fmt) {
 }
 
 void Video::copyBitmapPtr(const uint8_t *src, uint32_t size) {
-	if (_res->getDataType() == Resource::DT_DOS || _res->getDataType() == Resource::DT_AMIGA) {
+	if (_res->getDataType() == DT_DOS || _res->getDataType() == DT_AMIGA) {
 		decode_amiga(src, _tempBitmap);
 		scaleBitmap(_tempBitmap, FMT_CLUT);
-	} else if (_res->getDataType() == Resource::DT_ATARI) {
+	} else if (_res->getDataType() == DT_ATARI) {
 		decode_atari(src, _tempBitmap);
 		scaleBitmap(_tempBitmap, FMT_CLUT);
-	} else if (_res->getDataType() == Resource::DT_WIN31) {
+	} else if (_res->getDataType() == DT_WIN31) {
 		yflip(src, BITMAP_W, BITMAP_H, _tempBitmap);
 		scaleBitmap(_tempBitmap, FMT_CLUT);
-	} else if (_res->getDataType() == Resource::DT_3DO) {
+	} else if (_res->getDataType() == DT_3DO) {
 		deinterlace555(src, BITMAP_W, BITMAP_H, _bitmap555);
 		scaleBitmap((const uint8_t *)_bitmap555, FMT_RGB555);
 	} else { // .BMP
@@ -586,11 +586,11 @@ static void readPaletteAmiga(const uint8_t *buf, int num, Color pal[16]) {
 void Video::changePal(uint8_t palNum) {
 	if (palNum < 32 && palNum != _currentPal) {
 		Color pal[16];
-		if (_res->getDataType() == Resource::DT_WIN31) {
+		if (_res->getDataType() == DT_WIN31) {
 			readPaletteWin31(_res->_segVideoPal, palNum, pal);
-		} else if (_res->getDataType() == Resource::DT_3DO) {
+		} else if (_res->getDataType() == DT_3DO) {
 			readPalette3DO(_res->_segVideoPal, palNum, pal);
-		} else if (_res->getDataType() == Resource::DT_DOS && _useEGA) {
+		} else if (_res->getDataType() == DT_DOS && _useEGA) {
 			readPaletteEGA(_res->_segVideoPal, palNum, pal);
 		} else {
 			readPaletteAmiga(_res->_segVideoPal, palNum, pal);
@@ -636,7 +636,7 @@ void Video::drawRect(uint8_t page, uint8_t color, int x1, int y1, int x2, int y2
 }
 
 void Video::drawBitmap3DO(const char *name, SystemStub *stub) {
-	assert(_res->getDataType() == Resource::DT_3DO);
+	assert(_res->getDataType() == DT_3DO);
 	int w, h;
 	uint16_t *data = _res->_3do->loadShape555(name, &w, &h);
 	if (data) {


Commit: 90cd956dc4de776bfa78a8fcd997c8efeffb8902
    https://github.com/scummvm/scummvm/commit/90cd956dc4de776bfa78a8fcd997c8efeffb8902
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Renaming of filenames

Changed paths:
  A engines/awe/aifc_player.cpp
  A engines/awe/aifc_player.h
  A engines/awe/sfx_player.cpp
  A engines/awe/sfx_player.h
  A engines/awe/static_res.cpp
  A engines/awe/system_stub.cpp
  A engines/awe/system_stub.h
  R engines/awe/aifcplayer.cpp
  R engines/awe/aifcplayer.h
  R engines/awe/sfxplayer.cpp
  R engines/awe/sfxplayer.h
  R engines/awe/staticres.cpp
  R engines/awe/systemstub.h
  R engines/awe/systemstub_sdl.cpp
    engines/awe/awe.cpp
    engines/awe/engine.cpp
    engines/awe/engine.h
    engines/awe/graphics_gl.cpp
    engines/awe/graphics_soft.cpp
    engines/awe/mixer.cpp
    engines/awe/module.mk
    engines/awe/script.cpp
    engines/awe/video.cpp


diff --git a/engines/awe/aifcplayer.cpp b/engines/awe/aifc_player.cpp
similarity index 99%
rename from engines/awe/aifcplayer.cpp
rename to engines/awe/aifc_player.cpp
index b63022225a9..a92b4b6b3ae 100644
--- a/engines/awe/aifcplayer.cpp
+++ b/engines/awe/aifc_player.cpp
@@ -19,7 +19,7 @@
  *
  */
 
-#include "awe/aifcplayer.h"
+#include "awe/aifc_player.h"
 #include "awe/util.h"
 
 namespace Awe {
diff --git a/engines/awe/aifcplayer.h b/engines/awe/aifc_player.h
similarity index 100%
rename from engines/awe/aifcplayer.h
rename to engines/awe/aifc_player.h
diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index f51e3b1f442..94fde0ac7b0 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -29,7 +29,7 @@
 #include "awe/resource.h"
 #include "awe/scaler.h"
 #include "awe/script.h"
-#include "awe/systemstub.h"
+#include "awe/system_stub.h"
 #include "awe/util.h"
 #include "awe/video.h"
 
@@ -341,7 +341,7 @@ Common::Error AweEngine::run() {
 		}
 	}
 
-	SystemStub *stub = SystemStub_SDL_create();
+	SystemStub *stub = SystemStub_create();
 	stub->init(e->getGameTitle(lang), &dm);
 	e->setSystemStub(stub, graphics);
 	if (demo3JoyInputs && e->_res.getDataType() == DT_DOS) {
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index dbb7376301f..37e4e9e9453 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -23,7 +23,7 @@
 #include "awe/file.h"
 #include "awe/graphics.h"
 #include "awe/resource_nth.h"
-#include "awe/systemstub.h"
+#include "awe/system_stub.h"
 #include "awe/util.h"
 
 namespace Awe {
diff --git a/engines/awe/engine.h b/engines/awe/engine.h
index cdd85c2851c..aafab15c601 100644
--- a/engines/awe/engine.h
+++ b/engines/awe/engine.h
@@ -27,7 +27,7 @@
 #include "awe/intern.h"
 #include "awe/script.h"
 #include "awe/mixer.h"
-#include "awe/sfxplayer.h"
+#include "awe/sfx_player.h"
 #include "awe/resource.h"
 #include "awe/video.h"
 
diff --git a/engines/awe/graphics_gl.cpp b/engines/awe/graphics_gl.cpp
index 74d6ab19e6a..3313c3b6fd4 100644
--- a/engines/awe/graphics_gl.cpp
+++ b/engines/awe/graphics_gl.cpp
@@ -21,7 +21,7 @@
 
 #include "awe/graphics.h"
 #include "awe/util.h"
-#include "awe/systemstub.h"
+#include "awe/system_stub.h"
 
 namespace Awe {
 
diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
index 5b0a9381607..7fd648d517d 100644
--- a/engines/awe/graphics_soft.cpp
+++ b/engines/awe/graphics_soft.cpp
@@ -22,7 +22,7 @@
 #include "awe/graphics.h"
 #include "awe/util.h"
 #include "awe/screenshot.h"
-#include "awe/systemstub.h"
+#include "awe/system_stub.h"
 
 namespace Awe {
 
diff --git a/engines/awe/mixer.cpp b/engines/awe/mixer.cpp
index 5c798135855..f42edea33f1 100644
--- a/engines/awe/mixer.cpp
+++ b/engines/awe/mixer.cpp
@@ -20,9 +20,9 @@
  */
 
 //define MIX_INIT_FLUIDSYNTH MIX_INIT_MID // renamed with SDL2_mixer >= 2.0.2
-#include "awe/aifcplayer.h"
+#include "awe/aifc_player.h"
 #include "awe/mixer.h"
-#include "awe/sfxplayer.h"
+#include "awe/sfx_player.h"
 #include "awe/util.h"
 
 namespace Awe {
diff --git a/engines/awe/module.mk b/engines/awe/module.mk
index 46b98f96fb4..255c716e454 100644
--- a/engines/awe/module.mk
+++ b/engines/awe/module.mk
@@ -3,7 +3,7 @@ MODULE := engines/awe
 MODULE_OBJS = \
 	metaengine.o \
 	awe.o \
-	aifcplayer.o \
+	aifc_player.o \
 	bitmap.o \
 	detection.o \
 	engine.o \
@@ -20,9 +20,9 @@ MODULE_OBJS = \
 	scaler.o \
 	screenshot.o \
 	script.o \
-	sfxplayer.o \
-	staticres.o \
-	systemstub_sdl.o \
+	sfx_player.o \
+	static_res.o \
+	system_stub.o \
 	unpack.o \
 	util.o \
 	video.o
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index 9c99f83ee88..1e778fef5b6 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -24,8 +24,8 @@
 #include "awe/mixer.h"
 #include "awe/resource.h"
 #include "awe/video.h"
-#include "awe/sfxplayer.h"
-#include "awe/systemstub.h"
+#include "awe/sfx_player.h"
+#include "awe/system_stub.h"
 #include "awe/util.h"
 
 namespace Awe {
diff --git a/engines/awe/sfxplayer.cpp b/engines/awe/sfx_player.cpp
similarity index 99%
rename from engines/awe/sfxplayer.cpp
rename to engines/awe/sfx_player.cpp
index 514ee385303..6ed9915299f 100644
--- a/engines/awe/sfxplayer.cpp
+++ b/engines/awe/sfx_player.cpp
@@ -19,10 +19,10 @@
  *
  */
 
-#include "awe/sfxplayer.h"
+#include "awe/sfx_player.h"
 #include "awe/mixer.h"
 #include "awe/resource.h"
-#include "awe/systemstub.h"
+#include "awe/system_stub.h"
 #include "awe/util.h"
 
 namespace Awe {
diff --git a/engines/awe/sfxplayer.h b/engines/awe/sfx_player.h
similarity index 97%
rename from engines/awe/sfxplayer.h
rename to engines/awe/sfx_player.h
index e45910f329a..5bf4bb06693 100644
--- a/engines/awe/sfxplayer.h
+++ b/engines/awe/sfx_player.h
@@ -19,8 +19,8 @@
  *
  */
 
-#ifndef AWE_SFXPLAYER_H
-#define AWE_SFXPLAYER_H
+#ifndef AWE_SFX_PLAYER_H
+#define AWE_SFX_PLAYER_H
 
 #include "awe/intern.h"
 
diff --git a/engines/awe/staticres.cpp b/engines/awe/static_res.cpp
similarity index 100%
rename from engines/awe/staticres.cpp
rename to engines/awe/static_res.cpp
diff --git a/engines/awe/systemstub_sdl.cpp b/engines/awe/system_stub.cpp
similarity index 93%
rename from engines/awe/systemstub_sdl.cpp
rename to engines/awe/system_stub.cpp
index eb26d9f6ab0..196c1d49394 100644
--- a/engines/awe/systemstub_sdl.cpp
+++ b/engines/awe/system_stub.cpp
@@ -21,12 +21,12 @@
 
 #include "common/system.h"
 #include "awe/graphics.h"
-#include "awe/systemstub.h"
+#include "awe/system_stub.h"
 #include "awe/util.h"
 
 namespace Awe {
 
-struct SystemStub_SDL : SystemStub {
+struct SystemStubScummVM : SystemStub {
 	static const int kJoystickIndex = 0;
 	static const int kJoystickCommitValue = 16384;
 	static const float kAspectRatio;
@@ -44,8 +44,8 @@ struct SystemStub_SDL : SystemStub {
 #endif
 	int _screenshot = 0;
 
-	SystemStub_SDL();
-	virtual ~SystemStub_SDL() {
+	SystemStubScummVM();
+	virtual ~SystemStubScummVM() {
 	}
 
 	virtual void init(const char *title, const DisplayMode *dm);
@@ -62,9 +62,9 @@ struct SystemStub_SDL : SystemStub {
 	void setAspectRatio(int w, int h);
 };
 
-const float SystemStub_SDL::kAspectRatio = 16.f / 10.f;
+const float SystemStubScummVM::kAspectRatio = 16.f / 10.f;
 
-SystemStub_SDL::SystemStub_SDL()
+SystemStubScummVM::SystemStubScummVM()
 	: _w(0), _h(0)
 #ifdef TODO
 	, _window(0), _renderer(0), _texW(0), _texH(0), _texture(0)
@@ -72,7 +72,7 @@ SystemStub_SDL::SystemStub_SDL()
 {
 }
 
-void SystemStub_SDL::init(const char *title, const DisplayMode *dm) {
+void SystemStubScummVM::init(const char *title, const DisplayMode *dm) {
 #ifdef TODO
 	SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);
 	SDL_ShowCursor(SDL_DISABLE);
@@ -128,7 +128,7 @@ void SystemStub_SDL::init(const char *title, const DisplayMode *dm) {
 	_dm = *dm;
 }
 
-void SystemStub_SDL::fini() {
+void SystemStubScummVM::fini() {
 #ifdef TODO
 	if (_texture) {
 		SDL_DestroyTexture(_texture);
@@ -155,7 +155,7 @@ void SystemStub_SDL::fini() {
 #endif
 }
 
-void SystemStub_SDL::prepareScreen(int &w, int &h, float ar[4]) {
+void SystemStubScummVM::prepareScreen(int &w, int &h, float ar[4]) {
 	w = _w;
 	h = _h;
 	ar[0] = _aspectRatio[0];
@@ -169,7 +169,7 @@ void SystemStub_SDL::prepareScreen(int &w, int &h, float ar[4]) {
 #endif
 }
 
-void SystemStub_SDL::updateScreen() {
+void SystemStubScummVM::updateScreen() {
 #ifdef TODO
 	if (_renderer) {
 		SDL_RenderPresent(_renderer);
@@ -179,7 +179,7 @@ void SystemStub_SDL::updateScreen() {
 #endif
 }
 
-void SystemStub_SDL::setScreenPixels555(const uint16_t *data, int w, int h) {
+void SystemStubScummVM::setScreenPixels555(const uint16_t *data, int w, int h) {
 #ifdef TODO
 	if (_renderer) {
 		if (!_texture) {
@@ -207,7 +207,7 @@ void SystemStub_SDL::setScreenPixels555(const uint16_t *data, int w, int h) {
 #endif
 }
 
-void SystemStub_SDL::processEvents() {
+void SystemStubScummVM::processEvents() {
 #ifdef TODO
 	SDL_Event ev;
 	while (SDL_PollEvent(&ev)) {
@@ -439,15 +439,15 @@ void SystemStub_SDL::processEvents() {
 #endif
 }
 
-void SystemStub_SDL::sleep(uint32_t duration) {
+void SystemStubScummVM::sleep(uint32_t duration) {
 	g_system->delayMillis(duration);
 }
 
-uint32_t SystemStub_SDL::getTimeStamp() {
+uint32_t SystemStubScummVM::getTimeStamp() {
 	return g_system->getMillis();
 }
 
-void SystemStub_SDL::setAspectRatio(int w, int h) {
+void SystemStubScummVM::setAspectRatio(int w, int h) {
 	const float currentAspectRatio = w / (float)h;
 	if (int(currentAspectRatio * 100) == int(kAspectRatio * 100)) {
 		_aspectRatio[0] = 0.f;
@@ -476,8 +476,8 @@ void SystemStub_SDL::setAspectRatio(int w, int h) {
 	}
 }
 
-SystemStub *SystemStub_SDL_create() {
-	return new SystemStub_SDL();
+SystemStub *SystemStub_create() {
+	return new SystemStubScummVM();
 }
 
 } // namespace Awe
diff --git a/engines/awe/systemstub.h b/engines/awe/system_stub.h
similarity index 95%
rename from engines/awe/systemstub.h
rename to engines/awe/system_stub.h
index a35ab19a9d3..0c3e9fca216 100644
--- a/engines/awe/systemstub.h
+++ b/engines/awe/system_stub.h
@@ -19,8 +19,8 @@
  *
  */
 
-#ifndef AWE_SYSTEMSTUB_H
-#define AWE_SYSTEMSTUB_H
+#ifndef AWE_SYSTEM_STUB_H
+#define AWE_SYSTEM_STUB_H
 
 #include "awe/intern.h"
 
@@ -79,7 +79,7 @@ struct SystemStub {
 	virtual uint32_t getTimeStamp() = 0;
 };
 
-extern SystemStub *SystemStub_SDL_create();
+extern SystemStub *SystemStub_create();
 
 } // namespace Awe
 
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index 81f41ba471f..1a4eb9bdfc7 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -25,7 +25,7 @@
 #include "awe/resource.h"
 #include "awe/resource_3do.h"
 #include "awe/scaler.h"
-#include "awe/systemstub.h"
+#include "awe/system_stub.h"
 #include "awe/util.h"
 
 namespace Awe {


Commit: a9e680a8ae03cde575c00f5d613f11bba3a87b06
    https://github.com/scummvm/scummvm/commit/a9e680a8ae03cde575c00f5d613f11bba3a87b06
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Work on SystemStubScummVM class

Changed paths:
    engines/awe/awe.cpp
    engines/awe/system_stub.cpp
    engines/awe/system_stub.h


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 94fde0ac7b0..13a98fbda2a 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -22,7 +22,6 @@
 #include "audio/mixer.h"
 #include "common/config-manager.h"
 #include "common/stream.h"
-#include "engines/util.h"
 #include "awe/awe.h"
 #include "awe/engine.h"
 #include "awe/graphics.h"
@@ -306,9 +305,6 @@ Common::Error AweEngine::run() {
 	bool defaultGraphics = true;
 	bool demo3JoyInputs = false;
 
-	// Initialize backend
-	initGraphics(dm.width, dm.height);
-
 	Awe::Engine *e = new Awe::Engine(*_mixer, dataType, part);
 	if (defaultGraphics) {
 		// if not set, use original software graphics for 199x editions and GL for the anniversary and 3DO versions
@@ -342,11 +338,13 @@ Common::Error AweEngine::run() {
 	}
 
 	SystemStub *stub = SystemStub_create();
-	stub->init(e->getGameTitle(lang), &dm);
+	stub->init(dm);
 	e->setSystemStub(stub, graphics);
+
 	if (demo3JoyInputs && e->_res.getDataType() == DT_DOS) {
 		e->_res.readDemo3Joy();
 	}
+
 	e->setup(lang, graphicsType, nullptr, 1);
 
 	while (!stub->_pi.quit) {
diff --git a/engines/awe/system_stub.cpp b/engines/awe/system_stub.cpp
index 196c1d49394..5dc384419a8 100644
--- a/engines/awe/system_stub.cpp
+++ b/engines/awe/system_stub.cpp
@@ -20,6 +20,8 @@
  */
 
 #include "common/system.h"
+#include "engines/util.h"
+#include "graphics/screen.h"
 #include "awe/graphics.h"
 #include "awe/system_stub.h"
 #include "awe/util.h"
@@ -31,7 +33,7 @@ struct SystemStubScummVM : SystemStub {
 	static const int kJoystickCommitValue = 16384;
 	static const float kAspectRatio;
 
-	int _w = 0, _h = 0;
+	::Graphics::Screen *_screen = nullptr;
 	float _aspectRatio[4] = { 0.0 };
 #ifdef TODO
 	SDL_Window *_window;
@@ -44,139 +46,52 @@ struct SystemStubScummVM : SystemStub {
 #endif
 	int _screenshot = 0;
 
-	SystemStubScummVM();
-	virtual ~SystemStubScummVM() {
-	}
+	SystemStubScummVM() {}
+	~SystemStubScummVM() override;
 
-	virtual void init(const char *title, const DisplayMode *dm);
-	virtual void fini();
+	void init(const DisplayMode &dm) override;
+	void fini() override;
 
-	virtual void prepareScreen(int &w, int &h, float ar[4]);
-	virtual void updateScreen();
-	virtual void setScreenPixels555(const uint16_t *data, int w, int h);
+	void prepareScreen(int &w, int &h, float ar[4]) override;
+	void updateScreen() override;
+	void setScreenPixels555(const uint16_t *data, int w, int h) override;
 
-	virtual void processEvents();
-	virtual void sleep(uint32_t duration);
-	virtual uint32_t getTimeStamp();
+	void processEvents() override;
+	void sleep(uint32_t duration) override;
+	virtual uint32_t getTimeStamp() override;
 
 	void setAspectRatio(int w, int h);
 };
 
 const float SystemStubScummVM::kAspectRatio = 16.f / 10.f;
 
-SystemStubScummVM::SystemStubScummVM()
-	: _w(0), _h(0)
-#ifdef TODO
-	, _window(0), _renderer(0), _texW(0), _texH(0), _texture(0)
-#endif
-{
+SystemStubScummVM::~SystemStubScummVM() {
+	delete _screen;
 }
 
-void SystemStubScummVM::init(const char *title, const DisplayMode *dm) {
-#ifdef TODO
-	SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);
-	SDL_ShowCursor(SDL_DISABLE);
-	// SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1");
+void SystemStubScummVM::init(const DisplayMode &dm) {
+	// Initialize backend
+	initGraphics(dm.width, dm.height);
+	_screen = new ::Graphics::Screen();
 
-	int windowW = 0;
-	int windowH = 0;
-	int flags = dm->opengl ? SDL_WINDOW_OPENGL : 0;
-	if (dm->mode == DisplayMode::WINDOWED) {
-		flags |= SDL_WINDOW_RESIZABLE;
-		windowW = dm->width;
-		windowH = dm->height;
-	} else {
-		flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
-	}
-	_window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowW, windowH, flags);
-	SDL_GetWindowSize(_window, &_w, &_h);
-
-	if (dm->opengl) {
-		_glcontext = SDL_GL_CreateContext(_window);
-	} else {
-		_glcontext = 0;
-		_renderer = SDL_CreateRenderer(_window, -1, SDL_RENDERER_ACCELERATED);
-		SDL_SetRenderDrawColor(_renderer, 0, 0, 0, 255);
-		SDL_RenderClear(_renderer);
-	}
-	_aspectRatio[0] = _aspectRatio[1] = 0.;
-	_aspectRatio[2] = _aspectRatio[3] = 1.;
-	if (dm->mode == DisplayMode::FULLSCREEN_AR) {
-		if (dm->opengl) {
-			setAspectRatio(_w, _h);
-		} else {
-			SDL_RenderSetLogicalSize(_renderer, 320, 200);
-		}
-	}
-	_joystick = 0;
-	_controller = 0;
-	if (SDL_NumJoysticks() > 0) {
-
-#if SDL_COMPILEDVERSION >= SDL_VERSIONNUM(2,0,2)
-		SDL_GameControllerAddMappingsFromFile("gamecontrollerdb.txt");
-#endif
-
-		if (SDL_IsGameController(kJoystickIndex)) {
-			_controller = SDL_GameControllerOpen(kJoystickIndex);
-		}
-		if (!_controller) {
-			_joystick = SDL_JoystickOpen(kJoystickIndex);
-		}
-	}
-#endif
 	_screenshot = 1;
-	_dm = *dm;
+	_dm = dm;
 }
 
 void SystemStubScummVM::fini() {
-#ifdef TODO
-	if (_texture) {
-		SDL_DestroyTexture(_texture);
-		_texture = 0;
-	}
-	if (_joystick) {
-		SDL_JoystickClose(_joystick);
-		_joystick = 0;
-	}
-	if (_controller) {
-		SDL_GameControllerClose(_controller);
-		_controller = 0;
-	}
-	if (_renderer) {
-		SDL_DestroyRenderer(_renderer);
-		_renderer = 0;
-	}
-	if (_glcontext) {
-		SDL_GL_DeleteContext(_glcontext);
-		_glcontext = 0;
-	}
-	SDL_DestroyWindow(_window);
-	SDL_Quit();
-#endif
 }
 
 void SystemStubScummVM::prepareScreen(int &w, int &h, float ar[4]) {
-	w = _w;
-	h = _h;
+	w = _screen->w;
+	h = _screen->h;
 	ar[0] = _aspectRatio[0];
 	ar[1] = _aspectRatio[1];
 	ar[2] = _aspectRatio[2];
 	ar[3] = _aspectRatio[3];
-#ifdef TODO
-	if (_renderer) {
-		SDL_RenderClear(_renderer);
-	}
-#endif
 }
 
 void SystemStubScummVM::updateScreen() {
-#ifdef TODO
-	if (_renderer) {
-		SDL_RenderPresent(_renderer);
-	} else {
-		SDL_GL_SwapWindow(_window);
-	}
-#endif
+	_screen->update();
 }
 
 void SystemStubScummVM::setScreenPixels555(const uint16_t *data, int w, int h) {
@@ -204,6 +119,8 @@ void SystemStubScummVM::setScreenPixels555(const uint16_t *data, int w, int h) {
 		SDL_UpdateTexture(_texture, &r, data, w * sizeof(uint16_t));
 		SDL_RenderCopy(_renderer, _texture, 0, 0);
 	}
+#else
+	error("TODO: setScreenPixels555");
 #endif
 }
 
diff --git a/engines/awe/system_stub.h b/engines/awe/system_stub.h
index 0c3e9fca216..0eaf419ab27 100644
--- a/engines/awe/system_stub.h
+++ b/engines/awe/system_stub.h
@@ -65,7 +65,7 @@ struct SystemStub {
 	SystemStub() {}
 	virtual ~SystemStub() {}
 
-	virtual void init(const char *title, const DisplayMode *dm) = 0;
+	virtual void init(const DisplayMode &dm) = 0;
 	virtual void fini() = 0;
 
 	// GL rendering


Commit: df32e7744d4258411474624cba7bff7e02d10041
    https://github.com/scummvm/scummvm/commit/df32e7744d4258411474624cba7bff7e02d10041
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Implement ScummVM event loop

Changed paths:
    engines/awe/metaengine.cpp
    engines/awe/metaengine.h
    engines/awe/system_stub.cpp


diff --git a/engines/awe/metaengine.cpp b/engines/awe/metaengine.cpp
index 38f930f5489..3ada037c4ee 100644
--- a/engines/awe/metaengine.cpp
+++ b/engines/awe/metaengine.cpp
@@ -59,7 +59,8 @@ static const KeybindingRecord GAME_KEYS[] = {
 	{ KEYBIND_LEFT, "LEFT", _s("Left"), "LEFT", nullptr, "JOY_LEFT"},
 	{ KEYBIND_RIGHT, "RIGHT", _s("Right"), "RIGHT", nullptr, "JOY_RIGHT"},
 	{ KEYBIND_SELECT, "SELECT", _s("Select/Kick/Run"), "SPACE", "RETURN", "JOY_A" },
-	{ KEYBIND_CODE, "CODE", _s("Enter Level Code"), "c", nullptr, "JOY_B" },
+	{ KEYBIND_JUMP, "JUMP", _s("Jump"), "LSHIFT", "RSHIFT", "JOY_B" },
+	{ KEYBIND_CODE, "CODE", _s("Enter Level Code"), "c", nullptr, "JOY_X" },
 	{ KEYBIND_NONE, nullptr, nullptr, nullptr, nullptr, nullptr }
 };
 
diff --git a/engines/awe/metaengine.h b/engines/awe/metaengine.h
index a846934872f..e0ca13ec84a 100644
--- a/engines/awe/metaengine.h
+++ b/engines/awe/metaengine.h
@@ -34,6 +34,7 @@ enum KeybindingAction {
 	KEYBIND_LEFT,
 	KEYBIND_RIGHT,
 	KEYBIND_SELECT,
+	KEYBIND_JUMP,
 	KEYBIND_CODE
 };
 
diff --git a/engines/awe/system_stub.cpp b/engines/awe/system_stub.cpp
index 5dc384419a8..e2211914207 100644
--- a/engines/awe/system_stub.cpp
+++ b/engines/awe/system_stub.cpp
@@ -20,9 +20,11 @@
  */
 
 #include "common/system.h"
+#include "common/events.h"
 #include "engines/util.h"
 #include "graphics/screen.h"
 #include "awe/graphics.h"
+#include "awe/metaengine.h"
 #include "awe/system_stub.h"
 #include "awe/util.h"
 
@@ -125,235 +127,107 @@ void SystemStubScummVM::setScreenPixels555(const uint16_t *data, int w, int h) {
 }
 
 void SystemStubScummVM::processEvents() {
-#ifdef TODO
-	SDL_Event ev;
-	while (SDL_PollEvent(&ev)) {
+	Common::Event ev;
+	while (g_system->getEventManager()->pollEvent(ev)) {
 		switch (ev.type) {
-		case SDL_QUIT:
+		case Common::EVENT_QUIT:
+		case Common::EVENT_RETURN_TO_LAUNCHER:
 			_pi.quit = true;
 			break;
-		case SDL_WINDOWEVENT:
-			if (ev.window.event == SDL_WINDOWEVENT_RESIZED) {
-				_w = _dm.width = ev.window.data1;
-				_h = _dm.height = ev.window.data2;
-			} else if (ev.window.event == SDL_WINDOWEVENT_CLOSE) {
-				_pi.quit = true;
+
+		case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+			switch (ev.customType) {
+			case KEYBIND_LEFT:
+				_pi.dirMask |= PlayerInput::DIR_LEFT;
+				break;
+			case KEYBIND_RIGHT:
+				_pi.dirMask |= PlayerInput::DIR_RIGHT;
+				break;
+			case KEYBIND_UP:
+				_pi.dirMask |= PlayerInput::DIR_UP;
+				break;
+			case KEYBIND_DOWN:
+				_pi.dirMask |= PlayerInput::DIR_DOWN;
+				break;
+			case KEYBIND_SELECT:
+				_pi.action = true;
+				break;
+			case KEYBIND_JUMP:
+				_pi.jump = true;
+				break;
+			default:
+				break;
 			}
 			break;
-		case SDL_KEYUP:
-			switch (ev.key.keysym.sym) {
-			case SDLK_LEFT:
+
+		case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
+			switch (ev.customType) {
+			case KEYBIND_LEFT:
 				_pi.dirMask &= ~PlayerInput::DIR_LEFT;
 				break;
-			case SDLK_RIGHT:
+			case KEYBIND_RIGHT:
 				_pi.dirMask &= ~PlayerInput::DIR_RIGHT;
 				break;
-			case SDLK_UP:
+			case KEYBIND_UP:
 				_pi.dirMask &= ~PlayerInput::DIR_UP;
 				break;
-			case SDLK_DOWN:
+			case KEYBIND_DOWN:
 				_pi.dirMask &= ~PlayerInput::DIR_DOWN;
 				break;
-			case SDLK_SPACE:
-			case SDLK_RETURN:
+			case KEYBIND_SELECT:
 				_pi.action = false;
 				break;
-			case SDLK_LSHIFT:
-			case SDLK_RSHIFT:
+			case KEYBIND_JUMP:
 				_pi.jump = false;
 				break;
-			case SDLK_s:
-				_pi.screenshot = true;
+			case KEYBIND_CODE:
+				_pi.code = false;
 				break;
-			case SDLK_c:
-				_pi.code = true;
+			default:
 				break;
-			case SDLK_p:
+			}
+			break;
+
+		case Common::EVENT_KEYUP:
+			switch (ev.kbd.keycode) {
+			case Common::KEYCODE_s:
+				_pi.screenshot = true;
+				break;
+			case Common::KEYCODE_p:
 				_pi.pause = true;
 				break;
-			case SDLK_ESCAPE:
-			case SDLK_AC_BACK:
+			case Common::KEYCODE_ESCAPE:
+			case Common::KEYCODE_AC_BACK:
 				_pi.back = true;
 				break;
-			case SDLK_AC_HOME:
+			case Common::KEYCODE_AC_HOME:
 				_pi.quit = true;
 				break;
 			default:
 				break;
 			}
 			break;
-		case SDL_KEYDOWN:
-			if (ev.key.keysym.mod & KMOD_ALT) {
-				if (ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_KP_ENTER) {
-				} else if (ev.key.keysym.sym == SDLK_x) {
+
+		case Common::EVENT_KEYDOWN:
+			if (ev.kbd.flags & Common::KBD_ALT) {
+				if (ev.kbd.keycode == Common::KEYCODE_x) {
 					_pi.quit = true;
 				}
 				break;
-			} else if (ev.key.keysym.mod & KMOD_CTRL) {
-				if (ev.key.keysym.sym == SDLK_f) {
+			} else if (ev.kbd.flags & Common::KBD_CTRL) {
+				if (ev.kbd.keycode == Common::KEYCODE_f) {
 					_pi.fastMode = true;
 				}
 				break;
 			}
-			_pi.lastChar = ev.key.keysym.sym;
-			switch (ev.key.keysym.sym) {
-			case SDLK_LEFT:
-				_pi.dirMask |= PlayerInput::DIR_LEFT;
-				break;
-			case SDLK_RIGHT:
-				_pi.dirMask |= PlayerInput::DIR_RIGHT;
-				break;
-			case SDLK_UP:
-				_pi.dirMask |= PlayerInput::DIR_UP;
-				break;
-			case SDLK_DOWN:
-				_pi.dirMask |= PlayerInput::DIR_DOWN;
-				break;
-			case SDLK_SPACE:
-			case SDLK_RETURN:
-				_pi.action = true;
-				break;
-			case SDLK_LSHIFT:
-			case SDLK_RSHIFT:
-				_pi.jump = true;
-				break;
-			default:
-				break;
-			}
-			break;
-		case SDL_JOYHATMOTION:
-			if (_joystick) {
-				_pi.dirMask = 0;
-				if (ev.jhat.value & SDL_HAT_UP) {
-					_pi.dirMask |= PlayerInput::DIR_UP;
-				}
-				if (ev.jhat.value & SDL_HAT_DOWN) {
-					_pi.dirMask |= PlayerInput::DIR_DOWN;
-				}
-				if (ev.jhat.value & SDL_HAT_LEFT) {
-					_pi.dirMask |= PlayerInput::DIR_LEFT;
-				}
-				if (ev.jhat.value & SDL_HAT_RIGHT) {
-					_pi.dirMask |= PlayerInput::DIR_RIGHT;
-				}
-			}
-			break;
-		case SDL_JOYAXISMOTION:
-			if (_joystick) {
-				switch (ev.jaxis.axis) {
-				case 0:
-					_pi.dirMask &= ~(PlayerInput::DIR_RIGHT | PlayerInput::DIR_LEFT);
-					if (ev.jaxis.value > kJoystickCommitValue) {
-						_pi.dirMask |= PlayerInput::DIR_RIGHT;
-					} else if (ev.jaxis.value < -kJoystickCommitValue) {
-						_pi.dirMask |= PlayerInput::DIR_LEFT;
-					}
-					break;
-				case 1:
-					_pi.dirMask &= ~(PlayerInput::DIR_UP | PlayerInput::DIR_DOWN);
-					if (ev.jaxis.value > kJoystickCommitValue) {
-						_pi.dirMask |= PlayerInput::DIR_DOWN;
-					} else if (ev.jaxis.value < -kJoystickCommitValue) {
-						_pi.dirMask |= PlayerInput::DIR_UP;
-					}
-					break;
-				}
-			}
-			break;
-		case SDL_JOYBUTTONDOWN:
-		case SDL_JOYBUTTONUP:
-			if (_joystick) {
-				_pi.action = (ev.jbutton.state == SDL_PRESSED);
-			}
-			break;
-		case SDL_CONTROLLERAXISMOTION:
-			if (_controller) {
-				switch (ev.caxis.axis) {
-				case SDL_CONTROLLER_AXIS_LEFTX:
-				case SDL_CONTROLLER_AXIS_RIGHTX:
-					if (ev.caxis.value < -kJoystickCommitValue) {
-						_pi.dirMask |= PlayerInput::DIR_LEFT;
-					} else {
-						_pi.dirMask &= ~PlayerInput::DIR_LEFT;
-					}
-					if (ev.caxis.value > kJoystickCommitValue) {
-						_pi.dirMask |= PlayerInput::DIR_RIGHT;
-					} else {
-						_pi.dirMask &= ~PlayerInput::DIR_RIGHT;
-					}
-					break;
-				case SDL_CONTROLLER_AXIS_LEFTY:
-				case SDL_CONTROLLER_AXIS_RIGHTY:
-					if (ev.caxis.value < -kJoystickCommitValue) {
-						_pi.dirMask |= PlayerInput::DIR_UP;
-					} else {
-						_pi.dirMask &= ~PlayerInput::DIR_UP;
-					}
-					if (ev.caxis.value > kJoystickCommitValue) {
-						_pi.dirMask |= PlayerInput::DIR_DOWN;
-					} else {
-						_pi.dirMask &= ~PlayerInput::DIR_DOWN;
-					}
-					break;
-				}
-			}
-			break;
-		case SDL_CONTROLLERBUTTONDOWN:
-		case SDL_CONTROLLERBUTTONUP:
-			if (_controller) {
-				const bool pressed = (ev.cbutton.state == SDL_PRESSED);
-				switch (ev.cbutton.button) {
-				case SDL_CONTROLLER_BUTTON_BACK:
-					_pi.back = pressed;
-					break;
-				case SDL_CONTROLLER_BUTTON_GUIDE:
-					_pi.code = pressed;
-					break;
-				case SDL_CONTROLLER_BUTTON_START:
-					_pi.pause = pressed;
-					break;
-				case SDL_CONTROLLER_BUTTON_DPAD_UP:
-					if (pressed) {
-						_pi.dirMask |= PlayerInput::DIR_UP;
-					} else {
-						_pi.dirMask &= ~PlayerInput::DIR_UP;
-					}
-					break;
-				case SDL_CONTROLLER_BUTTON_DPAD_DOWN:
-					if (pressed) {
-						_pi.dirMask |= PlayerInput::DIR_DOWN;
-					} else {
-						_pi.dirMask &= ~PlayerInput::DIR_DOWN;
-					}
-					break;
-				case SDL_CONTROLLER_BUTTON_DPAD_LEFT:
-					if (pressed) {
-						_pi.dirMask |= PlayerInput::DIR_LEFT;
-					} else {
-						_pi.dirMask &= ~PlayerInput::DIR_LEFT;
-					}
-					break;
-				case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
-					if (pressed) {
-						_pi.dirMask |= PlayerInput::DIR_RIGHT;
-					} else {
-						_pi.dirMask &= ~PlayerInput::DIR_RIGHT;
-					}
-					break;
-				case SDL_CONTROLLER_BUTTON_A:
-					_pi.action = pressed;
-					break;
-				case SDL_CONTROLLER_BUTTON_B:
-					_pi.jump = pressed;
-					break;
-				}
-			}
+
+			_pi.lastChar = ev.kbd.keycode;
 			break;
+
 		default:
 			break;
 		}
 	}
-#endif
 }
 
 void SystemStubScummVM::sleep(uint32_t duration) {


Commit: bf2b494ff2006cae9b21f02e95155f5438e7f69c
    https://github.com/scummvm/scummvm/commit/bf2b494ff2006cae9b21f02e95155f5438e7f69c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Remove deprecated detectVersion method

Changed paths:
    engines/awe/awe.cpp
    engines/awe/engine.cpp
    engines/awe/engine.h
    engines/awe/resource.cpp
    engines/awe/resource.h


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 13a98fbda2a..f16a73000e5 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -305,7 +305,7 @@ Common::Error AweEngine::run() {
 	bool defaultGraphics = true;
 	bool demo3JoyInputs = false;
 
-	Awe::Engine *e = new Awe::Engine(*_mixer, dataType, part);
+	Awe::Engine *e = new Awe::Engine(_mixer, dataType, part);
 	if (defaultGraphics) {
 		// if not set, use original software graphics for 199x editions and GL for the anniversary and 3DO versions
 		graphicsType = getGraphicsType(e->_res.getDataType());
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index 37e4e9e9453..9072c4be272 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -28,11 +28,10 @@
 
 namespace Awe {
 
-Engine::Engine(Audio::Mixer &mixer, DataType dataType, int partNum) :
-		_mix(mixer), _script(&_mix, &_res, &_ply, &_vid),
+Engine::Engine(Audio::Mixer *mixer, DataType dataType, int partNum) :
+		_mix(mixer), _script(mixer, &_res, &_ply, &_vid),
 		_res(&_vid, dataType), _ply(&_res), _vid(&_res),
 		_partNum(partNum) {
-	_res.detectVersion();
 }
 
 static const int _restartPos[36 * 2] = {
@@ -177,7 +176,7 @@ void Engine::setup(Language lang, int graphicsType, const char *scalerName, int
 void Engine::finish() {
 	_graphics->fini();
 	_ply.stop();
-	_mix.stopAll();
+	_mix->stopAll();
 	_res.freeMemBlock();
 }
 
diff --git a/engines/awe/engine.h b/engines/awe/engine.h
index aafab15c601..fcefc0eac01 100644
--- a/engines/awe/engine.h
+++ b/engines/awe/engine.h
@@ -48,13 +48,13 @@ struct Engine {
 	Graphics *_graphics = nullptr;
 	SystemStub *_stub = nullptr;
 	Script _script;
-	Audio::Mixer &_mix;
+	Audio::Mixer *_mix;
 	Resource _res;
 	SfxPlayer _ply;
 	Video _vid;
 	int _partNum;
 
-	Engine(Audio::Mixer &mixer, DataType dataType, int partNum);
+	Engine(Audio::Mixer *mixer, DataType dataType, int partNum);
 
 	void setSystemStub(SystemStub *, Graphics *);
 
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 3e7ff9f47ca..62417ba63ce 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -33,13 +33,16 @@ namespace Awe {
 
 static const char *atariDemo = "aw.tos";
 
+static const char *kGameTitleEU = "Another World";
+static const char *kGameTitleUS = "Out Of This World";
+static const char *kGameTitle15thEdition = "Another World 15th anniversary edition";
+static const char *kGameTitle20thEdition = "Another World 20th anniversary edition";
+
 Resource::Resource(Video *vid, DataType dataType) :
 		_vid(vid), _dataType(dataType) {
-	_bankPrefix = "bank";
-	_hasPasswordScreen = true;
-	_numMemList = 0;
-	_lang = Common::EN_ANY;
-	_amigaMemList = 0;
+	if (_dataType == DT_ATARI) {
+		_amigaMemList = detectAmigaAtari();
+	}
 }
 
 Resource::~Resource() {
@@ -65,7 +68,7 @@ bool Resource::readBank(const MemEntry *me, uint8_t *dstBuf) {
 	return ret;
 }
 
-static const AmigaMemEntry *detectAmigaAtari() {
+const AmigaMemEntry *Resource::detectAmigaAtari() {
 	Common::File f;
 
 	static const struct {
@@ -89,17 +92,6 @@ static const AmigaMemEntry *detectAmigaAtari() {
 	return nullptr;
 }
 
-void Resource::detectVersion() {
-	if (_dataType == DT_ATARI) {
-		_amigaMemList = detectAmigaAtari();
-	}
-}
-
-static const char *kGameTitleEU = "Another World";
-static const char *kGameTitleUS = "Out Of This World";
-static const char *kGameTitle15thEdition = "Another World 15th anniversary edition";
-static const char *kGameTitle20thEdition = "Another World 20th anniversary edition";
-
 const char *Resource::getGameTitle(Language lang) const {
 	switch (_dataType) {
 	case DT_15TH_EDITION:
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index 62b90349a45..d31ce20d47a 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -111,6 +111,7 @@ struct Resource {
 	static const AmigaMemEntry _memListAmigaEN[ENTRIES_COUNT];
 	static const AmigaMemEntry _memListAtariEN[ENTRIES_COUNT];
 	static const uint8_t _memListParts[][4];
+	static const AmigaMemEntry *detectAmigaAtari();
 
 	Video *_vid;
 	DataType _dataType;
@@ -142,7 +143,6 @@ struct Resource {
 	DataType getDataType() const {
 		return _dataType;
 	}
-	void detectVersion();
 	const char *getGameTitle(Language lang) const;
 	bool readBank(const MemEntry *me, uint8_t *dstBuf);
 	void readEntries();


Commit: 88f8b5f12de17c7533516f64e81f79328d94b8c8
    https://github.com/scummvm/scummvm/commit/88f8b5f12de17c7533516f64e81f79328d94b8c8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Further fields initialization

Changed paths:
    engines/awe/engine.cpp
    engines/awe/graphics_soft.cpp
    engines/awe/sfx_player.h


diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index 9072c4be272..b374f60feeb 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -28,13 +28,7 @@
 
 namespace Awe {
 
-Engine::Engine(Audio::Mixer *mixer, DataType dataType, int partNum) :
-		_mix(mixer), _script(mixer, &_res, &_ply, &_vid),
-		_res(&_vid, dataType), _ply(&_res), _vid(&_res),
-		_partNum(partNum) {
-}
-
-static const int _restartPos[36 * 2] = {
+static const uint16 RESTART_POS[36 * 2] = {
 	16008,  0, 16001,  0, 16002, 10, 16002, 12, 16002, 14,
 	16003, 20, 16003, 24, 16003, 26, 16004, 30, 16004, 31,
 	16004, 32, 16004, 33, 16004, 34, 16004, 35, 16004, 36,
@@ -45,6 +39,12 @@ static const int _restartPos[36 * 2] = {
 	16007, 0
 };
 
+Engine::Engine(Audio::Mixer *mixer, DataType dataType, int partNum) :
+		_mix(mixer), _script(mixer, &_res, &_ply, &_vid),
+		_res(&_vid, dataType), _ply(&_res), _vid(&_res),
+		_partNum(partNum) {
+}
+
 void Engine::setSystemStub(SystemStub *stub, Graphics *graphics) {
 	_stub = stub;
 	_script._stub = stub;
@@ -166,7 +166,7 @@ void Engine::setup(Language lang, int graphicsType, const char *scalerName, int
 		_state = kStateGame;
 		const int num = _partNum;
 		if (num < 36) {
-			_script.restartAt(_restartPos[num * 2], _restartPos[num * 2 + 1]);
+			_script.restartAt(RESTART_POS[num * 2], RESTART_POS[num * 2 + 1]);
 		} else {
 			_script.restartAt(num);
 		}
diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
index 7fd648d517d..e79c8090727 100644
--- a/engines/awe/graphics_soft.cpp
+++ b/engines/awe/graphics_soft.cpp
@@ -29,14 +29,14 @@ namespace Awe {
 struct GraphicsSoft : public Graphics {
 	typedef void (GraphicsSoft:: *drawLine)(int16_t x1, int16_t x2, int16_t y, uint8_t col);
 
-	uint8_t *_pagePtrs[4];
-	uint8_t *_drawPagePtr;
-	int _u, _v;
-	int _w, _h;
-	int _byteDepth;
+	uint8_t *_pagePtrs[4] = { nullptr };
+	uint8_t *_drawPagePtr = { nullptr };
+	int _u = 0, _v = 0;
+	int _w = 0, _h = 0;
+	int _byteDepth = 0;
 	Color _pal[16];
-	uint16_t *_colorBuffer;
-	int _screenshotNum;
+	uint16_t *_colorBuffer = nullptr;
+	int _screenshotNum = 0;
 
 	GraphicsSoft();
 	~GraphicsSoft();
diff --git a/engines/awe/sfx_player.h b/engines/awe/sfx_player.h
index 5bf4bb06693..326f47aeb7c 100644
--- a/engines/awe/sfx_player.h
+++ b/engines/awe/sfx_player.h
@@ -69,13 +69,13 @@ struct SfxPlayer {
 
 	Resource *_res;
 
-	uint16_t _delay;
-	uint16_t _resNum;
+	uint16_t _delay = 0;
+	uint16_t _resNum = 0;
 	SfxModule _sfxMod;
-	int16_t *_syncVar;
-	bool _playing;
-	int _rate;
-	int _samplesLeft;
+	int16_t *_syncVar = nullptr;
+	bool _playing = false;
+	int _rate = 0;
+	int _samplesLeft = 0;
 	SfxChannel _channels[NUM_CHANNELS];
 
 	SfxPlayer(Resource *res);


Commit: 675136adbf10cb357a144a3f0db746a8f0700f66
    https://github.com/scummvm/scummvm/commit/675136adbf10cb357a144a3f0db746a8f0700f66
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Change debug lines to use debug channels

Changed paths:
    engines/awe/aifc_player.cpp
    engines/awe/awe.cpp
    engines/awe/detection.cpp
    engines/awe/detection.h
    engines/awe/graphics_soft.cpp
    engines/awe/mixer.cpp
    engines/awe/pak.cpp
    engines/awe/resource.cpp
    engines/awe/resource_nth.cpp
    engines/awe/resource_win31.cpp
    engines/awe/script.cpp
    engines/awe/sfx_player.cpp
    engines/awe/util.h
    engines/awe/video.cpp


diff --git a/engines/awe/aifc_player.cpp b/engines/awe/aifc_player.cpp
index a92b4b6b3ae..8f4f0c8413b 100644
--- a/engines/awe/aifc_player.cpp
+++ b/engines/awe/aifc_player.cpp
@@ -60,14 +60,14 @@ bool AifcPlayer::play(int mixRate, const char *path, uint32_t startOffset) {
 						warning("Unsupported compression");
 						break;
 					}
-					debug(DBG_SND, "AIFF-C channels %d rate %d bits %d", channels, rate, bits);
+					debugC(kDebugSound, "AIFF-C channels %d rate %d bits %d", channels, rate, bits);
 					_rate.reset(rate, mixRate);
 				} else if (memcmp(buf, "SSND", 4) == 0) {
 					_f.readUint32BE(); // block offset
 					_f.readUint32BE(); // block size
 					_ssndOffset = startOffset + offset + 8 + 8;
 					_ssndSize = sz;
-					debug(DBG_SND, "AIFF-C ssnd size %d", _ssndSize);
+					debugC(kDebugSound, "AIFF-C ssnd size %d", _ssndSize);
 					break;
 				} else if (memcmp(buf, "FVER", 4) == 0) {
 					const uint32_t version = _f.readUint32BE();
diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index f16a73000e5..1c783db9ec3 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -69,10 +69,10 @@ static Graphics *createGraphics(int type) {
 		Graphics::_is1991 = true;
 		// fall-through
 	case GRAPHICS_SOFTWARE:
-		debug(DBG_INFO, "Using software graphics");
+		debugC(kDebugInfo, "Using software graphics");
 		return GraphicsSoft_create();
 	case GRAPHICS_GL:
-		debug(DBG_INFO, "Using GL graphics");
+		debugC(kDebugInfo, "Using GL graphics");
 #ifdef USE_GL
 		return GraphicsGL_create();
 #endif
@@ -224,42 +224,42 @@ int main(int argc, char *argv[]) {
 			return 0;
 		}
 	}
-	g_debugMask = DBG_INFO; // | DBG_VIDEO | DBG_SND | DBG_SCRIPT | DBG_BANK | DBG_SER;
+
 	Engine *e = new Engine(dataPath, part);
 	if (defaultGraphics) {
 		// if not set, use original software graphics for 199x editions and GL for the anniversary and 3DO versions
-		graphicsType = getGraphicsType(e->_res.getDataType());
+		graphicsType = getGraphicsType(dataType);
 		dm.opengl = (graphicsType == GRAPHICS_GL);
 	}
-	if (graphicsType != GRAPHICS_GL && e->_res.getDataType() == DT_3DO) {
+	if (graphicsType != GRAPHICS_GL && dataType == DT_3DO) {
 		graphicsType = GRAPHICS_SOFTWARE;
 		Graphics::_use555 = true;
 	}
 	Graphics *graphics = createGraphics(graphicsType);
-	if (e->_res.getDataType() == DT_20TH_EDITION) {
+	if (dataType == DT_20TH_EDITION) {
 		switch (Script::_difficulty) {
 		case DIFFICULTY_EASY:
-			debug(DBG_INFO, "Using easy difficulty");
+			debugC(kDebugInfo, "Using easy difficulty");
 			break;
 		case DIFFICULTY_NORMAL:
-			debug(DBG_INFO, "Using normal difficulty");
+			debugC(kDebugInfo, "Using normal difficulty");
 			break;
 		case DIFFICULTY_HARD:
-			debug(DBG_INFO, "Using hard difficulty");
+			debugC(kDebugInfo, "Using hard difficulty");
 			break;
 		}
 	}
-	if (e->_res.getDataType() == DT_15TH_EDITION || e->_res.getDataType() == DT_20TH_EDITION) {
+	if (dataType == DT_15TH_EDITION || dataType == DT_20TH_EDITION) {
 		if (Script::_useRemasteredAudio) {
-			debug(DBG_INFO, "Using remastered audio");
+			debugC(kDebugInfo, "Using remastered audio");
 		} else {
-			debug(DBG_INFO, "Using original audio");
+			debugC(kDebugInfo, "Using original audio");
 		}
 	}
 	SystemStub *stub = SystemStub_SDL_create();
 	stub->init(e->getGameTitle(lang), &dm);
 	e->setSystemStub(stub, graphics);
-	if (demo3JoyInputs && e->_res.getDataType() == DT_DOS) {
+	if (demo3JoyInputs && dataType == DT_DOS) {
 		e->_res.readDemo3Joy();
 	}
 	e->setup(lang, graphicsType, scaler.name, scaler.factor);
@@ -308,32 +308,32 @@ Common::Error AweEngine::run() {
 	Awe::Engine *e = new Awe::Engine(_mixer, dataType, part);
 	if (defaultGraphics) {
 		// if not set, use original software graphics for 199x editions and GL for the anniversary and 3DO versions
-		graphicsType = getGraphicsType(e->_res.getDataType());
+		graphicsType = getGraphicsType(dataType);
 		dm.opengl = (graphicsType == GRAPHICS_GL);
 	}
-	if (graphicsType != GRAPHICS_GL && e->_res.getDataType() == DT_3DO) {
+	if (graphicsType != GRAPHICS_GL && dataType == DT_3DO) {
 		graphicsType = GRAPHICS_SOFTWARE;
 		Graphics::_use555 = true;
 	}
 	Graphics *graphics = createGraphics(graphicsType);
-	if (e->_res.getDataType() == DT_20TH_EDITION) {
+	if (dataType == DT_20TH_EDITION) {
 		switch (Script::_difficulty) {
 		case DIFFICULTY_EASY:
-			debug(DBG_INFO, "Using easy difficulty");
+			debugC(kDebugInfo, "Using easy difficulty");
 			break;
 		case DIFFICULTY_NORMAL:
-			debug(DBG_INFO, "Using normal difficulty");
+			debugC(kDebugInfo, "Using normal difficulty");
 			break;
 		case DIFFICULTY_HARD:
-			debug(DBG_INFO, "Using hard difficulty");
+			debugC(kDebugInfo, "Using hard difficulty");
 			break;
 		}
 	}
-	if (e->_res.getDataType() == DT_15TH_EDITION || e->_res.getDataType() == DT_20TH_EDITION) {
+	if (dataType == DT_15TH_EDITION || dataType == DT_20TH_EDITION) {
 		if (Script::_useRemasteredAudio) {
-			debug(DBG_INFO, "Using remastered audio");
+			debugC(kDebugInfo, "Using remastered audio");
 		} else {
-			debug(DBG_INFO, "Using original audio");
+			debugC(kDebugInfo, "Using original audio");
 		}
 	}
 
@@ -341,7 +341,7 @@ Common::Error AweEngine::run() {
 	stub->init(dm);
 	e->setSystemStub(stub, graphics);
 
-	if (demo3JoyInputs && e->_res.getDataType() == DT_DOS) {
+	if (demo3JoyInputs && dataType == DT_DOS) {
 		e->_res.readDemo3Joy();
 	}
 
diff --git a/engines/awe/detection.cpp b/engines/awe/detection.cpp
index 587410fad07..5a115ec7cb0 100644
--- a/engines/awe/detection.cpp
+++ b/engines/awe/detection.cpp
@@ -30,10 +30,13 @@
 #include "awe/detection_tables.h"
 
 const DebugChannelDef AweMetaEngineDetection::debugFlagList[] = {
-	{ Awe::kDebugLogic, "Logic", "Logic debug level" },
+	{ Awe::kDebugScript, "Scripts", "Scripts debug level" },
 	{ Awe::kDebugBank, "Bank", "Bank debug level" },
 	{ Awe::kDebugVideo, "Video", "Video debug level" },
+	{ Awe::kDebugSound, "Sound", "Sound debug level" },
 	{ Awe::kDebugInfo, "Info", "Info debug level" },
+	{ Awe::kDebugPak, "Pak", "Pak debug level" },
+	{ Awe::kDebugResource, "Resource", "Resource debug level" },
 	DEBUG_CHANNEL_END
 };
 
diff --git a/engines/awe/detection.h b/engines/awe/detection.h
index 763e9d7ee37..7b03ee7e79c 100644
--- a/engines/awe/detection.h
+++ b/engines/awe/detection.h
@@ -27,10 +27,13 @@
 namespace Awe {
 
 enum AweDebugChannels {
-	kDebugLogic = 1 << 0,
+	kDebugScript = 1 << 0,
 	kDebugBank = 1 << 1,
 	kDebugVideo = 1 << 2,
-	kDebugInfo = 1 << 3
+	kDebugSound = 1 << 3,
+	kDebugInfo = 1 << 4,
+	kDebugPak = 1 << 5,
+	kDebugResource = 1 << 6
 };
 
 enum DataType {
diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
index e79c8090727..be328c9afb4 100644
--- a/engines/awe/graphics_soft.cpp
+++ b/engines/awe/graphics_soft.cpp
@@ -440,7 +440,7 @@ static void dumpBuffer555(const uint16_t *src, int w, int h, int num) {
 	char name[32];
 	snprintf(name, sizeof(name), "screenshot-%d.tga", num);
 	saveTGA(name, src, w, h);
-	debug(DBG_INFO, "Written '%s'", name);
+	debugC(kDebugInfo, "Written '%s'", name);
 }
 
 static void dumpPalette555(uint16_t *dst, int w, const Color *pal) {
diff --git a/engines/awe/mixer.cpp b/engines/awe/mixer.cpp
index f42edea33f1..0b67087b66a 100644
--- a/engines/awe/mixer.cpp
+++ b/engines/awe/mixer.cpp
@@ -388,7 +388,7 @@ struct Mixer_impl {
 		stopMusic();
 		stopSfxMusic();
 		for (std::map<int, Mix_Chunk *>::iterator it = _preloads.begin(); it != _preloads.end(); ++it) {
-			debug(DBG_SND, "Flush preload %d", it->first);
+			debugC(kDebugSound, "Flush preload %d", it->first);
 			Mix_FreeChunk(it->second);
 		}
 		_preloads.clear();
@@ -441,49 +441,49 @@ void Mixer::update() {
 }
 
 void Mixer::playSoundRaw(uint8_t channel, const uint8_t *data, uint16_t freq, uint8_t volume) {
-	debug(DBG_SND, "Mixer::playChannel(%d, %d, %d)", channel, freq, volume);
+	debugC(kDebugSound, "Mixer::playChannel(%d, %d, %d)", channel, freq, volume);
 	if (_impl) {
 		return _impl->playSoundRaw(channel, data, freq, volume);
 	}
 }
 
 void Mixer::playSoundWav(uint8_t channel, const uint8_t *data, uint16_t freq, uint8_t volume, uint8_t loop) {
-	debug(DBG_SND, "Mixer::playSoundWav(%d, %d, %d)", channel, volume, loop);
+	debugC(kDebugSound, "Mixer::playSoundWav(%d, %d, %d)", channel, volume, loop);
 	if (_impl) {
 		return _impl->playSoundWav(channel, data, freq, volume, loop);
 	}
 }
 
 void Mixer::stopSound(uint8_t channel) {
-	debug(DBG_SND, "Mixer::stopChannel(%d)", channel);
+	debugC(kDebugSound, "Mixer::stopChannel(%d)", channel);
 	if (_impl) {
 		return _impl->stopSound(channel);
 	}
 }
 
 void Mixer::setChannelVolume(uint8_t channel, uint8_t volume) {
-	debug(DBG_SND, "Mixer::setChannelVolume(%d, %d)", channel, volume);
+	debugC(kDebugSound, "Mixer::setChannelVolume(%d, %d)", channel, volume);
 	if (_impl) {
 		return _impl->setChannelVolume(channel, volume);
 	}
 }
 
 void Mixer::playMusic(const char *path, uint8_t loop) {
-	debug(DBG_SND, "Mixer::playMusic(%s, %d)", path, loop);
+	debugC(kDebugSound, "Mixer::playMusic(%s, %d)", path, loop);
 	if (_impl) {
 		return _impl->playMusic(path, (loop != 0) ? -1 : 0);
 	}
 }
 
 void Mixer::stopMusic() {
-	debug(DBG_SND, "Mixer::stopMusic()");
+	debugC(kDebugSound, "Mixer::stopMusic()");
 	if (_impl) {
 		return _impl->stopMusic();
 	}
 }
 
 void Mixer::playAifcMusic(const char *path, uint32_t offset) {
-	debug(DBG_SND, "Mixer::playAifcMusic(%s)", path);
+	debugC(kDebugSound, "Mixer::playAifcMusic(%s)", path);
 	if (!_aifc) {
 		_aifc = new AifcPlayer();
 	}
@@ -496,7 +496,7 @@ void Mixer::playAifcMusic(const char *path, uint32_t offset) {
 }
 
 void Mixer::stopAifcMusic() {
-	debug(DBG_SND, "Mixer::stopAifcMusic()");
+	debugC(kDebugSound, "Mixer::stopAifcMusic()");
 	if (_impl && _aifc) {
 		_aifc->stop();
 		_impl->stopAifcMusic();
@@ -504,35 +504,35 @@ void Mixer::stopAifcMusic() {
 }
 
 void Mixer::playSfxMusic(int num) {
-	debug(DBG_SND, "Mixer::playSfxMusic(%d)", num);
+	debugC(kDebugSound, "Mixer::playSfxMusic(%d)", num);
 	if (_impl && _sfx) {
 		return _impl->playSfxMusic(_sfx);
 	}
 }
 
 void Mixer::stopSfxMusic() {
-	debug(DBG_SND, "Mixer::stopSfxMusic()");
+	debugC(kDebugSound, "Mixer::stopSfxMusic()");
 	if (_impl && _sfx) {
 		return _impl->stopSfxMusic();
 	}
 }
 
 void Mixer::stopAll() {
-	debug(DBG_SND, "Mixer::stopAll()");
+	debugC(kDebugSound, "Mixer::stopAll()");
 	if (_impl) {
 		return _impl->stopAll();
 	}
 }
 
 void Mixer::preloadSoundAiff(uint8_t num, const uint8_t *data) {
-	debug(DBG_SND, "Mixer::preloadSoundAiff(num:%d, data:%p)", num, data);
+	debugC(kDebugSound, "Mixer::preloadSoundAiff(num:%d, data:%p)", num, data);
 	if (_impl) {
 		return _impl->preloadSoundAiff(num, data);
 	}
 }
 
 void Mixer::playSoundAiff(uint8_t channel, uint8_t num, uint8_t volume) {
-	debug(DBG_SND, "Mixer::playSoundAiff()");
+	debugC(kDebugSound, "Mixer::playSoundAiff()");
 	if (_impl) {
 		return _impl->playSoundAiff(channel, num, volume);
 	}
diff --git a/engines/awe/pak.cpp b/engines/awe/pak.cpp
index 0f9995b9604..df8f38fe6c3 100644
--- a/engines/awe/pak.cpp
+++ b/engines/awe/pak.cpp
@@ -79,7 +79,7 @@ void Pak::readEntries() {
 	_f.seek(entriesOffset);
 	const uint32_t entriesSize = READ_LE_UINT32(header + 8);
 	_entriesCount = entriesSize / 0x40;
-	debug(DBG_PAK, "Pak::readEntries() entries count %d", _entriesCount);
+	debugC(kDebugPak, "Pak::readEntries() entries count %d", _entriesCount);
 	_entries = (PakEntry *)calloc(_entriesCount, sizeof(PakEntry));
 	if (!_entries) {
 		_entriesCount = 0;
@@ -99,7 +99,7 @@ void Pak::readEntries() {
 		Common::strcpy_s(e->name, name + 4);
 		e->offset = READ_LE_UINT32(buf + 0x38);
 		e->size = READ_LE_UINT32(buf + 0x3C);
-		debug(DBG_PAK, "Pak::readEntries() buf '%s' size %d", e->name, e->size);
+		debugC(kDebugPak, "Pak::readEntries() buf '%s' size %d", e->name, e->size);
 	}
 	qsort(_entries, _entriesCount, sizeof(PakEntry), comparePakEntry);
 	// the original executable descrambles the (ke)y.txt file and check the last 4 bytes.
@@ -118,14 +118,14 @@ void Pak::readEntries() {
 }
 
 const PakEntry *Pak::find(const char *name) {
-	debug(DBG_PAK, "Pak::find() '%s'", name);
+	debugC(kDebugPak, "Pak::find() '%s'", name);
 	PakEntry tmp;
 	Common::strcpy_s(tmp.name, name);
 	return (const PakEntry *)bsearch(&tmp, _entries, _entriesCount, sizeof(PakEntry), comparePakEntry);
 }
 
 void Pak::loadData(const PakEntry *e, uint8_t *buf, uint32_t *size) {
-	debug(DBG_PAK, "Pak::loadData() %d bytes from 0x%x", e->size, e->offset);
+	debugC(kDebugPak, "Pak::loadData() %d bytes from 0x%x", e->size, e->offset);
 	_f.seek(e->offset);
 	if (_f.ioErr()) {
 		*size = 0;
@@ -134,7 +134,7 @@ void Pak::loadData(const PakEntry *e, uint8_t *buf, uint32_t *size) {
 	_f.read(buf, e->size);
 	if (e->size > 5 && memcmp(buf, "TooDC", 5) == 0) {
 		const int dataSize = e->size - 6;
-		debug(DBG_PAK, "Pak::loadData() encoded TooDC data, size %d", dataSize);
+		debugC(kDebugPak, "Pak::loadData() encoded TooDC data, size %d", dataSize);
 		if ((dataSize & 3) != 0) {
 			// descrambler operates on uint32_t
 			warning("Unexpected size %d for encoded TooDC data '%s'", dataSize, e->name);
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 62417ba63ce..a60befa8031 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -279,7 +279,7 @@ void Resource::load() {
 			warning("Resource::load() ec=0x%X (me->bankNum == 0)", 0xF00);
 			me->status = STATUS_NULL;
 		} else {
-			debug(DBG_BANK, "Resource::load() bufPos=0x%X size=%d type=%d pos=0x%X bankNum=%d", memPtr - _memPtrStart, me->packedSize, me->type, me->bankPos, me->bankNum);
+			debugC(kDebugBank, "Resource::load() bufPos=0x%X size=%d type=%d pos=0x%X bankNum=%d", memPtr - _memPtrStart, me->packedSize, me->type, me->bankPos, me->bankNum);
 			if (readBank(me, memPtr)) {
 				if (me->type == RT_BITMAP) {
 					_vid->copyBitmapPtr(_vidCurPtr, me->unpackedSize);
diff --git a/engines/awe/resource_nth.cpp b/engines/awe/resource_nth.cpp
index 94dbf74c84b..a85904fdd3a 100644
--- a/engines/awe/resource_nth.cpp
+++ b/engines/awe/resource_nth.cpp
@@ -373,7 +373,7 @@ struct Resource20th : ResourceNth {
 			} else {
 				snprintf(_datName, sizeof(_datName), "%s2011.%s", names[part - 1], exts[type]);
 			}
-			debug(DBG_RESOURCE, "Loading '%s'", _datName);
+			debugC(kDebugResource, "Loading '%s'", _datName);
 		} else {
 			_datName[0] = 0;
 		}
diff --git a/engines/awe/resource_win31.cpp b/engines/awe/resource_win31.cpp
index 3595588c0e3..7023a8f1159 100644
--- a/engines/awe/resource_win31.cpp
+++ b/engines/awe/resource_win31.cpp
@@ -263,7 +263,7 @@ bool ResourceWin31::readEntries() {
 	const int count = _f.read(buf, sizeof(buf));
 	if (count == 32 && memcmp(buf, "NL\00\00", 4) == 0) {
 		_entriesCount = READ_LE_UINT16(buf + 4);
-		debug(DBG_RESOURCE, "Read %d entries in win31 '%s'", _entriesCount, FILENAME);
+		debugC(kDebugResource, "Read %d entries in win31 '%s'", _entriesCount, FILENAME);
 		_entries = (Win31BankEntry *)calloc(_entriesCount, sizeof(Win31BankEntry));
 		if (_entries) {
 			uint16_t key = READ_LE_UINT16(buf + 0x14);
@@ -277,7 +277,7 @@ bool ResourceWin31::readEntries() {
 				e->size = READ_LE_UINT32(buf + 20);
 				e->offset = READ_LE_UINT32(buf + 24);
 				e->packedSize = READ_LE_UINT32(buf + 28);
-				debug(DBG_RESOURCE, "Res #%03d '%s' type %d size %d (%d) offset 0x%x", i, e->name, e->type, e->size, e->packedSize, e->offset);
+				debugC(kDebugResource, "Res #%03d '%s' type %d size %d (%d) offset 0x%x", i, e->name, e->type, e->size, e->packedSize, e->offset);
 				assert(e->size == 0 || flags == 0x80);
 			}
 			readStrings();
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index 1e778fef5b6..41748ea432a 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -62,21 +62,21 @@ void Script::init() {
 void Script::op_movConst() {
 	uint8_t i = _scriptPtr.fetchByte();
 	int16_t n = _scriptPtr.fetchWord();
-	debug(DBG_SCRIPT, "Script::op_movConst(0x%02X, %d)", i, n);
+	debugC(kDebugScript, "Script::op_movConst(0x%02X, %d)", i, n);
 	_scriptVars[i] = n;
 }
 
 void Script::op_mov() {
 	uint8_t i = _scriptPtr.fetchByte();
 	uint8_t j = _scriptPtr.fetchByte();
-	debug(DBG_SCRIPT, "Script::op_mov(0x%02X, 0x%02X)", i, j);
+	debugC(kDebugScript, "Script::op_mov(0x%02X, 0x%02X)", i, j);
 	_scriptVars[i] = _scriptVars[j];
 }
 
 void Script::op_add() {
 	uint8_t i = _scriptPtr.fetchByte();
 	uint8_t j = _scriptPtr.fetchByte();
-	debug(DBG_SCRIPT, "Script::op_add(0x%02X, 0x%02X)", i, j);
+	debugC(kDebugScript, "Script::op_add(0x%02X, 0x%02X)", i, j);
 	_scriptVars[i] += _scriptVars[j];
 }
 
@@ -99,13 +99,13 @@ void Script::op_addConst() {
 	}
 	uint8_t i = _scriptPtr.fetchByte();
 	int16_t n = _scriptPtr.fetchWord();
-	debug(DBG_SCRIPT, "Script::op_addConst(0x%02X, %d)", i, n);
+	debugC(kDebugScript, "Script::op_addConst(0x%02X, %d)", i, n);
 	_scriptVars[i] += n;
 }
 
 void Script::op_call() {
 	uint16_t off = _scriptPtr.fetchWord();
-	debug(DBG_SCRIPT, "Script::op_call(0x%X)", off);
+	debugC(kDebugScript, "Script::op_call(0x%X)", off);
 	if (_stackPtr == 0x40) {
 		error("Script::op_call() ec=0x%X stack overflow", 0x8F);
 	}
@@ -115,7 +115,7 @@ void Script::op_call() {
 }
 
 void Script::op_ret() {
-	debug(DBG_SCRIPT, "Script::op_ret()");
+	debugC(kDebugScript, "Script::op_ret()");
 	if (_stackPtr == 0) {
 		error("Script::op_ret() ec=0x%X stack underflow", 0x8F);
 	}
@@ -124,27 +124,27 @@ void Script::op_ret() {
 }
 
 void Script::op_yieldTask() {
-	debug(DBG_SCRIPT, "Script::op_yieldTask()");
+	debugC(kDebugScript, "Script::op_yieldTask()");
 	_scriptPaused = true;
 }
 
 void Script::op_jmp() {
 	uint16_t off = _scriptPtr.fetchWord();
-	debug(DBG_SCRIPT, "Script::op_jmp(0x%02X)", off);
+	debugC(kDebugScript, "Script::op_jmp(0x%02X)", off);
 	_scriptPtr.pc = _res->_segCode + off;
 }
 
 void Script::op_installTask() {
 	uint8_t i = _scriptPtr.fetchByte();
 	uint16_t n = _scriptPtr.fetchWord();
-	debug(DBG_SCRIPT, "Script::op_installTask(0x%X, 0x%X)", i, n);
+	debugC(kDebugScript, "Script::op_installTask(0x%X, 0x%X)", i, n);
 	assert(i < 0x40);
 	_scriptTasks[1][i] = n;
 }
 
 void Script::op_jmpIfVar() {
 	uint8_t i = _scriptPtr.fetchByte();
-	debug(DBG_SCRIPT, "Script::op_jmpIfVar(0x%02X)", i);
+	debugC(kDebugScript, "Script::op_jmpIfVar(0x%02X)", i);
 	--_scriptVars[i];
 	if (_scriptVars[i] != 0) {
 		op_jmp();
@@ -165,7 +165,7 @@ void Script::op_condJmp() {
 	} else {
 		a = _scriptPtr.fetchByte();
 	}
-	debug(DBG_SCRIPT, "Script::op_condJmp(%d, 0x%02X, 0x%02X) var=0x%02X", op, b, a, var);
+	debugC(kDebugScript, "Script::op_condJmp(%d, 0x%02X, 0x%02X) var=0x%02X", op, b, a, var);
 	bool expr = false;
 	switch (op & 7) {
 	case 0:
@@ -223,7 +223,7 @@ void Script::op_condJmp() {
 
 void Script::op_setPalette() {
 	uint16_t i = _scriptPtr.fetchWord();
-	debug(DBG_SCRIPT, "Script::op_changePalette(%d)", i);
+	debugC(kDebugScript, "Script::op_changePalette(%d)", i);
 	const int num = i >> 8;
 	if (_vid->_graphics->_fixUpPalette == FIXUP_PALETTE_REDRAW) {
 		if (_res->_currentPart == 16001) {
@@ -246,7 +246,7 @@ void Script::op_changeTasksState() {
 	}
 	uint8_t state = _scriptPtr.fetchByte();
 
-	debug(DBG_SCRIPT, "Script::op_changeTasksState(%d, %d, %d)", start, end, state);
+	debugC(kDebugScript, "Script::op_changeTasksState(%d, %d, %d)", start, end, state);
 
 	if (state == 2) {
 		for (; start <= end; ++start) {
@@ -261,27 +261,27 @@ void Script::op_changeTasksState() {
 
 void Script::op_selectPage() {
 	uint8_t i = _scriptPtr.fetchByte();
-	debug(DBG_SCRIPT, "Script::op_selectPage(%d)", i);
+	debugC(kDebugScript, "Script::op_selectPage(%d)", i);
 	_vid->setWorkPagePtr(i);
 }
 
 void Script::op_fillPage() {
 	uint8_t i = _scriptPtr.fetchByte();
 	uint8_t color = _scriptPtr.fetchByte();
-	debug(DBG_SCRIPT, "Script::op_fillPage(%d, %d)", i, color);
+	debugC(kDebugScript, "Script::op_fillPage(%d, %d)", i, color);
 	_vid->fillPage(i, color);
 }
 
 void Script::op_copyPage() {
 	uint8_t i = _scriptPtr.fetchByte();
 	uint8_t j = _scriptPtr.fetchByte();
-	debug(DBG_SCRIPT, "Script::op_copyPage(%d, %d)", i, j);
+	debugC(kDebugScript, "Script::op_copyPage(%d, %d)", i, j);
 	_vid->copyPage(i, j, _scriptVars[VAR_SCROLL_Y]);
 }
 
 void Script::op_updateDisplay() {
 	uint8_t page = _scriptPtr.fetchByte();
-	debug(DBG_SCRIPT, "Script::op_updateDisplay(%d)", page);
+	debugC(kDebugScript, "Script::op_updateDisplay(%d)", page);
 	inp_handleSpecialKeys();
 
 #ifndef BYPASS_PROTECTION
@@ -311,7 +311,7 @@ void Script::op_updateDisplay() {
 }
 
 void Script::op_removeTask() {
-	debug(DBG_SCRIPT, "Script::op_removeTask()");
+	debugC(kDebugScript, "Script::op_removeTask()");
 	_scriptPtr.pc = _res->_segCode + 0xFFFF;
 	_scriptPaused = true;
 }
@@ -321,42 +321,42 @@ void Script::op_drawString() {
 	uint16_t x = _scriptPtr.fetchByte();
 	uint16_t y = _scriptPtr.fetchByte();
 	uint16_t col = _scriptPtr.fetchByte();
-	debug(DBG_SCRIPT, "Script::op_drawString(0x%03X, %d, %d, %d)", strId, x, y, col);
+	debugC(kDebugScript, "Script::op_drawString(0x%03X, %d, %d, %d)", strId, x, y, col);
 	_vid->drawString(col, x, y, strId);
 }
 
 void Script::op_sub() {
 	uint8_t i = _scriptPtr.fetchByte();
 	uint8_t j = _scriptPtr.fetchByte();
-	debug(DBG_SCRIPT, "Script::op_sub(0x%02X, 0x%02X)", i, j);
+	debugC(kDebugScript, "Script::op_sub(0x%02X, 0x%02X)", i, j);
 	_scriptVars[i] -= _scriptVars[j];
 }
 
 void Script::op_and() {
 	uint8_t i = _scriptPtr.fetchByte();
 	uint16_t n = _scriptPtr.fetchWord();
-	debug(DBG_SCRIPT, "Script::op_and(0x%02X, %d)", i, n);
+	debugC(kDebugScript, "Script::op_and(0x%02X, %d)", i, n);
 	_scriptVars[i] = (uint16_t)_scriptVars[i] & n;
 }
 
 void Script::op_or() {
 	uint8_t i = _scriptPtr.fetchByte();
 	uint16_t n = _scriptPtr.fetchWord();
-	debug(DBG_SCRIPT, "Script::op_or(0x%02X, %d)", i, n);
+	debugC(kDebugScript, "Script::op_or(0x%02X, %d)", i, n);
 	_scriptVars[i] = (uint16_t)_scriptVars[i] | n;
 }
 
 void Script::op_shl() {
 	uint8_t i = _scriptPtr.fetchByte();
 	uint16_t n = _scriptPtr.fetchWord();
-	debug(DBG_SCRIPT, "Script::op_shl(0x%02X, %d)", i, n);
+	debugC(kDebugScript, "Script::op_shl(0x%02X, %d)", i, n);
 	_scriptVars[i] = (uint16_t)_scriptVars[i] << n;
 }
 
 void Script::op_shr() {
 	uint8_t i = _scriptPtr.fetchByte();
 	uint16_t n = _scriptPtr.fetchWord();
-	debug(DBG_SCRIPT, "Script::op_shr(0x%02X, %d)", i, n);
+	debugC(kDebugScript, "Script::op_shr(0x%02X, %d)", i, n);
 	_scriptVars[i] = (uint16_t)_scriptVars[i] >> n;
 }
 
@@ -365,7 +365,7 @@ void Script::op_playSound() {
 	uint8_t freq = _scriptPtr.fetchByte();
 	uint8_t vol = _scriptPtr.fetchByte();
 	uint8_t channel = _scriptPtr.fetchByte();
-	debug(DBG_SCRIPT, "Script::op_playSound(0x%X, %d, %d, %d)", resNum, freq, vol, channel);
+	debugC(kDebugScript, "Script::op_playSound(0x%X, %d, %d, %d)", resNum, freq, vol, channel);
 	snd_playSound(resNum, freq, vol, channel);
 }
 
@@ -375,7 +375,7 @@ static void preloadSoundCb(void *userdata, int soundNum, const uint8_t *data) {
 
 void Script::op_updateResources() {
 	uint16_t num = _scriptPtr.fetchWord();
-	debug(DBG_SCRIPT, "Script::op_updateResources(%d)", num);
+	debugC(kDebugScript, "Script::op_updateResources(%d)", num);
 	if (num == 0) {
 		_ply->stop();
 		_mix->stopAll();
@@ -389,7 +389,7 @@ void Script::op_playMusic() {
 	uint16_t resNum = _scriptPtr.fetchWord();
 	uint16_t delay = _scriptPtr.fetchWord();
 	uint8_t pos = _scriptPtr.fetchByte();
-	debug(DBG_SCRIPT, "Script::op_playMusic(0x%X, %d, %d)", resNum, delay, pos);
+	debugC(kDebugScript, "Script::op_playMusic(0x%X, %d, %d)", resNum, delay, pos);
 	snd_playMusic(resNum, delay, pos);
 }
 
@@ -455,10 +455,10 @@ void Script::runTasks() {
 				_scriptPtr.pc = _res->_segCode + n;
 				_stackPtr = 0;
 				_scriptPaused = false;
-				debug(DBG_SCRIPT, "Script::runTasks() i=0x%02X n=0x%02X", i, n);
+				debugC(kDebugScript, "Script::runTasks() i=0x%02X n=0x%02X", i, n);
 				executeTask();
 				_scriptTasks[0][i] = _scriptPtr.pc - _res->_segCode;
-				debug(DBG_SCRIPT, "Script::runTasks() i=0x%02X pos=0x%X", i, _scriptTasks[0][i]);
+				debugC(kDebugScript, "Script::runTasks() i=0x%02X pos=0x%X", i, _scriptTasks[0][i]);
 			}
 		}
 	}
@@ -478,7 +478,7 @@ void Script::executeTask() {
 				pt.y = 199;
 				pt.x += h;
 			}
-			debug(DBG_VIDEO, "vid_opcd_0x80 : opcode=0x%X off=0x%X x=%d y=%d", opcode, off, pt.x, pt.y);
+			debugC(kDebugVideo, "vid_opcd_0x80 : opcode=0x%X off=0x%X x=%d y=%d", opcode, off, pt.x, pt.y);
 			_vid->setDataBuffer(_res->_segVideo1, off);
 			if (_is3DO) {
 				_vid->drawShape3DO(0xFF, 64, &pt);
@@ -522,7 +522,7 @@ void Script::executeTask() {
 					zoom = _scriptPtr.fetchByte();
 				}
 			}
-			debug(DBG_VIDEO, "vid_opcd_0x40 : off=0x%X x=%d y=%d", off, pt.x, pt.y);
+			debugC(kDebugVideo, "vid_opcd_0x40 : off=0x%X x=%d y=%d", off, pt.x, pt.y);
 			_vid->setDataBuffer(_res->_useSegVideo2 ? _res->_segVideo2 : _res->_segVideo1, off);
 			if (_is3DO) {
 				_vid->drawShape3DO(0xFF, zoom, &pt);
@@ -535,7 +535,7 @@ void Script::executeTask() {
 				case 11:
 				{
 					const int num = _scriptPtr.fetchByte();
-					debug(DBG_SCRIPT, "Script::op11() setPalette %d", num);
+					debugC(kDebugScript, "Script::op11() setPalette %d", num);
 					_vid->changePal(num);
 				}
 				continue;
@@ -543,7 +543,7 @@ void Script::executeTask() {
 				{
 					const int var = _scriptPtr.fetchByte();
 					const int shift = _scriptPtr.fetchByte();
-					debug(DBG_SCRIPT, "Script::op22() VAR(0x%02X) <<= %d", var, shift);
+					debugC(kDebugScript, "Script::op22() VAR(0x%02X) <<= %d", var, shift);
 					_scriptVars[var] = (uint16_t)_scriptVars[var] << shift;
 				}
 				continue;
@@ -551,14 +551,14 @@ void Script::executeTask() {
 				{
 					const int var = _scriptPtr.fetchByte();
 					const int shift = _scriptPtr.fetchByte();
-					debug(DBG_SCRIPT, "Script::op23() VAR(0x%02X) >>= %d", var, shift);
+					debugC(kDebugScript, "Script::op23() VAR(0x%02X) >>= %d", var, shift);
 					_scriptVars[var] = (uint16_t)_scriptVars[var] >> shift;
 				}
 				continue;
 				case 26:
 				{
 					const int num = _scriptPtr.fetchByte();
-					debug(DBG_SCRIPT, "Script::op26() playMusic %d", num);
+					debugC(kDebugScript, "Script::op26() playMusic %d", num);
 					snd_playMusic(num, 0, 0);
 				}
 				continue;
@@ -574,7 +574,7 @@ void Script::executeTask() {
 				case 28:
 				{
 					const uint8_t var = _scriptPtr.fetchByte();
-					debug(DBG_SCRIPT, "Script::op28() jmpIf(VAR(0x%02X) == 0)");
+					debugC(kDebugScript, "Script::op28() jmpIf(VAR(0x%02X) == 0)");
 					if (_scriptVars[var] == 0) {
 						op_jmp();
 					} else {
@@ -585,7 +585,7 @@ void Script::executeTask() {
 				case 29:
 				{
 					const uint8_t var = _scriptPtr.fetchByte();
-					debug(DBG_SCRIPT, "Script::op29() jmpIf(VAR(0x%02X) != 0)");
+					debugC(kDebugScript, "Script::op29() jmpIf(VAR(0x%02X) != 0)");
 					if (_scriptVars[var] != 0) {
 						op_jmp();
 					} else {
@@ -764,7 +764,7 @@ static int getSoundFreq(uint8_t period) {
 }
 
 void Script::snd_playSound(uint16_t resNum, uint8_t freq, uint8_t vol, uint8_t channel) {
-	debug(DBG_SND, "snd_playSound(0x%X, %d, %d, %d)", resNum, freq, vol, channel);
+	debugC(kDebugSound, "snd_playSound(0x%X, %d, %d, %d)", resNum, freq, vol, channel);
 	if (vol == 0) {
 #ifdef TODO
 		_mix->stopSound(channel);
@@ -835,7 +835,7 @@ void Script::snd_playSound(uint16_t resNum, uint8_t freq, uint8_t vol, uint8_t c
 
 void Script::snd_playMusic(uint16_t resNum, uint16_t delay, uint8_t pos) {
 #ifdef TODO
-	debug(DBG_SND, "snd_playMusic(0x%X, %d, %d)", resNum, delay, pos);
+	debugC(kDebugSound, "snd_playMusic(0x%X, %d, %d)", resNum, delay, pos);
 	uint8_t loop = 0;
 	switch (_res->getDataType()) {
 	case DT_20TH_EDITION:
@@ -911,7 +911,7 @@ void Script::fixUpPalette_changeScreen(int part, int screen) {
 		break;
 	}
 	if (pal != -1) {
-		debug(DBG_SCRIPT, "Setting palette %d for part %d screen %d", pal, part, screen);
+		debugC(kDebugScript, "Setting palette %d for part %d screen %d", pal, part, screen);
 		_vid->changePal(pal);
 	}
 }
diff --git a/engines/awe/sfx_player.cpp b/engines/awe/sfx_player.cpp
index 6ed9915299f..634babe60cb 100644
--- a/engines/awe/sfx_player.cpp
+++ b/engines/awe/sfx_player.cpp
@@ -33,18 +33,18 @@ SfxPlayer::SfxPlayer(Resource *res)
 }
 
 void SfxPlayer::setEventsDelay(uint16_t delay) {
-	debug(DBG_SND, "SfxPlayer::setEventsDelay(%d)", delay);
+	debugC(kDebugSound, "SfxPlayer::setEventsDelay(%d)", delay);
 	_delay = delay;
 }
 
 void SfxPlayer::loadSfxModule(uint16_t resNum, uint16_t delay, uint8_t pos) {
-	debug(DBG_SND, "SfxPlayer::loadSfxModule(0x%X, %d, %d)", resNum, delay, pos);
+	debugC(kDebugSound, "SfxPlayer::loadSfxModule(0x%X, %d, %d)", resNum, delay, pos);
 	MemEntry *me = &_res->_memList[resNum];
 	if (me->status == Resource::STATUS_LOADED && me->type == Resource::RT_MUSIC) {
 		memset(&_sfxMod, 0, sizeof(SfxModule));
 		_sfxMod.curOrder = pos;
 		_sfxMod.numOrder = me->bufPtr[0x3F];
-		debug(DBG_SND, "SfxPlayer::loadSfxModule() curOrder = 0x%X numOrder = 0x%X", _sfxMod.curOrder, _sfxMod.numOrder);
+		debugC(kDebugSound, "SfxPlayer::loadSfxModule() curOrder = 0x%X numOrder = 0x%X", _sfxMod.curOrder, _sfxMod.numOrder);
 		_sfxMod.orderTable = me->bufPtr + 0x40;
 		if (delay == 0) {
 			_delay = READ_BE_UINT16(me->bufPtr);
@@ -52,7 +52,7 @@ void SfxPlayer::loadSfxModule(uint16_t resNum, uint16_t delay, uint8_t pos) {
 			_delay = delay;
 		}
 		_sfxMod.data = me->bufPtr + 0xC0;
-		debug(DBG_SND, "SfxPlayer::loadSfxModule() eventDelay = %d ms", _delay);
+		debugC(kDebugSound, "SfxPlayer::loadSfxModule() eventDelay = %d ms", _delay);
 		prepareInstruments(me->bufPtr + 2);
 	} else {
 		warning("SfxPlayer::loadSfxModule() ec=0x%X", 0xF8);
@@ -69,7 +69,7 @@ void SfxPlayer::prepareInstruments(const uint8_t *p) {
 			MemEntry *me = &_res->_memList[resNum];
 			if (me->status == Resource::STATUS_LOADED && me->type == Resource::RT_SOUND) {
 				ins->data = me->bufPtr;
-				debug(DBG_SND, "Loaded instrument 0x%X n=%d volume=%d", resNum, i, ins->volume);
+				debugC(kDebugSound, "Loaded instrument 0x%X n=%d volume=%d", resNum, i, ins->volume);
 			} else {
 				error("Error loading instrument 0x%X", resNum);
 			}
@@ -150,12 +150,12 @@ void SfxPlayer::readSamples(int16_t *buf, int len) {
 }
 
 void SfxPlayer::start() {
-	debug(DBG_SND, "SfxPlayer::start()");
+	debugC(kDebugSound, "SfxPlayer::start()");
 	_sfxMod.curPos = 0;
 }
 
 void SfxPlayer::stop() {
-	debug(DBG_SND, "SfxPlayer::stop()");
+	debugC(kDebugSound, "SfxPlayer::stop()");
 	_playing = false;
 }
 
@@ -167,7 +167,7 @@ void SfxPlayer::handleEvents() {
 		patternData += 4;
 	}
 	_sfxMod.curPos += 4 * 4;
-	debug(DBG_SND, "SfxPlayer::handleEvents() order = 0x%X curPos = 0x%X", order, _sfxMod.curPos);
+	debugC(kDebugSound, "SfxPlayer::handleEvents() order = 0x%X curPos = 0x%X", order, _sfxMod.curPos);
 	if (_sfxMod.curPos >= 1024) {
 		_sfxMod.curPos = 0;
 		order = _sfxMod.curOrder + 1;
@@ -188,7 +188,7 @@ void SfxPlayer::handlePattern(uint8_t channel, const uint8_t *data) {
 		if (sample != 0) {
 			uint8_t *ptr = _sfxMod.samples[sample - 1].data;
 			if (ptr != 0) {
-				debug(DBG_SND, "SfxPlayer::handlePattern() preparing sample %d", sample);
+				debugC(kDebugSound, "SfxPlayer::handlePattern() preparing sample %d", sample);
 				pat.sampleVolume = _sfxMod.samples[sample - 1].volume;
 				pat.sampleStart = 8;
 				pat.sampleBuffer = ptr;
@@ -222,7 +222,7 @@ void SfxPlayer::handlePattern(uint8_t channel, const uint8_t *data) {
 		}
 	}
 	if (pat.note_1 == 0xFFFD) {
-		debug(DBG_SND, "SfxPlayer::handlePattern() _syncVar = 0x%X", pat.note_2);
+		debugC(kDebugSound, "SfxPlayer::handlePattern() _syncVar = 0x%X", pat.note_2);
 		*_syncVar = pat.note_2;
 	} else if (pat.note_1 == 0xFFFE) {
 		_channels[channel].sampleLen = 0;
@@ -230,7 +230,7 @@ void SfxPlayer::handlePattern(uint8_t channel, const uint8_t *data) {
 		assert(pat.note_1 >= 0x37 && pat.note_1 < 0x1000);
 		// convert Amiga period value to hz
 		const int freq = kPaulaFreq / (pat.note_1 * 2);
-		debug(DBG_SND, "SfxPlayer::handlePattern() adding sample freq = 0x%X", freq);
+		debugC(kDebugSound, "SfxPlayer::handlePattern() adding sample freq = 0x%X", freq);
 		SfxChannel *ch = &_channels[channel];
 		ch->sampleData = pat.sampleBuffer + pat.sampleStart;
 		ch->sampleLen = pat.sampleLen;
diff --git a/engines/awe/util.h b/engines/awe/util.h
index 505481bb53e..7d9d28bcb5e 100644
--- a/engines/awe/util.h
+++ b/engines/awe/util.h
@@ -24,20 +24,10 @@
 
 #include "common/textconsole.h"
 #include "awe/intern.h"
+#include "awe/detection.h"
 
 namespace Awe {
 
-enum {
-	DBG_SCRIPT = 1 << 0,
-	DBG_BANK = 1 << 1,
-	DBG_VIDEO = 1 << 2,
-	DBG_SND = 1 << 3,
-	DBG_SER = 1 << 4,
-	DBG_INFO = 1 << 5,
-	DBG_PAK = 1 << 6,
-	DBG_RESOURCE = 1 << 7,
-};
-
 extern uint16_t g_debugMask;
 
 extern void string_lower(char *p);
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index 1a4eb9bdfc7..239a53b6e76 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -137,7 +137,7 @@ void Video::drawShapePart3DO(int color, int part, const Point *pt) {
 
 void Video::drawShape3DO(int color, int zoom, const Point *pt) {
 	const int code = _pData.fetchByte();
-	debug(DBG_VIDEO, "Video::drawShape3DO() code=0x%x pt=%d,%d", code, pt->x, pt->y);
+	debugC(kDebugVideo, "Video::drawShape3DO() code=0x%x pt=%d,%d", code, pt->x, pt->y);
 	if (color == 0xFF) {
 		color = code & 31;
 	}
@@ -272,7 +272,7 @@ void Video::drawShapeParts(uint16_t zoom, const Point *pgc) {
 	pt.x = pgc->x - _pData.fetchByte() * zoom / 64;
 	pt.y = pgc->y - _pData.fetchByte() * zoom / 64;
 	int16_t n = _pData.fetchByte();
-	debug(DBG_VIDEO, "Video::drawShapeParts n=%d", n);
+	debugC(kDebugVideo, "Video::drawShapeParts n=%d", n);
 	for (; n >= 0; --n) {
 		uint16_t offset = _pData.fetchWord();
 		Point po(pt);
@@ -357,7 +357,7 @@ void Video::drawString(uint8_t color, uint16_t x, uint16_t y, uint16_t strId) {
 		warning("Unknown string id %d", strId);
 		return;
 	}
-	debug(DBG_VIDEO, "drawString(%d, %d, %d, '%s')", color, x, y, str);
+	debugC(kDebugVideo, "drawString(%d, %d, %d, '%s')", color, x, y, str);
 	uint16_t xx = x;
 	int len = strlen(str);
 	for (int i = 0; i < len; ++i) {
@@ -404,17 +404,17 @@ uint8_t Video::getPagePtr(uint8_t page) {
 }
 
 void Video::setWorkPagePtr(uint8_t page) {
-	debug(DBG_VIDEO, "Video::setWorkPagePtr(%d)", page);
+	debugC(kDebugVideo, "Video::setWorkPagePtr(%d)", page);
 	_buffers[0] = getPagePtr(page);
 }
 
 void Video::fillPage(uint8_t page, uint8_t color) {
-	debug(DBG_VIDEO, "Video::fillPage(%d, %d)", page, color);
+	debugC(kDebugVideo, "Video::fillPage(%d, %d)", page, color);
 	_graphics->clearBuffer(getPagePtr(page), color);
 }
 
 void Video::copyPage(uint8_t src, uint8_t dst, int16_t vscroll) {
-	debug(DBG_VIDEO, "Video::copyPage(%d, %d)", src, dst);
+	debugC(kDebugVideo, "Video::copyPage(%d, %d)", src, dst);
 	if (src >= 0xFE || ((src &= ~0x40) & 0x80) == 0) { // no vscroll
 		_graphics->copyBuffer(getPagePtr(dst), getPagePtr(src));
 	} else {
@@ -601,7 +601,7 @@ void Video::changePal(uint8_t palNum) {
 }
 
 void Video::updateDisplay(uint8_t page, SystemStub *stub) {
-	debug(DBG_VIDEO, "Video::updateDisplay(%d)", page);
+	debugC(kDebugVideo, "Video::updateDisplay(%d)", page);
 	if (page != 0xFE) {
 		if (page == 0xFF) {
 			SWAP(_buffers[1], _buffers[2]);


Commit: ccce5711a3f2548ada481a9a808216f033784339
    https://github.com/scummvm/scummvm/commit/ccce5711a3f2548ada481a9a808216f033784339
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Cleanup loading memlist.bin

Changed paths:
    engines/awe/awe.cpp
    engines/awe/resource.cpp
    engines/awe/resource.h
    engines/awe/system_stub.cpp


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 1c783db9ec3..0df58fa384f 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -298,8 +298,8 @@ Common::Error AweEngine::run() {
 
 	DisplayMode dm;
 	dm.mode = DisplayMode::WINDOWED;
-	dm.width = DEFAULT_WINDOW_W;
-	dm.height = DEFAULT_WINDOW_H;
+	dm.width = GFX_W;
+	dm.height = GFX_H;
 	dm.opengl = (graphicsType == GRAPHICS_GL);
 
 	bool defaultGraphics = true;
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index a60befa8031..8aa58fd9173 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -135,30 +135,26 @@ void Resource::readEntries() {
 	case DT_DOS:
 	{
 		_hasPasswordScreen = false; // DOS demo versions do not have the resources
-		File f;
-		if (f.open("demo01", _dataDir)) {
+		Common::File f;
+		if (Common::File::exists("demo01")) {
 			_bankPrefix = "demo";
 		}
-		if (f.open("memlist.bin", _dataDir)) {
+		if (f.open("memlist.bin")) {
 			MemEntry *me = _memList;
-			while (1) {
+
+			for (;;) {
 				assert(_numMemList < ARRAYSIZE(_memList));
-				me->status = f.readByte();
-				me->type = f.readByte();
-				me->bufPtr = 0; f.readUint32BE();
-				me->rankNum = f.readByte();
-				me->bankNum = f.readByte();
-				me->bankPos = f.readUint32BE();
-				me->packedSize = f.readUint32BE();
-				me->unpackedSize = f.readUint32BE();
+				me->load(&f);
+
 				if (me->status == 0xFF) {
 					const int num = _memListParts[8][1]; // 16008 bytecode
 					assert(num < _numMemList);
-					char bank[16];
-					snprintf(bank, sizeof(bank), "%s%02x", _bankPrefix, _memList[num].bankNum);
-					_hasPasswordScreen = f.open(bank, _dataDir);
+					Common::String bank = Common::String::format(
+						"%s%02x", _bankPrefix, _memList[num].bankNum);
+					_hasPasswordScreen = Common::File::exists(bank.c_str());
 					return;
 				}
+
 				++_numMemList;
 				++me;
 			}
@@ -666,4 +662,15 @@ void Resource::readDemo3Joy() {
 	}
 }
 
+void MemEntry::load(Common::SeekableReadStream *src) {
+	status = src->readByte();
+	type = src->readByte();
+	bufPtr = nullptr; (void)src->readUint32BE();
+	rankNum = src->readByte();
+	bankNum = src->readByte();
+	bankPos = src->readUint32BE();
+	packedSize = src->readUint32BE();
+	unpackedSize = src->readUint32BE();
+}
+
 } // namespace Awe
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index d31ce20d47a..47eb24bbfda 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -36,6 +36,8 @@ struct MemEntry {
 	uint32_t bankPos = 0;      // 0x8
 	uint32_t packedSize = 0;   // 0xC
 	uint32_t unpackedSize = 0; // 0x12
+
+	void load(Common::SeekableReadStream *src);
 };
 
 struct AmigaMemEntry {
diff --git a/engines/awe/system_stub.cpp b/engines/awe/system_stub.cpp
index e2211914207..9628d679e46 100644
--- a/engines/awe/system_stub.cpp
+++ b/engines/awe/system_stub.cpp
@@ -37,15 +37,6 @@ struct SystemStubScummVM : SystemStub {
 
 	::Graphics::Screen *_screen = nullptr;
 	float _aspectRatio[4] = { 0.0 };
-#ifdef TODO
-	SDL_Window *_window;
-	SDL_Renderer *_renderer;
-	SDL_GLContext _glcontext;
-	int _texW, _texH;
-	SDL_Texture *_texture;
-	SDL_Joystick *_joystick;
-	SDL_GameController *_controller;
-#endif
 	int _screenshot = 0;
 
 	SystemStubScummVM() {}
@@ -73,7 +64,8 @@ SystemStubScummVM::~SystemStubScummVM() {
 
 void SystemStubScummVM::init(const DisplayMode &dm) {
 	// Initialize backend
-	initGraphics(dm.width, dm.height);
+	::Graphics::PixelFormat format(2, 5, 5, 5, 1, 11, 6, 1, 0);
+	initGraphics(dm.width, dm.height, &format);
 	_screen = new ::Graphics::Screen();
 
 	_screenshot = 1;
@@ -84,8 +76,8 @@ void SystemStubScummVM::fini() {
 }
 
 void SystemStubScummVM::prepareScreen(int &w, int &h, float ar[4]) {
-	w = _screen->w;
-	h = _screen->h;
+	assert(w == _screen->w && h == _screen->h);
+
 	ar[0] = _aspectRatio[0];
 	ar[1] = _aspectRatio[1];
 	ar[2] = _aspectRatio[2];
@@ -98,6 +90,11 @@ void SystemStubScummVM::updateScreen() {
 
 void SystemStubScummVM::setScreenPixels555(const uint16_t *data, int w, int h) {
 #ifdef TODO
+	assert(_screen);
+
+	Graphics::Surface s;
+
+
 	if (_renderer) {
 		if (!_texture) {
 			_texture = SDL_CreateTexture(_renderer, SDL_PIXELFORMAT_RGB555, SDL_TEXTUREACCESS_STREAMING, w, h);
@@ -121,8 +118,6 @@ void SystemStubScummVM::setScreenPixels555(const uint16_t *data, int w, int h) {
 		SDL_UpdateTexture(_texture, &r, data, w * sizeof(uint16_t));
 		SDL_RenderCopy(_renderer, _texture, 0, 0);
 	}
-#else
-	error("TODO: setScreenPixels555");
 #endif
 }
 


Commit: 14941bf8968f72fb6babf5c68a6829d6c1a3256f
    https://github.com/scummvm/scummvm/commit/14941bf8968f72fb6babf5c68a6829d6c1a3256f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Rename the Graphics base class to Gfx

This is avoid confusion with the ScummVM Graphics namespace

Changed paths:
  A engines/awe/gfx.h
  R engines/awe/graphics.h
    engines/awe/awe.cpp
    engines/awe/engine.cpp
    engines/awe/engine.h
    engines/awe/graphics_gl.cpp
    engines/awe/graphics_soft.cpp
    engines/awe/script.cpp
    engines/awe/static_res.cpp
    engines/awe/system_stub.cpp
    engines/awe/video.cpp
    engines/awe/video.h


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 0df58fa384f..6fd47705732 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -24,7 +24,7 @@
 #include "common/stream.h"
 #include "awe/awe.h"
 #include "awe/engine.h"
-#include "awe/graphics.h"
+#include "awe/gfx.h"
 #include "awe/resource.h"
 #include "awe/scaler.h"
 #include "awe/script.h"
@@ -57,16 +57,16 @@ static const struct {
 	{ 0,  -1 }
 };
 
-bool Graphics::_is1991 = false;
-bool Graphics::_use555 = false;
+bool Gfx::_is1991 = false;
+bool Gfx::_use555 = false;
 bool Video::_useEGA = false;
 Difficulty Script::_difficulty = DIFFICULTY_NORMAL;
 bool Script::_useRemasteredAudio = true;
 
-static Graphics *createGraphics(int type) {
+static Gfx *createGraphics(int type) {
 	switch (type) {
 	case GRAPHICS_ORIGINAL:
-		Graphics::_is1991 = true;
+		Gfx::_is1991 = true;
 		// fall-through
 	case GRAPHICS_SOFTWARE:
 		debugC(kDebugInfo, "Using software graphics");
@@ -313,9 +313,9 @@ Common::Error AweEngine::run() {
 	}
 	if (graphicsType != GRAPHICS_GL && dataType == DT_3DO) {
 		graphicsType = GRAPHICS_SOFTWARE;
-		Graphics::_use555 = true;
+		Gfx::_use555 = true;
 	}
-	Graphics *graphics = createGraphics(graphicsType);
+	Gfx *graphics = createGraphics(graphicsType);
 	if (dataType == DT_20TH_EDITION) {
 		switch (Script::_difficulty) {
 		case DIFFICULTY_EASY:
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index b374f60feeb..d51b76c7a6e 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -21,7 +21,7 @@
 
 #include "awe/engine.h"
 #include "awe/file.h"
-#include "awe/graphics.h"
+#include "awe/gfx.h"
 #include "awe/resource_nth.h"
 #include "awe/system_stub.h"
 #include "awe/util.h"
@@ -45,7 +45,7 @@ Engine::Engine(Audio::Mixer *mixer, DataType dataType, int partNum) :
 		_partNum(partNum) {
 }
 
-void Engine::setSystemStub(SystemStub *stub, Graphics *graphics) {
+void Engine::setSystemStub(SystemStub *stub, Gfx *graphics) {
 	_stub = stub;
 	_script._stub = stub;
 	_graphics = graphics;
@@ -102,7 +102,7 @@ void Engine::setup(Language lang, int graphicsType, const char *scalerName, int
 	_res.allocMemBlock();
 	_res.readEntries();
 	_res.dumpEntries();
-	const bool isNth = !Graphics::_is1991 && (_res.getDataType() == DT_15TH_EDITION || _res.getDataType() == DT_20TH_EDITION);
+	const bool isNth = !Gfx::_is1991 && (_res.getDataType() == DT_15TH_EDITION || _res.getDataType() == DT_20TH_EDITION);
 	if (isNth) {
 		// get HD background bitmaps resolution
 		_res._nth->getBitmapSize(&w, &h);
diff --git a/engines/awe/engine.h b/engines/awe/engine.h
index fcefc0eac01..e5a56b21b84 100644
--- a/engines/awe/engine.h
+++ b/engines/awe/engine.h
@@ -33,7 +33,7 @@
 
 namespace Awe {
 
-struct Graphics;
+struct Gfx;
 struct SystemStub;
 
 struct Engine {
@@ -45,7 +45,7 @@ struct Engine {
 	};
 
 	int _state = 0;
-	Graphics *_graphics = nullptr;
+	Gfx *_graphics = nullptr;
 	SystemStub *_stub = nullptr;
 	Script _script;
 	Audio::Mixer *_mix;
@@ -56,7 +56,7 @@ struct Engine {
 
 	Engine(Audio::Mixer *mixer, DataType dataType, int partNum);
 
-	void setSystemStub(SystemStub *, Graphics *);
+	void setSystemStub(SystemStub *, Gfx *);
 
 	const char *getGameTitle(Language lang) const {
 		return _res.getGameTitle(lang);
diff --git a/engines/awe/graphics.h b/engines/awe/gfx.h
similarity index 97%
rename from engines/awe/graphics.h
rename to engines/awe/gfx.h
index 5bb2208d049..e47c2ddba96 100644
--- a/engines/awe/graphics.h
+++ b/engines/awe/gfx.h
@@ -58,7 +58,7 @@ enum {
 
 struct SystemStub;
 
-struct Graphics {
+struct Gfx {
 	static const uint8_t _font[];
 	static bool _is1991; // draw graphics as in the original 1991 game release
 	static bool _use555; // use 16bits graphics buffer (for 3DO)
@@ -69,7 +69,7 @@ struct Graphics {
 	int _fixUpPalette = 0;
 	bool _screenshot = false;
 
-	virtual ~Graphics() {};
+	virtual ~Gfx() {};
 
 	virtual void init(int targetW, int targetH) { _screenshot = false; }
 	virtual void fini() {}
@@ -89,7 +89,7 @@ struct Graphics {
 	virtual void drawBitmapOverlay(const uint8_t *data, int w, int h, int fmt, SystemStub *stub) = 0;
 };
 
-Graphics *GraphicsSoft_create();
+Gfx *GraphicsSoft_create();
 
 } // namespace Awe
 
diff --git a/engines/awe/graphics_gl.cpp b/engines/awe/graphics_gl.cpp
index 3313c3b6fd4..6a250801917 100644
--- a/engines/awe/graphics_gl.cpp
+++ b/engines/awe/graphics_gl.cpp
@@ -19,7 +19,7 @@
  *
  */
 
-#include "awe/graphics.h"
+#include "awe/gfx.h"
 #include "awe/util.h"
 #include "awe/system_stub.h"
 
diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
index be328c9afb4..0e994acdb98 100644
--- a/engines/awe/graphics_soft.cpp
+++ b/engines/awe/graphics_soft.cpp
@@ -19,14 +19,14 @@
  *
  */
 
-#include "awe/graphics.h"
+#include "awe/gfx.h"
 #include "awe/util.h"
 #include "awe/screenshot.h"
 #include "awe/system_stub.h"
 
 namespace Awe {
 
-struct GraphicsSoft : public Graphics {
+struct GraphicsSoft : public Gfx {
 	typedef void (GraphicsSoft:: *drawLine)(int16_t x1, int16_t x2, int16_t y, uint8_t col);
 
 	uint8_t *_pagePtrs[4] = { nullptr };
@@ -348,7 +348,7 @@ void GraphicsSoft::setWorkPagePtr(uint8_t page) {
 }
 
 void GraphicsSoft::init(int targetW, int targetH) {
-	Graphics::init(targetW, targetH);
+	Gfx::init(targetW, targetH);
 	setSize(targetW, targetH);
 }
 
@@ -516,7 +516,7 @@ void GraphicsSoft::drawBitmapOverlay(const uint8_t *data, int w, int h, int fmt,
 	}
 }
 
-Graphics *GraphicsSoft_create() {
+Gfx *GraphicsSoft_create() {
 	return new GraphicsSoft();
 }
 
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index 41748ea432a..70a7c240954 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -19,7 +19,7 @@
  *
  */
 
-#include "awe/graphics.h"
+#include "awe/gfx.h"
 #include "awe/script.h"
 #include "awe/mixer.h"
 #include "awe/resource.h"
diff --git a/engines/awe/static_res.cpp b/engines/awe/static_res.cpp
index fe6ba4e58cb..4c26c611876 100644
--- a/engines/awe/static_res.cpp
+++ b/engines/awe/static_res.cpp
@@ -19,7 +19,7 @@
  *
  */
 
-#include "awe/graphics.h"
+#include "awe/gfx.h"
 #include "awe/script.h"
 #include "awe/resource.h"
 #include "awe/video.h"
@@ -70,7 +70,7 @@ const uint16_t Script::_periodTable[] = {
 	 190,  180,  170,  160,  151,  143,  135,  127,  120,  113
 };
 
-const uint8_t Graphics::_font[] = {
+const uint8_t Gfx::_font[] = {
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00,
 	0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x7E, 0x24, 0x24, 0x7E, 0x24, 0x00,
 	0x08, 0x3E, 0x48, 0x3C, 0x12, 0x7C, 0x10, 0x00, 0x42, 0xA4, 0x48, 0x10, 0x24, 0x4A, 0x84, 0x00,
@@ -1410,7 +1410,7 @@ const uint8_t *Video::_vertices3DO[201] = {
 	&_verticesData3DO[6276],
 };
 
-const uint16_t Graphics::_shapesMaskOffset[] = {
+const uint16_t Gfx::_shapesMaskOffset[] = {
 	0x0000, 0x0022, 0x0052, 0x006c, 0x008c, 0x00ca, 0x0110, 0x0142,
 	0x0180, 0x01a8, 0x01fe, 0x021c, 0x025a, 0x0298, 0x02c2, 0x0314,
 	0x0334, 0x034e, 0x0376, 0x039e, 0x03c0, 0x03e8, 0x0402, 0x0440,
@@ -1439,9 +1439,9 @@ const uint16_t Graphics::_shapesMaskOffset[] = {
 	0x1c16
 };
 
-const int Graphics::_shapesMaskCount = ARRAYSIZE(_shapesMaskOffset);
+const int Gfx::_shapesMaskCount = ARRAYSIZE(_shapesMaskOffset);
 
-const uint8_t Graphics::_shapesMaskData[] = {
+const uint8_t Gfx::_shapesMaskData[] = {
 	0x0f, 0x10, 0x07, 0xff, 0x07, 0xfe, 0x0f, 0xfe, 0x0f, 0xfc, 0x1f, 0xf8, 0x1f, 0xf0, 0x3f, 0xf0,
 	0x3f, 0xe0, 0x7f, 0xc0, 0x7f, 0x80, 0x7f, 0x80, 0x7f, 0x00, 0x7e, 0x00, 0x7e, 0x00, 0x7e, 0x00,
 	0xfc, 0x00, 0x0b, 0x17, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x7f, 0x00, 0x7f, 0x00,
diff --git a/engines/awe/system_stub.cpp b/engines/awe/system_stub.cpp
index 9628d679e46..9bff15f47ad 100644
--- a/engines/awe/system_stub.cpp
+++ b/engines/awe/system_stub.cpp
@@ -23,7 +23,7 @@
 #include "common/events.h"
 #include "engines/util.h"
 #include "graphics/screen.h"
-#include "awe/graphics.h"
+#include "awe/gfx.h"
 #include "awe/metaengine.h"
 #include "awe/system_stub.h"
 #include "awe/util.h"
@@ -64,15 +64,17 @@ SystemStubScummVM::~SystemStubScummVM() {
 
 void SystemStubScummVM::init(const DisplayMode &dm) {
 	// Initialize backend
-	::Graphics::PixelFormat format(2, 5, 5, 5, 1, 11, 6, 1, 0);
+	Graphics::PixelFormat format(2, 5, 5, 5, 1, 11, 6, 1, 0);
 	initGraphics(dm.width, dm.height, &format);
-	_screen = new ::Graphics::Screen();
+	_screen = new Graphics::Screen();
 
 	_screenshot = 1;
 	_dm = dm;
 }
 
 void SystemStubScummVM::fini() {
+	delete _screen;
+	_screen = nullptr;
 }
 
 void SystemStubScummVM::prepareScreen(int &w, int &h, float ar[4]) {
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index 239a53b6e76..83cd5760246 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -21,7 +21,7 @@
 
 #include "awe/video.h"
 #include "awe/bitmap.h"
-#include "awe/graphics.h"
+#include "awe/gfx.h"
 #include "awe/resource.h"
 #include "awe/resource_3do.h"
 #include "awe/scaler.h"
@@ -282,7 +282,7 @@ void Video::drawShapeParts(uint16_t zoom, const Point *pgc) {
 		if (offset & 0x8000) {
 			color = _pData.fetchByte();
 			const int num = _pData.fetchByte();
-			if (Graphics::_is1991) {
+			if (Gfx::_is1991) {
 				if (!_hasHeadSprites && (color & 0x80) != 0) {
 					_graphics->drawSprite(_buffers[0], num, &po, color & 0x7F);
 					continue;
@@ -506,7 +506,7 @@ void Video::copyBitmapPtr(const uint8_t *src, uint32_t size) {
 		deinterlace555(src, BITMAP_W, BITMAP_H, _bitmap555);
 		scaleBitmap((const uint8_t *)_bitmap555, FMT_RGB555);
 	} else { // .BMP
-		if (Graphics::_is1991) {
+		if (Gfx::_is1991) {
 			const int w = READ_LE_UINT32(src + 0x12);
 			const int h = READ_LE_UINT32(src + 0x16);
 			if (w == BITMAP_W && h == BITMAP_H) {
diff --git a/engines/awe/video.h b/engines/awe/video.h
index d854d6f6436..1370a11c5a7 100644
--- a/engines/awe/video.h
+++ b/engines/awe/video.h
@@ -31,7 +31,7 @@ struct StrEntry {
 	const char *str = nullptr;
 };
 
-struct Graphics;
+struct Gfx;
 struct Resource;
 struct Scaler;
 struct SystemStub;
@@ -57,7 +57,7 @@ struct Video {
 	static bool _useEGA;
 
 	Resource *_res;
-	Graphics *_graphics = nullptr;
+	Gfx *_graphics = nullptr;
 	bool _hasHeadSprites = false;
 	bool _displayHead = false;
 


Commit: 77b3a8e570f3060d5b6d5016780adb686204a61a
    https://github.com/scummvm/scummvm/commit/77b3a8e570f3060d5b6d5016780adb686204a61a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Graphics beginning to display

Changed paths:
    engines/awe/system_stub.cpp


diff --git a/engines/awe/system_stub.cpp b/engines/awe/system_stub.cpp
index 9bff15f47ad..e1bdeca92b7 100644
--- a/engines/awe/system_stub.cpp
+++ b/engines/awe/system_stub.cpp
@@ -78,7 +78,8 @@ void SystemStubScummVM::fini() {
 }
 
 void SystemStubScummVM::prepareScreen(int &w, int &h, float ar[4]) {
-	assert(w == _screen->w && h == _screen->h);
+	w = _screen->w;
+	h = _screen->h;
 
 	ar[0] = _aspectRatio[0];
 	ar[1] = _aspectRatio[1];
@@ -91,36 +92,12 @@ void SystemStubScummVM::updateScreen() {
 }
 
 void SystemStubScummVM::setScreenPixels555(const uint16_t *data, int w, int h) {
-#ifdef TODO
 	assert(_screen);
 
-	Graphics::Surface s;
-
-
-	if (_renderer) {
-		if (!_texture) {
-			_texture = SDL_CreateTexture(_renderer, SDL_PIXELFORMAT_RGB555, SDL_TEXTUREACCESS_STREAMING, w, h);
-			if (!_texture) {
-				return;
-			}
-			_texW = w;
-			_texH = h;
-		}
-		assert(w <= _texW && h <= _texH);
-		SDL_Rect r;
-		r.w = w;
-		r.h = h;
-		if (w != _texW && h != _texH) {
-			r.x = (_texW - w) / 2;
-			r.y = (_texH - h) / 2;
-		} else {
-			r.x = 0;
-			r.y = 0;
-		}
-		SDL_UpdateTexture(_texture, &r, data, w * sizeof(uint16_t));
-		SDL_RenderCopy(_renderer, _texture, 0, 0);
-	}
-#endif
+	assert(w == _screen->w && h == _screen->h);
+	uint16 *dest = (uint16 *)_screen->getPixels();
+	Common::copy(data, data + w * h, dest);
+	_screen->markAllDirty();
 }
 
 void SystemStubScummVM::processEvents() {


Commit: 2f2fc40e455fa41c23c28949fc335162c59a778f
    https://github.com/scummvm/scummvm/commit/2f2fc40e455fa41c23c28949fc335162c59a778f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Cleanup of startup code, global static initializations

Changed paths:
    engines/awe/awe.cpp


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 6fd47705732..b357498eeeb 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -57,11 +57,11 @@ static const struct {
 	{ 0,  -1 }
 };
 
-bool Gfx::_is1991 = false;
-bool Gfx::_use555 = false;
-bool Video::_useEGA = false;
-Difficulty Script::_difficulty = DIFFICULTY_NORMAL;
-bool Script::_useRemasteredAudio = true;
+bool Gfx::_is1991;
+bool Gfx::_use555;
+bool Video::_useEGA;
+Difficulty Script::_difficulty;
+bool Script::_useRemasteredAudio;
 
 static Gfx *createGraphics(int type) {
 	switch (type) {
@@ -80,7 +80,6 @@ static Gfx *createGraphics(int type) {
 	return 0;
 }
 
-
 static int getGraphicsType(DataType type) {
 	switch (type) {
 	case DT_15TH_EDITION:
@@ -92,194 +91,16 @@ static int getGraphicsType(DataType type) {
 	}
 }
 
-static const int DEFAULT_WINDOW_W = 640;
-static const int DEFAULT_WINDOW_H = 400;
-
-
-#ifdef TODO
-static const char USAGE[] =
-"raw(gl) - Another World Interpreter\n"
-"Usage: %s [OPTIONS]...\n"
-"  --datapath=PATH   Path to data files (default '.')\n"
-"  --language=LANG   Language (fr,us,de,es,it)\n"
-"  --part=NUM        Game part to start from (0-35 or 16001-16009)\n"
-"  --render=NAME     Renderer (original,software,gl)\n"
-"  --window=WxH      Windowed display size (default '640x400')\n"
-"  --fullscreen      Fullscreen display (stretched)\n"
-"  --fullscreen-ar   Fullscreen display (16:10 aspect ratio)\n"
-"  --ega-palette     Use EGA palette with DOS version\n"
-"  --demo3-joy       Use inputs from 'demo3.joy' (DOS demo)\n"
-"  --difficulty=DIFF Difficulty (easy,normal,hard)\n"
-"  --audio=AUDIO     Audio (original,remastered)\n"
-;
-
-
-
-int main(int argc, char *argv[]) {
-	char *dataPath = 0;
-	int part = 16001;
-	Language lang = Common::FR_FRA;
-	int graphicsType = GRAPHICS_GL;
-	DisplayMode dm;
-	dm.mode = DisplayMode::WINDOWED;
-	dm.width = DEFAULT_WINDOW_W;
-	dm.height = DEFAULT_WINDOW_H;
-	dm.opengl = (graphicsType == GRAPHICS_GL);
-	Scaler scaler;
-	scaler.name[0] = 0;
-	scaler.factor = 1;
-	bool defaultGraphics = true;
-	bool demo3JoyInputs = false;
-	if (argc == 2) {
-		// data path as the only command line argument
-		struct stat st;
-		if (stat(argv[1], &st) == 0 && S_ISDIR(st.st_mode)) {
-			dataPath = strdup(argv[1]);
-		}
-	}
-	while (1) {
-		static struct option options[] = {
-			{ "datapath", required_argument, 0, 'd' },
-			{ "language", required_argument, 0, 'l' },
-			{ "part",     required_argument, 0, 'p' },
-			{ "render",   required_argument, 0, 'r' },
-			{ "window",   required_argument, 0, 'w' },
-			{ "fullscreen", no_argument,     0, 'f' },
-			{ "fullscreen-ar", no_argument,  0, 'a' },
-			{ "scaler",   required_argument, 0, 's' },
-			{ "ega-palette", no_argument,    0, 'e' },
-			{ "demo3-joy",  no_argument,     0, 'j' },
-			{ "difficulty", required_argument, 0, 'i' },
-			{ "audio",    required_argument, 0, 'u' },
-			{ "help",       no_argument,     0, 'h' },
-			{ 0, 0, 0, 0 }
-		};
-		int index;
-		const int c = getopt_long(argc, argv, "", options, &index);
-		if (c == -1) {
-			break;
-		}
-		switch (c) {
-		case 'd':
-			dataPath = strdup(optarg);
-			break;
-		case 'l':
-			for (int i = 0; LANGUAGES[i].name; ++i) {
-				if (strcmp(optarg, LANGUAGES[i].name) == 0) {
-					lang = (Language)LANGUAGES[i].lang;
-					break;
-				}
-			}
-			break;
-		case 'p':
-			part = atoi(optarg);
-			break;
-		case 'r':
-			for (int i = 0; GRAPHICS[i].name; ++i) {
-				if (strcmp(optarg, GRAPHICS[i].name) == 0) {
-					graphicsType = GRAPHICS[i].type;
-					dm.opengl = (graphicsType == GRAPHICS_GL);
-					defaultGraphics = false;
-					break;
-				}
-			}
-			break;
-		case 'w':
-			sscanf(optarg, "%dx%d", &dm.width, &dm.height);
-			break;
-		case 'f':
-			dm.mode = DisplayMode::FULLSCREEN;
-			break;
-		case 'a':
-			dm.mode = DisplayMode::FULLSCREEN_AR;
-			break;
-		case 's':
-			parseScaler(optarg, &scaler);
-			break;
-		case 'e':
-			Video::_useEGA = true;
-			break;
-		case 'j':
-			demo3JoyInputs = true;
-			break;
-		case 'i':
-			for (int i = 0; DIFFICULTIES[i].name; ++i) {
-				if (strcmp(optarg, DIFFICULTIES[i].name) == 0) {
-					Script::_difficulty = (Difficulty)DIFFICULTIES[i].difficulty;
-					break;
-				}
-			}
-			break;
-		case 'u':
-			if (strcmp(optarg, "remastered") == 0) {
-				Script::_useRemasteredAudio = true;
-			} else if (strcmp(optarg, "original") == 0) {
-				Script::_useRemasteredAudio = false;
-			}
-			break;
-		case 'h':
-			// fall-through
-		default:
-			printf(USAGE, argv[0]);
-			return 0;
-		}
-	}
-
-	Engine *e = new Engine(dataPath, part);
-	if (defaultGraphics) {
-		// if not set, use original software graphics for 199x editions and GL for the anniversary and 3DO versions
-		graphicsType = getGraphicsType(dataType);
-		dm.opengl = (graphicsType == GRAPHICS_GL);
-	}
-	if (graphicsType != GRAPHICS_GL && dataType == DT_3DO) {
-		graphicsType = GRAPHICS_SOFTWARE;
-		Graphics::_use555 = true;
-	}
-	Graphics *graphics = createGraphics(graphicsType);
-	if (dataType == DT_20TH_EDITION) {
-		switch (Script::_difficulty) {
-		case DIFFICULTY_EASY:
-			debugC(kDebugInfo, "Using easy difficulty");
-			break;
-		case DIFFICULTY_NORMAL:
-			debugC(kDebugInfo, "Using normal difficulty");
-			break;
-		case DIFFICULTY_HARD:
-			debugC(kDebugInfo, "Using hard difficulty");
-			break;
-		}
-	}
-	if (dataType == DT_15TH_EDITION || dataType == DT_20TH_EDITION) {
-		if (Script::_useRemasteredAudio) {
-			debugC(kDebugInfo, "Using remastered audio");
-		} else {
-			debugC(kDebugInfo, "Using original audio");
-		}
-	}
-	SystemStub *stub = SystemStub_SDL_create();
-	stub->init(e->getGameTitle(lang), &dm);
-	e->setSystemStub(stub, graphics);
-	if (demo3JoyInputs && dataType == DT_DOS) {
-		e->_res.readDemo3Joy();
-	}
-	e->setup(lang, graphicsType, scaler.name, scaler.factor);
-	while (!stub->_pi.quit) {
-		e->run();
-	}
-	e->finish();
-	delete e;
-	stub->fini();
-	delete stub;
-	return 0;
-}
-
-#endif
-
-
 AweEngine::AweEngine(OSystem *syst, const Awe::AweGameDescription *gameDesc)
 		: Engine(syst), _gameDescription(gameDesc),
 		_random("Awe") {
 	g_engine = this;
+
+	Gfx::_is1991 = false;
+	Gfx::_use555 = false;
+	Video::_useEGA = false;
+	Script::_difficulty = DIFFICULTY_NORMAL;
+	Script::_useRemasteredAudio = true;
 }
 
 AweEngine::~AweEngine() {
@@ -306,15 +127,18 @@ Common::Error AweEngine::run() {
 	bool demo3JoyInputs = false;
 
 	Awe::Engine *e = new Awe::Engine(_mixer, dataType, part);
+
 	if (defaultGraphics) {
 		// if not set, use original software graphics for 199x editions and GL for the anniversary and 3DO versions
 		graphicsType = getGraphicsType(dataType);
 		dm.opengl = (graphicsType == GRAPHICS_GL);
 	}
+
 	if (graphicsType != GRAPHICS_GL && dataType == DT_3DO) {
 		graphicsType = GRAPHICS_SOFTWARE;
 		Gfx::_use555 = true;
 	}
+
 	Gfx *graphics = createGraphics(graphicsType);
 	if (dataType == DT_20TH_EDITION) {
 		switch (Script::_difficulty) {
@@ -329,6 +153,7 @@ Common::Error AweEngine::run() {
 			break;
 		}
 	}
+
 	if (dataType == DT_15TH_EDITION || dataType == DT_20TH_EDITION) {
 		if (Script::_useRemasteredAudio) {
 			debugC(kDebugInfo, "Using remastered audio");


Commit: 6582a9fd6ce9b7467da71abc87540a5824bd0fa1
    https://github.com/scummvm/scummvm/commit/6582a9fd6ce9b7467da71abc87540a5824bd0fa1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Adding override keyword

Changed paths:
    engines/awe/graphics_soft.cpp


diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
index 0e994acdb98..831994b6a0b 100644
--- a/engines/awe/graphics_soft.cpp
+++ b/engines/awe/graphics_soft.cpp
@@ -62,21 +62,21 @@ struct GraphicsSoft : public Gfx {
 	}
 	void setWorkPagePtr(uint8_t page);
 
-	virtual void init(int targetW, int targetH);
-
-	virtual void setFont(const uint8_t *src, int w, int h);
-	virtual void setPalette(const Color *colors, int count);
-	virtual void setSpriteAtlas(const uint8_t *src, int w, int h, int xSize, int ySize);
-	virtual void drawSprite(int buffer, int num, const Point *pt, uint8_t color);
-	virtual void drawBitmap(int buffer, const uint8_t *data, int w, int h, int fmt);
-	virtual void drawPoint(int buffer, uint8_t color, const Point *pt);
-	virtual void drawQuadStrip(int buffer, uint8_t color, const QuadStrip *qs);
-	virtual void drawStringChar(int buffer, uint8_t color, char c, const Point *pt);
-	virtual void clearBuffer(int num, uint8_t color);
-	virtual void copyBuffer(int dst, int src, int vscroll = 0);
-	virtual void drawBuffer(int num, SystemStub *stub);
-	virtual void drawRect(int num, uint8_t color, const Point *pt, int w, int h);
-	virtual void drawBitmapOverlay(const uint8_t *data, int w, int h, int fmt, SystemStub *stub);
+	void init(int targetW, int targetH) override;
+
+	void setFont(const uint8_t *src, int w, int h) override;
+	void setPalette(const Color *colors, int count) override;
+	void setSpriteAtlas(const uint8_t *src, int w, int h, int xSize, int ySize) override;
+	void drawSprite(int buffer, int num, const Point *pt, uint8_t color) override;
+	void drawBitmap(int buffer, const uint8_t *data, int w, int h, int fmt) override;
+	void drawPoint(int buffer, uint8_t color, const Point *pt) override;
+	void drawQuadStrip(int buffer, uint8_t color, const QuadStrip *qs) override;
+	void drawStringChar(int buffer, uint8_t color, char c, const Point *pt) override;
+	void clearBuffer(int num, uint8_t color) override;
+	void copyBuffer(int dst, int src, int vscroll = 0) override;
+	void drawBuffer(int num, SystemStub *stub) override;
+	void drawRect(int num, uint8_t color, const Point *pt, int w, int h) override;
+	void drawBitmapOverlay(const uint8_t *data, int w, int h, int fmt, SystemStub *stub) override;
 };
 
 


Commit: a1af080b6fc765a97db58c7546c6810d2f829260
    https://github.com/scummvm/scummvm/commit/a1af080b6fc765a97db58c7546c6810d2f829260
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Change Gfx::_use555 to use PixelFormat

Changed paths:
    engines/awe/awe.cpp
    engines/awe/gfx.h
    engines/awe/graphics_soft.cpp
    engines/awe/intern.h
    engines/awe/system_stub.cpp


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index b357498eeeb..1f83138c5ba 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -58,7 +58,7 @@ static const struct {
 };
 
 bool Gfx::_is1991;
-bool Gfx::_use555;
+Graphics::PixelFormat Gfx::_format;
 bool Video::_useEGA;
 Difficulty Script::_difficulty;
 bool Script::_useRemasteredAudio;
@@ -97,7 +97,7 @@ AweEngine::AweEngine(OSystem *syst, const Awe::AweGameDescription *gameDesc)
 	g_engine = this;
 
 	Gfx::_is1991 = false;
-	Gfx::_use555 = false;
+	Gfx::_format = Graphics::PixelFormat::createFormatCLUT8();
 	Video::_useEGA = false;
 	Script::_difficulty = DIFFICULTY_NORMAL;
 	Script::_useRemasteredAudio = true;
@@ -136,7 +136,7 @@ Common::Error AweEngine::run() {
 
 	if (graphicsType != GRAPHICS_GL && dataType == DT_3DO) {
 		graphicsType = GRAPHICS_SOFTWARE;
-		Gfx::_use555 = true;
+		Gfx::_format = Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0);
 	}
 
 	Gfx *graphics = createGraphics(graphicsType);
diff --git a/engines/awe/gfx.h b/engines/awe/gfx.h
index e47c2ddba96..5f504fed6fd 100644
--- a/engines/awe/gfx.h
+++ b/engines/awe/gfx.h
@@ -22,6 +22,7 @@
 #ifndef AWE_GRAPHICS_H
 #define AWE_GRAPHICS_H
 
+#include "graphics/pixelformat.h"
 #include "awe/intern.h"
 
 namespace Awe {
@@ -61,7 +62,7 @@ struct SystemStub;
 struct Gfx {
 	static const uint8_t _font[];
 	static bool _is1991; // draw graphics as in the original 1991 game release
-	static bool _use555; // use 16bits graphics buffer (for 3DO)
+	static Graphics::PixelFormat _format;
 	static const uint16_t _shapesMaskOffset[];
 	static const int _shapesMaskCount;
 	static const uint8_t _shapesMaskData[];
diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
index 831994b6a0b..92d502642b9 100644
--- a/engines/awe/graphics_soft.cpp
+++ b/engines/awe/graphics_soft.cpp
@@ -101,7 +101,7 @@ void GraphicsSoft::setSize(int w, int h) {
 	_v = (h << 16) / GFX_H;
 	_w = w;
 	_h = h;
-	_byteDepth = _use555 ? 2 : 1;
+	_byteDepth = _format.bytesPerPixel;
 	assert(_byteDepth == 1 || _byteDepth == 2);
 	_colorBuffer = (uint16_t *)realloc(_colorBuffer, _w * _h * sizeof(uint16_t));
 	if (!_colorBuffer) {
@@ -212,7 +212,9 @@ void GraphicsSoft::drawChar(uint8_t c, uint16_t x, uint16_t y, uint8_t color) {
 				}
 			}
 		} else if (_byteDepth == 2) {
-			const uint16_t rgbColor = _pal[color].rgb555();
+			const uint16_t rgbColor = _format.RGBToColor(
+				_pal[color].r, _pal[color].g, _pal[color].b);
+
 			for (int j = 0; j < 8; ++j) {
 				const uint8_t ch = ft[j];
 				for (int i = 0; i < 8; ++i) {
@@ -280,16 +282,22 @@ void GraphicsSoft::drawPoint(int16_t x, int16_t y, uint8_t color) {
 		}
 	} else if (_byteDepth == 2) {
 		switch (color) {
-		case COL_ALPHA:
-			blend_rgb555((uint16_t *)(_drawPagePtr + offset), _pal[ALPHA_COLOR_INDEX].rgb555());
+		case COL_ALPHA: {
+			const Color &c = _pal[ALPHA_COLOR_INDEX];
+			const uint16 rgbColor = _format.RGBToColor(c.r, c.g, c.b);
+			blend_rgb555((uint16_t *)(_drawPagePtr + offset), rgbColor);
 			break;
+		}
 		case COL_PAGE:
 			*(uint16_t *)(_drawPagePtr + offset) = *(uint16_t *)(_pagePtrs[0] + offset);
 			break;
-		default:
-			*(uint16_t *)(_drawPagePtr + offset) = _pal[color].rgb555();
+		default: {
+			const Color &c = _pal[color];
+			const uint16 rgbColor = _format.RGBToColor(c.r, c.g, c.b);
+			*(uint16_t *)(_drawPagePtr + offset) = rgbColor;
 			break;
 		}
+		}
 	}
 }
 
@@ -303,7 +311,9 @@ void GraphicsSoft::drawLineT(int16_t x1, int16_t x2, int16_t y, uint8_t color) {
 			_drawPagePtr[offset + i] |= 8;
 		}
 	} else if (_byteDepth == 2) {
-		const uint16_t rgbColor = _pal[ALPHA_COLOR_INDEX].rgb555();
+		const Color &c = _pal[ALPHA_COLOR_INDEX];
+		const uint16_t rgbColor = _format.RGBToColor(c.r, c.g, c.b);
+
 		uint16_t *p = (uint16_t *)(_drawPagePtr + offset);
 		for (int i = 0; i < w; ++i) {
 			blend_rgb555(p + i, rgbColor);
@@ -319,7 +329,8 @@ void GraphicsSoft::drawLineN(int16_t x1, int16_t x2, int16_t y, uint8_t color) {
 	if (_byteDepth == 1) {
 		memset(_drawPagePtr + offset, color, w);
 	} else if (_byteDepth == 2) {
-		const uint16_t rgbColor = _pal[color].rgb555();
+		const Color &c = _pal[color];
+		const uint16 rgbColor = _format.RGBToColor(c.r, c.g, c.b);
 		uint16_t *p = (uint16_t *)(_drawPagePtr + offset);
 		for (int i = 0; i < w; ++i) {
 			p[i] = rgbColor;
@@ -415,7 +426,8 @@ void GraphicsSoft::clearBuffer(int num, uint8_t color) {
 	if (_byteDepth == 1) {
 		memset(getPagePtr(num), color, getPageSize());
 	} else if (_byteDepth == 2) {
-		const uint16_t rgbColor = _pal[color].rgb555();
+		const Color &c = _pal[color];
+		const uint16 rgbColor = _format.RGBToColor(c.r, c.g, c.b);
 		uint16_t *p = (uint16_t *)getPagePtr(num);
 		for (int i = 0; i < _w * _h; ++i) {
 			p[i] = rgbColor;
@@ -443,14 +455,19 @@ static void dumpBuffer555(const uint16_t *src, int w, int h, int num) {
 	debugC(kDebugInfo, "Written '%s'", name);
 }
 
-static void dumpPalette555(uint16_t *dst, int w, const Color *pal) {
+static void dumpPalette555(uint16_t *dst, int w,
+		const Graphics::PixelFormat &format, const Color *pal) {
 	static const int SZ = 16;
 	for (int color = 0; color < 16; ++color) {
 		uint16_t *p = dst + (color & 7) * SZ;
 		for (int y = 0; y < SZ; ++y) {
 			for (int x = 0; x < SZ; ++x) {
-				p[x] = pal[color].rgb555();
+				const Color &c = pal[color];
+				const uint16 rgbColor = format.RGBToColor(c.r, c.g, c.b);
+
+				p[x] = rgbColor;
 			}
+
 			p += w;
 		}
 		if (color == 7) {
@@ -466,10 +483,12 @@ void GraphicsSoft::drawBuffer(int num, SystemStub *stub) {
 	if (_byteDepth == 1) {
 		const uint8_t *src = getPagePtr(num);
 		for (int i = 0; i < _w * _h; ++i) {
-			_colorBuffer[i] = _pal[src[i]].rgb555();
+			const Color &c = _pal[src[i]];
+			const uint16 rgbColor = _format.RGBToColor(c.r, c.g, c.b);
+			_colorBuffer[i] = rgbColor;
 		}
 		if (0) {
-			dumpPalette555(_colorBuffer, _w, _pal);
+			dumpPalette555(_colorBuffer, _w, _format, _pal);
 		}
 		stub->setScreenPixels555(_colorBuffer, _w, _h);
 		if (_screenshot) {
@@ -492,7 +511,9 @@ void GraphicsSoft::drawBuffer(int num, SystemStub *stub) {
 void GraphicsSoft::drawRect(int num, uint8_t color, const Point *pt, int w, int h) {
 	assert(_byteDepth == 2);
 	setWorkPagePtr(num);
-	const uint16_t rgbColor = _pal[color].rgb555();
+
+	const Color &c = _pal[color];
+	const uint16 rgbColor = _format.RGBToColor(c.r, c.g, c.b);
 	const int x1 = xScale(pt->x);
 	const int y1 = yScale(pt->y);
 	const int x2 = xScale(pt->x + w - 1);
diff --git a/engines/awe/intern.h b/engines/awe/intern.h
index 4b09e34acc9..4efc6cd34c8 100644
--- a/engines/awe/intern.h
+++ b/engines/awe/intern.h
@@ -86,10 +86,6 @@ struct Color {
 	uint8_t r = 0;
 	uint8_t g = 0;
 	uint8_t b = 0;
-
-	uint16_t rgb555() const {
-		return ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);
-	}
 };
 
 struct Frac {
diff --git a/engines/awe/system_stub.cpp b/engines/awe/system_stub.cpp
index e1bdeca92b7..d14831c79aa 100644
--- a/engines/awe/system_stub.cpp
+++ b/engines/awe/system_stub.cpp
@@ -64,8 +64,7 @@ SystemStubScummVM::~SystemStubScummVM() {
 
 void SystemStubScummVM::init(const DisplayMode &dm) {
 	// Initialize backend
-	Graphics::PixelFormat format(2, 5, 5, 5, 1, 11, 6, 1, 0);
-	initGraphics(dm.width, dm.height, &format);
+	initGraphics(dm.width, dm.height, &Gfx::_format);
 	_screen = new Graphics::Screen();
 
 	_screenshot = 1;
@@ -92,9 +91,9 @@ void SystemStubScummVM::updateScreen() {
 }
 
 void SystemStubScummVM::setScreenPixels555(const uint16_t *data, int w, int h) {
-	assert(_screen);
-
+	assert(_screen && Gfx::_format.bytesPerPixel == 2);
 	assert(w == _screen->w && h == _screen->h);
+
 	uint16 *dest = (uint16 *)_screen->getPixels();
 	Common::copy(data, data + w * h, dest);
 	_screen->markAllDirty();


Commit: 87ab3aad6dfb6295a8f775288c4dbce7baead019
    https://github.com/scummvm/scummvm/commit/87ab3aad6dfb6295a8f775288c4dbce7baead019
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Use 8-bit screen surface for old DOS version

Changed paths:
    engines/awe/gfx.h
    engines/awe/graphics_gl.cpp
    engines/awe/graphics_soft.cpp
    engines/awe/intern.h
    engines/awe/system_stub.cpp
    engines/awe/system_stub.h
    engines/awe/video.cpp


diff --git a/engines/awe/gfx.h b/engines/awe/gfx.h
index 5f504fed6fd..8b9e4877ac1 100644
--- a/engines/awe/gfx.h
+++ b/engines/awe/gfx.h
@@ -22,7 +22,7 @@
 #ifndef AWE_GRAPHICS_H
 #define AWE_GRAPHICS_H
 
-#include "graphics/pixelformat.h"
+#include "graphics/surface.h"
 #include "awe/intern.h"
 
 namespace Awe {
@@ -87,7 +87,7 @@ struct Gfx {
 	virtual void copyBuffer(int dst, int src, int vscroll = 0) = 0;
 	virtual void drawBuffer(int num, SystemStub *) = 0;
 	virtual void drawRect(int num, uint8_t color, const Point *pt, int w, int h) = 0;
-	virtual void drawBitmapOverlay(const uint8_t *data, int w, int h, int fmt, SystemStub *stub) = 0;
+	virtual void drawBitmapOverlay(const Graphics::Surface &src, int fmt, SystemStub *stub) = 0;
 };
 
 Gfx *GraphicsSoft_create();
diff --git a/engines/awe/graphics_gl.cpp b/engines/awe/graphics_gl.cpp
index 6a250801917..cf1e2611015 100644
--- a/engines/awe/graphics_gl.cpp
+++ b/engines/awe/graphics_gl.cpp
@@ -335,7 +335,7 @@ struct GraphicsGL : Graphics {
 	virtual void copyBuffer(int dstListNum, int srcListNum, int vscroll = 0);
 	virtual void drawBuffer(int listNum, SystemStub *stub);
 	virtual void drawRect(int num, uint8_t color, const Point *pt, int w, int h);
-	virtual void drawBitmapOverlay(const uint8_t *data, int w, int h, int fmt, SystemStub *stub);
+	virtual void drawBitmapOverlay(const Graphics::Surface &src, int fmt, SystemStub *stub);
 
 	void initFbo();
 	void drawVerticesFlat(int count, const Point *vertices);
@@ -824,7 +824,7 @@ void GraphicsGL::drawRect(int num, uint8_t color, const Point *pt, int w, int h)
 	glEnd();
 }
 
-void GraphicsGL::drawBitmapOverlay(const uint8_t *data, int w, int h, int fmt, SystemStub *stub) {
+void GraphicsGL::drawBitmapOverlay(const Graphics::Surface &src, int fmt, SystemStub *stub) {
 	if (fmt == FMT_RGB555) {
 	}
 }
diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
index 92d502642b9..464a4d9e799 100644
--- a/engines/awe/graphics_soft.cpp
+++ b/engines/awe/graphics_soft.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "graphics/managed_surface.h"
 #include "awe/gfx.h"
 #include "awe/util.h"
 #include "awe/screenshot.h"
@@ -35,7 +36,7 @@ struct GraphicsSoft : public Gfx {
 	int _w = 0, _h = 0;
 	int _byteDepth = 0;
 	Color _pal[16];
-	uint16_t *_colorBuffer = nullptr;
+	bool _palChanged = false;
 	int _screenshotNum = 0;
 
 	GraphicsSoft();
@@ -76,14 +77,13 @@ struct GraphicsSoft : public Gfx {
 	void copyBuffer(int dst, int src, int vscroll = 0) override;
 	void drawBuffer(int num, SystemStub *stub) override;
 	void drawRect(int num, uint8_t color, const Point *pt, int w, int h) override;
-	void drawBitmapOverlay(const uint8_t *data, int w, int h, int fmt, SystemStub *stub) override;
+	void drawBitmapOverlay(const Graphics::Surface &src, int fmt, SystemStub *stub) override;
 };
 
 
 GraphicsSoft::GraphicsSoft() {
 	_fixUpPalette = FIXUP_PALETTE_NONE;
 	memset(_pagePtrs, 0, sizeof(_pagePtrs));
-	_colorBuffer = 0;
 	memset(_pal, 0, sizeof(_pal));
 	_screenshotNum = 1;
 }
@@ -93,7 +93,6 @@ GraphicsSoft::~GraphicsSoft() {
 		free(_pagePtrs[i]);
 		_pagePtrs[i] = 0;
 	}
-	free(_colorBuffer);
 }
 
 void GraphicsSoft::setSize(int w, int h) {
@@ -103,10 +102,7 @@ void GraphicsSoft::setSize(int w, int h) {
 	_h = h;
 	_byteDepth = _format.bytesPerPixel;
 	assert(_byteDepth == 1 || _byteDepth == 2);
-	_colorBuffer = (uint16_t *)realloc(_colorBuffer, _w * _h * sizeof(uint16_t));
-	if (!_colorBuffer) {
-		error("Unable to allocate color buffer w %d h %d", _w, _h);
-	}
+
 	for (int i = 0; i < 4; ++i) {
 		_pagePtrs[i] = (uint8_t *)realloc(_pagePtrs[i], getPageSize());
 		if (!_pagePtrs[i]) {
@@ -370,7 +366,9 @@ void GraphicsSoft::setFont(const uint8_t *src, int w, int h) {
 }
 
 void GraphicsSoft::setPalette(const Color *colors, int count) {
-	memcpy(_pal, colors, sizeof(Color) * MIN(count, 16));
+	count = MIN(count, 16);
+	memcpy(_pal, colors, sizeof(Color) * count);
+	_palChanged = true;
 }
 
 void GraphicsSoft::setSpriteAtlas(const uint8_t *src, int w, int h, int xSize, int ySize) {
@@ -448,64 +446,32 @@ void GraphicsSoft::copyBuffer(int dst, int src, int vscroll) {
 	}
 }
 
-static void dumpBuffer555(const uint16_t *src, int w, int h, int num) {
-	char name[32];
-	snprintf(name, sizeof(name), "screenshot-%d.tga", num);
-	saveTGA(name, src, w, h);
-	debugC(kDebugInfo, "Written '%s'", name);
-}
-
-static void dumpPalette555(uint16_t *dst, int w,
-		const Graphics::PixelFormat &format, const Color *pal) {
-	static const int SZ = 16;
-	for (int color = 0; color < 16; ++color) {
-		uint16_t *p = dst + (color & 7) * SZ;
-		for (int y = 0; y < SZ; ++y) {
-			for (int x = 0; x < SZ; ++x) {
-				const Color &c = pal[color];
-				const uint16 rgbColor = format.RGBToColor(c.r, c.g, c.b);
-
-				p[x] = rgbColor;
-			}
-
-			p += w;
-		}
-		if (color == 7) {
-			dst += SZ * w;
-		}
-	}
-}
-
 void GraphicsSoft::drawBuffer(int num, SystemStub *stub) {
 	int w, h;
 	float ar[4];
 	stub->prepareScreen(w, h, ar);
-	if (_byteDepth == 1) {
-		const uint8_t *src = getPagePtr(num);
-		for (int i = 0; i < _w * _h; ++i) {
-			const Color &c = _pal[src[i]];
-			const uint16 rgbColor = _format.RGBToColor(c.r, c.g, c.b);
-			_colorBuffer[i] = rgbColor;
-		}
-		if (0) {
-			dumpPalette555(_colorBuffer, _w, _format, _pal);
-		}
-		stub->setScreenPixels555(_colorBuffer, _w, _h);
-		if (_screenshot) {
-			dumpBuffer555(_colorBuffer, _w, _h, _screenshotNum);
-			++_screenshotNum;
-			_screenshot = false;
-		}
-	} else if (_byteDepth == 2) {
-		const uint16_t *src = (uint16_t *)getPagePtr(num);
-		stub->setScreenPixels555(src, _w, _h);
-		if (_screenshot) {
-			dumpBuffer555(src, _w, _h, _screenshotNum);
-			++_screenshotNum;
-			_screenshot = false;
-		}
+
+	if (_palChanged) {
+		stub->setPalette(_pal);
+		_palChanged = false;
 	}
+
+	Graphics::Surface s;
+	s.setPixels(getPagePtr(num));
+	s.w = s.pitch = w;
+	s.h = h;
+	s.format = (_byteDepth == 1) ?
+		Graphics::PixelFormat::createFormatCLUT8() :
+		_format;
+
+	stub->setScreenPixels(s);
 	stub->updateScreen();
+
+	if (_screenshot) {
+		warning("TODO: take screenshot");
+		++_screenshotNum;
+		_screenshot = false;
+	}
 }
 
 void GraphicsSoft::drawRect(int num, uint8_t color, const Point *pt, int w, int h) {
@@ -530,9 +496,9 @@ void GraphicsSoft::drawRect(int num, uint8_t color, const Point *pt, int w, int
 	}
 }
 
-void GraphicsSoft::drawBitmapOverlay(const uint8_t *data, int w, int h, int fmt, SystemStub *stub) {
+void GraphicsSoft::drawBitmapOverlay(const Graphics::Surface &src, int fmt, SystemStub *stub) {
 	if (fmt == FMT_RGB555) {
-		stub->setScreenPixels555((const uint16_t *)data, w, h);
+		stub->setScreenPixels(src);
 		stub->updateScreen();
 	}
 }
diff --git a/engines/awe/intern.h b/engines/awe/intern.h
index 4efc6cd34c8..96552bfb843 100644
--- a/engines/awe/intern.h
+++ b/engines/awe/intern.h
@@ -83,9 +83,10 @@ struct QuadStrip {
 };
 
 struct Color {
-	uint8_t r = 0;
-	uint8_t g = 0;
-	uint8_t b = 0;
+	byte rgb[3];
+	uint8_t &r = rgb[0];
+	uint8_t &g = rgb[1];
+	uint8_t &b = rgb[2];
 };
 
 struct Frac {
diff --git a/engines/awe/system_stub.cpp b/engines/awe/system_stub.cpp
index d14831c79aa..747f56d3b75 100644
--- a/engines/awe/system_stub.cpp
+++ b/engines/awe/system_stub.cpp
@@ -22,6 +22,7 @@
 #include "common/system.h"
 #include "common/events.h"
 #include "engines/util.h"
+#include "graphics/paletteman.h"
 #include "graphics/screen.h"
 #include "awe/gfx.h"
 #include "awe/metaengine.h"
@@ -47,7 +48,8 @@ struct SystemStubScummVM : SystemStub {
 
 	void prepareScreen(int &w, int &h, float ar[4]) override;
 	void updateScreen() override;
-	void setScreenPixels555(const uint16_t *data, int w, int h) override;
+	void setScreenPixels(const Graphics::Surface &src) override;
+	void setPalette(const Color pal[16]) override;
 
 	void processEvents() override;
 	void sleep(uint32_t duration) override;
@@ -90,15 +92,19 @@ void SystemStubScummVM::updateScreen() {
 	_screen->update();
 }
 
-void SystemStubScummVM::setScreenPixels555(const uint16_t *data, int w, int h) {
-	assert(_screen && Gfx::_format.bytesPerPixel == 2);
-	assert(w == _screen->w && h == _screen->h);
+void SystemStubScummVM::setScreenPixels(
+	const Graphics::Surface &src) {
+	assert(src.w == _screen->w && src.h == _screen->h);
 
-	uint16 *dest = (uint16 *)_screen->getPixels();
-	Common::copy(data, data + w * h, dest);
-	_screen->markAllDirty();
+	_screen->blitFrom(src);
 }
 
+void SystemStubScummVM::setPalette(const Color pal[16]) {
+	for (int i = 0; i < 16; ++i)
+		g_system->getPaletteManager()->setPalette(pal[i].rgb, i, 1);
+}
+
+
 void SystemStubScummVM::processEvents() {
 	Common::Event ev;
 	while (g_system->getEventManager()->pollEvent(ev)) {
diff --git a/engines/awe/system_stub.h b/engines/awe/system_stub.h
index 0eaf419ab27..68eb98c1836 100644
--- a/engines/awe/system_stub.h
+++ b/engines/awe/system_stub.h
@@ -72,7 +72,8 @@ struct SystemStub {
 	virtual void prepareScreen(int &w, int &h, float ar[4]) = 0;
 	virtual void updateScreen() = 0;
 	// framebuffer rendering
-	virtual void setScreenPixels555(const uint16_t *data, int w, int h) = 0;
+	virtual void setPalette(const Color pal[16]) = 0;
+	virtual void setScreenPixels(const Graphics::Surface &src) = 0;
 
 	virtual void processEvents() = 0;
 	virtual void sleep(uint32_t duration) = 0;
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index 83cd5760246..e4903def0ed 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "graphics/surface.h"
 #include "awe/video.h"
 #include "awe/bitmap.h"
 #include "awe/gfx.h"
@@ -638,9 +639,15 @@ void Video::drawRect(uint8_t page, uint8_t color, int x1, int y1, int x2, int y2
 void Video::drawBitmap3DO(const char *name, SystemStub *stub) {
 	assert(_res->getDataType() == DT_3DO);
 	int w, h;
-	uint16_t *data = _res->_3do->loadShape555(name, &w, &h);
+	uint16 *data = _res->_3do->loadShape555(name, &w, &h);
 	if (data) {
-		_graphics->drawBitmapOverlay((const uint8_t *)data, w, h, FMT_RGB555, stub);
+		Graphics::Surface s;
+		s.setPixels(data);
+		s.w = s.pitch = w;
+		s.h = h;
+		s.format = Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0);
+
+		_graphics->drawBitmapOverlay(s, FMT_RGB555, stub);
 		free(data);
 	}
 }


Commit: 86de190b0205943deecefe6e6a20578092b6b595
    https://github.com/scummvm/scummvm/commit/86de190b0205943deecefe6e6a20578092b6b595
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Re-add original's script patch for incorrect codes

Changed paths:
    engines/awe/script.cpp


diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index 70a7c240954..08d02dc1be6 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -154,6 +154,17 @@ void Script::op_jmpIfVar() {
 }
 
 void Script::op_condJmp() {
+	// Script patch the original interpreter triggers
+	// if an incorrect code is entered at the start
+	if (_res->_currentPart == kPartCopyProtection &&
+			_res->_dataType == DT_DOS &&
+			(_scriptPtr.pc - _res->_segCode) == 0xc4c) {
+		byte *script = _scriptPtr.pc;
+		*script = 0x81;
+		WRITE_BE_UINT16(script + 3, 0xcb7);
+		WRITE_BE_UINT16(script + 153, 0xced);
+	}
+
 	uint8_t op = _scriptPtr.fetchByte();
 	const uint8_t var = _scriptPtr.fetchByte();
 	int16_t b = _scriptVars[var];


Commit: 1c6cb1004efe689ae2d7af982d962eedaca5e404
    https://github.com/scummvm/scummvm/commit/1c6cb1004efe689ae2d7af982d962eedaca5e404
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Update copy protection checks to use game option

Changed paths:
    engines/awe/awe.cpp
    engines/awe/engine.cpp
    engines/awe/resource.h
    engines/awe/script.cpp


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 1f83138c5ba..1bf7c5edba4 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -170,6 +170,7 @@ Common::Error AweEngine::run() {
 		e->_res.readDemo3Joy();
 	}
 
+	e->_res._copyProtection = ConfMan.getBool("copy_protection");
 	e->setup(lang, graphicsType, nullptr, 1);
 
 	while (!stub->_pi.quit) {
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index d51b76c7a6e..feb0e342731 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -144,22 +144,24 @@ void Engine::setup(Language lang, int graphicsType, const char *scalerName, int
 #ifdef TODO
 	_mix.init(mixerType);
 #endif
-#ifndef BYPASS_PROTECTION
-	switch (_res.getDataType()) {
-	case DT_DOS:
-		if (!_res._hasPasswordScreen) {
+
+	if (_res._copyProtection) {
+		switch (_res.getDataType()) {
+		case DT_DOS:
+			if (!_res._hasPasswordScreen) {
+				break;
+			}
+			/* fall-through */
+		case DT_AMIGA:
+		case DT_ATARI:
+		case DT_WIN31:
+			_partNum = kPartCopyProtection;
+			break;
+		default:
 			break;
 		}
-		/* fall-through */
-	case DT_AMIGA:
-	case DT_ATARI:
-	case DT_WIN31:
-		_partNum = kPartCopyProtection;
-		break;
-	default:
-		break;
 	}
-#endif
+
 	if (_res.getDataType() == DT_3DO && _partNum == kPartIntro) {
 		_state = kStateLogo3DO;
 	} else {
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index 47eb24bbfda..0d0c1b825d7 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -138,6 +138,7 @@ struct Resource {
 	const AmigaMemEntry *_amigaMemList;
 	DemoJoy _demo3Joy;
 	const char *const _dataDir = ".";
+	bool _copyProtection = false;
 
 	Resource(Video *vid, DataType dataType);
 	~Resource();
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index 08d02dc1be6..d37591f88bb 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -45,14 +45,16 @@ void Script::init() {
 		_scriptVars[0xF2] = 6000;
 	} else if (_res->getDataType() != DT_15TH_EDITION && _res->getDataType() != DT_20TH_EDITION) {
 		_scriptVars[VAR_RANDOM_SEED] = 0; // time(0);
-#ifdef BYPASS_PROTECTION
-		// these 3 variables are set by the game code
-		_scriptVars[0xBC] = 0x10;
-		_scriptVars[0xC6] = 0x80;
-		_scriptVars[0xF2] = (_res->getDataType() == DT_AMIGA || _res->getDataType() == DT_ATARI) ? 6000 : 4000;
-		// these 2 variables are set by the engine executable
-		_scriptVars[0xDC] = 33;
-#endif
+
+		if (!_res->_copyProtection) {
+			// these 3 variables are set by the game code
+			_scriptVars[0xBC] = 0x10;
+			_scriptVars[0xC6] = 0x80;
+			_scriptVars[0xF2] = (_res->getDataType() == DT_AMIGA || _res->getDataType() == DT_ATARI) ? 6000 : 4000;
+			// these 2 variables are set by the engine executable
+			_scriptVars[0xDC] = 33;
+		}
+
 		if (_res->getDataType() == DT_DOS || _res->getDataType() == DT_WIN31) {
 			_scriptVars[0xE4] = 20;
 		}
@@ -181,26 +183,27 @@ void Script::op_condJmp() {
 	switch (op & 7) {
 	case 0:
 		expr = (b == a);
-#ifdef BYPASS_PROTECTION
-		if (_res->_currentPart == kPartCopyProtection) {
-			//
-			// 0CB8: jmpIf(VAR(0x29) == VAR(0x1E), @0CD3)
-			// ...
-			//
-			if (var == 0x29 && (op & 0x80) != 0) {
-				// 4 symbols
-				_scriptVars[0x29] = _scriptVars[0x1E];
-				_scriptVars[0x2A] = _scriptVars[0x1F];
-				_scriptVars[0x2B] = _scriptVars[0x20];
-				_scriptVars[0x2C] = _scriptVars[0x21];
-				// counters
-				_scriptVars[0x32] = 6;
-				_scriptVars[0x64] = 20;
-				warning("Script::op_condJmp() bypassing protection");
-				expr = true;
+
+		if (!_res->_copyProtection) {
+			if (_res->_currentPart == kPartCopyProtection) {
+				//
+				// 0CB8: jmpIf(VAR(0x29) == VAR(0x1E), @0CD3)
+				// ...
+				//
+				if (var == 0x29 && (op & 0x80) != 0) {
+					// 4 symbols
+					_scriptVars[0x29] = _scriptVars[0x1E];
+					_scriptVars[0x2A] = _scriptVars[0x1F];
+					_scriptVars[0x2B] = _scriptVars[0x20];
+					_scriptVars[0x2C] = _scriptVars[0x21];
+					// counters
+					_scriptVars[0x32] = 6;
+					_scriptVars[0x64] = 20;
+					warning("Script::op_condJmp() bypassing protection");
+					expr = true;
+				}
 			}
 		}
-#endif
 		break;
 	case 1:
 		expr = (b != a);
@@ -295,12 +298,12 @@ void Script::op_updateDisplay() {
 	debugC(kDebugScript, "Script::op_updateDisplay(%d)", page);
 	inp_handleSpecialKeys();
 
-#ifndef BYPASS_PROTECTION
-	// entered protection symbols match the expected values
-	if (_res->_currentPart == kPartCopyProtection && _scriptVars[0x67] == 1) {
-		_scriptVars[0xDC] = 33;
+	if (_res->_copyProtection) {
+		// entered protection symbols match the expected values
+		if (_res->_currentPart == kPartCopyProtection && _scriptVars[0x67] == 1) {
+			_scriptVars[0xDC] = 33;
+		}
 	}
-#endif
 
 	const int frameHz = _is3DO ? 60 : 50;
 	if (!_fastMode && _scriptVars[VAR_PAUSE_SLICES] != 0) {


Commit: f990cedf3f5af797d3b176d5416ab3c393bcf19e
    https://github.com/scummvm/scummvm/commit/f990cedf3f5af797d3b176d5416ab3c393bcf19e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Remove redundant screenshot taking code

Changed paths:
  R engines/awe/screenshot.cpp
  R engines/awe/screenshot.h
    engines/awe/engine.cpp
    engines/awe/gfx.h
    engines/awe/graphics_soft.cpp
    engines/awe/module.mk
    engines/awe/system_stub.cpp
    engines/awe/system_stub.h
    engines/awe/video.cpp
    engines/awe/video.h


diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index feb0e342731..78be83c0580 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -187,10 +187,6 @@ void Engine::processInput() {
 		_script._fastMode = !_script._fastMode;
 		_stub->_pi.fastMode = false;
 	}
-	if (_stub->_pi.screenshot) {
-		_vid.captureDisplay();
-		_stub->_pi.screenshot = false;
-	}
 }
 
 void Engine::doThreeScreens() {
diff --git a/engines/awe/gfx.h b/engines/awe/gfx.h
index 8b9e4877ac1..39b75a65c13 100644
--- a/engines/awe/gfx.h
+++ b/engines/awe/gfx.h
@@ -68,11 +68,10 @@ struct Gfx {
 	static const uint8_t _shapesMaskData[];
 
 	int _fixUpPalette = 0;
-	bool _screenshot = false;
 
 	virtual ~Gfx() {};
 
-	virtual void init(int targetW, int targetH) { _screenshot = false; }
+	virtual void init(int targetW, int targetH) {}
 	virtual void fini() {}
 
 	virtual void setFont(const uint8_t *src, int w, int h) = 0;
diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
index 464a4d9e799..b51ac3e5c7c 100644
--- a/engines/awe/graphics_soft.cpp
+++ b/engines/awe/graphics_soft.cpp
@@ -22,7 +22,6 @@
 #include "graphics/managed_surface.h"
 #include "awe/gfx.h"
 #include "awe/util.h"
-#include "awe/screenshot.h"
 #include "awe/system_stub.h"
 
 namespace Awe {
@@ -37,7 +36,6 @@ struct GraphicsSoft : public Gfx {
 	int _byteDepth = 0;
 	Color _pal[16];
 	bool _palChanged = false;
-	int _screenshotNum = 0;
 
 	GraphicsSoft();
 	~GraphicsSoft();
@@ -85,7 +83,6 @@ GraphicsSoft::GraphicsSoft() {
 	_fixUpPalette = FIXUP_PALETTE_NONE;
 	memset(_pagePtrs, 0, sizeof(_pagePtrs));
 	memset(_pal, 0, sizeof(_pal));
-	_screenshotNum = 1;
 }
 
 GraphicsSoft::~GraphicsSoft() {
@@ -466,12 +463,6 @@ void GraphicsSoft::drawBuffer(int num, SystemStub *stub) {
 
 	stub->setScreenPixels(s);
 	stub->updateScreen();
-
-	if (_screenshot) {
-		warning("TODO: take screenshot");
-		++_screenshotNum;
-		_screenshot = false;
-	}
 }
 
 void GraphicsSoft::drawRect(int num, uint8_t color, const Point *pt, int w, int h) {
diff --git a/engines/awe/module.mk b/engines/awe/module.mk
index 255c716e454..acd40c1f07a 100644
--- a/engines/awe/module.mk
+++ b/engines/awe/module.mk
@@ -18,7 +18,6 @@ MODULE_OBJS = \
 	resource_nth.o \
 	resource_win31.o \
 	scaler.o \
-	screenshot.o \
 	script.o \
 	sfx_player.o \
 	static_res.o \
diff --git a/engines/awe/screenshot.cpp b/engines/awe/screenshot.cpp
deleted file mode 100644
index eb922d6667d..00000000000
--- a/engines/awe/screenshot.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "awe/screenshot.h"
-#include "awe/file.h"
-
-namespace Awe {
-
-static void TO_LE16(uint8_t *dst, uint16_t value) {
-	for (int i = 0; i < 2; ++i) {
-		dst[i] = value & 255;
-		value >>= 8;
-	}
-}
-
-#define kTgaImageTypeUncompressedTrueColor 2
-#define kTgaImageTypeRunLengthEncodedTrueColor 10
-#define kTgaDirectionTop (1 << 5)
-
-static const int TGA_HEADER_SIZE = 18;
-
-void saveTGA(const char *filename, const uint16_t *rgb555, int w, int h) {
-	static const uint8_t kImageType = kTgaImageTypeRunLengthEncodedTrueColor;
-	uint8_t buffer[TGA_HEADER_SIZE];
-	buffer[0] = 0; // ID Length
-	buffer[1] = 0; // ColorMap Type
-	buffer[2] = kImageType;
-	TO_LE16(buffer + 3, 0); // ColorMap Start
-	TO_LE16(buffer + 5, 0); // ColorMap Length
-	buffer[7] = 0;  // ColorMap Bits
-	TO_LE16(buffer + 8, 0); // X-origin
-	TO_LE16(buffer + 10, 0); // Y-origin
-	TO_LE16(buffer + 12, w); // Image Width
-	TO_LE16(buffer + 14, h); // Image Height
-	buffer[16] = 16; // Pixel Depth
-	buffer[17] = kTgaDirectionTop;  // Descriptor
-
-	Common::DumpFile f;
-	if (f.open(filename)) {
-		f.write(buffer, sizeof(buffer));
-		if (kImageType == kTgaImageTypeUncompressedTrueColor) {
-			for (int i = 0; i < w * h; ++i) {
-				const uint16_t color = *rgb555++;
-				f.writeByte(color & 255);
-				f.writeByte(color >> 8);
-			}
-		} else {
-			assert(kImageType == kTgaImageTypeRunLengthEncodedTrueColor);
-			uint16_t prevColor = *rgb555++;
-			int count = 0;
-			for (int i = 1; i < w * h; ++i) {
-				const uint16_t color = *rgb555++;
-				if (prevColor == color && count < 127) {
-					++count;
-					continue;
-				}
-				f.writeByte(count | 0x80);
-				f.writeByte(prevColor & 255);
-				f.writeByte(prevColor >> 8);
-				count = 0;
-				prevColor = color;
-			}
-			if (count != 0) {
-				f.writeByte(count | 0x80);
-				f.writeByte(prevColor & 255);
-				f.writeByte(prevColor >> 8);
-			}
-		}
-	}
-}
-
-static void fwriteUint16LE(Common::WriteStream *fp, uint16_t n) {
-	fp->writeUint16LE(n);
-}
-
-static void fwriteUint32LE(Common::WriteStream *fp, uint32_t n) {
-	fp->writeUint32LE(n);
-}
-
-static const uint16_t TAG_BM = 0x4D42;
-
-void saveBMP(const char *filename, const uint8_t *bits, const uint8_t *pal, int w, int h) {
-#ifdef TODO
-	FILE *fp = fopen(filename, "wb");
-	if (fp) {
-		int alignWidth = (w + 3) & ~3;
-		int imageSize = alignWidth * h;
-
-		// Write file header
-		fwriteUint16LE(fp, TAG_BM);
-		fwriteUint32LE(fp, 14 + 40 + 4 * 256 + imageSize);
-		fwriteUint16LE(fp, 0); // reserved1
-		fwriteUint16LE(fp, 0); // reserved2
-		fwriteUint32LE(fp, 14 + 40 + 4 * 256);
-
-		// Write info header
-		fwriteUint32LE(fp, 40);
-		fwriteUint32LE(fp, w);
-		fwriteUint32LE(fp, h);
-		fwriteUint16LE(fp, 1); // planes
-		fwriteUint16LE(fp, 8); // bit_count
-		fwriteUint32LE(fp, 0); // compression
-		fwriteUint32LE(fp, imageSize); // size_image
-		fwriteUint32LE(fp, 0); // x_pels_per_meter
-		fwriteUint32LE(fp, 0); // y_pels_per_meter
-		fwriteUint32LE(fp, 0); // num_colors_used
-		fwriteUint32LE(fp, 0); // num_colors_important
-
-		// Write palette data
-		for (int i = 0; i < 256; ++i) {
-			fp->writeByte(pal[2], fp);
-			fp->writeByte(pal[1], fp);
-			fp->writeByte(pal[0], fp);
-			fp->writeByte(0, fp);
-			pal += 3;
-		}
-
-		// Write bitmap data
-		const int pitch = w;
-		bits += h * pitch;
-		for (int i = 0; i < h; ++i) {
-			bits -= pitch;
-			fwrite(bits, w, 1, fp);
-			int pad = alignWidth - w;
-			while (pad--) {
-				fp->writeByte(0, fp);
-			}
-		}
-
-		fclose(fp);
-	}
-#else
-	error("TODO: saveBMP");
-#endif
-}
-
-} // namespace Awe
diff --git a/engines/awe/screenshot.h b/engines/awe/screenshot.h
deleted file mode 100644
index e40ff782be6..00000000000
--- a/engines/awe/screenshot.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AWE_SCREENSHOT_H
-#define AWE_SCREENSHOT_H
-
-#include "common/scummsys.h"
-
-namespace Awe {
-
-void saveTGA(const char *filename, const uint16_t *rgb, int w, int h);
-void saveBMP(const char *filename, const uint8_t *bits, const uint8_t *pal, int w, int h);
-
-} // namespace Awe
-
-#endif
diff --git a/engines/awe/system_stub.cpp b/engines/awe/system_stub.cpp
index 747f56d3b75..b3b2f75ab29 100644
--- a/engines/awe/system_stub.cpp
+++ b/engines/awe/system_stub.cpp
@@ -169,9 +169,6 @@ void SystemStubScummVM::processEvents() {
 
 		case Common::EVENT_KEYUP:
 			switch (ev.kbd.keycode) {
-			case Common::KEYCODE_s:
-				_pi.screenshot = true;
-				break;
 			case Common::KEYCODE_p:
 				_pi.pause = true;
 				break;
diff --git a/engines/awe/system_stub.h b/engines/awe/system_stub.h
index 68eb98c1836..9cae2e67398 100644
--- a/engines/awe/system_stub.h
+++ b/engines/awe/system_stub.h
@@ -43,7 +43,6 @@ struct PlayerInput {
 	bool back = false;
 	char lastChar = '\0';
 	bool fastMode = false;
-	bool screenshot = false;
 };
 
 struct DisplayMode {
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index e4903def0ed..83888b33483 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -617,10 +617,6 @@ void Video::updateDisplay(uint8_t page, SystemStub *stub) {
 	_graphics->drawBuffer(_buffers[1], stub);
 }
 
-void Video::captureDisplay() {
-	_graphics->_screenshot = true;
-}
-
 void Video::setPaletteColor(uint8_t color, int r, int g, int b) {
 	Color c;
 	c.r = r;
diff --git a/engines/awe/video.h b/engines/awe/video.h
index 1370a11c5a7..205eda40928 100644
--- a/engines/awe/video.h
+++ b/engines/awe/video.h
@@ -95,7 +95,6 @@ struct Video {
 	void copyBitmapPtr(const uint8_t *src, uint32_t size = 0);
 	void changePal(uint8_t pal);
 	void updateDisplay(uint8_t page, SystemStub *stub);
-	void captureDisplay();
 	void setPaletteColor(uint8_t color, int r, int g, int b);
 	void drawRect(uint8_t page, uint8_t color, int x1, int y1, int x2, int y2);
 	void drawBitmap3DO(const char *name, SystemStub *stub);


Commit: 9cf1e662cf82ea32aa19fdc846fda809942da7d8
    https://github.com/scummvm/scummvm/commit/9cf1e662cf82ea32aa19fdc846fda809942da7d8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Change Mixer class to Sound to avoid confusion with Audio::Mixer

Changed paths:
  A engines/awe/sound.cpp
  A engines/awe/sound.h
  R engines/awe/mixer.cpp
  R engines/awe/mixer.h
    engines/awe/awe.cpp
    engines/awe/engine.cpp
    engines/awe/engine.h
    engines/awe/module.mk
    engines/awe/script.cpp
    engines/awe/script.h
    engines/awe/sfx_player.cpp


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 1bf7c5edba4..04b1357a81e 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -126,7 +126,8 @@ Common::Error AweEngine::run() {
 	bool defaultGraphics = true;
 	bool demo3JoyInputs = false;
 
-	Awe::Engine *e = new Awe::Engine(_mixer, dataType, part);
+	Sound snd(_mixer);
+	Awe::Engine *e = new Awe::Engine(&snd, dataType, part);
 
 	if (defaultGraphics) {
 		// if not set, use original software graphics for 199x editions and GL for the anniversary and 3DO versions
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index 78be83c0580..9620937dd2b 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -39,8 +39,8 @@ static const uint16 RESTART_POS[36 * 2] = {
 	16007, 0
 };
 
-Engine::Engine(Audio::Mixer *mixer, DataType dataType, int partNum) :
-		_mix(mixer), _script(mixer, &_res, &_ply, &_vid),
+Engine::Engine(Sound *sound, DataType dataType, int partNum) :
+		_sound(sound), _script(sound, &_res, &_ply, &_vid),
 		_res(&_vid, dataType), _ply(&_res), _vid(&_res),
 		_partNum(partNum) {
 }
@@ -178,7 +178,7 @@ void Engine::setup(Language lang, int graphicsType, const char *scalerName, int
 void Engine::finish() {
 	_graphics->fini();
 	_ply.stop();
-	_mix->stopAll();
+	_sound->stopAll();
 	_res.freeMemBlock();
 }
 
diff --git a/engines/awe/engine.h b/engines/awe/engine.h
index e5a56b21b84..5bcfc9fd6f6 100644
--- a/engines/awe/engine.h
+++ b/engines/awe/engine.h
@@ -25,10 +25,10 @@
 
 #include "audio/mixer.h"
 #include "awe/intern.h"
+#include "awe/resource.h"
 #include "awe/script.h"
-#include "awe/mixer.h"
 #include "awe/sfx_player.h"
-#include "awe/resource.h"
+#include "awe/sound.h"
 #include "awe/video.h"
 
 namespace Awe {
@@ -48,13 +48,13 @@ struct Engine {
 	Gfx *_graphics = nullptr;
 	SystemStub *_stub = nullptr;
 	Script _script;
-	Audio::Mixer *_mix;
+	Sound *_sound;
 	Resource _res;
 	SfxPlayer _ply;
 	Video _vid;
 	int _partNum;
 
-	Engine(Audio::Mixer *mixer, DataType dataType, int partNum);
+	Engine(Sound *sound, DataType dataType, int partNum);
 
 	void setSystemStub(SystemStub *, Gfx *);
 
diff --git a/engines/awe/module.mk b/engines/awe/module.mk
index acd40c1f07a..ef9f8c1bb5d 100644
--- a/engines/awe/module.mk
+++ b/engines/awe/module.mk
@@ -11,7 +11,6 @@ MODULE_OBJS = \
 	graphics_gl.o \
 	graphics_soft.o \
 	metaengine.o \
-	mixer.o \
 	pak.o \
 	resource.o \
 	resource_3do.o \
@@ -20,6 +19,7 @@ MODULE_OBJS = \
 	scaler.o \
 	script.o \
 	sfx_player.o \
+	sound.o \
 	static_res.o \
 	system_stub.o \
 	unpack.o \
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index d37591f88bb..e1f650ca63b 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -21,17 +21,17 @@
 
 #include "awe/gfx.h"
 #include "awe/script.h"
-#include "awe/mixer.h"
 #include "awe/resource.h"
 #include "awe/video.h"
 #include "awe/sfx_player.h"
+#include "awe/sound.h"
 #include "awe/system_stub.h"
 #include "awe/util.h"
 
 namespace Awe {
 
-Script::Script(Audio::Mixer *mix, Resource *res, SfxPlayer *ply, Video *vid)
-	: _mix(mix), _res(res), _ply(ply), _vid(vid), _stub(0) {
+Script::Script(Sound *snd, Resource *res, SfxPlayer *ply, Video *vid)
+	: _sound(snd), _res(res), _ply(ply), _vid(vid), _stub(0) {
 }
 
 void Script::init() {
@@ -392,7 +392,7 @@ void Script::op_updateResources() {
 	debugC(kDebugScript, "Script::op_updateResources(%d)", num);
 	if (num == 0) {
 		_ply->stop();
-		_mix->stopAll();
+		_sound->stopAll();
 		_res->invalidateRes();
 	} else {
 		_res->update(num, preloadSoundCb, this);
@@ -409,7 +409,7 @@ void Script::op_playMusic() {
 
 void Script::restartAt(int part, int pos) {
 	_ply->stop();
-	_mix->stopAll();
+	_sound->stopAll();
 	if (_res->getDataType() == DT_20TH_EDITION) {
 		_scriptVars[0xBF] = _difficulty; // difficulty (0 to 2)
 		// _scriptVars[0xDB] = 1; // preload sounds (resnum >= 2000)
diff --git a/engines/awe/script.h b/engines/awe/script.h
index f644e4d8b78..f62c77014bc 100644
--- a/engines/awe/script.h
+++ b/engines/awe/script.h
@@ -27,7 +27,7 @@
 
 namespace Awe {
 
-struct Mixer;
+struct Sound;
 struct Resource;
 struct SfxPlayer;
 struct SystemStub;
@@ -67,7 +67,7 @@ struct Script {
 	static Difficulty _difficulty;
 	static bool _useRemasteredAudio;
 
-	Audio::Mixer *_mix;
+	Sound *_sound;
 	Resource *_res;
 	SfxPlayer *_ply;
 	Video *_vid;
@@ -85,7 +85,7 @@ struct Script {
 	bool _is3DO = false;
 	uint32_t _startTime = 0, _timeStamp = 0;
 
-	Script(Audio::Mixer *mix, Resource *res, SfxPlayer *ply, Video *vid);
+	Script(Sound *snd, Resource *res, SfxPlayer *ply, Video *vid);
 	void init();
 
 	void op_movConst();
diff --git a/engines/awe/sfx_player.cpp b/engines/awe/sfx_player.cpp
index 634babe60cb..78737cf97d9 100644
--- a/engines/awe/sfx_player.cpp
+++ b/engines/awe/sfx_player.cpp
@@ -20,8 +20,8 @@
  */
 
 #include "awe/sfx_player.h"
-#include "awe/mixer.h"
 #include "awe/resource.h"
+#include "awe/sound.h"
 #include "awe/system_stub.h"
 #include "awe/util.h"
 
diff --git a/engines/awe/mixer.cpp b/engines/awe/sound.cpp
similarity index 99%
rename from engines/awe/mixer.cpp
rename to engines/awe/sound.cpp
index 0b67087b66a..6971c647227 100644
--- a/engines/awe/mixer.cpp
+++ b/engines/awe/sound.cpp
@@ -21,7 +21,7 @@
 
 //define MIX_INIT_FLUIDSYNTH MIX_INIT_MID // renamed with SDL2_mixer >= 2.0.2
 #include "awe/aifc_player.h"
-#include "awe/mixer.h"
+#include "awe/sound.h"
 #include "awe/sfx_player.h"
 #include "awe/util.h"
 
diff --git a/engines/awe/mixer.h b/engines/awe/sound.h
similarity index 89%
rename from engines/awe/mixer.h
rename to engines/awe/sound.h
index eb28000e67c..11381567444 100644
--- a/engines/awe/mixer.h
+++ b/engines/awe/sound.h
@@ -19,9 +19,10 @@
  *
  */
 
-#ifndef AWE_MIXER_H
-#define AWE_MIXER_H
+#ifndef AWE_SOUND_H
+#define AWE_SOUND_H
 
+#include "audio/mixer.h"
 #include "awe/intern.h"
 
 namespace Awe {
@@ -32,6 +33,19 @@ enum MixerType {
 	kMixerTypeAiff
 };
 
+class Sound {
+private:
+	Audio::Mixer *_mixer;
+
+public:
+	Sound(Audio::Mixer *mixer) : _mixer(mixer) {
+	}
+
+	void stopAll() {
+		_mixer->stopAll();
+	}
+};
+
 #ifdef TODO
 struct AifcPlayer;
 struct SfxPlayer;


Commit: 49ef28b095ef994707587a5b24ff1371e1010301
    https://github.com/scummvm/scummvm/commit/49ef28b095ef994707587a5b24ff1371e1010301
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Implemented DOS raw sfx sounds

Changed paths:
    engines/awe/resource.cpp
    engines/awe/resource.h
    engines/awe/script.cpp
    engines/awe/script.h
    engines/awe/sound.cpp
    engines/awe/sound.h


diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 8aa58fd9173..f1f4c82e706 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -490,28 +490,32 @@ void Resource::loadHeads() {
 	}
 }
 
-uint8_t *Resource::loadWav(int num) {
+uint8_t *Resource::loadWav(int num, uint32 *size) {
 	if (_memList[num].status == STATUS_LOADED) {
 		return _memList[num].bufPtr;
 	}
-	uint32_t size = 0;
+
+	uint32_t dummy = 0;
+	if (!size)
+		size = &dummy;
 	uint8_t *p = 0;
 	switch (_dataType) {
 	case DT_15TH_EDITION:
 	case DT_20TH_EDITION:
-		p = _nth->loadWav(num, _scriptCurPtr, &size);
+		p = _nth->loadWav(num, _scriptCurPtr, size);
 		break;
 	case DT_WIN31:
-		p = _win31->loadFile(num, _scriptCurPtr, &size);
+		p = _win31->loadFile(num, _scriptCurPtr, size);
 		break;
 	default:
 		break;
 	}
 	if (p && size != 0) {
-		_scriptCurPtr += size;
+		_scriptCurPtr += *size;
 		_memList[num].bufPtr = p;
 		_memList[num].status = STATUS_LOADED;
 	}
+
 	return p;
 }
 
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index 0d0c1b825d7..da6a74e0c07 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -159,7 +159,7 @@ struct Resource {
 	uint8_t *loadDat(int num);
 	void loadFont();
 	void loadHeads();
-	uint8_t *loadWav(int num);
+	uint8_t *loadWav(int num, uint32 *size = nullptr);
 	const char *getString(int num);
 	const char *getMusicPath(int num, char *buf, int bufSize, uint32_t *offset = 0);
 	void setupPart(int part);
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index e1f650ca63b..a2b5a5c10f7 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -780,11 +780,7 @@ static int getSoundFreq(uint8_t period) {
 void Script::snd_playSound(uint16_t resNum, uint8_t freq, uint8_t vol, uint8_t channel) {
 	debugC(kDebugSound, "snd_playSound(0x%X, %d, %d, %d)", resNum, freq, vol, channel);
 	if (vol == 0) {
-#ifdef TODO
-		_mix->stopSound(channel);
-#else
-		::error("TODO: snd_playSound");
-#endif
+		_sound->stopSound(channel);
 		return;
 	}
 	if (vol > 63) {
@@ -799,7 +795,8 @@ void Script::snd_playSound(uint16_t resNum, uint8_t freq, uint8_t vol, uint8_t c
 		if (freq != 0) {
 			--freq;
 		}
-		/* fall-through */
+		// fall-through
+
 	case DT_15TH_EDITION:
 		if (freq >= 32) {
 			// Anniversary editions do not have the 170 period
@@ -809,77 +806,68 @@ void Script::snd_playSound(uint16_t resNum, uint8_t freq, uint8_t vol, uint8_t c
 			//  [33] dos=22372 20th=23704 amiga=22372 (period 160)
 			++freq;
 		}
-		/* fall-through */
-	case DT_WIN31:
-	{
-#ifdef TODO
-		uint8_t *buf = _res->loadWav(resNum);
+		// fall-through
+	case DT_WIN31: {
+		uint32 size = 0;
+		uint8_t *buf = _res->loadWav(resNum, &size);
 		if (buf) {
-			_mix->playSoundWav(channel, buf, getSoundFreq(freq), vol, getWavLooping(resNum));
+			_sound->playSoundWav(channel, buf, size,
+				getSoundFreq(freq), vol, getWavLooping(resNum));
 		}
-#else
-		::error("TODO: play wav");
-#endif
+		break;
 	}
-	break;
 	case DT_3DO:
-#ifdef TODO
-		_mix->playSoundAiff(channel, resNum, vol);
-#else
-		::error("TODO: play aiff");
-#endif
+		_sound->playSoundAiff(channel, resNum, vol);
 		break;
 	case DT_AMIGA:
 	case DT_ATARI:
 	case DT_ATARI_DEMO:
-	case DT_DOS:
-	{
-#ifdef TODO
+	case DT_DOS: {
 		MemEntry *me = &_res->_memList[resNum];
 		if (me->status == Resource::STATUS_LOADED) {
-			_mix->playSoundRaw(channel, me->bufPtr, getSoundFreq(freq), vol);
+			_sound->playSoundRaw(channel, me->bufPtr, me->unpackedSize, getSoundFreq(freq), vol);
 		}
-#else
-		::error("TODO: play sound raw");
-#endif
+		break;
 	}
-	break;
+
+	default:
+		break;
 	}
 }
 
 void Script::snd_playMusic(uint16_t resNum, uint16_t delay, uint8_t pos) {
-#ifdef TODO
 	debugC(kDebugSound, "snd_playMusic(0x%X, %d, %d)", resNum, delay, pos);
 	uint8_t loop = 0;
+
 	switch (_res->getDataType()) {
 	case DT_20TH_EDITION:
 		if (resNum == 5000) {
-			_mix->stopMusic();
+			_sound->stopMusic();
 			break;
 		}
 		if (resNum >= 5001 && resNum <= 5010) {
 			loop = 1;
 		}
-		/* fall-through */
+		// fall-through
 	case DT_15TH_EDITION:
 	case DT_WIN31:
 		if (resNum != 0) {
 			char path[MAXPATHLEN];
 			const char *p = _res->getMusicPath(resNum, path, sizeof(path));
 			if (p) {
-				_mix->playMusic(p, loop);
+				_sound->playMusic(p, loop);
 			}
 		}
 		break;
 	case DT_3DO:
 		if (resNum == 0) {
-			_mix->stopAifcMusic();
+			_sound->stopAifcMusic();
 		} else {
 			uint32_t offset = 0;
 			char path[MAXPATHLEN];
 			const char *p = _res->getMusicPath(resNum, path, sizeof(path), &offset);
 			if (p) {
-				_mix->playAifcMusic(p, offset);
+				_sound->playAifcMusic(p, offset);
 			}
 		}
 		break;
@@ -887,27 +875,20 @@ void Script::snd_playMusic(uint16_t resNum, uint16_t delay, uint8_t pos) {
 		if (resNum != 0) {
 			_ply->loadSfxModule(resNum, delay, pos);
 			_ply->start();
-			_mix->playSfxMusic(resNum);
+			_sound->playSfxMusic(resNum);
 		} else if (delay != 0) {
 			_ply->setEventsDelay(delay);
 		} else {
-			_mix->stopSfxMusic();
+			_sound->stopSfxMusic();
 		}
 		break;
 	}
-#else
-	::error("TODO: snd_playMusic");
-#endif
 }
 
 void Script::snd_preloadSound(uint16_t resNum, const uint8_t *data) {
-#ifdef TODO
 	if (_res->getDataType() == DT_3DO) {
-		_mix->preloadSoundAiff(resNum, data);
+		_sound->preloadSoundAiff(resNum, data);
 	}
-#else
-	::error("TODO: snd_preloadSound");
-#endif
 }
 
 void Script::fixUpPalette_changeScreen(int part, int screen) {
diff --git a/engines/awe/script.h b/engines/awe/script.h
index f62c77014bc..bdc3e9e7626 100644
--- a/engines/awe/script.h
+++ b/engines/awe/script.h
@@ -27,7 +27,7 @@
 
 namespace Awe {
 
-struct Sound;
+class Sound;
 struct Resource;
 struct SfxPlayer;
 struct SystemStub;
diff --git a/engines/awe/sound.cpp b/engines/awe/sound.cpp
index 6971c647227..a9df4605664 100644
--- a/engines/awe/sound.cpp
+++ b/engines/awe/sound.cpp
@@ -20,6 +20,13 @@
  */
 
 //define MIX_INIT_FLUIDSYNTH MIX_INIT_MID // renamed with SDL2_mixer >= 2.0.2
+#include "audio/mixer.h"
+#include "audio/audiostream.h"
+#include "audio/mididrv.h"
+#include "audio/midiparser.h"
+#include "audio/decoders/raw.h"
+#include "audio/decoders/wave.h"
+#include "common/memstream.h"
 #include "awe/aifc_player.h"
 #include "awe/sound.h"
 #include "awe/sfx_player.h"
@@ -27,6 +34,69 @@
 
 namespace Awe {
 
+void Sound::playMusic(const char *path, int loops) {
+	warning("TODO: playMusic");
+}
+
+void Sound::playSfxMusic(int num) {
+	warning("TODO: playSfxMusic");
+}
+
+void Sound::playAifcMusic(const char *path, uint32_t offset) {
+	warning("TODO: playAifcMusic");
+}
+
+void Sound::stopMusic() {
+	warning("TODO: stopMusic");
+}
+
+void Sound::stopAifcMusic() {
+	warning("TODO: stopAifcMusic");
+}
+
+void Sound::stopSfxMusic() {
+	warning("TODO: stopSfxMusic");
+}
+
+void Sound::preloadSoundAiff(byte num, const byte *data) {
+	warning("TODO: preloadSoundAiff");
+}
+
+void Sound::playSoundRaw(byte channel, const byte *data, size_t size,
+		int freq, byte volume) {
+	assert(channel < MAX_CHANNELS);
+
+	Common::MemoryReadStream *stream =
+		new Common::MemoryReadStream(data, size);
+	Audio::AudioStream *sound =
+		Audio::makeRawStream(stream, freq,
+			Audio::FLAG_16BITS,
+			DisposeAfterUse::YES);
+	_mixer->playStream(Audio::Mixer::kSFXSoundType, &_channels[channel],
+		sound, -1, 255, 0, DisposeAfterUse::YES);
+}
+
+void Sound::playSoundWav(byte channel, const byte *data, size_t size,
+		uint16_t freq, byte volume, byte loop) {
+	assert(channel < MAX_CHANNELS);
+
+	Common::MemoryReadStream *stream =
+		new Common::MemoryReadStream(data, size);
+	Audio::AudioStream *sound = Audio::makeWAVStream(
+		stream, DisposeAfterUse::YES);
+	_mixer->playStream(Audio::Mixer::kSFXSoundType, &_channels[channel],
+		sound, -1, 255, 0, DisposeAfterUse::YES);
+}
+
+void Sound::playSoundAiff(byte channel, byte num, byte volume) {
+	warning("TODO: playSoundAiff");
+}
+
+void Sound::stopSound(byte channel) {
+	assert(channel < MAX_CHANNELS);
+	_mixer->stopHandle(_channels[channel]);
+}
+
 #ifdef TODO
 enum {
 	TAG_RIFF = 0x46464952,
@@ -47,14 +117,14 @@ static int16_t mixS16(int sample1, int sample2) {
 }
 
 struct MixerChannel {
-	const uint8_t *_data;
+	const byte *_data;
 	Frac _pos;
 	uint32_t _len;
 	uint32_t _loopLen, _loopPos;
 	int _volume;
 	void (MixerChannel:: *_mixWav)(int16_t *sample, int count);
 
-	void initRaw(const uint8_t *data, int freq, int volume, int mixingFreq) {
+	void initRaw(const byte *data, int freq, int volume, int mixingFreq) {
 		_data = data + 8;
 		_pos.reset(freq, mixingFreq);
 
@@ -66,7 +136,7 @@ struct MixerChannel {
 		_volume = volume;
 	}
 
-	void initWav(const uint8_t *data, int freq, int volume, int mixingFreq, int len, bool bits16, bool stereo, bool loop) {
+	void initWav(const byte *data, int freq, int volume, int mixingFreq, int len, bool bits16, bool stereo, bool loop) {
 		_data = data;
 		_pos.reset(freq, mixingFreq);
 
@@ -137,7 +207,7 @@ struct MixerChannel {
 	}
 };
 
-static const uint8_t *loadWav(const uint8_t *data, int &freq, int &len, bool &bits16, bool &stereo) {
+static const byte *loadWav(const byte *data, int &freq, int &len, bool &bits16, bool &stereo) {
 	uint32_t riffMagic = READ_LE_UINT32(data);
 	if (riffMagic != TAG_RIFF) return 0;
 	uint32_t riffLength = READ_LE_UINT32(data + 4);
@@ -253,15 +323,15 @@ struct Mixer_impl {
 		}
 	}
 
-	void playSoundRaw(uint8_t channel, const uint8_t *data, int freq, uint8_t volume) {
+	void playSoundRaw(byte channel, const byte *data, int freq, byte volume) {
 		SDL_LockAudio();
 		_channels[channel].initRaw(data, freq, volume, kMixFreq);
 		SDL_UnlockAudio();
 	}
-	void playSoundWav(uint8_t channel, const uint8_t *data, int freq, uint8_t volume, bool loop) {
+	void playSoundWav(byte channel, const byte *data, int freq, byte volume, bool loop) {
 		int wavFreq, len;
 		bool bits16, stereo;
-		const uint8_t *wavData = loadWav(data, wavFreq, len, bits16, stereo);
+		const byte *wavData = loadWav(data, wavFreq, len, bits16, stereo);
 		if (!wavData) return;
 
 		if (wavFreq == 22050 || wavFreq == 44100 || wavFreq == 48000) {
@@ -272,7 +342,7 @@ struct Mixer_impl {
 		_channels[channel].initWav(wavData, freq, volume, kMixFreq, len, bits16, stereo, loop);
 		SDL_UnlockAudio();
 	}
-	void playSound(uint8_t channel, int volume, Mix_Chunk *chunk, int loops = 0) {
+	void playSound(byte channel, int volume, Mix_Chunk *chunk, int loops = 0) {
 		stopSound(channel);
 		if (chunk) {
 			Mix_PlayChannel(channel, chunk, loops);
@@ -280,7 +350,7 @@ struct Mixer_impl {
 		setChannelVolume(channel, volume);
 		_sounds[channel] = chunk;
 	}
-	void stopSound(uint8_t channel) {
+	void stopSound(byte channel) {
 		SDL_LockAudio();
 		_channels[channel]._data = 0;
 		SDL_UnlockAudio();
@@ -291,7 +361,7 @@ struct Mixer_impl {
 		Mix_FreeChunk(_sounds[channel]);
 		_sounds[channel] = 0;
 	}
-	void setChannelVolume(uint8_t channel, uint8_t volume) {
+	void setChannelVolume(byte channel, byte volume) {
 		SDL_LockAudio();
 		_channels[channel]._volume = volume;
 		SDL_UnlockAudio();
@@ -314,7 +384,7 @@ struct Mixer_impl {
 		_music = 0;
 	}
 
-	static void mixAifcPlayer(void *data, uint8_t *s16buf, int len) {
+	static void mixAifcPlayer(void *data, byte *s16buf, int len) {
 		((AifcPlayer *)data)->readSamples((int16_t *)s16buf, len / 2);
 	}
 	void playAifcMusic(AifcPlayer *aifc) {
@@ -359,7 +429,7 @@ struct Mixer_impl {
 		}
 	}
 
-	static void mixAudio(void *data, uint8_t *s16buf, int len) {
+	static void mixAudio(void *data, byte *s16buf, int len) {
 		memset(s16buf, 0, len);
 		Mixer_impl *mixer = (Mixer_impl *)data;
 		mixer->mixChannels((int16_t *)s16buf, len / sizeof(int16_t));
@@ -376,7 +446,7 @@ struct Mixer_impl {
 		}
 	}
 
-	static void mixAudioWav(void *data, uint8_t *s16buf, int len) {
+	static void mixAudioWav(void *data, byte *s16buf, int len) {
 		Mixer_impl *mixer = (Mixer_impl *)data;
 		mixer->mixChannelsWav((int16_t *)s16buf, len / sizeof(int16_t));
 	}
@@ -394,7 +464,7 @@ struct Mixer_impl {
 		_preloads.clear();
 	}
 
-	void preloadSoundAiff(int num, const uint8_t *data) {
+	void preloadSoundAiff(int num, const byte *data) {
 		if (_preloads.find(num) != _preloads.end()) {
 			warning("AIFF sound %d is already preloaded", num);
 		} else {
@@ -440,35 +510,35 @@ void Mixer::update() {
 	}
 }
 
-void Mixer::playSoundRaw(uint8_t channel, const uint8_t *data, uint16_t freq, uint8_t volume) {
+void Mixer::playSoundRaw(byte channel, const byte *data, uint16_t freq, byte volume) {
 	debugC(kDebugSound, "Mixer::playChannel(%d, %d, %d)", channel, freq, volume);
 	if (_impl) {
 		return _impl->playSoundRaw(channel, data, freq, volume);
 	}
 }
 
-void Mixer::playSoundWav(uint8_t channel, const uint8_t *data, uint16_t freq, uint8_t volume, uint8_t loop) {
+void Mixer::playSoundWav(byte channel, const byte *data, uint16_t freq, byte volume, byte loop) {
 	debugC(kDebugSound, "Mixer::playSoundWav(%d, %d, %d)", channel, volume, loop);
 	if (_impl) {
 		return _impl->playSoundWav(channel, data, freq, volume, loop);
 	}
 }
 
-void Mixer::stopSound(uint8_t channel) {
+void Mixer::stopSound(byte channel) {
 	debugC(kDebugSound, "Mixer::stopChannel(%d)", channel);
 	if (_impl) {
 		return _impl->stopSound(channel);
 	}
 }
 
-void Mixer::setChannelVolume(uint8_t channel, uint8_t volume) {
+void Mixer::setChannelVolume(byte channel, byte volume) {
 	debugC(kDebugSound, "Mixer::setChannelVolume(%d, %d)", channel, volume);
 	if (_impl) {
 		return _impl->setChannelVolume(channel, volume);
 	}
 }
 
-void Mixer::playMusic(const char *path, uint8_t loop) {
+void Mixer::playMusic(const char *path, byte loop) {
 	debugC(kDebugSound, "Mixer::playMusic(%s, %d)", path, loop);
 	if (_impl) {
 		return _impl->playMusic(path, (loop != 0) ? -1 : 0);
@@ -524,14 +594,14 @@ void Mixer::stopAll() {
 	}
 }
 
-void Mixer::preloadSoundAiff(uint8_t num, const uint8_t *data) {
+void Mixer::preloadSoundAiff(byte num, const byte *data) {
 	debugC(kDebugSound, "Mixer::preloadSoundAiff(num:%d, data:%p)", num, data);
 	if (_impl) {
 		return _impl->preloadSoundAiff(num, data);
 	}
 }
 
-void Mixer::playSoundAiff(uint8_t channel, uint8_t num, uint8_t volume) {
+void Mixer::playSoundAiff(byte channel, byte num, byte volume) {
 	debugC(kDebugSound, "Mixer::playSoundAiff()");
 	if (_impl) {
 		return _impl->playSoundAiff(channel, num, volume);
diff --git a/engines/awe/sound.h b/engines/awe/sound.h
index 11381567444..96a2cf0dbd2 100644
--- a/engines/awe/sound.h
+++ b/engines/awe/sound.h
@@ -27,6 +27,8 @@
 
 namespace Awe {
 
+#define MAX_CHANNELS 8
+
 enum MixerType {
 	kMixerTypeRaw,
 	kMixerTypeWav,
@@ -36,6 +38,7 @@ enum MixerType {
 class Sound {
 private:
 	Audio::Mixer *_mixer;
+	Audio::SoundHandle _channels[MAX_CHANNELS];
 
 public:
 	Sound(Audio::Mixer *mixer) : _mixer(mixer) {
@@ -44,9 +47,24 @@ public:
 	void stopAll() {
 		_mixer->stopAll();
 	}
+	void playMusic(const char *path, int loops);
+	void playAifcMusic(const char *path, uint32_t offset);
+	void playSfxMusic(int num);
+	void stopMusic();
+	void stopAifcMusic();
+	void stopSfxMusic();
+
+	void preloadSoundAiff(byte num, const byte *data);
+	void playSoundRaw(byte channel, const byte *data, size_t size,
+		int freq, byte volume);
+	void playSoundWav(byte channel, const byte *data, size_t size,
+		uint16_t freq, byte volume, byte loop);
+	void playSoundAiff(byte channel, byte num, byte volume);
+	void stopSound(byte channel);
 };
 
 #ifdef TODO
+
 struct AifcPlayer;
 struct SfxPlayer;
 struct Mixer_impl;
@@ -61,19 +79,19 @@ struct Mixer {
 	void quit();
 	void update();
 
-	void playSoundRaw(uint8_t channel, const uint8_t *data, uint16_t freq, uint8_t volume);
-	void playSoundWav(uint8_t channel, const uint8_t *data, uint16_t freq, uint8_t volume, uint8_t loop);
-	void stopSound(uint8_t channel);
-	void setChannelVolume(uint8_t channel, uint8_t volume);
-	void playMusic(const char *path, uint8_t loop);
+	void playSoundRaw(byte channel, const byte *data, uint16_t freq, byte volume);
+	void playSoundWav(byte channel, const byte *data, uint16_t freq, byte volume, byte loop);
+	void stopSound(byte channel);
+	void setChannelVolume(byte channel, byte volume);
+	void playMusic(const char *path, byte loop);
 	void stopMusic();
 	void playAifcMusic(const char *path, uint32_t offset);
 	void stopAifcMusic();
 	void playSfxMusic(int num);
 	void stopSfxMusic();
 	void stopAll();
-	void preloadSoundAiff(uint8_t num, const uint8_t *data);
-	void playSoundAiff(uint8_t channel, uint8_t num, uint8_t volume);
+	void preloadSoundAiff(byte num, const byte *data);
+	void playSoundAiff(byte channel, byte num, byte volume);
 };
 #endif
 


Commit: 9681e2ecaafe29fea88b14243c3de47eb27ec230
    https://github.com/scummvm/scummvm/commit/9681e2ecaafe29fea88b14243c3de47eb27ec230
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: gcc compilation fixes

Changed paths:
    engines/awe/engine.cpp
    engines/awe/graphics_soft.cpp
    engines/awe/metaengine.cpp
    engines/awe/pak.cpp
    engines/awe/resource.cpp
    engines/awe/resource_nth.cpp
    engines/awe/script.cpp
    engines/awe/sound.h


diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index 9620937dd2b..21159033d6a 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -115,13 +115,12 @@ void Engine::setup(Language lang, int graphicsType, const char *scalerName, int
 		_vid.setDefaultFont();
 	}
 	_script.init();
-	MixerType mixerType = kMixerTypeRaw;
+
 	switch (_res.getDataType()) {
 	case DT_DOS:
 	case DT_AMIGA:
 	case DT_ATARI:
 	case DT_ATARI_DEMO:
-		mixerType = kMixerTypeRaw;
 		switch (lang) {
 		case Common::FR_FRA:
 			_vid._stringsTable = Video::_stringsTableFr;
@@ -135,15 +134,10 @@ void Engine::setup(Language lang, int graphicsType, const char *scalerName, int
 	case DT_WIN31:
 	case DT_15TH_EDITION:
 	case DT_20TH_EDITION:
-		mixerType = kMixerTypeWav;
 		break;
 	case DT_3DO:
-		mixerType = kMixerTypeAiff;
 		break;
 	}
-#ifdef TODO
-	_mix.init(mixerType);
-#endif
 
 	if (_res._copyProtection) {
 		switch (_res.getDataType()) {
diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
index b51ac3e5c7c..a576160a069 100644
--- a/engines/awe/graphics_soft.cpp
+++ b/engines/awe/graphics_soft.cpp
@@ -343,7 +343,7 @@ void GraphicsSoft::drawLineP(int16_t x1, int16_t x2, int16_t y, uint8_t color) {
 }
 
 uint8_t *GraphicsSoft::getPagePtr(uint8_t page) {
-	assert(page >= 0 && page < 4);
+	assert(page < 4);
 	return _pagePtrs[page];
 }
 
diff --git a/engines/awe/metaengine.cpp b/engines/awe/metaengine.cpp
index 3ada037c4ee..210ca1d7ba4 100644
--- a/engines/awe/metaengine.cpp
+++ b/engines/awe/metaengine.cpp
@@ -75,7 +75,7 @@ const ADExtraGuiOptionsMap *AweMetaEngine::getAdvancedExtraGuiOptions() const {
 }
 
 Common::Error AweMetaEngine::createInstance(OSystem *syst, Engine **engine, const Awe::AweGameDescription *desc) const {
-	*engine = new Awe::AweEngine(syst, (Awe::AweGameDescription *)desc);
+	*engine = new Awe::AweEngine(syst, (const Awe::AweGameDescription *)desc);
 	return Common::kNoError;
 }
 
diff --git a/engines/awe/pak.cpp b/engines/awe/pak.cpp
index df8f38fe6c3..794e2540f58 100644
--- a/engines/awe/pak.cpp
+++ b/engines/awe/pak.cpp
@@ -64,7 +64,7 @@ void Pak::close() {
 }
 
 static int comparePakEntry(const void *a, const void *b) {
-	return scumm_stricmp(((PakEntry *)a)->name, ((PakEntry *)b)->name);
+	return scumm_stricmp(((const PakEntry *)a)->name, ((const PakEntry *)b)->name);
 }
 
 void Pak::readEntries() {
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index f1f4c82e706..4ee5861662e 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -275,7 +275,8 @@ void Resource::load() {
 			warning("Resource::load() ec=0x%X (me->bankNum == 0)", 0xF00);
 			me->status = STATUS_NULL;
 		} else {
-			debugC(kDebugBank, "Resource::load() bufPos=0x%X size=%d type=%d pos=0x%X bankNum=%d", memPtr - _memPtrStart, me->packedSize, me->type, me->bankPos, me->bankNum);
+			debugC(kDebugBank, "Resource::load() bufPos=0x%x size=%d type=%d pos=0x%X bankNum=%d", memPtr - _memPtrStart, me->packedSize, me->type, me->bankPos, me->bankNum);
+
 			if (readBank(me, memPtr)) {
 				if (me->type == RT_BITMAP) {
 					_vid->copyBitmapPtr(_vidCurPtr, me->unpackedSize);
diff --git a/engines/awe/resource_nth.cpp b/engines/awe/resource_nth.cpp
index a85904fdd3a..e79758fa2ce 100644
--- a/engines/awe/resource_nth.cpp
+++ b/engines/awe/resource_nth.cpp
@@ -410,8 +410,8 @@ struct Resource20th : ResourceNth {
 		char path[MAXPATHLEN];
 		if (!Script::_useRemasteredAudio) {
 			snprintf(path, sizeof(path), "%s/game/WGZ/original/file%03d.wgz", _dataPath, num);
-			struct stat s;
-			if (stat(path, &s) != 0) {
+
+			if (!Common::File::exists(path)) {
 				snprintf(path, sizeof(path), "%s/game/WGZ/original/file%03dB.wgz", _dataPath, num);
 			}
 			*size = 0;
@@ -457,11 +457,9 @@ struct Resource20th : ResourceNth {
 			snprintf(path, sizeof(path), "%s/game/WGZ/file163-%s-1.wgz", _dataPath, snd);
 		}
 		break;
-		default:
-		{
+		default: {
 			snprintf(path, sizeof(path), "%s/game/WGZ/file%03d.wgz", _dataPath, num);
-			struct stat s;
-			if (stat(path, &s) != 0) {
+			if (!Common::File::exists(path)) {
 				snprintf(path, sizeof(path), "%s/game/WGZ/file%03dB.wgz", _dataPath, num);
 			}
 		}
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index a2b5a5c10f7..ac757da20dd 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -588,7 +588,7 @@ void Script::executeTask() {
 				case 28:
 				{
 					const uint8_t var = _scriptPtr.fetchByte();
-					debugC(kDebugScript, "Script::op28() jmpIf(VAR(0x%02X) == 0)");
+					debugC(kDebugScript, "Script::op28() jmpIf(VAR(0x%02x) == 0)");
 					if (_scriptVars[var] == 0) {
 						op_jmp();
 					} else {
@@ -599,7 +599,7 @@ void Script::executeTask() {
 				case 29:
 				{
 					const uint8_t var = _scriptPtr.fetchByte();
-					debugC(kDebugScript, "Script::op29() jmpIf(VAR(0x%02X) != 0)");
+					debugC(kDebugScript, "Script::op29() jmpIf(VAR(0x%02x) != 0)");
 					if (_scriptVars[var] != 0) {
 						op_jmp();
 					} else {
diff --git a/engines/awe/sound.h b/engines/awe/sound.h
index 96a2cf0dbd2..60f83a3a228 100644
--- a/engines/awe/sound.h
+++ b/engines/awe/sound.h
@@ -29,12 +29,6 @@ namespace Awe {
 
 #define MAX_CHANNELS 8
 
-enum MixerType {
-	kMixerTypeRaw,
-	kMixerTypeWav,
-	kMixerTypeAiff
-};
-
 class Sound {
 private:
 	Audio::Mixer *_mixer;


Commit: 77ebbc8e7e8a28bc0dcd2947a7ebe3e442fb561b
    https://github.com/scummvm/scummvm/commit/77ebbc8e7e8a28bc0dcd2947a7ebe3e442fb561b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Remove redundant dataDir class fields

Changed paths:
    engines/awe/resource.cpp
    engines/awe/resource.h
    engines/awe/resource_3do.cpp
    engines/awe/resource_3do.h
    engines/awe/resource_nth.cpp
    engines/awe/resource_nth.h
    engines/awe/resource_win31.cpp
    engines/awe/resource_win31.h


diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 4ee5861662e..36b5b8a16b2 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -19,6 +19,7 @@
  *
  */
 
+#include "common/config-manager.h"
 #include "awe/resource.h"
 #include "awe/file.h"
 #include "awe/pak.h"
@@ -115,14 +116,14 @@ void Resource::readEntries() {
 	switch (_dataType) {
 	case DT_15TH_EDITION:
 		_numMemList = ENTRIES_COUNT;
-		_nth = ResourceNth::create(15, _dataDir);
+		_nth = ResourceNth::create(15);
 		if (_nth && _nth->init()) {
 			return;
 		}
 		break;
 	case DT_20TH_EDITION:
 		_numMemList = ENTRIES_COUNT_20TH;
-		_nth = ResourceNth::create(20, _dataDir);
+		_nth = ResourceNth::create(20);
 		if (_nth && _nth->init()) {
 			return;
 		}
@@ -163,14 +164,14 @@ void Resource::readEntries() {
 	break;
 	case DT_WIN31:
 		_numMemList = ENTRIES_COUNT;
-		_win31 = new ResourceWin31(_dataDir);
+		_win31 = new ResourceWin31();
 		if (_win31->readEntries()) {
 			return;
 		}
 		break;
 	case DT_3DO:
 		_numMemList = ENTRIES_COUNT;
-		_3do = new Resource3do(_dataDir);
+		_3do = new Resource3do();
 		if (_3do->readEntries()) {
 			return;
 		}
@@ -178,7 +179,7 @@ void Resource::readEntries() {
 	case DT_ATARI_DEMO:
 	{
 		File f;
-		if (f.open(atariDemo, _dataDir)) {
+		if (f.open(atariDemo)) {
 			static const struct {
 				uint8_t type;
 				uint8_t num;
@@ -202,7 +203,8 @@ void Resource::readEntries() {
 	}
 	break;
 	}
-	error("No data files found in '%s'", _dataDir);
+
+	error("No data files found");
 }
 
 void Resource::readEntriesAmiga(const AmigaMemEntry *entries, int count) {
@@ -546,17 +548,22 @@ const char *Resource::getMusicPath(int num, char *buf, int bufSize, uint32_t *of
 	case DT_3DO:
 		assert(offset);
 		name = _3do->getMusicName(num, offset);
+#ifdef OPERA_ISO
 		if (*offset != 0) {
-			return _dataDir; // playing music from .ISO
+			// playing music from .ISO
+			return dataDir;
 		}
+#endif
 		break;
 	default:
 		break;
 	}
+
 	if (name) {
-		snprintf(buf, bufSize, "%s/%s", _dataDir, name);
+		snprintf(buf, bufSize, "%s", name);
 		return buf;
 	}
+
 	return 0;
 }
 
@@ -655,7 +662,7 @@ void Resource::freeMemBlock() {
 void Resource::readDemo3Joy() {
 	static const char *filename = "demo3.joy";
 	File f;
-	if (f.open(filename, _dataDir)) {
+	if (f.open(filename)) {
 		const uint32_t fileSize = f.size();
 		_demo3Joy.bufPtr = (uint8_t *)malloc(fileSize);
 		if (_demo3Joy.bufPtr) {
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index da6a74e0c07..b6cab9b5692 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -137,7 +137,6 @@ struct Resource {
 	Language _lang = Language::EN_ANY;
 	const AmigaMemEntry *_amigaMemList;
 	DemoJoy _demo3Joy;
-	const char *const _dataDir = ".";
 	bool _copyProtection = false;
 
 	Resource(Video *vid, DataType dataType);
diff --git a/engines/awe/resource_3do.cpp b/engines/awe/resource_3do.cpp
index 6bb29ce3e73..c8e5e6084ab 100644
--- a/engines/awe/resource_3do.cpp
+++ b/engines/awe/resource_3do.cpp
@@ -203,16 +203,14 @@ static uint16_t *decodeShapeCcb(File *f, int dataSize, int *w, int *h) {
 	return buffer;
 }
 
-Resource3do::Resource3do(const char *dataPath)
-	: _dataPath(dataPath) {
-
-	Common::FSNode f(dataPath);
-
+Resource3do::Resource3do() {
+#ifdef OPERA_ISO
 	if (f.exists()) {
 		_iso = new OperaIso(dataPath);
 	} else {
 		_iso = 0;
 	}
+#endif
 }
 
 Resource3do::~Resource3do() {
@@ -250,7 +248,7 @@ uint8_t *Resource3do::loadFile(int num, uint8_t *dst, uint32_t *size) {
 		}
 	} else {
 		char path[MAXPATHLEN];
-		snprintf(path, sizeof(path), "%s/GameData/File%d", _dataPath, num);
+		snprintf(path, sizeof(path), "GameData/File%d", num);
 		File f;
 		if (f.open(path)) {
 			const int sz = f.size();
@@ -297,7 +295,7 @@ uint16_t *Resource3do::loadShape555(const char *name, int *w, int *h) {
 		}
 	} else {
 		char path[MAXPATHLEN];
-		snprintf(path, sizeof(path), "%s/GameData/%s", _dataPath, name);
+		snprintf(path, sizeof(path), "GameData/%s", name);
 		File f;
 		if (f.open(path)) {
 			const uint32_t dataSize = f.size();
diff --git a/engines/awe/resource_3do.h b/engines/awe/resource_3do.h
index 5000e407c63..f0f48e8b92a 100644
--- a/engines/awe/resource_3do.h
+++ b/engines/awe/resource_3do.h
@@ -30,12 +30,11 @@ namespace Awe {
 struct OperaIso;
 
 struct Resource3do {
-	const char *_dataPath;
 	char _musicPath[32] = { '\0' };
 	char _cpakPath[64] = { '\0' };
-	OperaIso *_iso;
+	OperaIso *_iso = nullptr;
 
-	Resource3do(const char *dataPath);
+	Resource3do();
 	~Resource3do();
 
 	bool readEntries();
diff --git a/engines/awe/resource_nth.cpp b/engines/awe/resource_nth.cpp
index e79758fa2ce..bbb147d8ddb 100644
--- a/engines/awe/resource_nth.cpp
+++ b/engines/awe/resource_nth.cpp
@@ -50,12 +50,12 @@ struct Resource15th : ResourceNth {
 	const char *_stringsTable[157];
 	bool _hasRemasteredMusic;
 
-	Resource15th(const char *dataPath) {
-		snprintf(_dataPath, sizeof(_dataPath), "%s/Music/AW/RmSnd", dataPath);
+	Resource15th() {
+		Common::strcpy_s(_dataPath, "Music/AW/RmSnd");
 
 		_hasRemasteredMusic = Common::FSNode(_dataPath).isDirectory();
-		snprintf(_dataPath, sizeof(_dataPath), "%s/Data", dataPath);
-		snprintf(_menuPath, sizeof(_menuPath), "%s/Menu", dataPath);
+		Common::strcpy_s(_dataPath, "Data");
+		Common::strcpy_s(_menuPath, "Menu");
 		_textBuf = 0;
 		memset(_stringsTable, 0, sizeof(_stringsTable));
 	}
@@ -279,7 +279,6 @@ static uint8_t *inflateGzip(const char *filepath) {
 }
 
 struct Resource20th : ResourceNth {
-	const char *_dataPath;
 	char *_textBuf;
 	const char *_stringsTable[192];
 	char _musicName[64];
@@ -287,12 +286,10 @@ struct Resource20th : ResourceNth {
 	char _datName[32];
 	const char *_bitmapSize;
 
-	Resource20th(const char *dataPath)
-		: _dataPath(dataPath), _textBuf(0) {
+	Resource20th() : _textBuf(0) {
 		memset(_stringsTable, 0, sizeof(_stringsTable));
 		_musicType = 0;
 		_datName[0] = 0;
-		//srand(time(NULL));
 	}
 
 	virtual ~Resource20th() {
@@ -303,7 +300,7 @@ struct Resource20th : ResourceNth {
 		static const char *dirs[] = { "BGZ", "DAT", "WGZ", 0 };
 		for (int i = 0; dirs[i]; ++i) {
 			char path[MAXPATHLEN];
-			snprintf(path, sizeof(path), "%s/game/%s", _dataPath, dirs[i]);
+			snprintf(path, sizeof(path), "game/%s", dirs[i]);
 			Common::FSNode f(path);
 
 			if (f.exists() && !f.isDirectory()) {
@@ -325,7 +322,7 @@ struct Resource20th : ResourceNth {
 		_bitmapSize = 0;
 		for (int i = 0; bmps[i]; ++i) {
 			char path[MAXPATHLEN];
-			snprintf(path, sizeof(path), "%s/game/BGZ/data%s", _dataPath, bmps[i]);
+			snprintf(path, sizeof(path), "game/BGZ/data%s", bmps[i]);
 			Common::FSNode f(path);
 
 			if (f.isDirectory()) {
@@ -338,24 +335,22 @@ struct Resource20th : ResourceNth {
 
 	virtual uint8_t *load(const char *name) {
 		if (strcmp(name, "font.bmp") == 0) {
-			char path[MAXPATHLEN];
-			snprintf(path, sizeof(path), "%s/game/BGZ/Font.bgz", _dataPath);
-			return inflateGzip(path);
+			return inflateGzip("game/BGZ/Font.bgz");
 		} else if (strcmp(name, "heads.bmp") == 0) {
-			char path[MAXPATHLEN];
-			snprintf(path, sizeof(path), "%s/game/BGZ/Heads.bgz", _dataPath);
-			return inflateGzip(path);
+			return inflateGzip("game/BGZ/Heads.bgz");
 		}
+
 		return 0;
 	}
 
 	virtual uint8_t *loadBmp(int num) {
 		char path[MAXPATHLEN];
 		if (num >= 3000 && _bitmapSize) {
-			snprintf(path, sizeof(path), "%s/game/BGZ/data%s/%s_e%04d.bgz", _dataPath, _bitmapSize, _bitmapSize, num);
+			snprintf(path, sizeof(path), "game/BGZ/data%s/%s_e%04d.bgz", _bitmapSize, _bitmapSize, num);
 		} else {
-			snprintf(path, sizeof(path), "%s/game/BGZ/file%03d.bgz", _dataPath, num);
+			snprintf(path, sizeof(path), "game/BGZ/file%03d.bgz", num);
 		}
+
 		return inflateGzip(path);
 	}
 
@@ -382,7 +377,8 @@ struct Resource20th : ResourceNth {
 	virtual uint8_t *loadDat(int num, uint8_t *dst, uint32_t *size) {
 		bool datOpen = false;
 		char path[MAXPATHLEN];
-		snprintf(path, sizeof(path), "%s/game/DAT", _dataPath);
+		Common::strcpy_s(path, "game/DAT");
+
 		File f;
 		if (_datName[0]) {
 			datOpen = f.open(_datName, path);
@@ -409,19 +405,21 @@ struct Resource20th : ResourceNth {
 	virtual uint8_t *loadWav(int num, uint8_t *dst, uint32_t *size) {
 		char path[MAXPATHLEN];
 		if (!Script::_useRemasteredAudio) {
-			snprintf(path, sizeof(path), "%s/game/WGZ/original/file%03d.wgz", _dataPath, num);
+			snprintf(path, sizeof(path), "game/WGZ/original/file%03d.wgz", num);
 
 			if (!Common::File::exists(path)) {
-				snprintf(path, sizeof(path), "%s/game/WGZ/original/file%03dB.wgz", _dataPath, num);
+				snprintf(path, sizeof(path), "game/WGZ/original/file%03dB.wgz", num);
 			}
+
 			*size = 0;
 			return inflateGzip(path);
 		}
+
 		switch (num) {
 		case 81:
 		{
 			const int r = g_engine->getRandomNumber(1, 3);
-			snprintf(path, sizeof(path), "%s/game/WGZ/file081-EX-%d.wgz", _dataPath, r);
+			snprintf(path, sizeof(path), "game/WGZ/file081-EX-%d.wgz", r);
 		}
 		break;
 		case 85:
@@ -431,7 +429,7 @@ struct Resource20th : ResourceNth {
 			if (_musicType == 1) {
 				snd = "EX";
 			}
-			snprintf(path, sizeof(path), "%s/game/WGZ/file085-%s-%d.wgz", _dataPath, snd, r);
+			snprintf(path, sizeof(path), "game/WGZ/file085-%s-%d.wgz", snd, r);
 		}
 		break;
 		case 96:
@@ -443,7 +441,7 @@ struct Resource20th : ResourceNth {
 			} else if (_musicType == 2) {
 				snd = "IN";
 			}
-			snprintf(path, sizeof(path), "%s/game/WGZ/file096-%s-%d.wgz", _dataPath, snd, r);
+			snprintf(path, sizeof(path), "game/WGZ/file096-%s-%d.wgz", snd, r);
 		}
 		break;
 		case 163:
@@ -454,13 +452,13 @@ struct Resource20th : ResourceNth {
 			} else if (_musicType == 2) {
 				snd = "IN";
 			}
-			snprintf(path, sizeof(path), "%s/game/WGZ/file163-%s-1.wgz", _dataPath, snd);
+			snprintf(path, sizeof(path), "game/WGZ/file163-%s-1.wgz", snd);
 		}
 		break;
 		default: {
-			snprintf(path, sizeof(path), "%s/game/WGZ/file%03d.wgz", _dataPath, num);
+			snprintf(path, sizeof(path), "game/WGZ/file%03d.wgz", num);
 			if (!Common::File::exists(path)) {
-				snprintf(path, sizeof(path), "%s/game/WGZ/file%03dB.wgz", _dataPath, num);
+				snprintf(path, sizeof(path), "game/WGZ/file%03dB.wgz", num);
 			}
 		}
 		break;
@@ -493,14 +491,14 @@ struct Resource20th : ResourceNth {
 			}
 			char path[MAXPATHLEN];
 			static const char *fmt[] = {
-				"%s/game/TXT/%s.txt",
-				"%s/game/TXT/Linux/%s.txt",
+				"game/TXT/%s.txt",
+				"game/TXT/Linux/%s.txt",
 				0
 			};
 			bool isOpen = false;
 			File f;
 			for (int i = 0; fmt[i] && !isOpen; ++i) {
-				snprintf(path, sizeof(path), fmt[i], _dataPath, name);
+				snprintf(path, sizeof(path), fmt[i], name);
 				isOpen = f.open(path);
 			}
 			if (isOpen) {
@@ -574,12 +572,12 @@ struct Resource20th : ResourceNth {
 	}
 };
 
-ResourceNth *ResourceNth::create(int edition, const char *dataPath) {
+ResourceNth *ResourceNth::create(int edition) {
 	switch (edition) {
 	case 15:
-		return new Resource15th(dataPath);
+		return new Resource15th();
 	case 20:
-		return new Resource20th(dataPath);
+		return new Resource20th();
 	}
 	return 0;
 }
diff --git a/engines/awe/resource_nth.h b/engines/awe/resource_nth.h
index 7ea783f1489..8d689acf794 100644
--- a/engines/awe/resource_nth.h
+++ b/engines/awe/resource_nth.h
@@ -41,7 +41,7 @@ struct ResourceNth {
 	virtual const char *getMusicName(int num) = 0;
 	virtual void getBitmapSize(int *w, int *h) = 0;
 
-	static ResourceNth *create(int edition, const char *dataPath);
+	static ResourceNth *create(int edition);
 };
 
 } // namespace Awe
diff --git a/engines/awe/resource_win31.cpp b/engines/awe/resource_win31.cpp
index 7023a8f1159..1e811d8ec25 100644
--- a/engines/awe/resource_win31.cpp
+++ b/engines/awe/resource_win31.cpp
@@ -246,9 +246,8 @@ struct LzHuffman {
 
 const char *ResourceWin31::FILENAME = "BANK";
 
-ResourceWin31::ResourceWin31(const char *dataPath)
-	: _dataPath(dataPath), _entries(0), _entriesCount(0) {
-	_f.open(FILENAME, dataPath);
+ResourceWin31::ResourceWin31() {
+	_f.open(FILENAME);
 	_textBuf = 0;
 	memset(_stringsTable, 0, sizeof(_stringsTable));
 }
@@ -301,7 +300,7 @@ uint8_t *ResourceWin31::loadFile(int num, uint8_t *dst, uint32_t *size) {
 		char name[32];
 		snprintf(name, sizeof(name), "%03d_%s", num, e->name);
 		File f;
-		if (f.open(name, _dataPath) && f.size() == e->size) {
+		if (f.open(name) && f.size() == e->size) {
 			f.read(dst, e->size);
 			return dst;
 		}
diff --git a/engines/awe/resource_win31.h b/engines/awe/resource_win31.h
index 9bb4a09196c..4622c0e1189 100644
--- a/engines/awe/resource_win31.h
+++ b/engines/awe/resource_win31.h
@@ -39,13 +39,12 @@ struct ResourceWin31 {
 	static const char *FILENAME;
 
 	File _f;
-	const char *_dataPath;
 	Win31BankEntry *_entries = nullptr;
 	int _entriesCount = 0;
 	uint8_t *_textBuf = nullptr;
 	const char *_stringsTable[614] = { nullptr };
 
-	ResourceWin31(const char *dataPath);
+	ResourceWin31();
 	~ResourceWin31();
 
 	bool readEntries();


Commit: 013f1006d530f65d59730c625f4361ef4bee2c28
    https://github.com/scummvm/scummvm/commit/013f1006d530f65d59730c625f4361ef4bee2c28
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Fix Windows 3.1 detection entry

Changed paths:
    engines/awe/detection_tables.h
    engines/awe/resource_win31.cpp


diff --git a/engines/awe/detection_tables.h b/engines/awe/detection_tables.h
index 1e07e860b07..3ac5fe42b6a 100644
--- a/engines/awe/detection_tables.h
+++ b/engines/awe/detection_tables.h
@@ -61,6 +61,7 @@ const AweGameDescription gameDescriptions[] = {
 			ADGF_UNSTABLE,
 			GUIO1(GUIO_NONE)
 		},
+		DT_WIN31
 	},
 	{ AD_TABLE_END_MARKER, 0 }
 };
diff --git a/engines/awe/resource_win31.cpp b/engines/awe/resource_win31.cpp
index 1e811d8ec25..7bf73033e99 100644
--- a/engines/awe/resource_win31.cpp
+++ b/engines/awe/resource_win31.cpp
@@ -247,9 +247,8 @@ struct LzHuffman {
 const char *ResourceWin31::FILENAME = "BANK";
 
 ResourceWin31::ResourceWin31() {
-	_f.open(FILENAME);
-	_textBuf = 0;
-	memset(_stringsTable, 0, sizeof(_stringsTable));
+	if (!_f.open(FILENAME))
+		error("Could not open BANK");
 }
 
 ResourceWin31::~ResourceWin31() {
@@ -260,6 +259,7 @@ ResourceWin31::~ResourceWin31() {
 bool ResourceWin31::readEntries() {
 	uint8_t buf[32];
 	const int count = _f.read(buf, sizeof(buf));
+
 	if (count == 32 && memcmp(buf, "NL\00\00", 4) == 0) {
 		_entriesCount = READ_LE_UINT16(buf + 4);
 		debugC(kDebugResource, "Read %d entries in win31 '%s'", _entriesCount, FILENAME);


Commit: 7d164dd87b8b772a9ce2d639788d7f507afcdc5a
    https://github.com/scummvm/scummvm/commit/7d164dd87b8b772a9ce2d639788d7f507afcdc5a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Further gcc compilation fixes

Changed paths:
    engines/awe/resource.cpp
    engines/awe/script.cpp
    engines/awe/video.h


diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 36b5b8a16b2..75082a17249 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -277,7 +277,9 @@ void Resource::load() {
 			warning("Resource::load() ec=0x%X (me->bankNum == 0)", 0xF00);
 			me->status = STATUS_NULL;
 		} else {
-			debugC(kDebugBank, "Resource::load() bufPos=0x%x size=%d type=%d pos=0x%X bankNum=%d", memPtr - _memPtrStart, me->packedSize, me->type, me->bankPos, me->bankNum);
+			debugC(kDebugBank, "Resource::load() bufPos=0x%x size=%d type=%d pos=0x%x bankNum=%d",
+				(uint)(memPtr - _memPtrStart), me->packedSize, me->type,
+				me->bankPos, me->bankNum);
 
 			if (readBank(me, memPtr)) {
 				if (me->type == RT_BITMAP) {
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index ac757da20dd..e52bad1ebe4 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -588,7 +588,7 @@ void Script::executeTask() {
 				case 28:
 				{
 					const uint8_t var = _scriptPtr.fetchByte();
-					debugC(kDebugScript, "Script::op28() jmpIf(VAR(0x%02x) == 0)");
+					debugC(kDebugScript, "Script::op28() jmpIf(VAR(0x%02x) == 0)", var);
 					if (_scriptVars[var] == 0) {
 						op_jmp();
 					} else {
@@ -599,7 +599,7 @@ void Script::executeTask() {
 				case 29:
 				{
 					const uint8_t var = _scriptPtr.fetchByte();
-					debugC(kDebugScript, "Script::op29() jmpIf(VAR(0x%02x) != 0)");
+					debugC(kDebugScript, "Script::op29() jmpIf(VAR(0x%02x) != 0)", var);
 					if (_scriptVars[var] != 0) {
 						op_jmp();
 					} else {
diff --git a/engines/awe/video.h b/engines/awe/video.h
index 205eda40928..6b14be897a3 100644
--- a/engines/awe/video.h
+++ b/engines/awe/video.h
@@ -27,8 +27,8 @@
 namespace Awe {
 
 struct StrEntry {
-	uint16_t id = 0;
-	const char *str = nullptr;
+	uint16_t id;
+	const char *str;
 };
 
 struct Gfx;


Commit: 0e40a74ed6ef72fe50a5c926bd0e8b497f4c0c2e
    https://github.com/scummvm/scummvm/commit/0e40a74ed6ef72fe50a5c926bd0e8b497f4c0c2e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Added 20th Anniversary detection entry

It crashes on startup, so still needs some work.
Also, was informed by original engine author that
this version has some issues, and is also missing
the startup main menu and difficulty selection.

Changed paths:
    engines/awe/detection.cpp
    engines/awe/detection_tables.h


diff --git a/engines/awe/detection.cpp b/engines/awe/detection.cpp
index 5a115ec7cb0..1e6cf77a6c4 100644
--- a/engines/awe/detection.cpp
+++ b/engines/awe/detection.cpp
@@ -41,7 +41,8 @@ const DebugChannelDef AweMetaEngineDetection::debugFlagList[] = {
 };
 
 AweMetaEngineDetection::AweMetaEngineDetection() : AdvancedMetaEngineDetection(
-	Awe::gameDescriptions, Awe::aweGames) {
+		Awe::gameDescriptions, Awe::aweGames) {
+	_flags = kADFlagMatchFullPaths;
 }
 
 REGISTER_PLUGIN_STATIC(AWE_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, AweMetaEngineDetection);
diff --git a/engines/awe/detection_tables.h b/engines/awe/detection_tables.h
index 3ac5fe42b6a..495294f4ac4 100644
--- a/engines/awe/detection_tables.h
+++ b/engines/awe/detection_tables.h
@@ -63,6 +63,18 @@ const AweGameDescription gameDescriptions[] = {
 		},
 		DT_WIN31
 	},
+	{
+		{
+			"anotherworld",
+			"20th Anniversary",
+			AD_ENTRY1s("game/dat/file017.dat", "3c3e73a77d2cab00324c1affd3f2ef8c", 25108),
+			Common::EN_ANY,
+			Common::kPlatformWindows,
+			ADGF_UNSTABLE,
+			GUIO1(GUIO_NONE)
+		},
+		DT_20TH_EDITION
+	},
 	{ AD_TABLE_END_MARKER, 0 }
 };
 


Commit: fcb8eb43f1c981762154c48092de08e6dd5d7b29
    https://github.com/scummvm/scummvm/commit/fcb8eb43f1c981762154c48092de08e6dd5d7b29
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Remove support for running 3do version from an .iso

Changed paths:
    engines/awe/resource.cpp
    engines/awe/resource_3do.cpp
    engines/awe/resource_3do.h


diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 75082a17249..0b41c55f5ee 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -550,12 +550,6 @@ const char *Resource::getMusicPath(int num, char *buf, int bufSize, uint32_t *of
 	case DT_3DO:
 		assert(offset);
 		name = _3do->getMusicName(num, offset);
-#ifdef OPERA_ISO
-		if (*offset != 0) {
-			// playing music from .ISO
-			return dataDir;
-		}
-#endif
 		break;
 	default:
 		break;
diff --git a/engines/awe/resource_3do.cpp b/engines/awe/resource_3do.cpp
index c8e5e6084ab..deb3a242f86 100644
--- a/engines/awe/resource_3do.cpp
+++ b/engines/awe/resource_3do.cpp
@@ -24,91 +24,6 @@
 
 namespace Awe {
 
-static const int ISO_BLOCK_SIZE = 2048;
-
-struct OperaIsoEntry {
-	char name[16];
-	uint32_t offset;
-	uint32_t size;
-};
-
-static int compareOperaIsoEntry(const void *a, const void *b) {
-	const OperaIsoEntry *entry1 = (const OperaIsoEntry *)a;
-	const OperaIsoEntry *entry2 = (const OperaIsoEntry *)b;
-	return strcmp(entry1->name, entry2->name);
-}
-
-static int compareOperaIsoEntryName(const void *name, const void *p) {
-	const OperaIsoEntry *entry = (const OperaIsoEntry *)p;
-	return strcmp((const char *)name, entry->name);
-}
-
-struct OperaIso {
-	File _f;
-	OperaIsoEntry *_entries;
-	int _entriesCount;
-
-	OperaIso(const char *filePath)
-		: _entries(0), _entriesCount(0) {
-		_f.open(filePath);
-	}
-	~OperaIso() {
-		free(_entries);
-	}
-	void readToc() {
-		uint8_t buf[128];
-		const int count = _f.read(buf, sizeof(buf));
-		if (count != sizeof(buf)) {
-			warning("Failed to read %d bytes", count);
-			return;
-		}
-		if (buf[0] != 1 || memcmp(buf + 40, "CD-ROM", 6) != 0) {
-			warning("Unexpected Opera ISO signature");
-			return;
-		}
-		const int block = READ_BE_UINT32(buf + 100);
-		readTocEntry(block);
-		qsort(_entries, _entriesCount, sizeof(OperaIsoEntry), compareOperaIsoEntry);
-	}
-	void readTocEntry(int block) {
-		uint32_t attr = 0;
-		do {
-			_f.seek(block * ISO_BLOCK_SIZE + 20, SEEK_SET);
-			do {
-				uint8_t buf[72];
-				_f.read(buf, sizeof(buf));
-				attr = READ_BE_UINT32(buf);
-				const char *name = (const char *)buf + 32;
-				const uint32_t count = READ_BE_UINT32(buf + 64);
-				const uint32_t offset = READ_BE_UINT32(buf + 68);
-				_f.seek(count * 4, SEEK_CUR);
-				switch (attr & 255) {
-				case 2:
-					_entries = (OperaIsoEntry *)realloc(_entries, (_entriesCount + 1) * sizeof(OperaIsoEntry));
-					if (_entries) {
-						OperaIsoEntry *e = &_entries[_entriesCount];
-						strncpy(e->name, name, sizeof(e->name) - 1);
-						e->name[sizeof(e->name) - 1] = 0;
-						e->offset = offset * ISO_BLOCK_SIZE;
-						e->size = READ_BE_UINT32(buf + 16);
-						++_entriesCount;
-					}
-					break;
-				case 7:
-					if (strcmp(name, "GameData") == 0) {
-						readTocEntry(offset);
-					}
-					break;
-				}
-			} while (attr != 0 && attr < 256);
-			++block;
-		} while ((attr >> 24) == 0x40);
-	}
-	const OperaIsoEntry *find(const char *name) const {
-		return (const OperaIsoEntry *)bsearch(name, _entries, _entriesCount, sizeof(OperaIsoEntry), compareOperaIsoEntryName);
-	}
-};
-
 static int decodeLzss(const uint8_t *src, uint32_t len, uint8_t *dst) {
 	uint32_t rd = 0, wr = 0;
 	while (rd < len) {
@@ -203,69 +118,32 @@ static uint16_t *decodeShapeCcb(File *f, int dataSize, int *w, int *h) {
 	return buffer;
 }
 
-Resource3do::Resource3do() {
-#ifdef OPERA_ISO
-	if (f.exists()) {
-		_iso = new OperaIso(dataPath);
-	} else {
-		_iso = 0;
-	}
-#endif
-}
-
-Resource3do::~Resource3do() {
-	delete _iso;
-}
-
 bool Resource3do::readEntries() {
-	if (_iso) {
-		_iso->readToc();
-		return _iso->_entriesCount != 0;
-	}
 	return true;
 }
 
 uint8_t *Resource3do::loadFile(int num, uint8_t *dst, uint32_t *size) {
 	uint8_t *in = dst;
-	if (_iso) {
-		char name[16];
-		snprintf(name, sizeof(name), "File%d", num);
-		const OperaIsoEntry *e = _iso->find(name);
-		if (e) {
+
+	char path[MAXPATHLEN];
+	snprintf(path, sizeof(path), "GameData/File%d", num);
+	File f;
+	if (f.open(path)) {
+		const int sz = f.size();
+		if (!dst) {
+			dst = (uint8_t *)malloc(sz);
 			if (!dst) {
-				dst = (uint8_t *)malloc(e->size);
-				if (!dst) {
-					warning("Unable to allocate %d bytes", e->size);
-					return 0;
-				}
+				warning("Unable to allocate %d bytes", sz);
+				return 0;
 			}
-			*size = e->size;
-			_iso->_f.seek(e->offset);
-			_iso->_f.read(dst, e->size);
-		} else {
-			warning("Failed to load '%s'", name);
-			return 0;
 		}
+		*size = sz;
+		f.read(dst, sz);
 	} else {
-		char path[MAXPATHLEN];
-		snprintf(path, sizeof(path), "GameData/File%d", num);
-		File f;
-		if (f.open(path)) {
-			const int sz = f.size();
-			if (!dst) {
-				dst = (uint8_t *)malloc(sz);
-				if (!dst) {
-					warning("Unable to allocate %d bytes", sz);
-					return 0;
-				}
-			}
-			*size = sz;
-			f.read(dst, sz);
-		} else {
-			warning("Failed to load '%s'", path);
-			return 0;
-		}
+		warning("Failed to load '%s'", path);
+		return 0;
 	}
+
 	if (dst && memcmp(dst, "\x00\xf4\x01\x00", 4) == 0) {
 		static const int SZ = 64000 * 2;
 		uint8_t *tmp = (uint8_t *)calloc(1, SZ);
@@ -287,48 +165,27 @@ uint8_t *Resource3do::loadFile(int num, uint8_t *dst, uint32_t *size) {
 }
 
 uint16_t *Resource3do::loadShape555(const char *name, int *w, int *h) {
-	if (_iso) {
-		const OperaIsoEntry *e = _iso->find(name);
-		if (e) {
-			_iso->_f.seek(e->offset);
-			return decodeShapeCcb(&_iso->_f, e->size, w, h);
-		}
-	} else {
-		char path[MAXPATHLEN];
-		snprintf(path, sizeof(path), "GameData/%s", name);
-		File f;
-		if (f.open(path)) {
-			const uint32_t dataSize = f.size();
-			return decodeShapeCcb(&f, dataSize, w, h);
-		}
+	char path[MAXPATHLEN];
+	snprintf(path, sizeof(path), "GameData/%s", name);
+	File f;
+	if (f.open(path)) {
+		const uint32_t dataSize = f.size();
+		return decodeShapeCcb(&f, dataSize, w, h);
 	}
-	return 0;
+
+	return nullptr;
 }
 
 const char *Resource3do::getMusicName(int num, uint32_t *offset) {
 	*offset = 0;
-	if (_iso) {
-		char name[16];
-		snprintf(name, sizeof(name), "song%d", num);
-		const OperaIsoEntry *e = _iso->find(name);
-		if (e) {
-			*offset = e->offset;
-		}
-		return 0;
-	}
+
 	snprintf(_musicPath, sizeof(_musicPath), "GameData/song%d", num);
 	return _musicPath;
 }
 
 const char *Resource3do::getCpak(const char *name, uint32_t *offset) {
 	*offset = 0;
-	if (_iso) {
-		const OperaIsoEntry *e = _iso->find(name);
-		if (e) {
-			*offset = e->offset;
-		}
-		return 0;
-	}
+
 	snprintf(_cpakPath, sizeof(_cpakPath), "GameData/%s", name);
 	return _cpakPath;
 }
diff --git a/engines/awe/resource_3do.h b/engines/awe/resource_3do.h
index f0f48e8b92a..8ecfa9f9414 100644
--- a/engines/awe/resource_3do.h
+++ b/engines/awe/resource_3do.h
@@ -27,15 +27,11 @@
 
 namespace Awe {
 
-struct OperaIso;
-
 struct Resource3do {
 	char _musicPath[32] = { '\0' };
 	char _cpakPath[64] = { '\0' };
-	OperaIso *_iso = nullptr;
 
-	Resource3do();
-	~Resource3do();
+	Resource3do() {}
 
 	bool readEntries();
 


Commit: bb30b9cd7c8e614d8238e66c4e7bd266c4d922e6
    https://github.com/scummvm/scummvm/commit/bb30b9cd7c8e614d8238e66c4e7bd266c4d922e6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Uppercase static arrays

Changed paths:
    engines/awe/engine.cpp
    engines/awe/gfx.h
    engines/awe/graphics_soft.cpp
    engines/awe/resource.cpp
    engines/awe/resource.h
    engines/awe/script.cpp
    engines/awe/script.h
    engines/awe/static_res.cpp
    engines/awe/video.cpp
    engines/awe/video.h


diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index 21159033d6a..5a4ded5e7e8 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -55,7 +55,7 @@ void Engine::run() {
 	switch (_state) {
 	case kStateLogo3DO:
 		doThreeScreens();
-		scrollText(0, 380, Video::_noteText3DO);
+		scrollText(0, 380, Video::NOTE_TEXT_3DO);
 		playCinepak("Logo.Cine");
 		playCinepak("Spintitle.Cine");
 		break;
@@ -123,11 +123,11 @@ void Engine::setup(Language lang, int graphicsType, const char *scalerName, int
 	case DT_ATARI_DEMO:
 		switch (lang) {
 		case Common::FR_FRA:
-			_vid._stringsTable = Video::_stringsTableFr;
+			_vid._stringsTable = Video::STRINGS_TABLE_FR;
 			break;
 		case Common::EN_ANY:
 		default:
-			_vid._stringsTable = Video::_stringsTableEng;
+			_vid._stringsTable = Video::STRINGS_TABLE_ENG;
 			break;
 		}
 		break;
@@ -185,9 +185,10 @@ void Engine::processInput() {
 
 void Engine::doThreeScreens() {
 	_script.snd_playMusic(1, 0, 0);
-	static const int bitmaps[] = { 67, 68, 69, -1 };
-	for (int i = 0; bitmaps[i] != -1 && !_stub->_pi.quit; ++i) {
-		_res.loadBmp(bitmaps[i]);
+	static const int BITMAPS[] = { 67, 68, 69, -1 };
+
+	for (int i = 0; BITMAPS[i] != -1 && !_stub->_pi.quit; ++i) {
+		_res.loadBmp(BITMAPS[i]);
 		_vid.updateDisplay(0, _stub);
 		while (!_stub->_pi.quit) {
 			_stub->processEvents();
@@ -202,7 +203,7 @@ void Engine::doThreeScreens() {
 }
 
 void Engine::doEndCredits() {
-	scrollText(0, 380, Video::_endText3DO);
+	scrollText(0, 380, Video::END_TEXT_3DO);
 	_script.snd_playMusic(0, 0, 0);
 	playCinepak("ootw2.cine");
 	_state = kStateTitle3DO;
@@ -218,11 +219,12 @@ void Engine::titlePage() {
 	_res.loadBmp(70);
 	static const int kCursorColor = 0;
 	_vid.setPaletteColor(kCursorColor, 255, 0, 0);
-	static const int yPos[] = { 97, 123, 149 };
+	static const uint16 YPOS[] = { 97, 123, 149 };
 	int y = 0;
+
 	while (!_stub->_pi.quit) {
 		_vid.copyPage(0, 1, 0);
-		_vid.drawRect(1, kCursorColor, 97, yPos[y], 210, yPos[y + 1]);
+		_vid.drawRect(1, kCursorColor, 97, YPOS[y], 210, YPOS[y + 1]);
 		_stub->processEvents();
 		if (_stub->_pi.dirMask & PlayerInput::DIR_DOWN) {
 			_stub->_pi.dirMask &= ~PlayerInput::DIR_DOWN;
diff --git a/engines/awe/gfx.h b/engines/awe/gfx.h
index 39b75a65c13..23cd6b380c5 100644
--- a/engines/awe/gfx.h
+++ b/engines/awe/gfx.h
@@ -60,12 +60,12 @@ enum {
 struct SystemStub;
 
 struct Gfx {
-	static const uint8_t _font[];
+	static const uint8_t FONT[];
 	static bool _is1991; // draw graphics as in the original 1991 game release
 	static Graphics::PixelFormat _format;
-	static const uint16_t _shapesMaskOffset[];
-	static const int _shapesMaskCount;
-	static const uint8_t _shapesMaskData[];
+	static const uint16_t SHAPES_MASK_OFFSET[];
+	static const int SHAPES_MASK_COUNT;
+	static const uint8_t SHAPES_MASK_DATA[];
 
 	int _fixUpPalette = 0;
 
diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
index a576160a069..f507c3a401c 100644
--- a/engines/awe/graphics_soft.cpp
+++ b/engines/awe/graphics_soft.cpp
@@ -193,7 +193,7 @@ void GraphicsSoft::drawChar(uint8_t c, uint16_t x, uint16_t y, uint8_t color) {
 	if (x <= GFX_W - 8 && y <= GFX_H - 8) {
 		x = xScale(x);
 		y = yScale(y);
-		const uint8_t *ft = _font + (c - 0x20) * 8;
+		const uint8_t *ft = FONT + (c - 0x20) * 8;
 		const int offset = (x + y * _w) * _byteDepth;
 		if (_byteDepth == 1) {
 			for (int j = 0; j < 8; ++j) {
@@ -376,9 +376,9 @@ void GraphicsSoft::setSpriteAtlas(const uint8_t *src, int w, int h, int xSize, i
 
 void GraphicsSoft::drawSprite(int buffer, int num, const Point *pt, uint8_t color) {
 	if (_is1991) {
-		if (num < _shapesMaskCount) {
+		if (num < SHAPES_MASK_COUNT) {
 			setWorkPagePtr(buffer);
-			const uint8_t *data = _shapesMaskData + _shapesMaskOffset[num];
+			const uint8_t *data = SHAPES_MASK_DATA + SHAPES_MASK_OFFSET[num];
 			drawSpriteMask(pt->x, pt->y, color, data);
 		}
 	}
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 0b41c55f5ee..cdbd59c6571 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -39,6 +39,10 @@ static const char *kGameTitleUS = "Out Of This World";
 static const char *kGameTitle15thEdition = "Another World 15th anniversary edition";
 static const char *kGameTitle20thEdition = "Another World 20th anniversary edition";
 
+static const int MEMLIST_BMP[] = {
+	145, 144, 73, 72, 70, 69, 68, 67, -1
+};
+
 Resource::Resource(Video *vid, DataType dataType) :
 		_vid(vid), _dataType(dataType) {
 	if (_dataType == DT_ATARI) {
@@ -75,17 +79,17 @@ const AmigaMemEntry *Resource::detectAmigaAtari() {
 	static const struct {
 		uint32_t bank01Size;
 		const AmigaMemEntry *entries;
-	} _files[] = {
-		{ 244674, Resource::_memListAmigaFR },
-		{ 244868, Resource::_memListAmigaEN },
-		{ 227142, Resource::_memListAtariEN },
+	} FILES[] = {
+		{ 244674, Resource::MEMLIST_AMIGA_FR },
+		{ 244868, Resource::MEMLIST_AMIGA_EN },
+		{ 227142, Resource::MEMLIST_ATARI_EN },
 		{ 0, 0 }
 	};
 	if (f.open("bank01")) {
 		const uint32_t size = f.size();
-		for (int i = 0; _files[i].entries; ++i) {
-			if (_files[i].bank01Size == size) {
-				return _files[i].entries;
+		for (int i = 0; FILES[i].entries; ++i) {
+			if (FILES[i].bank01Size == size) {
+				return FILES[i].entries;
 			}
 		}
 	}
@@ -148,7 +152,7 @@ void Resource::readEntries() {
 				me->load(&f);
 
 				if (me->status == 0xFF) {
-					const int num = _memListParts[8][1]; // 16008 bytecode
+					const int num = MEMLIST_PARTS[8][1]; // 16008 bytecode
 					assert(num < _numMemList);
 					Common::String bank = Common::String::format(
 						"%s%02x", _bankPrefix, _memList[num].bankNum);
@@ -185,18 +189,18 @@ void Resource::readEntries() {
 				uint8_t num;
 				uint32_t offset;
 				uint16_t size;
-			} data[] = {
+			} DATA[] = {
 				{ RT_SHAPE, 0x19, 0x50f0, 65146 },
 				{ RT_PALETTE, 0x17, 0x14f6a, 2048 },
 				{ RT_BYTECODE, 0x18, 0x1576a, 8368 }
 			};
 			_numMemList = ENTRIES_COUNT;
 			for (int i = 0; i < 3; ++i) {
-				MemEntry *entry = &_memList[data[i].num];
-				entry->type = data[i].type;
+				MemEntry *entry = &_memList[DATA[i].num];
+				entry->type = DATA[i].type;
 				entry->bankNum = 15;
-				entry->bankPos = data[i].offset;
-				entry->packedSize = entry->unpackedSize = data[i].size;
+				entry->bankPos = DATA[i].offset;
+				entry->packedSize = entry->unpackedSize = DATA[i].size;
 			}
 			return;
 		}
@@ -323,52 +327,51 @@ void Resource::invalidateAll() {
 }
 
 static const uint8_t *getSoundsList3DO(int num) {
-	static const uint8_t intro7[] = {
+	static const uint8_t INTRO7[] = {
 		0x33, 0xFF
 	};
-	static const uint8_t water7[] = {
+	static const uint8_t WATER7[] = {
 		0x08, 0x10, 0x2D, 0x30, 0x31, 0x32, 0x35, 0x39, 0x3A, 0x3C,
 		0x3D, 0x3E, 0x4A, 0x4B, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
 		0x54, 0xFF
 	};
-	static const uint8_t pri1[] = {
+	static const uint8_t PRI1[] = {
 		0x52, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D,
 		0x5E, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
 		0x69, 0x70, 0x71, 0x72, 0x73, 0xFF
 	};
-	static const uint8_t cite1[] = {
+	static const uint8_t CITE1[] = {
 		0x02, 0x03, 0x52, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B,
 		0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x63, 0x66, 0x6A, 0x6B, 0x6C,
 		0x6D, 0x6E, 0x6F, 0x70, 0x72, 0x74, 0x75, 0x77, 0x78, 0x79,
 		0x7A, 0x7B, 0x7C, 0x88, 0xFF
 	};
-	static const uint8_t arene2[] = {
+	static const uint8_t ARENE2[] = {
 		0x52, 0x57, 0x58, 0x59, 0x5B, 0x84, 0x8B, 0x8C, 0x8E, 0xFF
 	};
-	static const uint8_t luxe2[] = {
+	static const uint8_t LUXE2[] = {
 		0x30, 0x52, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C,
 		0x5D, 0x5E, 0x5F, 0x60, 0x66, 0x67, 0x6B, 0x6C, 0x70, 0x74,
 		0x75, 0x79, 0x7A, 0x8D, 0xFF
 	};
-	static const uint8_t final3[] = {
+	static const uint8_t FINAL3[] = {
 		0x08, 0x0E, 0x0F, 0x57, 0xFF
 	};
+
 	switch (num) {
-	case 2001: return intro7;
-	case 2002: return water7;
-	case 2003: return pri1;
-	case 2004: return cite1;
-	case 2005: return arene2;
-	case 2006: return luxe2;
-	case 2007: return final3;
+	case 2001: return INTRO7;
+	case 2002: return WATER7;
+	case 2003: return PRI1;
+	case 2004: return CITE1;
+	case 2005: return ARENE2;
+	case 2006: return LUXE2;
+	case 2007: return FINAL3;
+	default: break;
 	}
+
 	return 0;
 }
 
-static const int _memListBmp[] = {
-	145, 144, 73, 72, 70, 69, 68, 67, -1
-};
-
 void Resource::update(uint16_t num, PreloadSoundProc preloadSound, void *data) {
 	if (num > 16000) {
 		_nextPart = num;
@@ -389,8 +392,8 @@ void Resource::update(uint16_t num, PreloadSoundProc preloadSound, void *data) {
 			loadBmp(num);
 			break;
 		}
-		for (int i = 0; _memListBmp[i] != -1; ++i) {
-			if (num == _memListBmp[i]) {
+		for (int i = 0; MEMLIST_BMP[i] != -1; ++i) {
+			if (num == MEMLIST_BMP[i]) {
 				loadBmp(num);
 				return;
 			}
@@ -563,7 +566,7 @@ const char *Resource::getMusicPath(int num, char *buf, int bufSize, uint32_t *of
 	return 0;
 }
 
-const uint8_t Resource::_memListParts[][4] = {
+const uint8_t Resource::MEMLIST_PARTS[][4] = {
 	{ 0x14, 0x15, 0x16, 0x00 }, // 16000 - protection screens
 	{ 0x17, 0x18, 0x19, 0x00 }, // 16001 - introduction
 	{ 0x1A, 0x1B, 0x1C, 0x11 }, // 16002 - water
@@ -589,7 +592,7 @@ void Resource::setupPart(int ptrId) {
 			invalidateAll();
 			uint8_t **segments[4] = { &_segVideoPal, &_segCode, &_segVideo1, &_segVideo2 };
 			for (int i = 0; i < 4; ++i) {
-				const int num = _memListParts[ptrId - 16000][i];
+				const int num = MEMLIST_PARTS[ptrId - 16000][i];
 				if (num != 0) {
 					if (_dataType == DT_20TH_EDITION && 0) {
 						// HD assets
@@ -615,10 +618,10 @@ void Resource::setupPart(int ptrId) {
 			uint8_t ivd2 = 0;
 			if (ptrId >= 16000 && ptrId <= 16009) {
 				uint16_t part = ptrId - 16000;
-				ipal = _memListParts[part][0];
-				icod = _memListParts[part][1];
-				ivd1 = _memListParts[part][2];
-				ivd2 = _memListParts[part][3];
+				ipal = MEMLIST_PARTS[part][0];
+				icod = MEMLIST_PARTS[part][1];
+				ivd1 = MEMLIST_PARTS[part][2];
+				ivd2 = MEMLIST_PARTS[part][3];
 			} else {
 				error("Resource::setupPart() ec=0x%X invalid part", 0xF07);
 			}
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index b6cab9b5692..4bf4b4811d4 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -109,10 +109,10 @@ struct Resource {
 		STATUS_TOLOAD,
 	};
 
-	static const AmigaMemEntry _memListAmigaFR[ENTRIES_COUNT];
-	static const AmigaMemEntry _memListAmigaEN[ENTRIES_COUNT];
-	static const AmigaMemEntry _memListAtariEN[ENTRIES_COUNT];
-	static const uint8_t _memListParts[][4];
+	static const AmigaMemEntry MEMLIST_AMIGA_FR[ENTRIES_COUNT];
+	static const AmigaMemEntry MEMLIST_AMIGA_EN[ENTRIES_COUNT];
+	static const AmigaMemEntry MEMLIST_ATARI_EN[ENTRIES_COUNT];
+	static const uint8_t MEMLIST_PARTS[][4];
 	static const AmigaMemEntry *detectAmigaAtari();
 
 	Video *_vid;
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index e52bad1ebe4..90748d7a8e3 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -427,7 +427,7 @@ void Script::restartAt(int part, int pos) {
 		//   00CA: updateResources(res=71)
 
 		// Use "Another World" title screen if language is set to French
-		const bool awTitleScreen = (_vid->_stringsTable == Video::_stringsTableFr);
+		const bool awTitleScreen = (_vid->_stringsTable == Video::STRINGS_TABLE_FR);
 		_scriptVars[0x54] = awTitleScreen ? 0x1 : 0x81;
 	}
 	_res->setupPart(part);
@@ -617,7 +617,7 @@ void Script::executeTask() {
 			if (opcode > 0x1A) {
 				error("Script::executeTask() ec=0x%X invalid opcode=0x%X", 0xFFF, opcode);
 			} else {
-				(this->*_opTable[opcode])();
+				(this->*OPCODE_TABLE[opcode])();
 			}
 		}
 	}
@@ -774,7 +774,7 @@ static uint8_t getWavLooping(uint16_t resNum) {
 }
 
 static int getSoundFreq(uint8_t period) {
-	return kPaulaFreq / (Script::_periodTable[period] * 2);
+	return kPaulaFreq / (Script::PERIOD_TABLE[period] * 2);
 }
 
 void Script::snd_playSound(uint16_t resNum, uint8_t freq, uint8_t vol, uint8_t channel) {
diff --git a/engines/awe/script.h b/engines/awe/script.h
index bdc3e9e7626..ed6ac4eede3 100644
--- a/engines/awe/script.h
+++ b/engines/awe/script.h
@@ -62,8 +62,8 @@ struct Script {
 		VAR_PAUSE_SLICES = 0xFF
 	};
 
-	static const OpcodeStub _opTable[];
-	static const uint16_t _periodTable[];
+	static const OpcodeStub OPCODE_TABLE[];
+	static const uint16_t PERIOD_TABLE[];
 	static Difficulty _difficulty;
 	static bool _useRemasteredAudio;
 
diff --git a/engines/awe/static_res.cpp b/engines/awe/static_res.cpp
index 4c26c611876..ede78fca056 100644
--- a/engines/awe/static_res.cpp
+++ b/engines/awe/static_res.cpp
@@ -26,7 +26,7 @@
 
 namespace Awe {
 
-const Script::OpcodeStub Script::_opTable[] = {
+const Script::OpcodeStub Script::OPCODE_TABLE[] = {
 	/* 0x00 */
 	&Script::op_movConst,
 	&Script::op_mov,
@@ -63,14 +63,14 @@ const Script::OpcodeStub Script::_opTable[] = {
 	&Script::op_playMusic
 };
 
-const uint16_t Script::_periodTable[] = {
+const uint16_t Script::PERIOD_TABLE[] = {
 	1076, 1016,  960,  906,  856,  808,  762,  720,  678,  640,
 	 604,  570,  538,  508,  480,  453,  428,  404,  381,  360,
 	 339,  320,  302,  285,  269,  254,  240,  226,  214,  202,
 	 190,  180,  170,  160,  151,  143,  135,  127,  120,  113
 };
 
-const uint8_t Gfx::_font[] = {
+const uint8_t Gfx::FONT[] = {
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00,
 	0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x7E, 0x24, 0x24, 0x7E, 0x24, 0x00,
 	0x08, 0x3E, 0x48, 0x3C, 0x12, 0x7C, 0x10, 0x00, 0x42, 0xA4, 0x48, 0x10, 0x24, 0x4A, 0x84, 0x00,
@@ -121,7 +121,7 @@ const uint8_t Gfx::_font[] = {
 	0x38, 0x44, 0x82, 0x82, 0x44, 0x28, 0xEE, 0x00, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA
 };
 
-const StrEntry Video::_stringsTableFr[] = {
+const StrEntry Video::STRINGS_TABLE_FR[] = {
 	{ 0x001, "P E A N U T  3000" },
 	{ 0x002, "Copyright  } 1990 Peanut Computer, Inc.\nAll rights reserved.\n\nCDOS Version 5.01" },
 	{ 0x003, "2" },
@@ -265,7 +265,7 @@ const StrEntry Video::_stringsTableFr[] = {
 	{ 0xFFFF, 0 }
 };
 
-const StrEntry Video::_stringsTableEng[] = {
+const StrEntry Video::STRINGS_TABLE_ENG[] = {
 	{ 0x001, "P E A N U T  3000" },
 	{ 0x002, "Copyright  } 1990 Peanut Computer, Inc.\nAll rights reserved.\n\nCDOS Version 5.01" },
 	{ 0x003, "2" },
@@ -409,7 +409,7 @@ const StrEntry Video::_stringsTableEng[] = {
 	{ 0xFFFF, 0 }
 };
 
-const StrEntry Video::_stringsTableDemo[] = {
+const StrEntry Video::STRINGS_TABLE_DEMO[] = {
 	{ 0x1F4, "Over Two Years in the Making" },
 	{ 0x1F5, "   A New, State\nof the Art, Polygon\n  Graphics System" },
 	{ 0x1F6, "   Comes to the\nComputer With Full\n Screen Graphics" },
@@ -420,7 +420,7 @@ const StrEntry Video::_stringsTableDemo[] = {
 	{ 0xFFFF, 0 }
 };
 
-const uint16_t Video::_stringsId15th[] = {
+const uint16_t Video::STRINGS_ID_15TH[] = {
 	0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, 0x008, 0x00A, 0x00B, 0x00C, 0x00D, 0x00E, 0x00F, 0x010, 0x011,
 	0x012, 0x013, 0x014, 0x015, 0x016, 0x017, 0x018, 0x019, 0x01A, 0x01B, 0x01C, 0x021, 0x022, 0x023, 0x024, 0x025,
 	0x026, 0x027, 0x028, 0x029, 0x02A, 0x02B, 0x02C, 0x031, 0x032, 0x033, 0x034, 0x035, 0x036, 0x037, 0x038, 0x039,
@@ -433,7 +433,7 @@ const uint16_t Video::_stringsId15th[] = {
 	0x16C, 0x16D, 0x16E, 0x16F, 0x170, 0x169, 0x172, 0x17F, 0x173, 0x17E, 0x174, 0x16A, 0x16B
 };
 
-const char *Video::_stringsTable15th[] = {
+const char *Video::STRINGS_TABLE_15TH[] = {
 	"P E A N U T  3000",
 	"Copyright  } 1990 Peanut Computer, Inc.\nAll rights reserved.\n\nCDOS Version 5.01",
 	"2",
@@ -595,7 +595,7 @@ const char *Video::_stringsTable15th[] = {
 
 const char *Video::_str0x194AtariDemo = "Je signale que Monsieur\na tout de meme 40 minutes\net 21 secondes de retard.";
 
-const StrEntry Video::_stringsTable3DO[] = {
+const StrEntry Video::STRINGS_TABLE_3DO[] = {
 	{ 1, "Copyright } 1997 Cortland Computer, Inc.\nAll rights reserved.\n\nGS/OS Version 7.03\nII Infinitum!" },
 	{ 2, "Copyright } 1997 Peanut Computer, Inc.\nAll rights reserved.\n\nOS/BH Version 7.03" },
 	{ 3, "2" },
@@ -706,7 +706,7 @@ const StrEntry Video::_stringsTable3DO[] = {
 	{ 0xFFFF, 0 }
 };
 
-const char *Video::_noteText3DO = {
+const char *Video::NOTE_TEXT_3DO = {
 	"From the diary of Lester Knight\n"
 	"Chaykin.\n"
 	"\n"
@@ -738,7 +738,7 @@ const char *Video::_noteText3DO = {
 	"moving along before I...\n"
 };
 
-const char *Video::_endText3DO = {
+const char *Video::END_TEXT_3DO = {
 	"Original Programming, Artwork, &\n"
 	"Design\n"
 	"Eric Chahi\n"
@@ -810,7 +810,7 @@ const char *Video::_endText3DO = {
 	"Bill \"Angus\" Guschwan at 3DO\n"
 };
 
-static const uint8_t _verticesData3DO[] = {
+static const uint8_t VERTICES_DATA_3DO[] = {
 	0x0f, 0x10, 0x05, 0x10, 0x05, 0x0f, 0x05, 0x0e, 0x04, 0x0e, 0x04, 0x0d, 0x03, 0x0c, 0x03, 0x0b,
 	0x02, 0x0b, 0x02, 0x0a, 0x01, 0x09, 0x01, 0x08, 0x01, 0x08, 0x01, 0x07, 0x01, 0x06, 0x01, 0x06,
 	0x01, 0x06, 0x00, 0x05, 0x0b, 0x17, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x01, 0x07,
@@ -1206,211 +1206,211 @@ static const uint8_t _verticesData3DO[] = {
 	0x01, 0x02, 0x00, 0x00, 0x06, 0x04, 0x00, 0x03, 0x01, 0x04, 0x03, 0x04, 0x04, 0x05, 0x00, 0x00
 };
 
-const uint8_t *Video::_vertices3DO[201] = {
-	&_verticesData3DO[0],
-	&_verticesData3DO[36],
-	&_verticesData3DO[84],
-	&_verticesData3DO[112],
-	&_verticesData3DO[144],
-	&_verticesData3DO[208],
-	&_verticesData3DO[244],
-	&_verticesData3DO[296],
-	&_verticesData3DO[328],
-	&_verticesData3DO[368],
-	&_verticesData3DO[412],
-	&_verticesData3DO[444],
-	&_verticesData3DO[476],
-	&_verticesData3DO[540],
-	&_verticesData3DO[584],
-	&_verticesData3DO[628],
-	&_verticesData3DO[660],
-	&_verticesData3DO[688],
-	&_verticesData3DO[728],
-	&_verticesData3DO[768],
-	&_verticesData3DO[804],
-	&_verticesData3DO[844],
-	&_verticesData3DO[872],
-	&_verticesData3DO[936],
-	&_verticesData3DO[976],
-	&_verticesData3DO[1020],
-	&_verticesData3DO[1060],
-	&_verticesData3DO[1100],
-	&_verticesData3DO[1132],
-	&_verticesData3DO[1196],
-	&_verticesData3DO[1260],
-	&_verticesData3DO[1324],
-	&_verticesData3DO[1392],
-	&_verticesData3DO[1460],
-	&_verticesData3DO[1528],
-	&_verticesData3DO[1596],
-	&_verticesData3DO[1664],
-	&_verticesData3DO[1732],
-	&_verticesData3DO[1760],
-	&_verticesData3DO[1808],
-	&_verticesData3DO[1844],
-	&_verticesData3DO[1876],
-	&_verticesData3DO[1940],
-	&_verticesData3DO[1976],
-	&_verticesData3DO[2028],
-	&_verticesData3DO[2052],
-	&_verticesData3DO[2084],
-	&_verticesData3DO[2124],
-	&_verticesData3DO[2168],
-	&_verticesData3DO[2200],
-	&_verticesData3DO[2232],
-	&_verticesData3DO[2276],
-	&_verticesData3DO[2320],
-	&_verticesData3DO[2348],
-	&_verticesData3DO[2388],
-	&_verticesData3DO[2428],
-	&_verticesData3DO[2464],
-	&_verticesData3DO[2528],
-	&_verticesData3DO[2568],
-	&_verticesData3DO[2596],
-	&_verticesData3DO[2660],
-	&_verticesData3DO[2700],
-	&_verticesData3DO[2744],
-	&_verticesData3DO[2784],
-	&_verticesData3DO[2824],
-	&_verticesData3DO[2856],
-	&_verticesData3DO[2920],
-	&_verticesData3DO[2984],
-	&_verticesData3DO[3048],
-	&_verticesData3DO[3116],
-	&_verticesData3DO[3184],
-	&_verticesData3DO[3252],
-	&_verticesData3DO[3320],
-	&_verticesData3DO[3388],
-	&_verticesData3DO[3456],
-	&_verticesData3DO[3476],
-	&_verticesData3DO[3488],
-	&_verticesData3DO[3504],
-	&_verticesData3DO[3516],
-	&_verticesData3DO[3528],
-	&_verticesData3DO[3548],
-	&_verticesData3DO[3560],
-	&_verticesData3DO[3572],
-	&_verticesData3DO[3584],
-	&_verticesData3DO[3596],
-	&_verticesData3DO[3624],
-	&_verticesData3DO[3652],
-	&_verticesData3DO[3680],
-	&_verticesData3DO[3708],
-	&_verticesData3DO[3736],
-	&_verticesData3DO[3764],
-	&_verticesData3DO[3796],
-	&_verticesData3DO[3828],
-	&_verticesData3DO[3860],
-	&_verticesData3DO[3892],
-	&_verticesData3DO[3928],
-	&_verticesData3DO[3964],
-	&_verticesData3DO[4000],
-	&_verticesData3DO[4036],
-	&_verticesData3DO[4072],
-	&_verticesData3DO[4080],
-	&_verticesData3DO[4088],
-	&_verticesData3DO[4100],
-	&_verticesData3DO[4108],
-	&_verticesData3DO[4116],
-	&_verticesData3DO[4128],
-	&_verticesData3DO[4136],
-	&_verticesData3DO[4152],
-	&_verticesData3DO[4184],
-	&_verticesData3DO[4216],
-	&_verticesData3DO[4248],
-	&_verticesData3DO[4280],
-	&_verticesData3DO[4316],
-	&_verticesData3DO[4352],
-	&_verticesData3DO[4388],
-	&_verticesData3DO[4424],
-	&_verticesData3DO[4460],
-	&_verticesData3DO[4468],
-	&_verticesData3DO[4476],
-	&_verticesData3DO[4488],
-	&_verticesData3DO[4496],
-	&_verticesData3DO[4504],
-	&_verticesData3DO[4516],
-	&_verticesData3DO[4524],
-	&_verticesData3DO[4540],
-	&_verticesData3DO[4568],
-	&_verticesData3DO[4600],
-	&_verticesData3DO[4628],
-	&_verticesData3DO[4668],
-	&_verticesData3DO[4696],
-	&_verticesData3DO[4736],
-	&_verticesData3DO[4764],
-	&_verticesData3DO[4788],
-	&_verticesData3DO[4816],
-	&_verticesData3DO[4848],
-	&_verticesData3DO[4908],
-	&_verticesData3DO[4968],
-	&_verticesData3DO[4996],
-	&_verticesData3DO[5012],
-	&_verticesData3DO[5024],
-	&_verticesData3DO[5040],
-	&_verticesData3DO[5056],
-	&_verticesData3DO[5072],
-	&_verticesData3DO[5088],
-	&_verticesData3DO[5104],
-	&_verticesData3DO[5120],
-	&_verticesData3DO[5156],
-	&_verticesData3DO[5172],
-	&_verticesData3DO[5204],
-	&_verticesData3DO[5264],
-	&_verticesData3DO[5292],
-	&_verticesData3DO[5316],
-	&_verticesData3DO[5376],
-	&_verticesData3DO[5404],
-	&_verticesData3DO[5432],
-	&_verticesData3DO[5440],
-	&_verticesData3DO[5448],
-	&_verticesData3DO[5456],
-	&_verticesData3DO[5464],
-	&_verticesData3DO[5472],
-	&_verticesData3DO[5488],
-	&_verticesData3DO[5508],
-	&_verticesData3DO[5524],
-	&_verticesData3DO[5544],
-	&_verticesData3DO[5552],
-	&_verticesData3DO[5576],
-	&_verticesData3DO[5584],
-	&_verticesData3DO[5608],
-	&_verticesData3DO[5616],
-	&_verticesData3DO[5636],
-	&_verticesData3DO[5656],
-	&_verticesData3DO[5676],
-	&_verticesData3DO[5696],
-	&_verticesData3DO[5716],
-	&_verticesData3DO[5736],
-	&_verticesData3DO[5756],
-	&_verticesData3DO[5776],
-	&_verticesData3DO[5796],
-	&_verticesData3DO[5808],
-	&_verticesData3DO[5832],
-	&_verticesData3DO[5856],
-	&_verticesData3DO[5880],
-	&_verticesData3DO[5900],
-	&_verticesData3DO[5924],
-	&_verticesData3DO[5944],
-	&_verticesData3DO[5960],
-	&_verticesData3DO[5976],
-	&_verticesData3DO[5992],
-	&_verticesData3DO[6012],
-	&_verticesData3DO[6032],
-	&_verticesData3DO[6052],
-	&_verticesData3DO[6072],
-	&_verticesData3DO[6096],
-	&_verticesData3DO[6120],
-	&_verticesData3DO[6144],
-	&_verticesData3DO[6164],
-	&_verticesData3DO[6188],
-	&_verticesData3DO[6224],
-	&_verticesData3DO[6240],
-	&_verticesData3DO[6264],
-	&_verticesData3DO[6276],
+const uint8_t *Video::VERTICES_3DO[201] = {
+	&VERTICES_DATA_3DO[0],
+	&VERTICES_DATA_3DO[36],
+	&VERTICES_DATA_3DO[84],
+	&VERTICES_DATA_3DO[112],
+	&VERTICES_DATA_3DO[144],
+	&VERTICES_DATA_3DO[208],
+	&VERTICES_DATA_3DO[244],
+	&VERTICES_DATA_3DO[296],
+	&VERTICES_DATA_3DO[328],
+	&VERTICES_DATA_3DO[368],
+	&VERTICES_DATA_3DO[412],
+	&VERTICES_DATA_3DO[444],
+	&VERTICES_DATA_3DO[476],
+	&VERTICES_DATA_3DO[540],
+	&VERTICES_DATA_3DO[584],
+	&VERTICES_DATA_3DO[628],
+	&VERTICES_DATA_3DO[660],
+	&VERTICES_DATA_3DO[688],
+	&VERTICES_DATA_3DO[728],
+	&VERTICES_DATA_3DO[768],
+	&VERTICES_DATA_3DO[804],
+	&VERTICES_DATA_3DO[844],
+	&VERTICES_DATA_3DO[872],
+	&VERTICES_DATA_3DO[936],
+	&VERTICES_DATA_3DO[976],
+	&VERTICES_DATA_3DO[1020],
+	&VERTICES_DATA_3DO[1060],
+	&VERTICES_DATA_3DO[1100],
+	&VERTICES_DATA_3DO[1132],
+	&VERTICES_DATA_3DO[1196],
+	&VERTICES_DATA_3DO[1260],
+	&VERTICES_DATA_3DO[1324],
+	&VERTICES_DATA_3DO[1392],
+	&VERTICES_DATA_3DO[1460],
+	&VERTICES_DATA_3DO[1528],
+	&VERTICES_DATA_3DO[1596],
+	&VERTICES_DATA_3DO[1664],
+	&VERTICES_DATA_3DO[1732],
+	&VERTICES_DATA_3DO[1760],
+	&VERTICES_DATA_3DO[1808],
+	&VERTICES_DATA_3DO[1844],
+	&VERTICES_DATA_3DO[1876],
+	&VERTICES_DATA_3DO[1940],
+	&VERTICES_DATA_3DO[1976],
+	&VERTICES_DATA_3DO[2028],
+	&VERTICES_DATA_3DO[2052],
+	&VERTICES_DATA_3DO[2084],
+	&VERTICES_DATA_3DO[2124],
+	&VERTICES_DATA_3DO[2168],
+	&VERTICES_DATA_3DO[2200],
+	&VERTICES_DATA_3DO[2232],
+	&VERTICES_DATA_3DO[2276],
+	&VERTICES_DATA_3DO[2320],
+	&VERTICES_DATA_3DO[2348],
+	&VERTICES_DATA_3DO[2388],
+	&VERTICES_DATA_3DO[2428],
+	&VERTICES_DATA_3DO[2464],
+	&VERTICES_DATA_3DO[2528],
+	&VERTICES_DATA_3DO[2568],
+	&VERTICES_DATA_3DO[2596],
+	&VERTICES_DATA_3DO[2660],
+	&VERTICES_DATA_3DO[2700],
+	&VERTICES_DATA_3DO[2744],
+	&VERTICES_DATA_3DO[2784],
+	&VERTICES_DATA_3DO[2824],
+	&VERTICES_DATA_3DO[2856],
+	&VERTICES_DATA_3DO[2920],
+	&VERTICES_DATA_3DO[2984],
+	&VERTICES_DATA_3DO[3048],
+	&VERTICES_DATA_3DO[3116],
+	&VERTICES_DATA_3DO[3184],
+	&VERTICES_DATA_3DO[3252],
+	&VERTICES_DATA_3DO[3320],
+	&VERTICES_DATA_3DO[3388],
+	&VERTICES_DATA_3DO[3456],
+	&VERTICES_DATA_3DO[3476],
+	&VERTICES_DATA_3DO[3488],
+	&VERTICES_DATA_3DO[3504],
+	&VERTICES_DATA_3DO[3516],
+	&VERTICES_DATA_3DO[3528],
+	&VERTICES_DATA_3DO[3548],
+	&VERTICES_DATA_3DO[3560],
+	&VERTICES_DATA_3DO[3572],
+	&VERTICES_DATA_3DO[3584],
+	&VERTICES_DATA_3DO[3596],
+	&VERTICES_DATA_3DO[3624],
+	&VERTICES_DATA_3DO[3652],
+	&VERTICES_DATA_3DO[3680],
+	&VERTICES_DATA_3DO[3708],
+	&VERTICES_DATA_3DO[3736],
+	&VERTICES_DATA_3DO[3764],
+	&VERTICES_DATA_3DO[3796],
+	&VERTICES_DATA_3DO[3828],
+	&VERTICES_DATA_3DO[3860],
+	&VERTICES_DATA_3DO[3892],
+	&VERTICES_DATA_3DO[3928],
+	&VERTICES_DATA_3DO[3964],
+	&VERTICES_DATA_3DO[4000],
+	&VERTICES_DATA_3DO[4036],
+	&VERTICES_DATA_3DO[4072],
+	&VERTICES_DATA_3DO[4080],
+	&VERTICES_DATA_3DO[4088],
+	&VERTICES_DATA_3DO[4100],
+	&VERTICES_DATA_3DO[4108],
+	&VERTICES_DATA_3DO[4116],
+	&VERTICES_DATA_3DO[4128],
+	&VERTICES_DATA_3DO[4136],
+	&VERTICES_DATA_3DO[4152],
+	&VERTICES_DATA_3DO[4184],
+	&VERTICES_DATA_3DO[4216],
+	&VERTICES_DATA_3DO[4248],
+	&VERTICES_DATA_3DO[4280],
+	&VERTICES_DATA_3DO[4316],
+	&VERTICES_DATA_3DO[4352],
+	&VERTICES_DATA_3DO[4388],
+	&VERTICES_DATA_3DO[4424],
+	&VERTICES_DATA_3DO[4460],
+	&VERTICES_DATA_3DO[4468],
+	&VERTICES_DATA_3DO[4476],
+	&VERTICES_DATA_3DO[4488],
+	&VERTICES_DATA_3DO[4496],
+	&VERTICES_DATA_3DO[4504],
+	&VERTICES_DATA_3DO[4516],
+	&VERTICES_DATA_3DO[4524],
+	&VERTICES_DATA_3DO[4540],
+	&VERTICES_DATA_3DO[4568],
+	&VERTICES_DATA_3DO[4600],
+	&VERTICES_DATA_3DO[4628],
+	&VERTICES_DATA_3DO[4668],
+	&VERTICES_DATA_3DO[4696],
+	&VERTICES_DATA_3DO[4736],
+	&VERTICES_DATA_3DO[4764],
+	&VERTICES_DATA_3DO[4788],
+	&VERTICES_DATA_3DO[4816],
+	&VERTICES_DATA_3DO[4848],
+	&VERTICES_DATA_3DO[4908],
+	&VERTICES_DATA_3DO[4968],
+	&VERTICES_DATA_3DO[4996],
+	&VERTICES_DATA_3DO[5012],
+	&VERTICES_DATA_3DO[5024],
+	&VERTICES_DATA_3DO[5040],
+	&VERTICES_DATA_3DO[5056],
+	&VERTICES_DATA_3DO[5072],
+	&VERTICES_DATA_3DO[5088],
+	&VERTICES_DATA_3DO[5104],
+	&VERTICES_DATA_3DO[5120],
+	&VERTICES_DATA_3DO[5156],
+	&VERTICES_DATA_3DO[5172],
+	&VERTICES_DATA_3DO[5204],
+	&VERTICES_DATA_3DO[5264],
+	&VERTICES_DATA_3DO[5292],
+	&VERTICES_DATA_3DO[5316],
+	&VERTICES_DATA_3DO[5376],
+	&VERTICES_DATA_3DO[5404],
+	&VERTICES_DATA_3DO[5432],
+	&VERTICES_DATA_3DO[5440],
+	&VERTICES_DATA_3DO[5448],
+	&VERTICES_DATA_3DO[5456],
+	&VERTICES_DATA_3DO[5464],
+	&VERTICES_DATA_3DO[5472],
+	&VERTICES_DATA_3DO[5488],
+	&VERTICES_DATA_3DO[5508],
+	&VERTICES_DATA_3DO[5524],
+	&VERTICES_DATA_3DO[5544],
+	&VERTICES_DATA_3DO[5552],
+	&VERTICES_DATA_3DO[5576],
+	&VERTICES_DATA_3DO[5584],
+	&VERTICES_DATA_3DO[5608],
+	&VERTICES_DATA_3DO[5616],
+	&VERTICES_DATA_3DO[5636],
+	&VERTICES_DATA_3DO[5656],
+	&VERTICES_DATA_3DO[5676],
+	&VERTICES_DATA_3DO[5696],
+	&VERTICES_DATA_3DO[5716],
+	&VERTICES_DATA_3DO[5736],
+	&VERTICES_DATA_3DO[5756],
+	&VERTICES_DATA_3DO[5776],
+	&VERTICES_DATA_3DO[5796],
+	&VERTICES_DATA_3DO[5808],
+	&VERTICES_DATA_3DO[5832],
+	&VERTICES_DATA_3DO[5856],
+	&VERTICES_DATA_3DO[5880],
+	&VERTICES_DATA_3DO[5900],
+	&VERTICES_DATA_3DO[5924],
+	&VERTICES_DATA_3DO[5944],
+	&VERTICES_DATA_3DO[5960],
+	&VERTICES_DATA_3DO[5976],
+	&VERTICES_DATA_3DO[5992],
+	&VERTICES_DATA_3DO[6012],
+	&VERTICES_DATA_3DO[6032],
+	&VERTICES_DATA_3DO[6052],
+	&VERTICES_DATA_3DO[6072],
+	&VERTICES_DATA_3DO[6096],
+	&VERTICES_DATA_3DO[6120],
+	&VERTICES_DATA_3DO[6144],
+	&VERTICES_DATA_3DO[6164],
+	&VERTICES_DATA_3DO[6188],
+	&VERTICES_DATA_3DO[6224],
+	&VERTICES_DATA_3DO[6240],
+	&VERTICES_DATA_3DO[6264],
+	&VERTICES_DATA_3DO[6276],
 };
 
-const uint16_t Gfx::_shapesMaskOffset[] = {
+const uint16_t Gfx::SHAPES_MASK_OFFSET[] = {
 	0x0000, 0x0022, 0x0052, 0x006c, 0x008c, 0x00ca, 0x0110, 0x0142,
 	0x0180, 0x01a8, 0x01fe, 0x021c, 0x025a, 0x0298, 0x02c2, 0x0314,
 	0x0334, 0x034e, 0x0376, 0x039e, 0x03c0, 0x03e8, 0x0402, 0x0440,
@@ -1439,9 +1439,9 @@ const uint16_t Gfx::_shapesMaskOffset[] = {
 	0x1c16
 };
 
-const int Gfx::_shapesMaskCount = ARRAYSIZE(_shapesMaskOffset);
+const int Gfx::SHAPES_MASK_COUNT = ARRAYSIZE(SHAPES_MASK_OFFSET);
 
-const uint8_t Gfx::_shapesMaskData[] = {
+const uint8_t Gfx::SHAPES_MASK_DATA[] = {
 	0x0f, 0x10, 0x07, 0xff, 0x07, 0xfe, 0x0f, 0xfe, 0x0f, 0xfc, 0x1f, 0xf8, 0x1f, 0xf0, 0x3f, 0xf0,
 	0x3f, 0xe0, 0x7f, 0xc0, 0x7f, 0x80, 0x7f, 0x80, 0x7f, 0x00, 0x7e, 0x00, 0x7e, 0x00, 0x7e, 0x00,
 	0xfc, 0x00, 0x0b, 0x17, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x7f, 0x00, 0x7f, 0x00,
@@ -1899,7 +1899,7 @@ const uint8_t Gfx::_shapesMaskData[] = {
 };
 
 // from https://en.wikipedia.org/wiki/Enhanced_Graphics_Adapter
-const uint8_t Video::_paletteEGA[] = {
+const uint8_t Video::PALETTE_EGA[] = {
         0x00, 0x00, 0x00, // black #0
         0x00, 0x00, 0xAA, // blue #1
         0x00, 0xAA, 0x00, // green #2
@@ -1918,7 +1918,7 @@ const uint8_t Video::_paletteEGA[] = {
         0xFF, 0xFF, 0xFF, // bright white #63
 };
 
-const AmigaMemEntry Resource::_memListAmigaFR[146] = {
+const AmigaMemEntry Resource::MEMLIST_AMIGA_FR[146] = {
 	{ 0, 0x1, 0x000000, 0x0000, 0x0000 },
 	{ 0, 0x1, 0x000000, 0x1A3C, 0x1A3C },
 	{ 0, 0x1, 0x001A3C, 0x2E34, 0x2E34 },
@@ -2067,7 +2067,7 @@ const AmigaMemEntry Resource::_memListAmigaFR[146] = {
 	{ 2, 0xB, 0x009882, 0x33C0, 0x7D00 },
 };
 
-const AmigaMemEntry Resource::_memListAmigaEN[146] = {
+const AmigaMemEntry Resource::MEMLIST_AMIGA_EN[146] = {
 	{ 0, 0x1, 0x000000, 0x0000, 0x0000 },
 	{ 0, 0x1, 0x000000, 0x1A3C, 0x1A3C },
 	{ 0, 0x1, 0x001A3C, 0x2E34, 0x2E34 },
@@ -2216,7 +2216,7 @@ const AmigaMemEntry Resource::_memListAmigaEN[146] = {
 	{ 2, 0xB, 0x009886, 0x33C0, 0X7D00 },
 };
 
-const AmigaMemEntry Resource::_memListAtariEN[146] = {
+const AmigaMemEntry Resource::MEMLIST_ATARI_EN[146] = {
 	{ 0, 0x1, 0x000000, 0x0000, 0x0000 },
 	{ 0, 0x1, 0x000000, 0x1A3C, 0x1A3C },
 	{ 0, 0x1, 0x001A3C, 0x2E34, 0x2E34 },
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index 83888b33483..ae083040102 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -118,8 +118,8 @@ void Video::drawShape(uint8_t color, uint16_t zoom, const Point *pt) {
 }
 
 void Video::drawShapePart3DO(int color, int part, const Point *pt) {
-	assert(part < (int)ARRAYSIZE(_vertices3DO));
-	const uint8_t *vertices = _vertices3DO[part];
+	assert(part < (int)ARRAYSIZE(VERTICES_3DO));
+	const uint8_t *vertices = VERTICES_3DO[part];
 	const int w = *vertices++;
 	const int h = *vertices++;
 	const int x = pt->x - w / 2;
@@ -332,12 +332,12 @@ void Video::drawString(uint8_t color, uint16_t x, uint16_t y, uint16_t strId) {
 	const char *str = 0;
 	if (_res->getDataType() == DT_15TH_EDITION || _res->getDataType() == DT_20TH_EDITION) {
 		for (int i = 0; i < NTH_EDITION_STRINGS_COUNT; ++i) {
-			if (Video::_stringsId15th[i] == strId) {
+			if (Video::STRINGS_ID_15TH[i] == strId) {
 				str = _res->getString(i);
 				if (str) {
 					escapedChars = true;
 				} else {
-					str = Video::_stringsTable15th[i];
+					str = Video::STRINGS_TABLE_15TH[i];
 				}
 				break;
 			}
@@ -345,13 +345,13 @@ void Video::drawString(uint8_t color, uint16_t x, uint16_t y, uint16_t strId) {
 	} else if (_res->getDataType() == DT_WIN31) {
 		str = _res->getString(strId);
 	} else if (_res->getDataType() == DT_3DO) {
-		str = findString(_stringsTable3DO, strId);
+		str = findString(STRINGS_TABLE_3DO, strId);
 	} else if (_res->getDataType() == DT_ATARI_DEMO && strId == 0x194) {
 		str = _str0x194AtariDemo;
 	} else {
 		str = findString(_stringsTable, strId);
 		if (!str && _res->getDataType() == DT_DOS) {
-			str = findString(_stringsTableDemo, strId);
+			str = findString(STRINGS_TABLE_DEMO, strId);
 		}
 	}
 	if (!str) {
@@ -556,7 +556,7 @@ static void readPaletteEGA(const uint8_t *buf, int num, Color pal[16]) {
 	for (int i = 0; i < 16; ++i) {
 		const uint16_t color = READ_BE_UINT16(p); p += 2;
 		if (1) {
-			const uint8_t *ega = &Video::_paletteEGA[3 * ((color >> 12) & 15)];
+			const uint8_t *ega = &Video::PALETTE_EGA[3 * ((color >> 12) & 15)];
 			pal[i].r = ega[0];
 			pal[i].g = ega[1];
 			pal[i].b = ega[2];
diff --git a/engines/awe/video.h b/engines/awe/video.h
index 6b14be897a3..c8b59bc9c90 100644
--- a/engines/awe/video.h
+++ b/engines/awe/video.h
@@ -42,17 +42,17 @@ struct Video {
 		BITMAP_H = 200
 	};
 
-	static const StrEntry _stringsTableFr[];
-	static const StrEntry _stringsTableEng[];
-	static const StrEntry _stringsTableDemo[];
-	static const uint16_t _stringsId15th[];
-	static const char *_stringsTable15th[];
+	static const StrEntry STRINGS_TABLE_FR[];
+	static const StrEntry STRINGS_TABLE_ENG[];
+	static const StrEntry STRINGS_TABLE_DEMO[];
+	static const uint16_t STRINGS_ID_15TH[];
+	static const char *STRINGS_TABLE_15TH[];
 	static const char *_str0x194AtariDemo;
-	static const StrEntry _stringsTable3DO[];
-	static const char *_noteText3DO;
-	static const char *_endText3DO;
-	static const uint8_t *_vertices3DO[201];
-	static const uint8_t _paletteEGA[];
+	static const StrEntry STRINGS_TABLE_3DO[];
+	static const char *NOTE_TEXT_3DO;
+	static const char *END_TEXT_3DO;
+	static const uint8_t *VERTICES_3DO[201];
+	static const uint8_t PALETTE_EGA[];
 
 	static bool _useEGA;
 


Commit: 575e53595d99ef4e113c93e3d51886036970f5d3
    https://github.com/scummvm/scummvm/commit/575e53595d99ef4e113c93e3d51886036970f5d3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Assert for graphics interface creation

Changed paths:
    engines/awe/awe.cpp


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 04b1357a81e..3215af9b4f7 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -77,6 +77,7 @@ static Gfx *createGraphics(int type) {
 		return GraphicsGL_create();
 #endif
 	}
+
 	return 0;
 }
 
@@ -141,6 +142,8 @@ Common::Error AweEngine::run() {
 	}
 
 	Gfx *graphics = createGraphics(graphicsType);
+	assert(graphics);
+
 	if (dataType == DT_20TH_EDITION) {
 		switch (Script::_difficulty) {
 		case DIFFICULTY_EASY:


Commit: 00c97f62c0a6d3a90cf16497b403e2d71535b3fd
    https://github.com/scummvm/scummvm/commit/00c97f62c0a6d3a90cf16497b403e2d71535b3fd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Remove remaining in-engine scaling code

Changed paths:
  R engines/awe/scaler.cpp
  R engines/awe/scaler.h
    engines/awe/awe.cpp
    engines/awe/engine.cpp
    engines/awe/engine.h
    engines/awe/module.mk
    engines/awe/video.cpp
    engines/awe/video.h


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 3215af9b4f7..3034f699908 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -26,7 +26,6 @@
 #include "awe/engine.h"
 #include "awe/gfx.h"
 #include "awe/resource.h"
-#include "awe/scaler.h"
 #include "awe/script.h"
 #include "awe/system_stub.h"
 #include "awe/util.h"
@@ -175,7 +174,7 @@ Common::Error AweEngine::run() {
 	}
 
 	e->_res._copyProtection = ConfMan.getBool("copy_protection");
-	e->setup(lang, graphicsType, nullptr, 1);
+	e->setup(lang, graphicsType);
 
 	while (!stub->_pi.quit) {
 		e->run();
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index 5a4ded5e7e8..934921047bb 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -87,17 +87,16 @@ void Engine::run() {
 	}
 }
 
-void Engine::setup(Language lang, int graphicsType, const char *scalerName, int scalerFactor) {
+void Engine::setup(Language lang, int graphicsType) {
 	_vid._graphics = _graphics;
-	int w = GFX_W * scalerFactor;
-	int h = GFX_H * scalerFactor;
+	int w = GFX_W;
+	int h = GFX_H;
 	if (_res.getDataType() != DT_3DO) {
 		_vid._graphics->_fixUpPalette = FIXUP_PALETTE_REDRAW;
 	}
+
 	_vid.init();
-	if (scalerFactor > 1) {
-		_vid.setScaler(scalerName, scalerFactor);
-	}
+
 	_res._lang = lang;
 	_res.allocMemBlock();
 	_res.readEntries();
diff --git a/engines/awe/engine.h b/engines/awe/engine.h
index 5bcfc9fd6f6..74b8c8de473 100644
--- a/engines/awe/engine.h
+++ b/engines/awe/engine.h
@@ -48,11 +48,11 @@ struct Engine {
 	Gfx *_graphics = nullptr;
 	SystemStub *_stub = nullptr;
 	Script _script;
-	Sound *_sound;
+	Sound *_sound = nullptr;
 	Resource _res;
 	SfxPlayer _ply;
 	Video _vid;
-	int _partNum;
+	int _partNum = 0;
 
 	Engine(Sound *sound, DataType dataType, int partNum);
 
@@ -63,7 +63,7 @@ struct Engine {
 	}
 
 	void run();
-	void setup(Language lang, int graphicsType, const char *scalerName, int scalerFactor);
+	void setup(Language lang, int graphicsType);
 	void finish();
 	void processInput();
 
diff --git a/engines/awe/module.mk b/engines/awe/module.mk
index ef9f8c1bb5d..eeabc223db8 100644
--- a/engines/awe/module.mk
+++ b/engines/awe/module.mk
@@ -16,7 +16,6 @@ MODULE_OBJS = \
 	resource_3do.o \
 	resource_nth.o \
 	resource_win31.o \
-	scaler.o \
 	script.o \
 	sfx_player.o \
 	sound.o \
diff --git a/engines/awe/scaler.cpp b/engines/awe/scaler.cpp
deleted file mode 100644
index 5f22a50a52e..00000000000
--- a/engines/awe/scaler.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "awe/scaler.h"
-
-namespace Awe {
-
-const Scaler *findScaler(const char *name) {
-	return 0;
-}
-
-} // namespace Awe
diff --git a/engines/awe/scaler.h b/engines/awe/scaler.h
deleted file mode 100644
index da6be0b532a..00000000000
--- a/engines/awe/scaler.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AWE_SCALER_H
-#define AWE_SCALER_H
-
-#include "awe/intern.h"
-
-namespace Awe {
-
-typedef void (*ScaleProc)(int factor, int byteDepth, uint8_t *dst, int dstPitch, const uint8_t *src, int srcPitch, int w, int h);
-
-#define SCALER_TAG 1
-
-struct Scaler {
-	uint32_t tag;
-	const char *name;
-	int factorMin, factorMax;
-	int bpp;
-	ScaleProc scale;
-};
-
-const Scaler *findScaler(const char *name);
-
-} // namespace Awe
-
-#endif
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index ae083040102..63bba627f0e 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -25,18 +25,12 @@
 #include "awe/gfx.h"
 #include "awe/resource.h"
 #include "awe/resource_3do.h"
-#include "awe/scaler.h"
 #include "awe/system_stub.h"
 #include "awe/util.h"
 
 namespace Awe {
 
-Video::Video(Resource *res)
-	: _res(res), _graphics(0), _hasHeadSprites(false), _displayHead(true) {
-}
-
-Video::~Video() {
-	free(_scalerBuffer);
+Video::Video(Resource *res) : _res(res) {
 }
 
 void Video::init() {
@@ -45,29 +39,6 @@ void Video::init() {
 	_buffers[1] = getPagePtr(2);
 	setWorkPagePtr(0xFE);
 	_pData.byteSwap = (_res->getDataType() == DT_3DO);
-	_scaler = 0;
-	_scalerBuffer = 0;
-}
-
-void Video::setScaler(const char *name, int factor) {
-	_scaler = findScaler(name);
-	if (!_scaler) {
-		warning("Scaler '%s' not found", name);
-	} else {
-		const int byteDepth = (_res->getDataType() == DT_3DO) ? 2 : 1;
-		if ((_scaler->bpp & (byteDepth * 8)) == 0) {
-			warning("Scaler '%s' does not support %d bits per pixel", name, (byteDepth << 8));
-			_scaler = 0;
-		} else {
-			if (factor < _scaler->factorMin) {
-				factor = _scaler->factorMin;
-			} else if (factor > _scaler->factorMax) {
-				factor = _scaler->factorMax;
-			}
-			_scalerFactor = factor;
-			_scalerBuffer = (uint8_t *)malloc((BITMAP_W * _scalerFactor) * (BITMAP_H * _scalerFactor) * byteDepth);
-		}
-	}
 }
 
 void Video::setDefaultFont() {
@@ -482,15 +453,7 @@ static void yflip(const uint8_t *src, int w, int h, uint8_t *dst) {
 }
 
 void Video::scaleBitmap(const uint8_t *src, int fmt) {
-	if (_scaler) {
-		const int w = BITMAP_W * _scalerFactor;
-		const int h = BITMAP_H * _scalerFactor;
-		const int depth = (fmt == FMT_CLUT) ? 1 : 2;
-		_scaler->scale(_scalerFactor, depth, _scalerBuffer, w * depth, src, BITMAP_W * depth, BITMAP_W, BITMAP_H);
-		_graphics->drawBitmap(_buffers[0], _scalerBuffer, w, h, fmt);
-	} else {
-		_graphics->drawBitmap(_buffers[0], src, BITMAP_W, BITMAP_H, fmt);
-	}
+	_graphics->drawBitmap(_buffers[0], src, BITMAP_W, BITMAP_H, fmt);
 }
 
 void Video::copyBitmapPtr(const uint8_t *src, uint32_t size) {
diff --git a/engines/awe/video.h b/engines/awe/video.h
index c8b59bc9c90..90e1fc99e8e 100644
--- a/engines/awe/video.h
+++ b/engines/awe/video.h
@@ -59,7 +59,7 @@ struct Video {
 	Resource *_res;
 	Gfx *_graphics = nullptr;
 	bool _hasHeadSprites = false;
-	bool _displayHead = false;
+	bool _displayHead = true;
 
 	uint8_t _nextPal = 0, _currentPal = 0;
 	uint8_t _buffers[3] = { 0 };
@@ -68,15 +68,11 @@ struct Video {
 	const StrEntry *_stringsTable = nullptr;
 	uint8_t _tempBitmap[BITMAP_W * BITMAP_H] = { 0 };
 	uint16_t _bitmap555[BITMAP_W * BITMAP_H] = { 0 };
-	const Scaler *_scaler = nullptr;
-	int _scalerFactor = 0;
-	uint8_t *_scalerBuffer = nullptr;
 
 	Video(Resource *res);
-	~Video();
+	~Video() {}
 	void init();
 
-	void setScaler(const char *name, int factor);
 	void setDefaultFont();
 	void setFont(const uint8_t *font);
 	void setHeads(const uint8_t *src);


Commit: a73c78e96c98368ca4b23759b37f727a48765b7f
    https://github.com/scummvm/scummvm/commit/a73c78e96c98368ca4b23759b37f727a48765b7f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Change _t types to ScummVM equivalent types

Changed paths:
    engines/awe/aifc_player.cpp
    engines/awe/aifc_player.h
    engines/awe/bitmap.cpp
    engines/awe/bitmap.h
    engines/awe/engine.cpp
    engines/awe/engine.h
    engines/awe/file.cpp
    engines/awe/file.h
    engines/awe/gfx.h
    engines/awe/graphics_gl.cpp
    engines/awe/graphics_soft.cpp
    engines/awe/intern.h
    engines/awe/pak.cpp
    engines/awe/pak.h
    engines/awe/resource.cpp
    engines/awe/resource.h
    engines/awe/resource_3do.cpp
    engines/awe/resource_3do.h
    engines/awe/resource_nth.cpp
    engines/awe/resource_nth.h
    engines/awe/resource_win31.cpp
    engines/awe/resource_win31.h
    engines/awe/script.cpp
    engines/awe/script.h
    engines/awe/sfx_player.cpp
    engines/awe/sfx_player.h
    engines/awe/sound.cpp
    engines/awe/sound.h
    engines/awe/static_res.cpp
    engines/awe/system_stub.cpp
    engines/awe/system_stub.h
    engines/awe/unpack.cpp
    engines/awe/unpack.h
    engines/awe/util.cpp
    engines/awe/util.h
    engines/awe/video.cpp
    engines/awe/video.h


diff --git a/engines/awe/aifc_player.cpp b/engines/awe/aifc_player.cpp
index 8f4f0c8413b..e7040b934af 100644
--- a/engines/awe/aifc_player.cpp
+++ b/engines/awe/aifc_player.cpp
@@ -24,8 +24,8 @@
 
 namespace Awe {
 
-static uint32_t READ_IEEE754(const uint8_t *p) {
-	const uint32_t m = READ_BE_UINT32(p + 2);
+static uint32 READ_IEEE754(const uint8 *p) {
+	const uint32 m = READ_BE_UINT32(p + 2);
 	const int exp = 30 - p[1];
 	return (m >> exp);
 }
@@ -33,18 +33,18 @@ static uint32_t READ_IEEE754(const uint8_t *p) {
 AifcPlayer::AifcPlayer() {
 }
 
-bool AifcPlayer::play(int mixRate, const char *path, uint32_t startOffset) {
+bool AifcPlayer::play(int mixRate, const char *path, uint32 startOffset) {
 	_ssndSize = 0;
 	if (_f.open(path)) {
 		_f.seek(startOffset);
-		uint8_t buf[12];
+		uint8 buf[12];
 		_f.read(buf, sizeof(buf));
 		if (memcmp(buf, "FORM", 4) == 0 && memcmp(buf + 8, "AIFC", 4) == 0) {
-			const uint32_t size = READ_BE_UINT32(buf + 4);
-			for (uint32_t offset = 12; offset + 8 < size; ) {
+			const uint32 size = READ_BE_UINT32(buf + 4);
+			for (uint32 offset = 12; offset + 8 < size; ) {
 				_f.seek(startOffset + offset);
 				_f.read(buf, 8);
-				const uint32_t sz = READ_BE_UINT32(buf + 4);
+				const uint32 sz = READ_BE_UINT32(buf + 4);
 				if (memcmp(buf, "COMM", 4) == 0) {
 					const int channels = _f.readUint16BE();
 					_f.readUint32BE(); // samples per frame
@@ -70,7 +70,7 @@ bool AifcPlayer::play(int mixRate, const char *path, uint32_t startOffset) {
 					debugC(kDebugSound, "AIFF-C ssnd size %d", _ssndSize);
 					break;
 				} else if (memcmp(buf, "FVER", 4) == 0) {
-					const uint32_t version = _f.readUint32BE();
+					const uint32 version = _f.readUint32BE();
 					if (version != 0xA2805140) {
 						warning("Unexpected AIFF-C version 0x%x (%s)", version, path);
 					}
@@ -106,29 +106,29 @@ void AifcPlayer::stop() {
 	_f.close();
 }
 
-static int16_t decodeSDX2(int16_t prev, int8_t data) {
+static int16 decodeSDX2(int16 prev, int8 data) {
 	const int sqr = data * ABS(data) * 2;
 	return (data & 1) != 0 ? prev + sqr : sqr;
 }
 
-int8_t AifcPlayer::readSampleData() {
+int8 AifcPlayer::readSampleData() {
 	if (_pos >= _ssndSize) {
 		_pos = 0;
 		_f.seek(_ssndOffset);
 	}
-	const int8_t data = _f.readByte();
+	const int8 data = _f.readByte();
 	++_pos;
 	return data;
 }
 
 void AifcPlayer::decodeSamples() {
-	for (uint32_t pos = _rate.getInt(); pos == _rate.getInt(); _rate.offset += _rate.inc) {
+	for (uint32 pos = _rate.getInt(); pos == _rate.getInt(); _rate.offset += _rate.inc) {
 		_sampleL = decodeSDX2(_sampleL, readSampleData());
 		_sampleR = decodeSDX2(_sampleR, readSampleData());
 	}
 }
 
-void AifcPlayer::readSamples(int16_t *buf, int len) {
+void AifcPlayer::readSamples(int16 *buf, int len) {
 	for (int i = 0; i < len; i += 2) {
 		decodeSamples();
 		*buf++ = _sampleL;
diff --git a/engines/awe/aifc_player.h b/engines/awe/aifc_player.h
index 9e856399856..4beb30f4a3f 100644
--- a/engines/awe/aifc_player.h
+++ b/engines/awe/aifc_player.h
@@ -29,20 +29,20 @@ namespace Awe {
 
 struct AifcPlayer {
 	File _f;
-	uint32_t _ssndOffset = 0;
-	uint32_t _ssndSize = 0;
-	uint32_t _pos = 0;
-	int16_t _sampleL = 0, _sampleR = 0;
+	uint32 _ssndOffset = 0;
+	uint32 _ssndSize = 0;
+	uint32 _pos = 0;
+	int16 _sampleL = 0, _sampleR = 0;
 	Frac _rate;
 
 	AifcPlayer();
 
-	bool play(int mixRate, const char *path, uint32_t offset);
+	bool play(int mixRate, const char *path, uint32 offset);
 	void stop();
 
-	int8_t readSampleData();
+	int8 readSampleData();
 	void decodeSamples();
-	void readSamples(int16_t *buf, int len);
+	void readSamples(int16 *buf, int len);
 };
 
 } // namespace Awe
diff --git a/engines/awe/bitmap.cpp b/engines/awe/bitmap.cpp
index c875d3ea361..37870d1ecf0 100644
--- a/engines/awe/bitmap.cpp
+++ b/engines/awe/bitmap.cpp
@@ -24,7 +24,7 @@
 
 namespace Awe {
 
-static void clut(const uint8_t *src, const uint8_t *pal, int pitch, int w, int h, int bpp, bool flipY, int colorKey, uint8_t *dst) {
+static void clut(const uint8 *src, const uint8 *pal, int pitch, int w, int h, int bpp, bool flipY, int colorKey, uint8 *dst) {
 	int dstPitch = bpp * w;
 	if (flipY) {
 		dst += (h - 1) * bpp * w;
@@ -48,11 +48,11 @@ static void clut(const uint8_t *src, const uint8_t *pal, int pitch, int w, int h
 	}
 }
 
-uint8_t *decode_bitmap(const uint8_t *src, bool alpha, int colorKey, int *w, int *h) {
+uint8 *decode_bitmap(const uint8 *src, bool alpha, int colorKey, int *w, int *h) {
 	if (memcmp(src, "BM", 2) != 0) {
 		return 0;
 	}
-	const uint32_t imageOffset = READ_LE_UINT32(src + 0xA);
+	const uint32 imageOffset = READ_LE_UINT32(src + 0xA);
 	const int width = READ_LE_UINT32(src + 0x12);
 	const int height = READ_LE_UINT32(src + 0x16);
 	const int depth = READ_LE_UINT16(src + 0x1C);
@@ -62,22 +62,22 @@ uint8_t *decode_bitmap(const uint8_t *src, bool alpha, int colorKey, int *w, int
 		return 0;
 	}
 	const int bpp = (!alpha && colorKey < 0) ? 3 : 4;
-	uint8_t *dst = (uint8_t *)malloc(width * height * bpp);
+	uint8 *dst = (uint8 *)malloc(width * height * bpp);
 	if (!dst) {
 		warning("Failed to allocate bitmap buffer, width %d height %d bpp %d", width, height, bpp);
 		return 0;
 	}
 	if (depth == 8) {
-		const uint8_t *palette = src + 14 /* BITMAPFILEHEADER */ + 40 /* BITMAPINFOHEADER */;
+		const uint8 *palette = src + 14 /* BITMAPFILEHEADER */ + 40 /* BITMAPINFOHEADER */;
 		const bool flipY = true;
 		clut(src + imageOffset, palette, (width + 3) & ~3, width, height, bpp, flipY, colorKey, dst);
 	} else {
 		assert(depth == 32 && bpp == 3);
-		const uint8_t *p = src + imageOffset;
+		const uint8 *p = src + imageOffset;
 		for (int y = height - 1; y >= 0; --y) {
-			uint8_t *q = dst + y * width * bpp;
+			uint8 *q = dst + y * width * bpp;
 			for (int x = 0; x < width; ++x) {
-				const uint32_t color = READ_LE_UINT32(p); p += 4;
+				const uint32 color = READ_LE_UINT32(p); p += 4;
 				*q++ = (color >> 16) & 255;
 				*q++ = (color >> 8) & 255;
 				*q++ = color & 255;
diff --git a/engines/awe/bitmap.h b/engines/awe/bitmap.h
index 6d7024a36fd..55795d8256b 100644
--- a/engines/awe/bitmap.h
+++ b/engines/awe/bitmap.h
@@ -26,7 +26,7 @@
 
 namespace Awe {
 
-uint8_t *decode_bitmap(const uint8_t *src, bool alpha, int colorKey, int *w, int *h);
+uint8 *decode_bitmap(const uint8 *src, bool alpha, int colorKey, int *w, int *h);
 
 } // namespace Awe
 
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index 934921047bb..2f30cff0f4e 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -246,10 +246,10 @@ void Engine::titlePage() {
 	_state = kStateGame;
 }
 
-void Engine::saveGameState(uint8_t slot, const char *desc) {
+void Engine::saveGameState(uint8 slot, const char *desc) {
 }
 
-void Engine::loadGameState(uint8_t slot) {
+void Engine::loadGameState(uint8 slot) {
 }
 
 } // namespace Awe
diff --git a/engines/awe/engine.h b/engines/awe/engine.h
index 74b8c8de473..88a278a3172 100644
--- a/engines/awe/engine.h
+++ b/engines/awe/engine.h
@@ -74,8 +74,8 @@ struct Engine {
 	void scrollText(int a, int b, const char *text);
 	void titlePage();
 
-	void saveGameState(uint8_t slot, const char *desc);
-	void loadGameState(uint8_t slot);
+	void saveGameState(uint8 slot, const char *desc);
+	void loadGameState(uint8 slot);
 };
 
 } // namespace Awe
diff --git a/engines/awe/file.cpp b/engines/awe/file.cpp
index 8ef7c17f974..8ed7aeea47f 100644
--- a/engines/awe/file.cpp
+++ b/engines/awe/file.cpp
@@ -33,10 +33,10 @@ struct File_impl {
 	}
 	virtual bool open(const char *path, const char *mode) = 0;
 	virtual void close() = 0;
-	virtual uint32_t size() = 0;
+	virtual uint32 size() = 0;
 	virtual void seek(int off, int whence) = 0;
-	virtual int read(void *ptr, uint32_t len) = 0;
-	virtual int write(void *ptr, uint32_t len) = 0;
+	virtual int read(void *ptr, uint32 len) = 0;
+	virtual int write(void *ptr, uint32 len) = 0;
 };
 
 struct stdFile : File_impl {
@@ -54,8 +54,8 @@ struct stdFile : File_impl {
 			_fp = 0;
 		}
 	}
-	uint32_t size() {
-		uint32_t sz = 0;
+	uint32 size() {
+		uint32 sz = 0;
 		if (_fp) {
 			int pos = ftell(_fp);
 			fseek(_fp, 0, SEEK_END);
@@ -69,9 +69,9 @@ struct stdFile : File_impl {
 			fseek(_fp, off, whence);
 		}
 	}
-	int read(void *ptr, uint32_t len) {
+	int read(void *ptr, uint32 len) {
 		if (_fp) {
-			uint32_t r = fread(ptr, 1, len, _fp);
+			uint32 r = fread(ptr, 1, len, _fp);
 			if (r != len) {
 				_ioErr = true;
 			}
@@ -79,9 +79,9 @@ struct stdFile : File_impl {
 		}
 		return 0;
 	}
-	int write(void *ptr, uint32_t len) {
+	int write(void *ptr, uint32 len) {
 		if (_fp) {
-			uint32_t r = fwrite(ptr, 1, len, _fp);
+			uint32 r = fwrite(ptr, 1, len, _fp);
 			if (r != len) {
 				_ioErr = true;
 			}
@@ -147,7 +147,7 @@ bool File::ioErr() const {
 	return _impl->_ioErr;
 }
 
-uint32_t File::size() {
+uint32 File::size() {
 	return _impl->size();
 }
 
@@ -155,69 +155,69 @@ void File::seek(int off, int whence) {
 	_impl->seek(off, whence);
 }
 
-int File::read(void *ptr, uint32_t len) {
+int File::read(void *ptr, uint32 len) {
 	return _impl->read(ptr, len);
 }
 
-uint8_t File::readByte() {
-	uint8_t b;
+uint8 File::readByte() {
+	uint8 b;
 	read(&b, 1);
 	return b;
 }
 
-uint16_t File::readUint16LE() {
-	uint8_t lo = readByte();
-	uint8_t hi = readByte();
+uint16 File::readUint16LE() {
+	uint8 lo = readByte();
+	uint8 hi = readByte();
 	return (hi << 8) | lo;
 }
 
-uint32_t File::readUint32LE() {
-	uint16_t lo = readUint16LE();
-	uint16_t hi = readUint16LE();
+uint32 File::readUint32LE() {
+	uint16 lo = readUint16LE();
+	uint16 hi = readUint16LE();
 	return (hi << 16) | lo;
 }
 
-uint16_t File::readUint16BE() {
-	uint8_t hi = readByte();
-	uint8_t lo = readByte();
+uint16 File::readUint16BE() {
+	uint8 hi = readByte();
+	uint8 lo = readByte();
 	return (hi << 8) | lo;
 }
 
-uint32_t File::readUint32BE() {
-	uint16_t hi = readUint16BE();
-	uint16_t lo = readUint16BE();
+uint32 File::readUint32BE() {
+	uint16 hi = readUint16BE();
+	uint16 lo = readUint16BE();
 	return (hi << 16) | lo;
 }
 
-int File::write(void *ptr, uint32_t len) {
+int File::write(void *ptr, uint32 len) {
 	return _impl->write(ptr, len);
 }
 
-void File::writeByte(uint8_t b) {
+void File::writeByte(uint8 b) {
 	write(&b, 1);
 }
 
-void File::writeUint16LE(uint16_t n) {
+void File::writeUint16LE(uint16 n) {
 	writeByte(n & 0xFF);
 	writeByte(n >> 8);
 }
 
-void File::writeUint32LE(uint32_t n) {
+void File::writeUint32LE(uint32 n) {
 	writeUint16LE(n & 0xFFFF);
 	writeUint16LE(n >> 16);
 }
 
-void File::writeUint16BE(uint16_t n) {
+void File::writeUint16BE(uint16 n) {
 	writeByte(n >> 8);
 	writeByte(n & 0xFF);
 }
 
-void File::writeUint32BE(uint32_t n) {
+void File::writeUint32BE(uint32 n) {
 	writeUint16BE(n >> 16);
 	writeUint16BE(n & 0xFFFF);
 }
 
-void dumpFile(const char *filename, const uint8_t *p, int size) {
+void dumpFile(const char *filename, const uint8 *p, int size) {
 	char path[MAXPATHLEN];
 	snprintf(path, sizeof(path), "DUMP/%s", filename);
 	FILE *fp = fopen(path, "wb");
@@ -231,7 +231,7 @@ void dumpFile(const char *filename, const uint8_t *p, int size) {
 }
 #endif
 
-void dumpFile(const char *filename, const uint8_t *p, int size) {
+void dumpFile(const char *filename, const uint8 *p, int size) {
 	error("TODO: dumpFile - %s", filename);
 }
 
diff --git a/engines/awe/file.h b/engines/awe/file.h
index 792844e5b93..8865559efb2 100644
--- a/engines/awe/file.h
+++ b/engines/awe/file.h
@@ -51,25 +51,25 @@ struct File {
 	bool openForWriting(const char *filepath);
 	void close();
 	bool ioErr() const;
-	uint32_t size();
+	uint32 size();
 	void seek(int off, int whence = SEEK_SET);
-	int read(void *ptr, uint32_t len);
-	uint8_t readByte();
-	uint16_t readUint16LE();
-	uint32_t readUint32LE();
-	uint16_t readUint16BE();
-	uint32_t readUint32BE();
-	int write(void *ptr, uint32_t size);
-	void writeByte(uint8_t b);
-	void writeUint16LE(uint16_t n);
-	void writeUint32LE(uint32_t n);
-	void writeUint16BE(uint16_t n);
-	void writeUint32BE(uint32_t n);
+	int read(void *ptr, uint32 len);
+	uint8 readByte();
+	uint16 readUint16LE();
+	uint32 readUint32LE();
+	uint16 readUint16BE();
+	uint32 readUint32BE();
+	int write(void *ptr, uint32 size);
+	void writeByte(uint8 b);
+	void writeUint16LE(uint16 n);
+	void writeUint32LE(uint32 n);
+	void writeUint16BE(uint16 n);
+	void writeUint32BE(uint32 n);
 };
 
 #endif
 
-void dumpFile(const char *filename, const uint8_t *p, int size);
+void dumpFile(const char *filename, const uint8 *p, int size);
 
 } // namespace Awe
 
diff --git a/engines/awe/gfx.h b/engines/awe/gfx.h
index 23cd6b380c5..167d18edc30 100644
--- a/engines/awe/gfx.h
+++ b/engines/awe/gfx.h
@@ -60,12 +60,12 @@ enum {
 struct SystemStub;
 
 struct Gfx {
-	static const uint8_t FONT[];
+	static const uint8 FONT[];
 	static bool _is1991; // draw graphics as in the original 1991 game release
 	static Graphics::PixelFormat _format;
-	static const uint16_t SHAPES_MASK_OFFSET[];
+	static const uint16 SHAPES_MASK_OFFSET[];
 	static const int SHAPES_MASK_COUNT;
-	static const uint8_t SHAPES_MASK_DATA[];
+	static const uint8 SHAPES_MASK_DATA[];
 
 	int _fixUpPalette = 0;
 
@@ -74,18 +74,18 @@ struct Gfx {
 	virtual void init(int targetW, int targetH) {}
 	virtual void fini() {}
 
-	virtual void setFont(const uint8_t *src, int w, int h) = 0;
+	virtual void setFont(const uint8 *src, int w, int h) = 0;
 	virtual void setPalette(const Color *colors, int count) = 0;
-	virtual void setSpriteAtlas(const uint8_t *src, int w, int h, int xSize, int ySize) = 0;
-	virtual void drawSprite(int buffer, int num, const Point *pt, uint8_t color) = 0;
-	virtual void drawBitmap(int buffer, const uint8_t *data, int w, int h, int fmt) = 0;
-	virtual void drawPoint(int buffer, uint8_t color, const Point *pt) = 0;
-	virtual void drawQuadStrip(int buffer, uint8_t color, const QuadStrip *qs) = 0;
-	virtual void drawStringChar(int buffer, uint8_t color, char c, const Point *pt) = 0;
-	virtual void clearBuffer(int num, uint8_t color) = 0;
+	virtual void setSpriteAtlas(const uint8 *src, int w, int h, int xSize, int ySize) = 0;
+	virtual void drawSprite(int buffer, int num, const Point *pt, uint8 color) = 0;
+	virtual void drawBitmap(int buffer, const uint8 *data, int w, int h, int fmt) = 0;
+	virtual void drawPoint(int buffer, uint8 color, const Point *pt) = 0;
+	virtual void drawQuadStrip(int buffer, uint8 color, const QuadStrip *qs) = 0;
+	virtual void drawStringChar(int buffer, uint8 color, char c, const Point *pt) = 0;
+	virtual void clearBuffer(int num, uint8 color) = 0;
 	virtual void copyBuffer(int dst, int src, int vscroll = 0) = 0;
 	virtual void drawBuffer(int num, SystemStub *) = 0;
-	virtual void drawRect(int num, uint8_t color, const Point *pt, int w, int h) = 0;
+	virtual void drawRect(int num, uint8 color, const Point *pt, int w, int h) = 0;
 	virtual void drawBitmapOverlay(const Graphics::Surface &src, int fmt, SystemStub *stub) = 0;
 };
 
diff --git a/engines/awe/graphics_gl.cpp b/engines/awe/graphics_gl.cpp
index cf1e2611015..bb9e049419c 100644
--- a/engines/awe/graphics_gl.cpp
+++ b/engines/awe/graphics_gl.cpp
@@ -74,18 +74,18 @@ struct Texture {
 	GLuint _id;
 	int _w, _h;
 	float _u, _v;
-	uint8_t *_rgbData;
-	const uint8_t *_raw16Data;
+	uint8 *_rgbData;
+	const uint8 *_raw16Data;
 	int _fmt;
 
 	void init();
-	void uploadDataCLUT(const uint8_t *data, int srcPitch, int w, int h, const Color *pal);
+	void uploadDataCLUT(const uint8 *data, int srcPitch, int w, int h, const Color *pal);
 	void uploadDataRGB(const void *data, int srcPitch, int w, int h, int fmt, int type);
 	void draw(int w, int h);
 	void clear();
-	void readRaw16(const uint8_t *src, const Color *pal, int w, int h);
-	void readFont(const uint8_t *src);
-	void readRGB555(const uint16_t *src, int w, int h);
+	void readRaw16(const uint8 *src, const Color *pal, int w, int h);
+	void readFont(const uint8 *src);
+	void readRGB555(const uint16 *src, int w, int h);
 };
 
 void Texture::init() {
@@ -98,11 +98,11 @@ void Texture::init() {
 	_fmt = -1;
 }
 
-static void convertTextureCLUT(const uint8_t *src, const int srcPitch, int w, int h, uint8_t *dst, int dstPitch, const Color *pal, bool alpha) {
+static void convertTextureCLUT(const uint8 *src, const int srcPitch, int w, int h, uint8 *dst, int dstPitch, const Color *pal, bool alpha) {
 	for (int y = 0; y < h; ++y) {
 		int offset = 0;
 		for (int x = 0; x < w; ++x) {
-			const uint8_t color = src[x];
+			const uint8 color = src[x];
 			dst[offset++] = pal[color].r;
 			dst[offset++] = pal[color].g;
 			dst[offset++] = pal[color].b;
@@ -119,7 +119,7 @@ static void convertTextureCLUT(const uint8_t *src, const int srcPitch, int w, in
 	}
 }
 
-void Texture::uploadDataCLUT(const uint8_t *data, int srcPitch, int w, int h, const Color *pal) {
+void Texture::uploadDataCLUT(const uint8 *data, int srcPitch, int w, int h, const Color *pal) {
 	if (w != _w || h != _h) {
 		free(_rgbData);
 		_rgbData = 0;
@@ -147,7 +147,7 @@ void Texture::uploadDataCLUT(const uint8_t *data, int srcPitch, int w, int h, co
 	if (!_rgbData) {
 		_w = _npotTex ? w : roundPow2(w);
 		_h = _npotTex ? h : roundPow2(h);
-		_rgbData = (uint8_t *)malloc(_w * _h * depth);
+		_rgbData = (uint8 *)malloc(_w * _h * depth);
 		if (!_rgbData) {
 			return;
 		}
@@ -213,20 +213,20 @@ void Texture::clear() {
 	_raw16Data = 0;
 }
 
-void Texture::readRaw16(const uint8_t *src, const Color *pal, int w, int h) {
+void Texture::readRaw16(const uint8 *src, const Color *pal, int w, int h) {
 	_raw16Data = src;
 	uploadDataCLUT(_raw16Data, w, w, h, pal);
 }
 
-void Texture::readFont(const uint8_t *src) {
+void Texture::readFont(const uint8 *src) {
 	_fmt = FMT_RGBA;
 	const int W = 96 * 8 * 2;
 	const int H = 8;
-	uint8_t *out = (uint8_t *)calloc(1, W * H);
+	uint8 *out = (uint8 *)calloc(1, W * H);
 	if (out) {
 		for (int i = 0; i < 96; ++i) {
 			for (int y = 0; y < 8; ++y) {
-				uint8_t mask = *src++;
+				uint8 mask = *src++;
 				for (int x = 0; x < 8; ++x) {
 					out[y * W + i * 16 + x] = (mask >> (7 - x)) & 1;
 				}
@@ -240,22 +240,22 @@ void Texture::readFont(const uint8_t *src) {
 	}
 }
 
-static uint16_t rgb555_to_565(const uint16_t color) {
+static uint16 rgb555_to_565(const uint16 color) {
 	const int r = (color >> 10) & 31;
 	const int g = (color >> 5) & 31;
 	const int b = color & 31;
 	return (r << 11) | (g << 6) | b;
 }
 
-void Texture::readRGB555(const uint16_t *src, int w, int h) {
-	_rgbData = (uint8_t *)malloc(w * h * sizeof(uint16_t));
+void Texture::readRGB555(const uint16 *src, int w, int h) {
+	_rgbData = (uint8 *)malloc(w * h * sizeof(uint16));
 	if (!_rgbData) {
 		return;
 	}
 	for (int i = 0; i < w * h; ++i) {
-		((uint16_t *)_rgbData)[i] = rgb555_to_565(src[i]);
+		((uint16 *)_rgbData)[i] = rgb555_to_565(src[i]);
 	}
-	uploadDataRGB(_rgbData, w * sizeof(uint16_t), w, h, GL_RGB, GL_UNSIGNED_SHORT_5_6_5);
+	uploadDataRGB(_rgbData, w * sizeof(uint16), w, h, GL_RGB, GL_UNSIGNED_SHORT_5_6_5);
 }
 
 struct DrawListEntry {
@@ -277,12 +277,12 @@ struct DrawList {
 		: fillColor(0), yOffset(0) {
 	}
 
-	void clear(uint8_t color) {
+	void clear(uint8 color) {
 		fillColor = color;
 		entries.clear();
 	}
 
-	void append(uint8_t color, int count, const Point *vertices) {
+	void append(uint8 color, int count, const Point *vertices) {
 		if (count <= DrawListEntry::NUM_VERTICES) {
 			DrawListEntry e;
 			e.color = color;
@@ -323,24 +323,24 @@ struct GraphicsGL : Graphics {
 	}
 
 	virtual void init(int targetW, int targetH);
-	virtual void setFont(const uint8_t *src, int w, int h);
+	virtual void setFont(const uint8 *src, int w, int h);
 	virtual void setPalette(const Color *colors, int count);
-	virtual void setSpriteAtlas(const uint8_t *src, int w, int h, int xSize, int ySize);
-	virtual void drawSprite(int listNum, int num, const Point *pt, uint8_t color);
-	virtual void drawBitmap(int listNum, const uint8_t *data, int w, int h, int fmt);
-	virtual void drawPoint(int listNum, uint8_t color, const Point *pt);
-	virtual void drawQuadStrip(int listNum, uint8_t color, const QuadStrip *qs);
-	virtual void drawStringChar(int listNum, uint8_t color, char c, const Point *pt);
-	virtual void clearBuffer(int listNum, uint8_t color);
+	virtual void setSpriteAtlas(const uint8 *src, int w, int h, int xSize, int ySize);
+	virtual void drawSprite(int listNum, int num, const Point *pt, uint8 color);
+	virtual void drawBitmap(int listNum, const uint8 *data, int w, int h, int fmt);
+	virtual void drawPoint(int listNum, uint8 color, const Point *pt);
+	virtual void drawQuadStrip(int listNum, uint8 color, const QuadStrip *qs);
+	virtual void drawStringChar(int listNum, uint8 color, char c, const Point *pt);
+	virtual void clearBuffer(int listNum, uint8 color);
 	virtual void copyBuffer(int dstListNum, int srcListNum, int vscroll = 0);
 	virtual void drawBuffer(int listNum, SystemStub *stub);
-	virtual void drawRect(int num, uint8_t color, const Point *pt, int w, int h);
+	virtual void drawRect(int num, uint8 color, const Point *pt, int w, int h);
 	virtual void drawBitmapOverlay(const Graphics::Surface &src, int fmt, SystemStub *stub);
 
 	void initFbo();
 	void drawVerticesFlat(int count, const Point *vertices);
 	void drawVerticesTex(int count, const Point *vertices);
-	void drawVerticesToFb(uint8_t color, int count, const Point *vertices);
+	void drawVerticesToFb(uint8 color, int count, const Point *vertices);
 };
 
 GraphicsGL::GraphicsGL() {
@@ -410,7 +410,7 @@ void GraphicsGL::initFbo() {
 	glPointSize(r);
 }
 
-void GraphicsGL::setFont(const uint8_t *src, int w, int h) {
+void GraphicsGL::setFont(const uint8 *src, int w, int h) {
 	if (src == 0) {
 		_fontTex.readFont(_font);
 	} else {
@@ -459,7 +459,7 @@ void GraphicsGL::setPalette(const Color *colors, int n) {
 	}
 }
 
-void GraphicsGL::setSpriteAtlas(const uint8_t *src, int w, int h, int xSize, int ySize) {
+void GraphicsGL::setSpriteAtlas(const uint8 *src, int w, int h, int xSize, int ySize) {
 	_spritesTex.uploadDataRGB(src, w * 4, w, h, GL_RGBA, GL_UNSIGNED_BYTE);
 	_spritesSizeX = xSize;
 	_spritesSizeY = ySize;
@@ -498,7 +498,7 @@ static void drawSpriteHelper(const Point *pt, int num, int xSize, int ySize, int
 	drawTexQuad(pos, uv, texId);
 }
 
-void GraphicsGL::drawSprite(int listNum, int num, const Point *pt, uint8_t color) {
+void GraphicsGL::drawSprite(int listNum, int num, const Point *pt, uint8 color) {
 	assert(listNum < NUM_LISTS);
 	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
 	glDrawBuffer(GL_COLOR_ATTACHMENT0 + listNum);
@@ -517,7 +517,7 @@ void GraphicsGL::drawSprite(int listNum, int num, const Point *pt, uint8_t color
 	glScalef(1., 1., 1.);
 }
 
-void GraphicsGL::drawBitmap(int listNum, const uint8_t *data, int w, int h, int fmt) {
+void GraphicsGL::drawBitmap(int listNum, const uint8 *data, int w, int h, int fmt) {
 	_backgroundTex._fmt = fmt;
 	switch (fmt) {
 	case FMT_CLUT:
@@ -529,7 +529,7 @@ void GraphicsGL::drawBitmap(int listNum, const uint8_t *data, int w, int h, int
 		break;
 	case FMT_RGB555:
 		_backgroundTex.clear();
-		_backgroundTex.readRGB555((const uint16_t *)data, w, h);
+		_backgroundTex.readRGB555((const uint16 *)data, w, h);
 		break;
 	}
 	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
@@ -546,7 +546,7 @@ void GraphicsGL::drawBitmap(int listNum, const uint8_t *data, int w, int h, int
 	_drawLists[listNum].clear(COL_BMP);
 }
 
-void GraphicsGL::drawVerticesToFb(uint8_t color, int count, const Point *vertices) {
+void GraphicsGL::drawVerticesToFb(uint8 color, int count, const Point *vertices) {
 	glScalef((float)_fbW / SCREEN_W, (float)_fbH / SCREEN_H, 1);
 
 	if (color == COL_PAGE) {
@@ -569,7 +569,7 @@ void GraphicsGL::drawVerticesToFb(uint8_t color, int count, const Point *vertice
 	glScalef(1., 1., 1.);
 }
 
-void GraphicsGL::drawPoint(int listNum, uint8_t color, const Point *pt) {
+void GraphicsGL::drawPoint(int listNum, uint8 color, const Point *pt) {
 	assert(listNum < NUM_LISTS);
 	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
 	glDrawBuffer(GL_COLOR_ATTACHMENT0 + listNum);
@@ -586,7 +586,7 @@ void GraphicsGL::drawPoint(int listNum, uint8_t color, const Point *pt) {
 	}
 }
 
-void GraphicsGL::drawQuadStrip(int listNum, uint8_t color, const QuadStrip *qs) {
+void GraphicsGL::drawQuadStrip(int listNum, uint8 color, const QuadStrip *qs) {
 	assert(listNum < NUM_LISTS);
 	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
 	glDrawBuffer(GL_COLOR_ATTACHMENT0 + listNum);
@@ -603,7 +603,7 @@ void GraphicsGL::drawQuadStrip(int listNum, uint8_t color, const QuadStrip *qs)
 	}
 }
 
-void GraphicsGL::drawStringChar(int listNum, uint8_t color, char c, const Point *pt) {
+void GraphicsGL::drawStringChar(int listNum, uint8 color, char c, const Point *pt) {
 	assert(listNum < NUM_LISTS);
 	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
 	glDrawBuffer(GL_COLOR_ATTACHMENT0 + listNum);
@@ -702,7 +702,7 @@ void GraphicsGL::drawVerticesTex(int count, const Point *vertices) {
 	glEnd();
 }
 
-void GraphicsGL::clearBuffer(int listNum, uint8_t color) {
+void GraphicsGL::clearBuffer(int listNum, uint8 color) {
 	assert(listNum < NUM_LISTS);
 	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
 	glDrawBuffer(GL_COLOR_ATTACHMENT0 + listNum);
@@ -799,7 +799,7 @@ void GraphicsGL::drawBuffer(int listNum, SystemStub *stub) {
 	stub->updateScreen();
 }
 
-void GraphicsGL::drawRect(int num, uint8_t color, const Point *pt, int w, int h) {
+void GraphicsGL::drawRect(int num, uint8 color, const Point *pt, int w, int h) {
 
 	// ignore 'num' target framebuffer as this is only used for the title screen with the 3DO version
 	assert(color < 16);
diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
index f507c3a401c..ebdffafdcfb 100644
--- a/engines/awe/graphics_soft.cpp
+++ b/engines/awe/graphics_soft.cpp
@@ -27,10 +27,10 @@
 namespace Awe {
 
 struct GraphicsSoft : public Gfx {
-	typedef void (GraphicsSoft:: *drawLine)(int16_t x1, int16_t x2, int16_t y, uint8_t col);
+	typedef void (GraphicsSoft:: *drawLine)(int16 x1, int16 x2, int16 y, uint8 col);
 
-	uint8_t *_pagePtrs[4] = { nullptr };
-	uint8_t *_drawPagePtr = { nullptr };
+	uint8 *_pagePtrs[4] = { nullptr };
+	uint8 *_drawPagePtr = { nullptr };
 	int _u = 0, _v = 0;
 	int _w = 0, _h = 0;
 	int _byteDepth = 0;
@@ -48,33 +48,33 @@ struct GraphicsSoft : public Gfx {
 	}
 
 	void setSize(int w, int h);
-	void drawPolygon(uint8_t color, const QuadStrip &qs);
-	void drawChar(uint8_t c, uint16_t x, uint16_t y, uint8_t color);
-	void drawSpriteMask(int x, int y, uint8_t color, const uint8_t *data);
-	void drawPoint(int16_t x, int16_t y, uint8_t color);
-	void drawLineT(int16_t x1, int16_t x2, int16_t y, uint8_t color);
-	void drawLineN(int16_t x1, int16_t x2, int16_t y, uint8_t color);
-	void drawLineP(int16_t x1, int16_t x2, int16_t y, uint8_t color);
-	uint8_t *getPagePtr(uint8_t page);
+	void drawPolygon(uint8 color, const QuadStrip &qs);
+	void drawChar(uint8 c, uint16 x, uint16 y, uint8 color);
+	void drawSpriteMask(int x, int y, uint8 color, const uint8 *data);
+	void drawPoint(int16 x, int16 y, uint8 color);
+	void drawLineT(int16 x1, int16 x2, int16 y, uint8 color);
+	void drawLineN(int16 x1, int16 x2, int16 y, uint8 color);
+	void drawLineP(int16 x1, int16 x2, int16 y, uint8 color);
+	uint8 *getPagePtr(uint8 page);
 	int getPageSize() const {
 		return _w * _h * _byteDepth;
 	}
-	void setWorkPagePtr(uint8_t page);
+	void setWorkPagePtr(uint8 page);
 
 	void init(int targetW, int targetH) override;
 
-	void setFont(const uint8_t *src, int w, int h) override;
+	void setFont(const uint8 *src, int w, int h) override;
 	void setPalette(const Color *colors, int count) override;
-	void setSpriteAtlas(const uint8_t *src, int w, int h, int xSize, int ySize) override;
-	void drawSprite(int buffer, int num, const Point *pt, uint8_t color) override;
-	void drawBitmap(int buffer, const uint8_t *data, int w, int h, int fmt) override;
-	void drawPoint(int buffer, uint8_t color, const Point *pt) override;
-	void drawQuadStrip(int buffer, uint8_t color, const QuadStrip *qs) override;
-	void drawStringChar(int buffer, uint8_t color, char c, const Point *pt) override;
-	void clearBuffer(int num, uint8_t color) override;
+	void setSpriteAtlas(const uint8 *src, int w, int h, int xSize, int ySize) override;
+	void drawSprite(int buffer, int num, const Point *pt, uint8 color) override;
+	void drawBitmap(int buffer, const uint8 *data, int w, int h, int fmt) override;
+	void drawPoint(int buffer, uint8 color, const Point *pt) override;
+	void drawQuadStrip(int buffer, uint8 color, const QuadStrip *qs) override;
+	void drawStringChar(int buffer, uint8 color, char c, const Point *pt) override;
+	void clearBuffer(int num, uint8 color) override;
 	void copyBuffer(int dst, int src, int vscroll = 0) override;
 	void drawBuffer(int num, SystemStub *stub) override;
-	void drawRect(int num, uint8_t color, const Point *pt, int w, int h) override;
+	void drawRect(int num, uint8 color, const Point *pt, int w, int h) override;
 	void drawBitmapOverlay(const Graphics::Surface &src, int fmt, SystemStub *stub) override;
 };
 
@@ -101,7 +101,7 @@ void GraphicsSoft::setSize(int w, int h) {
 	assert(_byteDepth == 1 || _byteDepth == 2);
 
 	for (int i = 0; i < 4; ++i) {
-		_pagePtrs[i] = (uint8_t *)realloc(_pagePtrs[i], getPageSize());
+		_pagePtrs[i] = (uint8 *)realloc(_pagePtrs[i], getPageSize());
 		if (!_pagePtrs[i]) {
 			error("Not enough memory to allocate offscreen buffers");
 		}
@@ -110,13 +110,13 @@ void GraphicsSoft::setSize(int w, int h) {
 	setWorkPagePtr(2);
 }
 
-static uint32_t calcStep(const Point &p1, const Point &p2, uint16_t &dy) {
+static uint32 calcStep(const Point &p1, const Point &p2, uint16 &dy) {
 	dy = p2.y - p1.y;
-	uint16_t delta = (dy <= 1) ? 1 : dy;
+	uint16 delta = (dy <= 1) ? 1 : dy;
 	return ((p2.x - p1.x) * (0x4000 / delta)) << 2;
 }
 
-void GraphicsSoft::drawPolygon(uint8_t color, const QuadStrip &quadStrip) {
+void GraphicsSoft::drawPolygon(uint8 color, const QuadStrip &quadStrip) {
 	QuadStrip qs = quadStrip;
 	if (_w != GFX_W || _h != GFX_H) {
 		for (int i = 0; i < qs.numVertices; ++i) {
@@ -127,9 +127,9 @@ void GraphicsSoft::drawPolygon(uint8_t color, const QuadStrip &quadStrip) {
 	int i = 0;
 	int j = qs.numVertices - 1;
 
-	int16_t x2 = qs.vertices[i].x;
-	int16_t x1 = qs.vertices[j].x;
-	int16_t hliney = MIN(qs.vertices[i].y, qs.vertices[j].y);
+	int16 x2 = qs.vertices[i].x;
+	int16 x1 = qs.vertices[j].x;
+	int16 hliney = MIN(qs.vertices[i].y, qs.vertices[j].y);
 
 	++i;
 	--j;
@@ -147,8 +147,8 @@ void GraphicsSoft::drawPolygon(uint8_t color, const QuadStrip &quadStrip) {
 		break;
 	}
 
-	uint32_t cpt1 = x1 << 16;
-	uint32_t cpt2 = x2 << 16;
+	uint32 cpt1 = x1 << 16;
+	uint32 cpt2 = x2 << 16;
 
 	int numVertices = qs.numVertices;
 	while (1) {
@@ -156,9 +156,9 @@ void GraphicsSoft::drawPolygon(uint8_t color, const QuadStrip &quadStrip) {
 		if (numVertices == 0) {
 			return;
 		}
-		uint16_t h;
-		uint32_t step1 = calcStep(qs.vertices[j + 1], qs.vertices[j], h);
-		uint32_t step2 = calcStep(qs.vertices[i - 1], qs.vertices[i], h);
+		uint16 h;
+		uint32 step1 = calcStep(qs.vertices[j + 1], qs.vertices[j], h);
+		uint32 step2 = calcStep(qs.vertices[i - 1], qs.vertices[i], h);
 
 		++i;
 		--j;
@@ -189,15 +189,15 @@ void GraphicsSoft::drawPolygon(uint8_t color, const QuadStrip &quadStrip) {
 	}
 }
 
-void GraphicsSoft::drawChar(uint8_t c, uint16_t x, uint16_t y, uint8_t color) {
+void GraphicsSoft::drawChar(uint8 c, uint16 x, uint16 y, uint8 color) {
 	if (x <= GFX_W - 8 && y <= GFX_H - 8) {
 		x = xScale(x);
 		y = yScale(y);
-		const uint8_t *ft = FONT + (c - 0x20) * 8;
+		const uint8 *ft = FONT + (c - 0x20) * 8;
 		const int offset = (x + y * _w) * _byteDepth;
 		if (_byteDepth == 1) {
 			for (int j = 0; j < 8; ++j) {
-				const uint8_t ch = ft[j];
+				const uint8 ch = ft[j];
 				for (int i = 0; i < 8; ++i) {
 					if (ch & (1 << (7 - i))) {
 						_drawPagePtr[offset + j * _w + i] = color;
@@ -205,21 +205,21 @@ void GraphicsSoft::drawChar(uint8_t c, uint16_t x, uint16_t y, uint8_t color) {
 				}
 			}
 		} else if (_byteDepth == 2) {
-			const uint16_t rgbColor = _format.RGBToColor(
+			const uint16 rgbColor = _format.RGBToColor(
 				_pal[color].r, _pal[color].g, _pal[color].b);
 
 			for (int j = 0; j < 8; ++j) {
-				const uint8_t ch = ft[j];
+				const uint8 ch = ft[j];
 				for (int i = 0; i < 8; ++i) {
 					if (ch & (1 << (7 - i))) {
-						((uint16_t *)(_drawPagePtr + offset))[j * _w + i] = rgbColor;
+						((uint16 *)(_drawPagePtr + offset))[j * _w + i] = rgbColor;
 					}
 				}
 			}
 		}
 	}
 }
-void GraphicsSoft::drawSpriteMask(int x, int y, uint8_t color, const uint8_t *data) {
+void GraphicsSoft::drawSpriteMask(int x, int y, uint8 color, const uint8 *data) {
 	const int w = *data++;
 	x = xScale(x - w / 2);
 	const int h = *data++;
@@ -228,7 +228,7 @@ void GraphicsSoft::drawSpriteMask(int x, int y, uint8_t color, const uint8_t *da
 	for (int j = 0; j < h; ++j) {
 		const int yoffset = y + j;
 		for (int i = 0; i <= w / 16; ++i) {
-			const uint16_t mask = READ_BE_UINT16(data); data += 2;
+			const uint16 mask = READ_BE_UINT16(data); data += 2;
 			if (yoffset < 0 || yoffset >= _h) {
 				continue;
 			}
@@ -245,19 +245,19 @@ void GraphicsSoft::drawSpriteMask(int x, int y, uint8_t color, const uint8_t *da
 	}
 }
 
-static void blend_rgb555(uint16_t *dst, const uint16_t b) {
-	static const uint16_t RB_MASK = 0x7c1f;
-	static const uint16_t G_MASK = 0x03e0;
-	uint16_t a = *dst;
+static void blend_rgb555(uint16 *dst, const uint16 b) {
+	static const uint16 RB_MASK = 0x7c1f;
+	static const uint16 G_MASK = 0x03e0;
+	uint16 a = *dst;
 	if ((a & 0x8000) == 0) { // use bit 15 to prevent additive blending
-		uint16_t r = 0x8000;
+		uint16 r = 0x8000;
 		r |= (((a & RB_MASK) + (b & RB_MASK)) >> 1) & RB_MASK;
 		r |= (((a & G_MASK) + (b & G_MASK)) >> 1) & G_MASK;
 		*dst = r;
 	}
 }
 
-void GraphicsSoft::drawPoint(int16_t x, int16_t y, uint8_t color) {
+void GraphicsSoft::drawPoint(int16 x, int16 y, uint8 color) {
 	x = xScale(x);
 	y = yScale(y);
 	const int offset = (y * _w + x) * _byteDepth;
@@ -278,25 +278,25 @@ void GraphicsSoft::drawPoint(int16_t x, int16_t y, uint8_t color) {
 		case COL_ALPHA: {
 			const Color &c = _pal[ALPHA_COLOR_INDEX];
 			const uint16 rgbColor = _format.RGBToColor(c.r, c.g, c.b);
-			blend_rgb555((uint16_t *)(_drawPagePtr + offset), rgbColor);
+			blend_rgb555((uint16 *)(_drawPagePtr + offset), rgbColor);
 			break;
 		}
 		case COL_PAGE:
-			*(uint16_t *)(_drawPagePtr + offset) = *(uint16_t *)(_pagePtrs[0] + offset);
+			*(uint16 *)(_drawPagePtr + offset) = *(uint16 *)(_pagePtrs[0] + offset);
 			break;
 		default: {
 			const Color &c = _pal[color];
 			const uint16 rgbColor = _format.RGBToColor(c.r, c.g, c.b);
-			*(uint16_t *)(_drawPagePtr + offset) = rgbColor;
+			*(uint16 *)(_drawPagePtr + offset) = rgbColor;
 			break;
 		}
 		}
 	}
 }
 
-void GraphicsSoft::drawLineT(int16_t x1, int16_t x2, int16_t y, uint8_t color) {
-	int16_t xmax = MAX(x1, x2);
-	int16_t xmin = MIN(x1, x2);
+void GraphicsSoft::drawLineT(int16 x1, int16 x2, int16 y, uint8 color) {
+	int16 xmax = MAX(x1, x2);
+	int16 xmin = MIN(x1, x2);
 	int w = xmax - xmin + 1;
 	const int offset = (y * _w + xmin) * _byteDepth;
 	if (_byteDepth == 1) {
@@ -305,18 +305,18 @@ void GraphicsSoft::drawLineT(int16_t x1, int16_t x2, int16_t y, uint8_t color) {
 		}
 	} else if (_byteDepth == 2) {
 		const Color &c = _pal[ALPHA_COLOR_INDEX];
-		const uint16_t rgbColor = _format.RGBToColor(c.r, c.g, c.b);
+		const uint16 rgbColor = _format.RGBToColor(c.r, c.g, c.b);
 
-		uint16_t *p = (uint16_t *)(_drawPagePtr + offset);
+		uint16 *p = (uint16 *)(_drawPagePtr + offset);
 		for (int i = 0; i < w; ++i) {
 			blend_rgb555(p + i, rgbColor);
 		}
 	}
 }
 
-void GraphicsSoft::drawLineN(int16_t x1, int16_t x2, int16_t y, uint8_t color) {
-	int16_t xmax = MAX(x1, x2);
-	int16_t xmin = MIN(x1, x2);
+void GraphicsSoft::drawLineN(int16 x1, int16 x2, int16 y, uint8 color) {
+	int16 xmax = MAX(x1, x2);
+	int16 xmin = MIN(x1, x2);
 	const int w = xmax - xmin + 1;
 	const int offset = (y * _w + xmin) * _byteDepth;
 	if (_byteDepth == 1) {
@@ -324,30 +324,30 @@ void GraphicsSoft::drawLineN(int16_t x1, int16_t x2, int16_t y, uint8_t color) {
 	} else if (_byteDepth == 2) {
 		const Color &c = _pal[color];
 		const uint16 rgbColor = _format.RGBToColor(c.r, c.g, c.b);
-		uint16_t *p = (uint16_t *)(_drawPagePtr + offset);
+		uint16 *p = (uint16 *)(_drawPagePtr + offset);
 		for (int i = 0; i < w; ++i) {
 			p[i] = rgbColor;
 		}
 	}
 }
 
-void GraphicsSoft::drawLineP(int16_t x1, int16_t x2, int16_t y, uint8_t color) {
+void GraphicsSoft::drawLineP(int16 x1, int16 x2, int16 y, uint8 color) {
 	if (_drawPagePtr == _pagePtrs[0]) {
 		return;
 	}
-	int16_t xmax = MAX(x1, x2);
-	int16_t xmin = MIN(x1, x2);
+	int16 xmax = MAX(x1, x2);
+	int16 xmin = MIN(x1, x2);
 	const int w = xmax - xmin + 1;
 	const int offset = (y * _w + xmin) * _byteDepth;
 	memcpy(_drawPagePtr + offset, _pagePtrs[0] + offset, w * _byteDepth);
 }
 
-uint8_t *GraphicsSoft::getPagePtr(uint8_t page) {
+uint8 *GraphicsSoft::getPagePtr(uint8 page) {
 	assert(page < 4);
 	return _pagePtrs[page];
 }
 
-void GraphicsSoft::setWorkPagePtr(uint8_t page) {
+void GraphicsSoft::setWorkPagePtr(uint8 page) {
 	_drawPagePtr = getPagePtr(page);
 }
 
@@ -356,7 +356,7 @@ void GraphicsSoft::init(int targetW, int targetH) {
 	setSize(targetW, targetH);
 }
 
-void GraphicsSoft::setFont(const uint8_t *src, int w, int h) {
+void GraphicsSoft::setFont(const uint8 *src, int w, int h) {
 	if (_is1991) {
 		// no-op for 1991
 	}
@@ -368,23 +368,23 @@ void GraphicsSoft::setPalette(const Color *colors, int count) {
 	_palChanged = true;
 }
 
-void GraphicsSoft::setSpriteAtlas(const uint8_t *src, int w, int h, int xSize, int ySize) {
+void GraphicsSoft::setSpriteAtlas(const uint8 *src, int w, int h, int xSize, int ySize) {
 	if (_is1991) {
 		// no-op for 1991
 	}
 }
 
-void GraphicsSoft::drawSprite(int buffer, int num, const Point *pt, uint8_t color) {
+void GraphicsSoft::drawSprite(int buffer, int num, const Point *pt, uint8 color) {
 	if (_is1991) {
 		if (num < SHAPES_MASK_COUNT) {
 			setWorkPagePtr(buffer);
-			const uint8_t *data = SHAPES_MASK_DATA + SHAPES_MASK_OFFSET[num];
+			const uint8 *data = SHAPES_MASK_DATA + SHAPES_MASK_OFFSET[num];
 			drawSpriteMask(pt->x, pt->y, color, data);
 		}
 	}
 }
 
-void GraphicsSoft::drawBitmap(int buffer, const uint8_t *data, int w, int h, int fmt) {
+void GraphicsSoft::drawBitmap(int buffer, const uint8 *data, int w, int h, int fmt) {
 	switch (_byteDepth) {
 	case 1:
 		if (fmt == FMT_CLUT && _w == w && _h == h) {
@@ -402,28 +402,28 @@ void GraphicsSoft::drawBitmap(int buffer, const uint8_t *data, int w, int h, int
 	warning("GraphicsSoft::drawBitmap() unhandled fmt %d w %d h %d", fmt, w, h);
 }
 
-void GraphicsSoft::drawPoint(int buffer, uint8_t color, const Point *pt) {
+void GraphicsSoft::drawPoint(int buffer, uint8 color, const Point *pt) {
 	setWorkPagePtr(buffer);
 	drawPoint(pt->x, pt->y, color);
 }
 
-void GraphicsSoft::drawQuadStrip(int buffer, uint8_t color, const QuadStrip *qs) {
+void GraphicsSoft::drawQuadStrip(int buffer, uint8 color, const QuadStrip *qs) {
 	setWorkPagePtr(buffer);
 	drawPolygon(color, *qs);
 }
 
-void GraphicsSoft::drawStringChar(int buffer, uint8_t color, char c, const Point *pt) {
+void GraphicsSoft::drawStringChar(int buffer, uint8 color, char c, const Point *pt) {
 	setWorkPagePtr(buffer);
 	drawChar(c, pt->x, pt->y, color);
 }
 
-void GraphicsSoft::clearBuffer(int num, uint8_t color) {
+void GraphicsSoft::clearBuffer(int num, uint8 color) {
 	if (_byteDepth == 1) {
 		memset(getPagePtr(num), color, getPageSize());
 	} else if (_byteDepth == 2) {
 		const Color &c = _pal[color];
 		const uint16 rgbColor = _format.RGBToColor(c.r, c.g, c.b);
-		uint16_t *p = (uint16_t *)getPagePtr(num);
+		uint16 *p = (uint16 *)getPagePtr(num);
 		for (int i = 0; i < _w * _h; ++i) {
 			p[i] = rgbColor;
 		}
@@ -465,7 +465,7 @@ void GraphicsSoft::drawBuffer(int num, SystemStub *stub) {
 	stub->updateScreen();
 }
 
-void GraphicsSoft::drawRect(int num, uint8_t color, const Point *pt, int w, int h) {
+void GraphicsSoft::drawRect(int num, uint8 color, const Point *pt, int w, int h) {
 	assert(_byteDepth == 2);
 	setWorkPagePtr(num);
 
@@ -477,13 +477,13 @@ void GraphicsSoft::drawRect(int num, uint8_t color, const Point *pt, int w, int
 	const int y2 = yScale(pt->y + h - 1);
 	// horizontal
 	for (int x = x1; x <= x2; ++x) {
-		*(uint16_t *)(_drawPagePtr + (y1 * _w + x) * _byteDepth) = rgbColor;
-		*(uint16_t *)(_drawPagePtr + (y2 * _w + x) * _byteDepth) = rgbColor;
+		*(uint16 *)(_drawPagePtr + (y1 * _w + x) * _byteDepth) = rgbColor;
+		*(uint16 *)(_drawPagePtr + (y2 * _w + x) * _byteDepth) = rgbColor;
 	}
 	// vertical
 	for (int y = y1; y <= y2; ++y) {
-		*(uint16_t *)(_drawPagePtr + (y * _w + x1) * _byteDepth) = rgbColor;
-		*(uint16_t *)(_drawPagePtr + (y * _w + x2) * _byteDepth) = rgbColor;
+		*(uint16 *)(_drawPagePtr + (y * _w + x1) * _byteDepth) = rgbColor;
+		*(uint16 *)(_drawPagePtr + (y * _w + x2) * _byteDepth) = rgbColor;
 	}
 }
 
diff --git a/engines/awe/intern.h b/engines/awe/intern.h
index 96552bfb843..310ad2472c5 100644
--- a/engines/awe/intern.h
+++ b/engines/awe/intern.h
@@ -48,15 +48,15 @@ enum {
 };
 
 struct Ptr {
-	uint8_t *pc = nullptr;
+	uint8 *pc = nullptr;
 	bool byteSwap = false;
 
-	uint8_t fetchByte() {
+	uint8 fetchByte() {
 		return *pc++;
 	}
 
-	uint16_t fetchWord() {
-		const uint16_t i = byteSwap ? READ_LE_UINT16(pc) : READ_BE_UINT16(pc);
+	uint16 fetchWord() {
+		const uint16 i = byteSwap ? READ_LE_UINT16(pc) : READ_BE_UINT16(pc);
 		pc += 2;
 		return i;
 	}
@@ -64,7 +64,7 @@ struct Ptr {
 
 struct Point : public Common::Point {
 	Point() : Common::Point() {}
-	Point(int16_t xx, int16_t yy) : Common::Point(xx, yy) {}
+	Point(int16 xx, int16 yy) : Common::Point(xx, yy) {}
 	Point(const Point &p) : Common::Point(p) {}
 
 	void scale(int u, int v) {
@@ -78,32 +78,32 @@ struct QuadStrip {
 		MAX_VERTICES = 70
 	};
 
-	uint8_t numVertices = 0;
+	uint8 numVertices = 0;
 	Point vertices[MAX_VERTICES];
 };
 
 struct Color {
 	byte rgb[3];
-	uint8_t &r = rgb[0];
-	uint8_t &g = rgb[1];
-	uint8_t &b = rgb[2];
+	uint8 &r = rgb[0];
+	uint8 &g = rgb[1];
+	uint8 &b = rgb[2];
 };
 
 struct Frac {
 	static const int BITS = 16;
 	static const int MASK = (1 << BITS) - 1;
-	uint32_t inc = 0;
-	uint64_t offset = 0;
+	uint32 inc = 0;
+	uint64 offset = 0;
 
 	void reset(int n, int d) {
-		inc = (((int64_t)n) << BITS) / d;
+		inc = (((int64)n) << BITS) / d;
 		offset = 0;
 	}
 
-	uint32_t getInt() const {
+	uint32 getInt() const {
 		return offset >> BITS;
 	}
-	uint32_t getFrac() const {
+	uint32 getFrac() const {
 		return offset & MASK;
 	}
 	int interpolate(int sample1, int sample2) const {
diff --git a/engines/awe/pak.cpp b/engines/awe/pak.cpp
index 794e2540f58..c7e8f3ae369 100644
--- a/engines/awe/pak.cpp
+++ b/engines/awe/pak.cpp
@@ -24,17 +24,17 @@
 
 namespace Awe {
 
-// static const uint32_t XOR_KEY1 = 0x31111612;
-static const uint32_t XOR_KEY2 = 0x22683297;
-static const uint32_t CHECKSUM = 0x20202020;
+// static const uint32 XOR_KEY1 = 0x31111612;
+static const uint32 XOR_KEY2 = 0x22683297;
+static const uint32 CHECKSUM = 0x20202020;
 
-static uint8_t *decode_toodc(uint8_t *p, int count) {
-	uint32_t key = XOR_KEY2;
-	uint32_t acc = 0;
+static uint8 *decode_toodc(uint8 *p, int count) {
+	uint32 key = XOR_KEY2;
+	uint32 acc = 0;
 	for (int i = 0; i < count; ++i) {
-		uint8_t *q = p + i * 4;
-		const uint32_t data = READ_LE_UINT32(q) ^ key;
-		uint32_t r = (q[2] + q[1] + q[0]) ^ q[3];
+		uint8 *q = p + i * 4;
+		const uint32 data = READ_LE_UINT32(q) ^ key;
+		uint32 r = (q[2] + q[1] + q[0]) ^ q[3];
 		r += acc;
 		key += r;
 		acc += 0x4D;
@@ -68,16 +68,16 @@ static int comparePakEntry(const void *a, const void *b) {
 }
 
 void Pak::readEntries() {
-	uint8_t header[12];
+	uint8 header[12];
 
 	memset(header, 0, sizeof(header));
 	_f.read(header, sizeof(header));
 	if (_f.ioErr() || memcmp(header, "PACK", 4) != 0) {
 		return;
 	}
-	const uint32_t entriesOffset = READ_LE_UINT32(header + 4);
+	const uint32 entriesOffset = READ_LE_UINT32(header + 4);
 	_f.seek(entriesOffset);
-	const uint32_t entriesSize = READ_LE_UINT32(header + 8);
+	const uint32 entriesSize = READ_LE_UINT32(header + 8);
 	_entriesCount = entriesSize / 0x40;
 	debugC(kDebugPak, "Pak::readEntries() entries count %d", _entriesCount);
 	_entries = (PakEntry *)calloc(_entriesCount, sizeof(PakEntry));
@@ -86,7 +86,7 @@ void Pak::readEntries() {
 		return;
 	}
 	for (int i = 0; i < _entriesCount; ++i) {
-		uint8_t buf[0x40];
+		uint8 buf[0x40];
 		_f.read(buf, sizeof(buf));
 		if (_f.ioErr()) {
 			break;
@@ -105,13 +105,13 @@ void Pak::readEntries() {
 	// the original executable descrambles the (ke)y.txt file and check the last 4 bytes.
 	// this has been disabled in later re-releases and a key is bundled in the data files
 	if (0) {
-		uint8_t buf[128];
+		uint8 buf[128];
 		const PakEntry *e = find("check.txt");
 		if (e && e->size <= sizeof(buf)) {
-			uint32_t size = 0;
+			uint32 size = 0;
 			loadData(e, buf, &size);
 			assert(size >= 4);
-			const uint32_t num = READ_LE_UINT32(buf + size - 4);
+			const uint32 num = READ_LE_UINT32(buf + size - 4);
 			assert(num == CHECKSUM);
 		}
 	}
@@ -124,7 +124,7 @@ const PakEntry *Pak::find(const char *name) {
 	return (const PakEntry *)bsearch(&tmp, _entries, _entriesCount, sizeof(PakEntry), comparePakEntry);
 }
 
-void Pak::loadData(const PakEntry *e, uint8_t *buf, uint32_t *size) {
+void Pak::loadData(const PakEntry *e, uint8 *buf, uint32 *size) {
 	debugC(kDebugPak, "Pak::loadData() %d bytes from 0x%x", e->size, e->offset);
 	_f.seek(e->offset);
 	if (_f.ioErr()) {
@@ -136,7 +136,7 @@ void Pak::loadData(const PakEntry *e, uint8_t *buf, uint32_t *size) {
 		const int dataSize = e->size - 6;
 		debugC(kDebugPak, "Pak::loadData() encoded TooDC data, size %d", dataSize);
 		if ((dataSize & 3) != 0) {
-			// descrambler operates on uint32_t
+			// descrambler operates on uint32
 			warning("Unexpected size %d for encoded TooDC data '%s'", dataSize, e->name);
 		}
 		*size = dataSize - 4;
diff --git a/engines/awe/pak.h b/engines/awe/pak.h
index 38bb63bb2d5..45c5e00dd3d 100644
--- a/engines/awe/pak.h
+++ b/engines/awe/pak.h
@@ -29,8 +29,8 @@ namespace Awe {
 
 struct PakEntry {
 	char name[32] = { '\0' };
-	uint32_t offset = 0;
-	uint32_t size = 0;
+	uint32 offset = 0;
+	uint32 size = 0;
 };
 
 struct Pak {
@@ -48,7 +48,7 @@ struct Pak {
 
 	void readEntries();
 	const PakEntry *find(const char *name);
-	void loadData(const PakEntry *e, uint8_t *buf, uint32_t *size);
+	void loadData(const PakEntry *e, uint8 *buf, uint32 *size);
 };
 
 } // namespace Awe
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index cdbd59c6571..8e1f1fd7e0a 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -57,7 +57,7 @@ Resource::~Resource() {
 	delete _3do;
 }
 
-bool Resource::readBank(const MemEntry *me, uint8_t *dstBuf) {
+bool Resource::readBank(const MemEntry *me, uint8 *dstBuf) {
 	bool ret = false;
 	char name[10];
 	snprintf(name, sizeof(name), "%s%02x", _bankPrefix, me->bankNum);
@@ -77,7 +77,7 @@ const AmigaMemEntry *Resource::detectAmigaAtari() {
 	Common::File f;
 
 	static const struct {
-		uint32_t bank01Size;
+		uint32 bank01Size;
 		const AmigaMemEntry *entries;
 	} FILES[] = {
 		{ 244674, Resource::MEMLIST_AMIGA_FR },
@@ -86,7 +86,7 @@ const AmigaMemEntry *Resource::detectAmigaAtari() {
 		{ 0, 0 }
 	};
 	if (f.open("bank01")) {
-		const uint32_t size = f.size();
+		const uint32 size = f.size();
 		for (int i = 0; FILES[i].entries; ++i) {
 			if (FILES[i].bank01Size == size) {
 				return FILES[i].entries;
@@ -185,10 +185,10 @@ void Resource::readEntries() {
 		File f;
 		if (f.open(atariDemo)) {
 			static const struct {
-				uint8_t type;
-				uint8_t num;
-				uint32_t offset;
-				uint16_t size;
+				uint8 type;
+				uint8 num;
+				uint32 offset;
+				uint16 size;
 			} DATA[] = {
 				{ RT_SHAPE, 0x19, 0x50f0, 65146 },
 				{ RT_PALETTE, 0x17, 0x14f6a, 2048 },
@@ -233,7 +233,7 @@ void Resource::dumpEntries() {
 			if (_memList[i].bankNum == 5 && (_dataType == DT_AMIGA || _dataType == DT_ATARI)) {
 				continue;
 			}
-			uint8_t *p = (uint8_t *)malloc(_memList[i].unpackedSize);
+			uint8 *p = (uint8 *)malloc(_memList[i].unpackedSize);
 			if (p) {
 				if (readBank(&_memList[i], p)) {
 					char name[16];
@@ -251,7 +251,7 @@ void Resource::load() {
 		MemEntry *me = 0;
 
 		// get resource with max rankNum
-		uint8_t maxNum = 0;
+		uint8 maxNum = 0;
 		for (int i = 0; i < _numMemList; ++i) {
 			MemEntry *it = &_memList[i];
 			if (it->status == STATUS_TOLOAD && maxNum <= it->rankNum) {
@@ -265,12 +265,12 @@ void Resource::load() {
 
 		const int resourceNum = me - _memList;
 
-		uint8_t *memPtr = 0;
+		uint8 *memPtr = 0;
 		if (me->type == RT_BITMAP) {
 			memPtr = _vidCurPtr;
 		} else {
 			memPtr = _scriptCurPtr;
-			const uint32_t avail = uint32_t(_vidCurPtr - _scriptCurPtr);
+			const uint32 avail = uint32(_vidCurPtr - _scriptCurPtr);
 			if (me->unpackedSize > avail) {
 				warning("Resource::load() not enough memory, available=%d", avail);
 				me->status = STATUS_NULL;
@@ -326,35 +326,35 @@ void Resource::invalidateAll() {
 	_vid->_currentPal = 0xFF;
 }
 
-static const uint8_t *getSoundsList3DO(int num) {
-	static const uint8_t INTRO7[] = {
+static const uint8 *getSoundsList3DO(int num) {
+	static const uint8 INTRO7[] = {
 		0x33, 0xFF
 	};
-	static const uint8_t WATER7[] = {
+	static const uint8 WATER7[] = {
 		0x08, 0x10, 0x2D, 0x30, 0x31, 0x32, 0x35, 0x39, 0x3A, 0x3C,
 		0x3D, 0x3E, 0x4A, 0x4B, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52,
 		0x54, 0xFF
 	};
-	static const uint8_t PRI1[] = {
+	static const uint8 PRI1[] = {
 		0x52, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D,
 		0x5E, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
 		0x69, 0x70, 0x71, 0x72, 0x73, 0xFF
 	};
-	static const uint8_t CITE1[] = {
+	static const uint8 CITE1[] = {
 		0x02, 0x03, 0x52, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B,
 		0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x63, 0x66, 0x6A, 0x6B, 0x6C,
 		0x6D, 0x6E, 0x6F, 0x70, 0x72, 0x74, 0x75, 0x77, 0x78, 0x79,
 		0x7A, 0x7B, 0x7C, 0x88, 0xFF
 	};
-	static const uint8_t ARENE2[] = {
+	static const uint8 ARENE2[] = {
 		0x52, 0x57, 0x58, 0x59, 0x5B, 0x84, 0x8B, 0x8C, 0x8E, 0xFF
 	};
-	static const uint8_t LUXE2[] = {
+	static const uint8 LUXE2[] = {
 		0x30, 0x52, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C,
 		0x5D, 0x5E, 0x5F, 0x60, 0x66, 0x67, 0x6B, 0x6C, 0x70, 0x74,
 		0x75, 0x79, 0x7A, 0x8D, 0xFF
 	};
-	static const uint8_t FINAL3[] = {
+	static const uint8 FINAL3[] = {
 		0x08, 0x0E, 0x0F, 0x57, 0xFF
 	};
 
@@ -372,7 +372,7 @@ static const uint8_t *getSoundsList3DO(int num) {
 	return 0;
 }
 
-void Resource::update(uint16_t num, PreloadSoundProc preloadSound, void *data) {
+void Resource::update(uint16 num, PreloadSoundProc preloadSound, void *data) {
 	if (num > 16000) {
 		_nextPart = num;
 		return;
@@ -401,7 +401,7 @@ void Resource::update(uint16_t num, PreloadSoundProc preloadSound, void *data) {
 		break;
 	case DT_3DO:
 		if (num >= 2000) { // preload sounds
-			const uint8_t *soundsList = getSoundsList3DO(num);
+			const uint8 *soundsList = getSoundsList3DO(num);
 			for (int i = 0; soundsList[i] != 255; ++i) {
 				const int soundNum = soundsList[i];
 				loadDat(soundNum);
@@ -427,8 +427,8 @@ void Resource::update(uint16_t num, PreloadSoundProc preloadSound, void *data) {
 }
 
 void Resource::loadBmp(int num) {
-	uint32_t size = 0;
-	uint8_t *p = 0;
+	uint32 size = 0;
+	uint8 *p = 0;
 	switch (_dataType) {
 	case DT_15TH_EDITION:
 	case DT_20TH_EDITION:
@@ -449,13 +449,13 @@ void Resource::loadBmp(int num) {
 	}
 }
 
-uint8_t *Resource::loadDat(int num) {
+uint8 *Resource::loadDat(int num) {
 	assert(num < _numMemList);
 	if (_memList[num].status == STATUS_LOADED) {
 		return _memList[num].bufPtr;
 	}
-	uint32_t size = 0;
-	uint8_t *p = 0;
+	uint32 size = 0;
+	uint8 *p = 0;
 	switch (_dataType) {
 	case DT_15TH_EDITION:
 	case DT_20TH_EDITION:
@@ -480,7 +480,7 @@ uint8_t *Resource::loadDat(int num) {
 
 void Resource::loadFont() {
 	if (_nth) {
-		uint8_t *p = _nth->load("font.bmp");
+		uint8 *p = _nth->load("font.bmp");
 		if (p) {
 			_vid->setFont(p);
 			free(p);
@@ -490,7 +490,7 @@ void Resource::loadFont() {
 
 void Resource::loadHeads() {
 	if (_nth) {
-		uint8_t *p = _nth->load("heads.bmp");
+		uint8 *p = _nth->load("heads.bmp");
 		if (p) {
 			_vid->setHeads(p);
 			free(p);
@@ -498,15 +498,15 @@ void Resource::loadHeads() {
 	}
 }
 
-uint8_t *Resource::loadWav(int num, uint32 *size) {
+uint8 *Resource::loadWav(int num, uint32 *size) {
 	if (_memList[num].status == STATUS_LOADED) {
 		return _memList[num].bufPtr;
 	}
 
-	uint32_t dummy = 0;
+	uint32 dummy = 0;
 	if (!size)
 		size = &dummy;
-	uint8_t *p = 0;
+	uint8 *p = 0;
 	switch (_dataType) {
 	case DT_15TH_EDITION:
 	case DT_20TH_EDITION:
@@ -540,7 +540,7 @@ const char *Resource::getString(int num) {
 	return 0;
 }
 
-const char *Resource::getMusicPath(int num, char *buf, int bufSize, uint32_t *offset) {
+const char *Resource::getMusicPath(int num, char *buf, int bufSize, uint32 *offset) {
 	const char *name = 0;
 	switch (_dataType) {
 	case DT_15TH_EDITION:
@@ -566,7 +566,7 @@ const char *Resource::getMusicPath(int num, char *buf, int bufSize, uint32_t *of
 	return 0;
 }
 
-const uint8_t Resource::MEMLIST_PARTS[][4] = {
+const uint8 Resource::MEMLIST_PARTS[][4] = {
 	{ 0x14, 0x15, 0x16, 0x00 }, // 16000 - protection screens
 	{ 0x17, 0x18, 0x19, 0x00 }, // 16001 - introduction
 	{ 0x1A, 0x1B, 0x1C, 0x11 }, // 16002 - water
@@ -590,7 +590,7 @@ void Resource::setupPart(int ptrId) {
 	case DT_WIN31:
 		if (ptrId >= firstPart && ptrId <= 16009) {
 			invalidateAll();
-			uint8_t **segments[4] = { &_segVideoPal, &_segCode, &_segVideo1, &_segVideo2 };
+			uint8 **segments[4] = { &_segVideoPal, &_segCode, &_segVideo1, &_segVideo2 };
 			for (int i = 0; i < 4; ++i) {
 				const int num = MEMLIST_PARTS[ptrId - 16000][i];
 				if (num != 0) {
@@ -612,12 +612,12 @@ void Resource::setupPart(int ptrId) {
 	case DT_ATARI_DEMO:
 	case DT_DOS:
 		if (ptrId != _currentPart) {
-			uint8_t ipal = 0;
-			uint8_t icod = 0;
-			uint8_t ivd1 = 0;
-			uint8_t ivd2 = 0;
+			uint8 ipal = 0;
+			uint8 icod = 0;
+			uint8 ivd1 = 0;
+			uint8 ivd2 = 0;
 			if (ptrId >= 16000 && ptrId <= 16009) {
-				uint16_t part = ptrId - 16000;
+				uint16 part = ptrId - 16000;
 				ipal = MEMLIST_PARTS[part][0];
 				icod = MEMLIST_PARTS[part][1];
 				ivd1 = MEMLIST_PARTS[part][2];
@@ -647,7 +647,7 @@ void Resource::setupPart(int ptrId) {
 }
 
 void Resource::allocMemBlock() {
-	_memPtrStart = (uint8_t *)malloc(MEM_BLOCK_SIZE);
+	_memPtrStart = (uint8 *)malloc(MEM_BLOCK_SIZE);
 	_scriptBakPtr = _scriptCurPtr = _memPtrStart;
 	_vidCurPtr = _memPtrStart + MEM_BLOCK_SIZE - (320 * 200 / 2); // 4bpp bitmap
 	_useSegVideo2 = false;
@@ -662,8 +662,8 @@ void Resource::readDemo3Joy() {
 	static const char *filename = "demo3.joy";
 	File f;
 	if (f.open(filename)) {
-		const uint32_t fileSize = f.size();
-		_demo3Joy.bufPtr = (uint8_t *)malloc(fileSize);
+		const uint32 fileSize = f.size();
+		_demo3Joy.bufPtr = (uint8 *)malloc(fileSize);
 		if (_demo3Joy.bufPtr) {
 			_demo3Joy.bufSize = f.read(_demo3Joy.bufPtr, fileSize);
 			_demo3Joy.bufPos = -1;
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index 4bf4b4811d4..255ab3358a6 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -28,31 +28,31 @@
 namespace Awe {
 
 struct MemEntry {
-	uint8_t status = 0;        // 0x0
-	uint8_t type = 0;          // 0x1, Resource::ResType
-	uint8_t *bufPtr = nullptr; // 0x2
-	uint8_t rankNum = 0;       // 0x6
-	uint8_t bankNum = 0;       // 0x7
-	uint32_t bankPos = 0;      // 0x8
-	uint32_t packedSize = 0;   // 0xC
-	uint32_t unpackedSize = 0; // 0x12
+	uint8 status = 0;        // 0x0
+	uint8 type = 0;          // 0x1, Resource::ResType
+	uint8 *bufPtr = nullptr; // 0x2
+	uint8 rankNum = 0;       // 0x6
+	uint8 bankNum = 0;       // 0x7
+	uint32 bankPos = 0;      // 0x8
+	uint32 packedSize = 0;   // 0xC
+	uint32 unpackedSize = 0; // 0x12
 
 	void load(Common::SeekableReadStream *src);
 };
 
 struct AmigaMemEntry {
-	uint8_t type;
-	uint8_t bank;
-	uint32_t offset;
-	uint32_t packedSize;
-	uint32_t unpackedSize;
+	uint8 type;
+	uint8 bank;
+	uint32 offset;
+	uint32 packedSize;
+	uint32 unpackedSize;
 };
 
 struct DemoJoy {
-	uint8_t keymask = 0;
-	uint8_t counter = 0;
+	uint8 keymask = 0;
+	uint8 counter = 0;
 
-	uint8_t *bufPtr = nullptr;
+	uint8 *bufPtr = nullptr;
 	int bufPos = 0, bufSize = 0;
 
 	bool start() {
@@ -65,7 +65,7 @@ struct DemoJoy {
 		return false;
 	}
 
-	uint8_t update() {
+	uint8 update() {
 		if (bufPos >= 0 && bufPos < bufSize) {
 			if (counter == 0) {
 				keymask = bufPtr[bufPos++];
@@ -84,7 +84,7 @@ struct ResourceWin31;
 struct Resource3do;
 struct Video;
 
-typedef void (*PreloadSoundProc)(void *userdata, int num, const uint8_t *data);
+typedef void (*PreloadSoundProc)(void *userdata, int num, const uint8 *data);
 
 struct Resource {
 	enum ResType {
@@ -112,23 +112,23 @@ struct Resource {
 	static const AmigaMemEntry MEMLIST_AMIGA_FR[ENTRIES_COUNT];
 	static const AmigaMemEntry MEMLIST_AMIGA_EN[ENTRIES_COUNT];
 	static const AmigaMemEntry MEMLIST_ATARI_EN[ENTRIES_COUNT];
-	static const uint8_t MEMLIST_PARTS[][4];
+	static const uint8 MEMLIST_PARTS[][4];
 	static const AmigaMemEntry *detectAmigaAtari();
 
 	Video *_vid;
 	DataType _dataType;
 	MemEntry _memList[ENTRIES_COUNT_20TH];
-	uint16_t _numMemList = 0;
-	uint16_t _currentPart = 0, _nextPart = 0;
-	uint8_t *_memPtrStart = nullptr,
+	uint16 _numMemList = 0;
+	uint16 _currentPart = 0, _nextPart = 0;
+	uint8 *_memPtrStart = nullptr,
 		*_scriptBakPtr = nullptr,
 		*_scriptCurPtr = nullptr,
 		*_vidCurPtr = nullptr;
 	bool _useSegVideo2 = false;
-	uint8_t *_segVideoPal = nullptr;
-	uint8_t *_segCode = nullptr;
-	uint8_t *_segVideo1 = nullptr;
-	uint8_t *_segVideo2 = nullptr;
+	uint8 *_segVideoPal = nullptr;
+	uint8 *_segCode = nullptr;
+	uint8 *_segVideo1 = nullptr;
+	uint8 *_segVideo2 = nullptr;
 	const char *_bankPrefix = "bank";
 	bool _hasPasswordScreen = true;
 	ResourceNth *_nth = nullptr;
@@ -146,21 +146,21 @@ struct Resource {
 		return _dataType;
 	}
 	const char *getGameTitle(Language lang) const;
-	bool readBank(const MemEntry *me, uint8_t *dstBuf);
+	bool readBank(const MemEntry *me, uint8 *dstBuf);
 	void readEntries();
 	void readEntriesAmiga(const AmigaMemEntry *entries, int count);
 	void dumpEntries();
 	void load();
 	void invalidateAll();
 	void invalidateRes();
-	void update(uint16_t num, PreloadSoundProc, void *);
+	void update(uint16 num, PreloadSoundProc, void *);
 	void loadBmp(int num);
-	uint8_t *loadDat(int num);
+	uint8 *loadDat(int num);
 	void loadFont();
 	void loadHeads();
-	uint8_t *loadWav(int num, uint32 *size = nullptr);
+	uint8 *loadWav(int num, uint32 *size = nullptr);
 	const char *getString(int num);
-	const char *getMusicPath(int num, char *buf, int bufSize, uint32_t *offset = 0);
+	const char *getMusicPath(int num, char *buf, int bufSize, uint32 *offset = 0);
 	void setupPart(int part);
 	void allocMemBlock();
 	void freeMemBlock();
diff --git a/engines/awe/resource_3do.cpp b/engines/awe/resource_3do.cpp
index deb3a242f86..7d03b5c9aed 100644
--- a/engines/awe/resource_3do.cpp
+++ b/engines/awe/resource_3do.cpp
@@ -24,19 +24,19 @@
 
 namespace Awe {
 
-static int decodeLzss(const uint8_t *src, uint32_t len, uint8_t *dst) {
-	uint32_t rd = 0, wr = 0;
+static int decodeLzss(const uint8 *src, uint32 len, uint8 *dst) {
+	uint32 rd = 0, wr = 0;
 	while (rd < len) {
-		const uint8_t code = src[rd++];
+		const uint8 code = src[rd++];
 		for (int j = 0; j < 8 && rd < len; ++j) {
 			if (code & (1 << j)) {
 				dst[wr++] = src[rd++];
 			} else {
-				const uint16_t offset = 0xF000 | src[rd] | ((src[rd + 1] & 0xF) << 8);
+				const uint16 offset = 0xF000 | src[rd] | ((src[rd + 1] & 0xF) << 8);
 				const int llen = (src[rd + 1] >> 4) + 3;
 				rd += 2;
 				for (int i = 0; i < llen; ++i) {
-					dst[wr] = dst[wr + (int16_t)offset];
+					dst[wr] = dst[wr + (int16)offset];
 					++wr;
 				}
 			}
@@ -45,13 +45,13 @@ static int decodeLzss(const uint8_t *src, uint32_t len, uint8_t *dst) {
 	return wr;
 }
 
-static void decodeCcb16(int ccbWidth, int ccbHeight, File *f, uint32_t dataSize, uint16_t *dst) {
+static void decodeCcb16(int ccbWidth, int ccbHeight, File *f, uint32 dataSize, uint16 *dst) {
 	for (int y = 0; y < ccbHeight; ++y) {
 		const int scanlineSize = 4 * (f->readUint16BE() + 2);
 		int scanlineLen = 2;
 		int w = ccbWidth;
 		while (w > 0) {
-			uint8_t code = f->readByte();
+			uint8 code = f->readByte();
 			++scanlineLen;
 			const int count = (code & 63) + 1;
 			code >>= 6;
@@ -66,12 +66,12 @@ static void decodeCcb16(int ccbWidth, int ccbHeight, File *f, uint32_t dataSize,
 				scanlineLen += count * 2;
 				break;
 			case 2:
-				memset(dst, 0, count * sizeof(uint16_t));
+				memset(dst, 0, count * sizeof(uint16));
 				dst += count;
 				break;
 			case 3:
 			{
-				const uint16_t color = f->readUint16BE();
+				const uint16 color = f->readUint16BE();
 				for (int i = 0; i < count; ++i) {
 					*dst++ = color;
 				}
@@ -92,24 +92,24 @@ static void decodeCcb16(int ccbWidth, int ccbHeight, File *f, uint32_t dataSize,
 	}
 }
 
-static const uint8_t _ccb_bppTable[8] = {
+static const uint8 _ccb_bppTable[8] = {
 		0, 1, 2, 4, 6, 8, 16, 0
 };
 
-static uint16_t *decodeShapeCcb(File *f, int dataSize, int *w, int *h) {
-	const uint32_t flags = f->readUint32BE();
+static uint16 *decodeShapeCcb(File *f, int dataSize, int *w, int *h) {
+	const uint32 flags = f->readUint32BE();
 	f->seek(4, SEEK_CUR);
-	const uint32_t celData = f->readUint32BE();
+	const uint32 celData = f->readUint32BE();
 	f->seek(40, SEEK_CUR);
-	const uint32_t pre0 = f->readUint32BE();
-	const uint32_t pre1 = f->readUint32BE();
+	const uint32 pre0 = f->readUint32BE();
+	const uint32 pre1 = f->readUint32BE();
 	assert(celData == 0x30);
 	assert(flags & (1 << 9));
 	const int bpp = _ccb_bppTable[pre0 & 7];
 	assert(bpp == 16);
-	const uint32_t width = (pre1 & 0x3FF) + 1;
-	const uint32_t height = ((pre0 >> 6) & 0x3FF) + 1;
-	uint16_t *buffer = (uint16_t *)malloc(width * height * sizeof(uint16_t));
+	const uint32 width = (pre1 & 0x3FF) + 1;
+	const uint32 height = ((pre0 >> 6) & 0x3FF) + 1;
+	uint16 *buffer = (uint16 *)malloc(width * height * sizeof(uint16));
 	if (buffer) {
 		decodeCcb16(width, height, f, dataSize - 60, buffer);
 		*w = width;
@@ -122,8 +122,8 @@ bool Resource3do::readEntries() {
 	return true;
 }
 
-uint8_t *Resource3do::loadFile(int num, uint8_t *dst, uint32_t *size) {
-	uint8_t *in = dst;
+uint8 *Resource3do::loadFile(int num, uint8 *dst, uint32 *size) {
+	uint8 *in = dst;
 
 	char path[MAXPATHLEN];
 	snprintf(path, sizeof(path), "GameData/File%d", num);
@@ -131,7 +131,7 @@ uint8_t *Resource3do::loadFile(int num, uint8_t *dst, uint32_t *size) {
 	if (f.open(path)) {
 		const int sz = f.size();
 		if (!dst) {
-			dst = (uint8_t *)malloc(sz);
+			dst = (uint8 *)malloc(sz);
 			if (!dst) {
 				warning("Unable to allocate %d bytes", sz);
 				return 0;
@@ -146,7 +146,7 @@ uint8_t *Resource3do::loadFile(int num, uint8_t *dst, uint32_t *size) {
 
 	if (dst && memcmp(dst, "\x00\xf4\x01\x00", 4) == 0) {
 		static const int SZ = 64000 * 2;
-		uint8_t *tmp = (uint8_t *)calloc(1, SZ);
+		uint8 *tmp = (uint8 *)calloc(1, SZ);
 		if (!tmp) {
 			warning("Unable to allocate %d bytes", SZ);
 			if (in != dst) free(dst);
@@ -164,26 +164,26 @@ uint8_t *Resource3do::loadFile(int num, uint8_t *dst, uint32_t *size) {
 	return dst;
 }
 
-uint16_t *Resource3do::loadShape555(const char *name, int *w, int *h) {
+uint16 *Resource3do::loadShape555(const char *name, int *w, int *h) {
 	char path[MAXPATHLEN];
 	snprintf(path, sizeof(path), "GameData/%s", name);
 	File f;
 	if (f.open(path)) {
-		const uint32_t dataSize = f.size();
+		const uint32 dataSize = f.size();
 		return decodeShapeCcb(&f, dataSize, w, h);
 	}
 
 	return nullptr;
 }
 
-const char *Resource3do::getMusicName(int num, uint32_t *offset) {
+const char *Resource3do::getMusicName(int num, uint32 *offset) {
 	*offset = 0;
 
 	snprintf(_musicPath, sizeof(_musicPath), "GameData/song%d", num);
 	return _musicPath;
 }
 
-const char *Resource3do::getCpak(const char *name, uint32_t *offset) {
+const char *Resource3do::getCpak(const char *name, uint32 *offset) {
 	*offset = 0;
 
 	snprintf(_cpakPath, sizeof(_cpakPath), "GameData/%s", name);
diff --git a/engines/awe/resource_3do.h b/engines/awe/resource_3do.h
index 8ecfa9f9414..a0de15ccdec 100644
--- a/engines/awe/resource_3do.h
+++ b/engines/awe/resource_3do.h
@@ -35,10 +35,10 @@ struct Resource3do {
 
 	bool readEntries();
 
-	uint8_t *loadFile(int num, uint8_t *dst, uint32_t *size);
-	uint16_t *loadShape555(const char *name, int *w, int *h);
-	const char *getMusicName(int num, uint32_t *offset);
-	const char *getCpak(const char *name, uint32_t *offset);
+	uint8 *loadFile(int num, uint8 *dst, uint32 *size);
+	uint16 *loadShape555(const char *name, int *w, int *h);
+	const char *getMusicName(int num, uint32 *offset);
+	const char *getCpak(const char *name, uint32 *offset);
 };
 
 } // namespace Awe
diff --git a/engines/awe/resource_nth.cpp b/engines/awe/resource_nth.cpp
index bbb147d8ddb..850de4de754 100644
--- a/engines/awe/resource_nth.cpp
+++ b/engines/awe/resource_nth.cpp
@@ -70,13 +70,13 @@ struct Resource15th : ResourceNth {
 		return _pak._entriesCount != 0;
 	}
 
-	virtual uint8_t *load(const char *name) {
-		uint8_t *buf = 0;
+	virtual uint8 *load(const char *name) {
+		uint8 *buf = 0;
 		const PakEntry *e = _pak.find(name);
 		if (e) {
-			buf = (uint8_t *)malloc(e->size);
+			buf = (uint8 *)malloc(e->size);
 			if (buf) {
-				uint32_t size;
+				uint32 size;
 				_pak.loadData(e, buf, &size);
 			}
 		} else {
@@ -85,7 +85,7 @@ struct Resource15th : ResourceNth {
 		return buf;
 	}
 
-	virtual uint8_t *loadBmp(int num) {
+	virtual uint8 *loadBmp(int num) {
 		char name[16];
 		if (num >= 3000) {
 			snprintf(name, sizeof(name), "e%04d.bmp", num);
@@ -95,7 +95,7 @@ struct Resource15th : ResourceNth {
 		return load(name);
 	}
 
-	virtual uint8_t *loadDat(int num, uint8_t *dst, uint32_t *size) {
+	virtual uint8 *loadDat(int num, uint8 *dst, uint32 *size) {
 		char name[16];
 		snprintf(name, sizeof(name), "file%03d.dat", num);
 		const PakEntry *e = _pak.find(name);
@@ -108,7 +108,7 @@ struct Resource15th : ResourceNth {
 		return 0;
 	}
 
-	virtual uint8_t *loadWav(int num, uint8_t *dst, uint32_t *size) {
+	virtual uint8 *loadWav(int num, uint8 *dst, uint32 *size) {
 		char name[32];
 		const PakEntry *e = 0;
 		if (Script::_useRemasteredAudio) {
@@ -124,7 +124,7 @@ struct Resource15th : ResourceNth {
 			}
 		}
 		if (e) {
-			uint8_t *p = (uint8_t *)malloc(e->size);
+			uint8 *p = (uint8 *)malloc(e->size);
 			if (p) {
 				_pak.loadData(e, p, size);
 				*size = 0;
@@ -183,7 +183,7 @@ struct Resource15th : ResourceNth {
 							while (*p == ' ' || *p == '\t') {
 								++p;
 							}
-							if ((uint32_t)strNum < ARRAYSIZE(_stringsTable)) {
+							if ((uint32)strNum < ARRAYSIZE(_stringsTable)) {
 								_stringsTable[strNum] = p;
 							}
 						}
@@ -196,7 +196,7 @@ struct Resource15th : ResourceNth {
 
 	virtual const char *getString(Language lang, int num) {
 		loadStrings(lang);
-		if ((uint32_t)num < ARRAYSIZE(_stringsTable)) {
+		if ((uint32)num < ARRAYSIZE(_stringsTable)) {
 			return _stringsTable[num];
 		}
 		return 0;
@@ -229,20 +229,20 @@ struct Resource15th : ResourceNth {
 	}
 };
 
-static uint8_t *inflateGzip(const char *filepath) {
+static uint8 *inflateGzip(const char *filepath) {
 	File f;
 	if (!f.open(filepath)) {
 		warning("Unable to open '%s'", filepath);
 		return 0;
 	}
-	const uint16_t sig = f.readUint16LE();
+	const uint16 sig = f.readUint16LE();
 	if (sig != 0x8B1F) {
 		warning("Unexpected file signature 0x%x for '%s'", sig, filepath);
 		return 0;
 	}
 	f.seek(-4, SEEK_END);
-	const uint32_t dataSize = f.readUint32LE();
-	uint8_t *out = (uint8_t *)malloc(dataSize);
+	const uint32 dataSize = f.readUint32LE();
+	uint8 *out = (uint8 *)malloc(dataSize);
 	if (!out) {
 		warning("Failed to allocate %d bytes", dataSize);
 		return 0;
@@ -282,7 +282,7 @@ struct Resource20th : ResourceNth {
 	char *_textBuf;
 	const char *_stringsTable[192];
 	char _musicName[64];
-	uint8_t _musicType;
+	uint8 _musicType;
 	char _datName[32];
 	const char *_bitmapSize;
 
@@ -333,7 +333,7 @@ struct Resource20th : ResourceNth {
 		return true;
 	}
 
-	virtual uint8_t *load(const char *name) {
+	virtual uint8 *load(const char *name) {
 		if (strcmp(name, "font.bmp") == 0) {
 			return inflateGzip("game/BGZ/Font.bgz");
 		} else if (strcmp(name, "heads.bmp") == 0) {
@@ -343,7 +343,7 @@ struct Resource20th : ResourceNth {
 		return 0;
 	}
 
-	virtual uint8_t *loadBmp(int num) {
+	virtual uint8 *loadBmp(int num) {
 		char path[MAXPATHLEN];
 		if (num >= 3000 && _bitmapSize) {
 			snprintf(path, sizeof(path), "game/BGZ/data%s/%s_e%04d.bgz", _bitmapSize, _bitmapSize, num);
@@ -374,7 +374,7 @@ struct Resource20th : ResourceNth {
 		}
 	}
 
-	virtual uint8_t *loadDat(int num, uint8_t *dst, uint32_t *size) {
+	virtual uint8 *loadDat(int num, uint8 *dst, uint32 *size) {
 		bool datOpen = false;
 		char path[MAXPATHLEN];
 		Common::strcpy_s(path, "game/DAT");
@@ -388,8 +388,8 @@ struct Resource20th : ResourceNth {
 			datOpen = f.open(_datName, path);
 		}
 		if (datOpen) {
-			const uint32_t dataSize = f.size();
-			const uint32_t count = f.read(dst, dataSize);
+			const uint32 dataSize = f.size();
+			const uint32 count = f.read(dst, dataSize);
 			if (count != dataSize) {
 				warning("Failed to read %d bytes (expected %d)", dataSize, count);
 			}
@@ -402,7 +402,7 @@ struct Resource20th : ResourceNth {
 		return dst;
 	}
 
-	virtual uint8_t *loadWav(int num, uint8_t *dst, uint32_t *size) {
+	virtual uint8 *loadWav(int num, uint8 *dst, uint32 *size) {
 		char path[MAXPATHLEN];
 		if (!Script::_useRemasteredAudio) {
 			snprintf(path, sizeof(path), "game/WGZ/original/file%03d.wgz", num);
@@ -521,7 +521,7 @@ struct Resource20th : ResourceNth {
 	}
 	virtual const char *getString(Language lang, int num) {
 		loadStrings(lang);
-		if ((uint32_t)num < ARRAYSIZE(_stringsTable)) {
+		if ((uint32)num < ARRAYSIZE(_stringsTable)) {
 			return _stringsTable[num];
 		}
 		return 0;
diff --git a/engines/awe/resource_nth.h b/engines/awe/resource_nth.h
index 8d689acf794..9790d1f388b 100644
--- a/engines/awe/resource_nth.h
+++ b/engines/awe/resource_nth.h
@@ -31,12 +31,12 @@ struct ResourceNth {
 	}
 
 	virtual bool init() = 0;
-	virtual uint8_t *load(const char *name) = 0;
-	virtual uint8_t *loadBmp(int num) = 0;
+	virtual uint8 *load(const char *name) = 0;
+	virtual uint8 *loadBmp(int num) = 0;
 	virtual void preloadDat(int part, int type, int num) {
 	}
-	virtual uint8_t *loadDat(int num, uint8_t *dst, uint32_t *size) = 0;
-	virtual uint8_t *loadWav(int num, uint8_t *dst, uint32_t *size) = 0;
+	virtual uint8 *loadDat(int num, uint8 *dst, uint32 *size) = 0;
+	virtual uint8 *loadWav(int num, uint8 *dst, uint32 *size) = 0;
 	virtual const char *getString(Language lang, int num) = 0;
 	virtual const char *getMusicName(int num) = 0;
 	virtual void getBitmapSize(int *w, int *h) = 0;
diff --git a/engines/awe/resource_win31.cpp b/engines/awe/resource_win31.cpp
index 7bf73033e99..ce05e2e4da6 100644
--- a/engines/awe/resource_win31.cpp
+++ b/engines/awe/resource_win31.cpp
@@ -24,7 +24,7 @@
 
 namespace Awe {
 
-static const uint8_t _shuffleTable[256] = {
+static const uint8 _shuffleTable[256] = {
 	0xB2, 0x91, 0x49, 0xEE, 0x8C, 0xBC, 0x16, 0x0D, 0x07, 0x87, 0xCD, 0xB6, 0x4C, 0x44, 0x22, 0xB3,
 	0xAE, 0x96, 0xDF, 0x18, 0x7B, 0x28, 0x17, 0x9A, 0x74, 0x3C, 0x2E, 0x59, 0x69, 0x56, 0x38, 0x82,
 	0x7F, 0x25, 0x41, 0xC6, 0xE8, 0x8A, 0x86, 0x7A, 0xB5, 0x8B, 0xA7, 0xB1, 0x2C, 0x53, 0xF0, 0x3B,
@@ -43,11 +43,11 @@ static const uint8_t _shuffleTable[256] = {
 	0xAB, 0x0C, 0xCC, 0x78, 0xFC, 0x2A, 0xD8, 0x3A, 0xDD, 0x8F, 0x10, 0x29, 0xF4, 0x0A, 0xB8, 0xC3
 };
 
-static uint16_t decode(uint8_t *p, int size, uint16_t key) {
+static uint16 decode(uint8 *p, int size, uint16 key) {
 	for (int i = 0; i < size; ++i) {
-		const uint8_t dl = 1 + (key >> 8);
-		const uint8_t al = _shuffleTable[dl];
-		const uint8_t dh = al ^ (key & 255);
+		const uint8 dl = 1 + (key >> 8);
+		const uint8 al = _shuffleTable[dl];
+		const uint8 dh = al ^ (key & 255);
 		p[i] ^= al;
 		key = (dh << 8) | dl;
 	}
@@ -57,7 +57,7 @@ static uint16_t decode(uint8_t *p, int size, uint16_t key) {
 struct Bitstream {
 	File *_f;
 	int _size;
-	uint16_t _bits;
+	uint16 _bits;
 	int _len;
 
 	Bitstream()
@@ -71,7 +71,7 @@ struct Bitstream {
 		_len = 0;
 	}
 
-	uint8_t readByte() {
+	uint8 readByte() {
 		if (_len < 8) {
 			_bits <<= 8;
 			assert(_size > 0);
@@ -210,7 +210,7 @@ struct LzHuffman {
 			p = _parent[p];
 		} while (p != 0);
 	}
-	bool decode(uint8_t *out, int uncompressedSize) {
+	bool decode(uint8 *out, int uncompressedSize) {
 		resetHuffTables();
 		memset(_historyBuffer, ' ', sizeof(_historyBuffer));
 		int offset = 4078;
@@ -237,7 +237,7 @@ struct LzHuffman {
 		return currentSize == uncompressedSize;
 	}
 
-	bool decompressEntry(File &f, const Win31BankEntry *e, uint8_t *out) {
+	bool decompressEntry(File &f, const Win31BankEntry *e, uint8 *out) {
 		f.seek(e->offset);
 		_stream.reset(&f, e->packedSize);
 		return decode(out, e->size);
@@ -257,7 +257,7 @@ ResourceWin31::~ResourceWin31() {
 }
 
 bool ResourceWin31::readEntries() {
-	uint8_t buf[32];
+	uint8 buf[32];
 	const int count = _f.read(buf, sizeof(buf));
 
 	if (count == 32 && memcmp(buf, "NL\00\00", 4) == 0) {
@@ -265,13 +265,13 @@ bool ResourceWin31::readEntries() {
 		debugC(kDebugResource, "Read %d entries in win31 '%s'", _entriesCount, FILENAME);
 		_entries = (Win31BankEntry *)calloc(_entriesCount, sizeof(Win31BankEntry));
 		if (_entries) {
-			uint16_t key = READ_LE_UINT16(buf + 0x14);
+			uint16 key = READ_LE_UINT16(buf + 0x14);
 			for (int i = 0; i < _entriesCount; ++i) {
 				_f.read(buf, sizeof(buf));
 				key = decode(buf, sizeof(buf), key);
 				Win31BankEntry *e = &_entries[i];
 				memcpy(e->name, buf, 16);
-				const uint16_t flags = READ_LE_UINT16(buf + 16);
+				const uint16 flags = READ_LE_UINT16(buf + 16);
 				e->type = buf[19];
 				e->size = READ_LE_UINT32(buf + 20);
 				e->offset = READ_LE_UINT32(buf + 24);
@@ -285,12 +285,12 @@ bool ResourceWin31::readEntries() {
 	return _entries != 0;
 }
 
-uint8_t *ResourceWin31::loadFile(int num, uint8_t *dst, uint32_t *size) {
+uint8 *ResourceWin31::loadFile(int num, uint8 *dst, uint32 *size) {
 	if (num > 0 && num < _entriesCount) {
 		Win31BankEntry *e = &_entries[num];
 		*size = e->size;
 		if (!dst) {
-			dst = (uint8_t *)malloc(e->size);
+			dst = (uint8 *)malloc(e->size);
 			if (!dst) {
 				warning("Unable to allocate %d bytes", e->size);
 				return 0;
@@ -314,11 +314,11 @@ uint8_t *ResourceWin31::loadFile(int num, uint8_t *dst, uint32_t *size) {
 }
 
 void ResourceWin31::readStrings() {
-	uint32_t len, offset = 0;
+	uint32 len, offset = 0;
 	_textBuf = loadFile(148, 0, &len);
 	while (1) {
-		const uint32_t sep = READ_LE_UINT32(_textBuf + offset); offset += 4;
-		const uint16_t num = sep >> 16;
+		const uint32 sep = READ_LE_UINT32(_textBuf + offset); offset += 4;
+		const uint16 num = sep >> 16;
 		if (num == 0xFFFF) {
 			break;
 		}
diff --git a/engines/awe/resource_win31.h b/engines/awe/resource_win31.h
index 4622c0e1189..cb8dd0156bb 100644
--- a/engines/awe/resource_win31.h
+++ b/engines/awe/resource_win31.h
@@ -29,10 +29,10 @@ namespace Awe {
 
 struct Win31BankEntry {
 	char name[16] = { '\0' };
-	uint8_t type = 0;
-	uint32_t offset = 0;
-	uint32_t size = 0;
-	uint32_t packedSize = 0;
+	uint8 type = 0;
+	uint32 offset = 0;
+	uint32 size = 0;
+	uint32 packedSize = 0;
 };
 
 struct ResourceWin31 {
@@ -41,14 +41,14 @@ struct ResourceWin31 {
 	File _f;
 	Win31BankEntry *_entries = nullptr;
 	int _entriesCount = 0;
-	uint8_t *_textBuf = nullptr;
+	uint8 *_textBuf = nullptr;
 	const char *_stringsTable[614] = { nullptr };
 
 	ResourceWin31();
 	~ResourceWin31();
 
 	bool readEntries();
-	uint8_t *loadFile(int num, uint8_t *dst, uint32_t *size);
+	uint8 *loadFile(int num, uint8 *dst, uint32 *size);
 	void readStrings();
 	const char *getString(int num) const;
 	const char *getMusicName(int num) const;
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index 90748d7a8e3..e9cf0ac0f65 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -62,22 +62,22 @@ void Script::init() {
 }
 
 void Script::op_movConst() {
-	uint8_t i = _scriptPtr.fetchByte();
-	int16_t n = _scriptPtr.fetchWord();
+	uint8 i = _scriptPtr.fetchByte();
+	int16 n = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_movConst(0x%02X, %d)", i, n);
 	_scriptVars[i] = n;
 }
 
 void Script::op_mov() {
-	uint8_t i = _scriptPtr.fetchByte();
-	uint8_t j = _scriptPtr.fetchByte();
+	uint8 i = _scriptPtr.fetchByte();
+	uint8 j = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_mov(0x%02X, 0x%02X)", i, j);
 	_scriptVars[i] = _scriptVars[j];
 }
 
 void Script::op_add() {
-	uint8_t i = _scriptPtr.fetchByte();
-	uint8_t j = _scriptPtr.fetchByte();
+	uint8 i = _scriptPtr.fetchByte();
+	uint8 j = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_add(0x%02X, 0x%02X)", i, j);
 	_scriptVars[i] += _scriptVars[j];
 }
@@ -99,14 +99,14 @@ void Script::op_addConst() {
 			snd_playSound(0x5B, 1, 64, 1);
 		}
 	}
-	uint8_t i = _scriptPtr.fetchByte();
-	int16_t n = _scriptPtr.fetchWord();
+	uint8 i = _scriptPtr.fetchByte();
+	int16 n = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_addConst(0x%02X, %d)", i, n);
 	_scriptVars[i] += n;
 }
 
 void Script::op_call() {
-	uint16_t off = _scriptPtr.fetchWord();
+	uint16 off = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_call(0x%X)", off);
 	if (_stackPtr == 0x40) {
 		error("Script::op_call() ec=0x%X stack overflow", 0x8F);
@@ -131,21 +131,21 @@ void Script::op_yieldTask() {
 }
 
 void Script::op_jmp() {
-	uint16_t off = _scriptPtr.fetchWord();
+	uint16 off = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_jmp(0x%02X)", off);
 	_scriptPtr.pc = _res->_segCode + off;
 }
 
 void Script::op_installTask() {
-	uint8_t i = _scriptPtr.fetchByte();
-	uint16_t n = _scriptPtr.fetchWord();
+	uint8 i = _scriptPtr.fetchByte();
+	uint16 n = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_installTask(0x%X, 0x%X)", i, n);
 	assert(i < 0x40);
 	_scriptTasks[1][i] = n;
 }
 
 void Script::op_jmpIfVar() {
-	uint8_t i = _scriptPtr.fetchByte();
+	uint8 i = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_jmpIfVar(0x%02X)", i);
 	--_scriptVars[i];
 	if (_scriptVars[i] != 0) {
@@ -167,10 +167,10 @@ void Script::op_condJmp() {
 		WRITE_BE_UINT16(script + 153, 0xced);
 	}
 
-	uint8_t op = _scriptPtr.fetchByte();
-	const uint8_t var = _scriptPtr.fetchByte();
-	int16_t b = _scriptVars[var];
-	int16_t a;
+	uint8 op = _scriptPtr.fetchByte();
+	const uint8 var = _scriptPtr.fetchByte();
+	int16 b = _scriptVars[var];
+	int16 a;
 	if (op & 0x80) {
 		a = _scriptVars[_scriptPtr.fetchByte()];
 	} else if (op & 0x40) {
@@ -236,7 +236,7 @@ void Script::op_condJmp() {
 }
 
 void Script::op_setPalette() {
-	uint16_t i = _scriptPtr.fetchWord();
+	uint16 i = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_changePalette(%d)", i);
 	const int num = i >> 8;
 	if (_vid->_graphics->_fixUpPalette == FIXUP_PALETTE_REDRAW) {
@@ -252,13 +252,13 @@ void Script::op_setPalette() {
 }
 
 void Script::op_changeTasksState() {
-	uint8_t start = _scriptPtr.fetchByte();
-	uint8_t end = _scriptPtr.fetchByte();
+	uint8 start = _scriptPtr.fetchByte();
+	uint8 end = _scriptPtr.fetchByte();
 	if (end < start) {
 		warning("Script::op_changeTasksState() ec=0x%X (end < start)", 0x880);
 		return;
 	}
-	uint8_t state = _scriptPtr.fetchByte();
+	uint8 state = _scriptPtr.fetchByte();
 
 	debugC(kDebugScript, "Script::op_changeTasksState(%d, %d, %d)", start, end, state);
 
@@ -274,27 +274,27 @@ void Script::op_changeTasksState() {
 }
 
 void Script::op_selectPage() {
-	uint8_t i = _scriptPtr.fetchByte();
+	uint8 i = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_selectPage(%d)", i);
 	_vid->setWorkPagePtr(i);
 }
 
 void Script::op_fillPage() {
-	uint8_t i = _scriptPtr.fetchByte();
-	uint8_t color = _scriptPtr.fetchByte();
+	uint8 i = _scriptPtr.fetchByte();
+	uint8 color = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_fillPage(%d, %d)", i, color);
 	_vid->fillPage(i, color);
 }
 
 void Script::op_copyPage() {
-	uint8_t i = _scriptPtr.fetchByte();
-	uint8_t j = _scriptPtr.fetchByte();
+	uint8 i = _scriptPtr.fetchByte();
+	uint8 j = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_copyPage(%d, %d)", i, j);
 	_vid->copyPage(i, j, _scriptVars[VAR_SCROLL_Y]);
 }
 
 void Script::op_updateDisplay() {
-	uint8_t page = _scriptPtr.fetchByte();
+	uint8 page = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_updateDisplay(%d)", page);
 	inp_handleSpecialKeys();
 
@@ -331,64 +331,64 @@ void Script::op_removeTask() {
 }
 
 void Script::op_drawString() {
-	uint16_t strId = _scriptPtr.fetchWord();
-	uint16_t x = _scriptPtr.fetchByte();
-	uint16_t y = _scriptPtr.fetchByte();
-	uint16_t col = _scriptPtr.fetchByte();
+	uint16 strId = _scriptPtr.fetchWord();
+	uint16 x = _scriptPtr.fetchByte();
+	uint16 y = _scriptPtr.fetchByte();
+	uint16 col = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_drawString(0x%03X, %d, %d, %d)", strId, x, y, col);
 	_vid->drawString(col, x, y, strId);
 }
 
 void Script::op_sub() {
-	uint8_t i = _scriptPtr.fetchByte();
-	uint8_t j = _scriptPtr.fetchByte();
+	uint8 i = _scriptPtr.fetchByte();
+	uint8 j = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_sub(0x%02X, 0x%02X)", i, j);
 	_scriptVars[i] -= _scriptVars[j];
 }
 
 void Script::op_and() {
-	uint8_t i = _scriptPtr.fetchByte();
-	uint16_t n = _scriptPtr.fetchWord();
+	uint8 i = _scriptPtr.fetchByte();
+	uint16 n = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_and(0x%02X, %d)", i, n);
-	_scriptVars[i] = (uint16_t)_scriptVars[i] & n;
+	_scriptVars[i] = (uint16)_scriptVars[i] & n;
 }
 
 void Script::op_or() {
-	uint8_t i = _scriptPtr.fetchByte();
-	uint16_t n = _scriptPtr.fetchWord();
+	uint8 i = _scriptPtr.fetchByte();
+	uint16 n = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_or(0x%02X, %d)", i, n);
-	_scriptVars[i] = (uint16_t)_scriptVars[i] | n;
+	_scriptVars[i] = (uint16)_scriptVars[i] | n;
 }
 
 void Script::op_shl() {
-	uint8_t i = _scriptPtr.fetchByte();
-	uint16_t n = _scriptPtr.fetchWord();
+	uint8 i = _scriptPtr.fetchByte();
+	uint16 n = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_shl(0x%02X, %d)", i, n);
-	_scriptVars[i] = (uint16_t)_scriptVars[i] << n;
+	_scriptVars[i] = (uint16)_scriptVars[i] << n;
 }
 
 void Script::op_shr() {
-	uint8_t i = _scriptPtr.fetchByte();
-	uint16_t n = _scriptPtr.fetchWord();
+	uint8 i = _scriptPtr.fetchByte();
+	uint16 n = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_shr(0x%02X, %d)", i, n);
-	_scriptVars[i] = (uint16_t)_scriptVars[i] >> n;
+	_scriptVars[i] = (uint16)_scriptVars[i] >> n;
 }
 
 void Script::op_playSound() {
-	uint16_t resNum = _scriptPtr.fetchWord();
-	uint8_t freq = _scriptPtr.fetchByte();
-	uint8_t vol = _scriptPtr.fetchByte();
-	uint8_t channel = _scriptPtr.fetchByte();
+	uint16 resNum = _scriptPtr.fetchWord();
+	uint8 freq = _scriptPtr.fetchByte();
+	uint8 vol = _scriptPtr.fetchByte();
+	uint8 channel = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_playSound(0x%X, %d, %d, %d)", resNum, freq, vol, channel);
 	snd_playSound(resNum, freq, vol, channel);
 }
 
-static void preloadSoundCb(void *userdata, int soundNum, const uint8_t *data) {
+static void preloadSoundCb(void *userdata, int soundNum, const uint8 *data) {
 	((Script *)userdata)->snd_preloadSound(soundNum, data);
 }
 
 void Script::op_updateResources() {
-	uint16_t num = _scriptPtr.fetchWord();
+	uint16 num = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_updateResources(%d)", num);
 	if (num == 0) {
 		_ply->stop();
@@ -400,9 +400,9 @@ void Script::op_updateResources() {
 }
 
 void Script::op_playMusic() {
-	uint16_t resNum = _scriptPtr.fetchWord();
-	uint16_t delay = _scriptPtr.fetchWord();
-	uint8_t pos = _scriptPtr.fetchByte();
+	uint16 resNum = _scriptPtr.fetchWord();
+	uint16 delay = _scriptPtr.fetchWord();
+	uint8 pos = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_playMusic(0x%X, %d, %d)", resNum, delay, pos);
 	snd_playMusic(resNum, delay, pos);
 }
@@ -453,7 +453,7 @@ void Script::setupTasks() {
 	}
 	for (int i = 0; i < 0x40; ++i) {
 		_scriptStates[0][i] = _scriptStates[1][i];
-		uint16_t n = _scriptTasks[1][i];
+		uint16 n = _scriptTasks[1][i];
 		if (n != 0xFFFF) {
 			_scriptTasks[0][i] = (n == 0xFFFE) ? 0xFFFF : n;
 			_scriptTasks[1][i] = 0xFFFF;
@@ -464,7 +464,7 @@ void Script::setupTasks() {
 void Script::runTasks() {
 	for (int i = 0; i < 0x40 && !_stub->_pi.quit; ++i) {
 		if (_scriptStates[0][i] == 0) {
-			uint16_t n = _scriptTasks[0][i];
+			uint16 n = _scriptTasks[0][i];
 			if (n != 0xFFFF) {
 				_scriptPtr.pc = _res->_segCode + n;
 				_stackPtr = 0;
@@ -480,14 +480,14 @@ void Script::runTasks() {
 
 void Script::executeTask() {
 	while (!_scriptPaused) {
-		uint8_t opcode = _scriptPtr.fetchByte();
+		uint8 opcode = _scriptPtr.fetchByte();
 		if (opcode & 0x80) {
-			const uint16_t off = ((opcode << 8) | _scriptPtr.fetchByte()) << 1;
+			const uint16 off = ((opcode << 8) | _scriptPtr.fetchByte()) << 1;
 			_res->_useSegVideo2 = false;
 			Point pt;
 			pt.x = _scriptPtr.fetchByte();
 			pt.y = _scriptPtr.fetchByte();
-			int16_t h = pt.y - 199;
+			int16 h = pt.y - 199;
 			if (h > 0) {
 				pt.y = 199;
 				pt.x += h;
@@ -501,8 +501,8 @@ void Script::executeTask() {
 			}
 		} else if (opcode & 0x40) {
 			Point pt;
-			const uint8_t offsetHi = _scriptPtr.fetchByte();
-			const uint16_t off = ((offsetHi << 8) | _scriptPtr.fetchByte()) << 1;
+			const uint8 offsetHi = _scriptPtr.fetchByte();
+			const uint16 off = ((offsetHi << 8) | _scriptPtr.fetchByte()) << 1;
 			pt.x = _scriptPtr.fetchByte();
 			_res->_useSegVideo2 = false;
 			if (!(opcode & 0x20)) {
@@ -524,7 +524,7 @@ void Script::executeTask() {
 					pt.y = _scriptVars[pt.y];
 				}
 			}
-			uint16_t zoom = 64;
+			uint16 zoom = 64;
 			if (!(opcode & 2)) {
 				if (opcode & 1) {
 					zoom = _scriptVars[_scriptPtr.fetchByte()];
@@ -558,7 +558,7 @@ void Script::executeTask() {
 					const int var = _scriptPtr.fetchByte();
 					const int shift = _scriptPtr.fetchByte();
 					debugC(kDebugScript, "Script::op22() VAR(0x%02X) <<= %d", var, shift);
-					_scriptVars[var] = (uint16_t)_scriptVars[var] << shift;
+					_scriptVars[var] = (uint16)_scriptVars[var] << shift;
 				}
 				continue;
 				case 23:
@@ -566,7 +566,7 @@ void Script::executeTask() {
 					const int var = _scriptPtr.fetchByte();
 					const int shift = _scriptPtr.fetchByte();
 					debugC(kDebugScript, "Script::op23() VAR(0x%02X) >>= %d", var, shift);
-					_scriptVars[var] = (uint16_t)_scriptVars[var] >> shift;
+					_scriptVars[var] = (uint16)_scriptVars[var] >> shift;
 				}
 				continue;
 				case 26:
@@ -587,7 +587,7 @@ void Script::executeTask() {
 				continue;
 				case 28:
 				{
-					const uint8_t var = _scriptPtr.fetchByte();
+					const uint8 var = _scriptPtr.fetchByte();
 					debugC(kDebugScript, "Script::op28() jmpIf(VAR(0x%02x) == 0)", var);
 					if (_scriptVars[var] == 0) {
 						op_jmp();
@@ -598,7 +598,7 @@ void Script::executeTask() {
 				continue;
 				case 29:
 				{
-					const uint8_t var = _scriptPtr.fetchByte();
+					const uint8 var = _scriptPtr.fetchByte();
 					debugC(kDebugScript, "Script::op29() jmpIf(VAR(0x%02x) != 0)", var);
 					if (_scriptVars[var] != 0) {
 						op_jmp();
@@ -632,10 +632,10 @@ void Script::updateInput() {
 			_stub->_pi.lastChar = 0;
 		}
 	}
-	int16_t lr = 0;
-	int16_t m = 0;
-	int16_t ud = 0;
-	int16_t jd = 0;
+	int16 lr = 0;
+	int16 m = 0;
+	int16 ud = 0;
+	int16 jd = 0;
 	if (_stub->_pi.dirMask & PlayerInput::DIR_RIGHT) {
 		lr = 1;
 		m |= 1;
@@ -668,7 +668,7 @@ void Script::updateInput() {
 	_scriptVars[VAR_HERO_POS_JUMP_DOWN] = jd;
 	_scriptVars[VAR_HERO_POS_LEFT_RIGHT] = lr;
 	_scriptVars[VAR_HERO_POS_MASK] = m;
-	int16_t action = 0;
+	int16 action = 0;
 	if (_stub->_pi.action) {
 		action = 1;
 		m |= 0x80;
@@ -676,7 +676,7 @@ void Script::updateInput() {
 	_scriptVars[VAR_HERO_ACTION] = action;
 	_scriptVars[VAR_HERO_ACTION_POS_MASK] = m;
 	if (_res->_currentPart == kPartWater) {
-		const uint8_t mask = _res->_demo3Joy.update();
+		const uint8 mask = _res->_demo3Joy.update();
 		if (mask != 0) {
 			_scriptVars[VAR_HERO_ACTION_POS_MASK] = mask;
 			_scriptVars[VAR_HERO_POS_MASK] = mask & 15;
@@ -756,7 +756,7 @@ void Script::inp_handleSpecialKeys() {
 	}
 }
 
-static uint8_t getWavLooping(uint16_t resNum) {
+static uint8 getWavLooping(uint16 resNum) {
 	switch (resNum) {
 	case 1:
 	case 3:
@@ -773,11 +773,11 @@ static uint8_t getWavLooping(uint16_t resNum) {
 	return 0;
 }
 
-static int getSoundFreq(uint8_t period) {
+static int getSoundFreq(uint8 period) {
 	return kPaulaFreq / (Script::PERIOD_TABLE[period] * 2);
 }
 
-void Script::snd_playSound(uint16_t resNum, uint8_t freq, uint8_t vol, uint8_t channel) {
+void Script::snd_playSound(uint16 resNum, uint8 freq, uint8 vol, uint8 channel) {
 	debugC(kDebugSound, "snd_playSound(0x%X, %d, %d, %d)", resNum, freq, vol, channel);
 	if (vol == 0) {
 		_sound->stopSound(channel);
@@ -809,7 +809,7 @@ void Script::snd_playSound(uint16_t resNum, uint8_t freq, uint8_t vol, uint8_t c
 		// fall-through
 	case DT_WIN31: {
 		uint32 size = 0;
-		uint8_t *buf = _res->loadWav(resNum, &size);
+		uint8 *buf = _res->loadWav(resNum, &size);
 		if (buf) {
 			_sound->playSoundWav(channel, buf, size,
 				getSoundFreq(freq), vol, getWavLooping(resNum));
@@ -835,9 +835,9 @@ void Script::snd_playSound(uint16_t resNum, uint8_t freq, uint8_t vol, uint8_t c
 	}
 }
 
-void Script::snd_playMusic(uint16_t resNum, uint16_t delay, uint8_t pos) {
+void Script::snd_playMusic(uint16 resNum, uint16 delay, uint8 pos) {
 	debugC(kDebugSound, "snd_playMusic(0x%X, %d, %d)", resNum, delay, pos);
-	uint8_t loop = 0;
+	uint8 loop = 0;
 
 	switch (_res->getDataType()) {
 	case DT_20TH_EDITION:
@@ -863,7 +863,7 @@ void Script::snd_playMusic(uint16_t resNum, uint16_t delay, uint8_t pos) {
 		if (resNum == 0) {
 			_sound->stopAifcMusic();
 		} else {
-			uint32_t offset = 0;
+			uint32 offset = 0;
 			char path[MAXPATHLEN];
 			const char *p = _res->getMusicPath(resNum, path, sizeof(path), &offset);
 			if (p) {
@@ -885,7 +885,7 @@ void Script::snd_playMusic(uint16_t resNum, uint16_t delay, uint8_t pos) {
 	}
 }
 
-void Script::snd_preloadSound(uint16_t resNum, const uint8_t *data) {
+void Script::snd_preloadSound(uint16 resNum, const uint8 *data) {
 	if (_res->getDataType() == DT_3DO) {
 		_sound->preloadSoundAiff(resNum, data);
 	}
diff --git a/engines/awe/script.h b/engines/awe/script.h
index ed6ac4eede3..df560753186 100644
--- a/engines/awe/script.h
+++ b/engines/awe/script.h
@@ -63,7 +63,7 @@ struct Script {
 	};
 
 	static const OpcodeStub OPCODE_TABLE[];
-	static const uint16_t PERIOD_TABLE[];
+	static const uint16 PERIOD_TABLE[];
 	static Difficulty _difficulty;
 	static bool _useRemasteredAudio;
 
@@ -73,17 +73,17 @@ struct Script {
 	Video *_vid;
 	SystemStub *_stub = nullptr;
 
-	int16_t _scriptVars[256] = { 0 };
-	uint16_t _scriptStackCalls[64] = { 0 };
-	uint16_t _scriptTasks[2][64] = { { 0 } };
-	uint8_t _scriptStates[2][64] = { { 0 } };
+	int16 _scriptVars[256] = { 0 };
+	uint16 _scriptStackCalls[64] = { 0 };
+	uint16 _scriptTasks[2][64] = { { 0 } };
+	uint8 _scriptStates[2][64] = { { 0 } };
 	Ptr _scriptPtr;
-	uint8_t _stackPtr = 0;
+	uint8 _stackPtr = 0;
 	bool _scriptPaused = false;
 	bool _fastMode = false;
 	int _screenNum = 0;
 	bool _is3DO = false;
-	uint32_t _startTime = 0, _timeStamp = 0;
+	uint32 _startTime = 0, _timeStamp = 0;
 
 	Script(Sound *snd, Resource *res, SfxPlayer *ply, Video *vid);
 	void init();
@@ -125,9 +125,9 @@ struct Script {
 	void updateInput();
 	void inp_handleSpecialKeys();
 
-	void snd_playSound(uint16_t resNum, uint8_t freq, uint8_t vol, uint8_t channel);
-	void snd_playMusic(uint16_t resNum, uint16_t delay, uint8_t pos);
-	void snd_preloadSound(uint16_t resNum, const uint8_t *data);
+	void snd_playSound(uint16 resNum, uint8 freq, uint8 vol, uint8 channel);
+	void snd_playMusic(uint16 resNum, uint16 delay, uint8 pos);
+	void snd_preloadSound(uint16 resNum, const uint8 *data);
 
 	void fixUpPalette_changeScreen(int part, int screen);
 };
diff --git a/engines/awe/sfx_player.cpp b/engines/awe/sfx_player.cpp
index 78737cf97d9..a8b22cb37b1 100644
--- a/engines/awe/sfx_player.cpp
+++ b/engines/awe/sfx_player.cpp
@@ -32,12 +32,12 @@ SfxPlayer::SfxPlayer(Resource *res)
 	_playing = false;
 }
 
-void SfxPlayer::setEventsDelay(uint16_t delay) {
+void SfxPlayer::setEventsDelay(uint16 delay) {
 	debugC(kDebugSound, "SfxPlayer::setEventsDelay(%d)", delay);
 	_delay = delay;
 }
 
-void SfxPlayer::loadSfxModule(uint16_t resNum, uint16_t delay, uint8_t pos) {
+void SfxPlayer::loadSfxModule(uint16 resNum, uint16 delay, uint8 pos) {
 	debugC(kDebugSound, "SfxPlayer::loadSfxModule(0x%X, %d, %d)", resNum, delay, pos);
 	MemEntry *me = &_res->_memList[resNum];
 	if (me->status == Resource::STATUS_LOADED && me->type == Resource::RT_MUSIC) {
@@ -59,11 +59,11 @@ void SfxPlayer::loadSfxModule(uint16_t resNum, uint16_t delay, uint8_t pos) {
 	}
 }
 
-void SfxPlayer::prepareInstruments(const uint8_t *p) {
+void SfxPlayer::prepareInstruments(const uint8 *p) {
 	memset(_sfxMod.samples, 0, sizeof(_sfxMod.samples));
 	for (int i = 0; i < 15; ++i) {
 		SfxInstrument *ins = &_sfxMod.samples[i];
-		uint16_t resNum = READ_BE_UINT16(p); p += 2;
+		uint16 resNum = READ_BE_UINT16(p); p += 2;
 		if (resNum != 0) {
 			ins->volume = READ_BE_UINT16(p);
 			MemEntry *me = &_res->_memList[resNum];
@@ -85,18 +85,18 @@ void SfxPlayer::play(int rate) {
 	memset(_channels, 0, sizeof(_channels));
 }
 
-static int16_t toS16(int a) {
+static int16 toS16(int a) {
 	if (a <= -128) {
 		return -32768;
 	} else if (a >= 127) {
 		return 32767;
 	} else {
-		const uint8_t u8 = (a ^ 0x80);
+		const uint8 u8 = (a ^ 0x80);
 		return ((u8 << 8) | u8) - 32768;
 	}
 }
 
-static void mixChannel(int16_t &s, SfxChannel *ch) {
+static void mixChannel(int16 &s, SfxChannel *ch) {
 	if (ch->sampleLen == 0) {
 		return;
 	}
@@ -114,12 +114,12 @@ static void mixChannel(int16_t &s, SfxChannel *ch) {
 			return;
 		}
 	}
-	int sample = ch->pos.interpolate((int8_t)ch->sampleData[pos1], (int8_t)ch->sampleData[pos2]);
+	int sample = ch->pos.interpolate((int8)ch->sampleData[pos1], (int8)ch->sampleData[pos2]);
 	sample = s + toS16(sample * ch->volume / 64);
 	s = (sample < -32768 ? -32768 : (sample > 32767 ? 32767 : sample));
 }
 
-void SfxPlayer::mixSamples(int16_t *buf, int len) {
+void SfxPlayer::mixSamples(int16 *buf, int len) {
 	while (len != 0) {
 		if (_samplesLeft == 0) {
 			handleEvents();
@@ -143,7 +143,7 @@ void SfxPlayer::mixSamples(int16_t *buf, int len) {
 	}
 }
 
-void SfxPlayer::readSamples(int16_t *buf, int len) {
+void SfxPlayer::readSamples(int16 *buf, int len) {
 	if (_delay != 0) {
 		mixSamples(buf, len / 2);
 	}
@@ -160,9 +160,9 @@ void SfxPlayer::stop() {
 }
 
 void SfxPlayer::handleEvents() {
-	uint8_t order = _sfxMod.orderTable[_sfxMod.curOrder];
-	const uint8_t *patternData = _sfxMod.data + _sfxMod.curPos + order * 1024;
-	for (uint8_t ch = 0; ch < 4; ++ch) {
+	uint8 order = _sfxMod.orderTable[_sfxMod.curOrder];
+	const uint8 *patternData = _sfxMod.data + _sfxMod.curPos + order * 1024;
+	for (uint8 ch = 0; ch < 4; ++ch) {
 		handlePattern(ch, patternData);
 		patternData += 4;
 	}
@@ -178,22 +178,22 @@ void SfxPlayer::handleEvents() {
 	}
 }
 
-void SfxPlayer::handlePattern(uint8_t channel, const uint8_t *data) {
+void SfxPlayer::handlePattern(uint8 channel, const uint8 *data) {
 	SfxPattern pat;
 	memset(&pat, 0, sizeof(SfxPattern));
 	pat.note_1 = READ_BE_UINT16(data + 0);
 	pat.note_2 = READ_BE_UINT16(data + 2);
 	if (pat.note_1 != 0xFFFD) {
-		uint16_t sample = (pat.note_2 & 0xF000) >> 12;
+		uint16 sample = (pat.note_2 & 0xF000) >> 12;
 		if (sample != 0) {
-			uint8_t *ptr = _sfxMod.samples[sample - 1].data;
+			uint8 *ptr = _sfxMod.samples[sample - 1].data;
 			if (ptr != 0) {
 				debugC(kDebugSound, "SfxPlayer::handlePattern() preparing sample %d", sample);
 				pat.sampleVolume = _sfxMod.samples[sample - 1].volume;
 				pat.sampleStart = 8;
 				pat.sampleBuffer = ptr;
 				pat.sampleLen = READ_BE_UINT16(ptr) * 2;
-				uint16_t loopLen = READ_BE_UINT16(ptr + 2) * 2;
+				uint16 loopLen = READ_BE_UINT16(ptr + 2) * 2;
 				if (loopLen != 0) {
 					pat.loopPos = pat.sampleLen;
 					pat.loopLen = loopLen;
@@ -201,16 +201,16 @@ void SfxPlayer::handlePattern(uint8_t channel, const uint8_t *data) {
 					pat.loopPos = 0;
 					pat.loopLen = 0;
 				}
-				int16_t m = pat.sampleVolume;
-				uint8_t effect = (pat.note_2 & 0x0F00) >> 8;
+				int16 m = pat.sampleVolume;
+				uint8 effect = (pat.note_2 & 0x0F00) >> 8;
 				if (effect == 5) { // volume up
-					uint8_t volume = (pat.note_2 & 0xFF);
+					uint8 volume = (pat.note_2 & 0xFF);
 					m += volume;
 					if (m > 0x3F) {
 						m = 0x3F;
 					}
 				} else if (effect == 6) { // volume down
-					uint8_t volume = (pat.note_2 & 0xFF);
+					uint8 volume = (pat.note_2 & 0xFF);
 					m -= volume;
 					if (m < 0) {
 						m = 0;
diff --git a/engines/awe/sfx_player.h b/engines/awe/sfx_player.h
index 326f47aeb7c..9a94f53d382 100644
--- a/engines/awe/sfx_player.h
+++ b/engines/awe/sfx_player.h
@@ -27,36 +27,36 @@
 namespace Awe {
 
 struct SfxInstrument {
-	uint8_t *data = nullptr;
-	uint16_t volume = 0;
+	uint8 *data = nullptr;
+	uint16 volume = 0;
 };
 
 struct SfxModule {
-	const uint8_t *data = nullptr;
-	uint16_t curPos = 0;
-	uint8_t curOrder = 0;
-	uint8_t numOrder = 0;
-	uint8_t *orderTable = nullptr;
+	const uint8 *data = nullptr;
+	uint16 curPos = 0;
+	uint8 curOrder = 0;
+	uint8 numOrder = 0;
+	uint8 *orderTable = nullptr;
 	SfxInstrument samples[15];
 };
 
 struct SfxPattern {
-	uint16_t note_1 = 0;
-	uint16_t note_2 = 0;
-	uint16_t sampleStart = 0;
-	uint8_t *sampleBuffer = nullptr;
-	uint16_t sampleLen = 0;
-	uint16_t loopPos = 0;
-	uint16_t loopLen = 0;
-	uint16_t sampleVolume = 0;
+	uint16 note_1 = 0;
+	uint16 note_2 = 0;
+	uint16 sampleStart = 0;
+	uint8 *sampleBuffer = nullptr;
+	uint16 sampleLen = 0;
+	uint16 loopPos = 0;
+	uint16 loopLen = 0;
+	uint16 sampleVolume = 0;
 };
 
 struct SfxChannel {
-	uint8_t *sampleData = nullptr;
-	uint16_t sampleLen = 0;
-	uint16_t sampleLoopPos = 0;
-	uint16_t sampleLoopLen = 0;
-	uint16_t volume = 0;
+	uint8 *sampleData = nullptr;
+	uint16 sampleLen = 0;
+	uint16 sampleLoopPos = 0;
+	uint16 sampleLoopLen = 0;
+	uint16 volume = 0;
 	Frac pos;
 };
 
@@ -69,10 +69,10 @@ struct SfxPlayer {
 
 	Resource *_res;
 
-	uint16_t _delay = 0;
-	uint16_t _resNum = 0;
+	uint16 _delay = 0;
+	uint16 _resNum = 0;
 	SfxModule _sfxMod;
-	int16_t *_syncVar = nullptr;
+	int16 *_syncVar = nullptr;
 	bool _playing = false;
 	int _rate = 0;
 	int _samplesLeft = 0;
@@ -80,16 +80,16 @@ struct SfxPlayer {
 
 	SfxPlayer(Resource *res);
 
-	void setEventsDelay(uint16_t delay);
-	void loadSfxModule(uint16_t resNum, uint16_t delay, uint8_t pos);
-	void prepareInstruments(const uint8_t *p);
+	void setEventsDelay(uint16 delay);
+	void loadSfxModule(uint16 resNum, uint16 delay, uint8 pos);
+	void prepareInstruments(const uint8 *p);
 	void play(int rate);
-	void mixSamples(int16_t *buf, int len);
-	void readSamples(int16_t *buf, int len);
+	void mixSamples(int16 *buf, int len);
+	void readSamples(int16 *buf, int len);
 	void start();
 	void stop();
 	void handleEvents();
-	void handlePattern(uint8_t channel, const uint8_t *patternData);
+	void handlePattern(uint8 channel, const uint8 *patternData);
 };
 
 } // namespace Awe
diff --git a/engines/awe/sound.cpp b/engines/awe/sound.cpp
index a9df4605664..d171011b08d 100644
--- a/engines/awe/sound.cpp
+++ b/engines/awe/sound.cpp
@@ -42,7 +42,7 @@ void Sound::playSfxMusic(int num) {
 	warning("TODO: playSfxMusic");
 }
 
-void Sound::playAifcMusic(const char *path, uint32_t offset) {
+void Sound::playAifcMusic(const char *path, uint32 offset) {
 	warning("TODO: playAifcMusic");
 }
 
@@ -77,7 +77,7 @@ void Sound::playSoundRaw(byte channel, const byte *data, size_t size,
 }
 
 void Sound::playSoundWav(byte channel, const byte *data, size_t size,
-		uint16_t freq, byte volume, byte loop) {
+		uint16 freq, byte volume, byte loop) {
 	assert(channel < MAX_CHANNELS);
 
 	Common::MemoryReadStream *stream =
@@ -107,11 +107,11 @@ enum {
 
 static const bool kAmigaStereoChannels = false; // 0,3:left 1,2:right
 
-static int16_t toS16(int a) {
+static int16 toS16(int a) {
 	return ((a << 8) | a) - 32768;
 }
 
-static int16_t mixS16(int sample1, int sample2) {
+static int16 mixS16(int sample1, int sample2) {
 	const int sample = sample1 + sample2;
 	return sample < -32768 ? -32768 : ((sample > 32767 ? 32767 : sample));
 }
@@ -119,10 +119,10 @@ static int16_t mixS16(int sample1, int sample2) {
 struct MixerChannel {
 	const byte *_data;
 	Frac _pos;
-	uint32_t _len;
-	uint32_t _loopLen, _loopPos;
+	uint32 _len;
+	uint32 _loopLen, _loopPos;
 	int _volume;
-	void (MixerChannel:: *_mixWav)(int16_t *sample, int count);
+	void (MixerChannel:: *_mixWav)(int16 *sample, int count);
 
 	void initRaw(const byte *data, int freq, int volume, int mixingFreq) {
 		_data = data + 8;
@@ -146,9 +146,9 @@ struct MixerChannel {
 		_volume = volume;
 		_mixWav = bits16 ? (stereo ? &MixerChannel::mixWav<16, true> : &MixerChannel::mixWav<16, false>) : (stereo ? &MixerChannel::mixWav<8, true> : &MixerChannel::mixWav<8, false>);
 	}
-	void mixRaw(int16_t &sample) {
+	void mixRaw(int16 &sample) {
 		if (_data) {
-			uint32_t pos = _pos.getInt();
+			uint32 pos = _pos.getInt();
 			_pos.offset += _pos.inc;
 			if (_loopLen != 0) {
 				if (pos >= _loopPos + _loopLen) {
@@ -166,9 +166,9 @@ struct MixerChannel {
 	}
 
 	template<int bits, bool stereo>
-	void mixWav(int16_t *samples, int count) {
+	void mixWav(int16 *samples, int count) {
 		for (int i = 0; i < count; i += 2) {
-			uint32_t pos = _pos.getInt();
+			uint32 pos = _pos.getInt();
 			_pos.offset += _pos.inc;
 			if (pos >= _len) {
 				if (_loopLen != 0) {
@@ -186,7 +186,7 @@ struct MixerChannel {
 			if (bits == 8) { // U8
 				valueL = toS16(_data[pos]) * _volume / 64;
 			} else { // S16
-				valueL = ((int16_t)READ_LE_UINT16(&_data[pos * sizeof(int16_t)])) * _volume / 64;
+				valueL = ((int16)READ_LE_UINT16(&_data[pos * sizeof(int16)])) * _volume / 64;
 			}
 			*samples = mixS16(*samples, valueL);
 			++samples;
@@ -198,7 +198,7 @@ struct MixerChannel {
 				if (bits == 8) { // U8
 					valueR = toS16(_data[pos + 1]) * _volume / 64;
 				} else { // S16
-					valueR = ((int16_t)READ_LE_UINT16(&_data[(pos + 1) * sizeof(int16_t)])) * _volume / 64;
+					valueR = ((int16)READ_LE_UINT16(&_data[(pos + 1) * sizeof(int16)])) * _volume / 64;
 				}
 			}
 			*samples = mixS16(*samples, valueR);
@@ -208,13 +208,13 @@ struct MixerChannel {
 };
 
 static const byte *loadWav(const byte *data, int &freq, int &len, bool &bits16, bool &stereo) {
-	uint32_t riffMagic = READ_LE_UINT32(data);
+	uint32 riffMagic = READ_LE_UINT32(data);
 	if (riffMagic != TAG_RIFF) return 0;
-	uint32_t riffLength = READ_LE_UINT32(data + 4);
-	uint32_t waveMagic = READ_LE_UINT32(data + 8);
+	uint32 riffLength = READ_LE_UINT32(data + 4);
+	uint32 waveMagic = READ_LE_UINT32(data + 8);
 	if (waveMagic != TAG_WAVE) return 0;
-	uint32_t offset = 12;
-	uint32_t chunkMagic, chunkLength = 0;
+	uint32 offset = 12;
+	uint32 chunkMagic, chunkLength = 0;
 	// find fmt chunk
 	do {
 		offset += chunkLength + (chunkLength & 1);
@@ -255,7 +255,7 @@ static const byte *loadWav(const byte *data, int &freq, int &len, bool &bits16,
 		offset += 8;
 	} while (chunkMagic != TAG_data);
 
-	uint32_t lengthSamples = chunkLength;
+	uint32 lengthSamples = chunkLength;
 	if (offset + lengthSamples - 4 > riffLength) {
 		lengthSamples = riffLength + 4 - offset;
 	}
@@ -385,7 +385,7 @@ struct Mixer_impl {
 	}
 
 	static void mixAifcPlayer(void *data, byte *s16buf, int len) {
-		((AifcPlayer *)data)->readSamples((int16_t *)s16buf, len / 2);
+		((AifcPlayer *)data)->readSamples((int16 *)s16buf, len / 2);
 	}
 	void playAifcMusic(AifcPlayer *aifc) {
 		Mix_HookMusic(mixAifcPlayer, aifc);
@@ -409,7 +409,7 @@ struct Mixer_impl {
 		SDL_UnlockAudio();
 	}
 
-	void mixChannels(int16_t *samples, int count) {
+	void mixChannels(int16 *samples, int count) {
 		if (kAmigaStereoChannels) {
 			for (int i = 0; i < count; i += 2) {
 				_channels[0].mixRaw(*samples);
@@ -432,13 +432,13 @@ struct Mixer_impl {
 	static void mixAudio(void *data, byte *s16buf, int len) {
 		memset(s16buf, 0, len);
 		Mixer_impl *mixer = (Mixer_impl *)data;
-		mixer->mixChannels((int16_t *)s16buf, len / sizeof(int16_t));
+		mixer->mixChannels((int16 *)s16buf, len / sizeof(int16));
 		if (mixer->_sfx) {
-			mixer->_sfx->readSamples((int16_t *)s16buf, len / sizeof(int16_t));
+			mixer->_sfx->readSamples((int16 *)s16buf, len / sizeof(int16));
 		}
 	}
 
-	void mixChannelsWav(int16_t *samples, int count) {
+	void mixChannelsWav(int16 *samples, int count) {
 		for (int i = 0; i < kMixChannels; ++i) {
 			if (_channels[i]._data) {
 				(_channels[i].*_channels[i]._mixWav)(samples, count);
@@ -448,7 +448,7 @@ struct Mixer_impl {
 
 	static void mixAudioWav(void *data, byte *s16buf, int len) {
 		Mixer_impl *mixer = (Mixer_impl *)data;
-		mixer->mixChannelsWav((int16_t *)s16buf, len / sizeof(int16_t));
+		mixer->mixChannelsWav((int16 *)s16buf, len / sizeof(int16));
 	}
 
 	void stopAll() {
@@ -468,7 +468,7 @@ struct Mixer_impl {
 		if (_preloads.find(num) != _preloads.end()) {
 			warning("AIFF sound %d is already preloaded", num);
 		} else {
-			const uint32_t size = READ_BE_UINT32(data + 4) + 8;
+			const uint32 size = READ_BE_UINT32(data + 4) + 8;
 			SDL_RWops *rw = SDL_RWFromConstMem(data, size);
 			Mix_Chunk *chunk = Mix_LoadWAV_RW(rw, 1);
 			_preloads[num] = chunk;
@@ -510,14 +510,14 @@ void Mixer::update() {
 	}
 }
 
-void Mixer::playSoundRaw(byte channel, const byte *data, uint16_t freq, byte volume) {
+void Mixer::playSoundRaw(byte channel, const byte *data, uint16 freq, byte volume) {
 	debugC(kDebugSound, "Mixer::playChannel(%d, %d, %d)", channel, freq, volume);
 	if (_impl) {
 		return _impl->playSoundRaw(channel, data, freq, volume);
 	}
 }
 
-void Mixer::playSoundWav(byte channel, const byte *data, uint16_t freq, byte volume, byte loop) {
+void Mixer::playSoundWav(byte channel, const byte *data, uint16 freq, byte volume, byte loop) {
 	debugC(kDebugSound, "Mixer::playSoundWav(%d, %d, %d)", channel, volume, loop);
 	if (_impl) {
 		return _impl->playSoundWav(channel, data, freq, volume, loop);
@@ -552,7 +552,7 @@ void Mixer::stopMusic() {
 	}
 }
 
-void Mixer::playAifcMusic(const char *path, uint32_t offset) {
+void Mixer::playAifcMusic(const char *path, uint32 offset) {
 	debugC(kDebugSound, "Mixer::playAifcMusic(%s)", path);
 	if (!_aifc) {
 		_aifc = new AifcPlayer();
diff --git a/engines/awe/sound.h b/engines/awe/sound.h
index 60f83a3a228..97ec13c390c 100644
--- a/engines/awe/sound.h
+++ b/engines/awe/sound.h
@@ -42,7 +42,7 @@ public:
 		_mixer->stopAll();
 	}
 	void playMusic(const char *path, int loops);
-	void playAifcMusic(const char *path, uint32_t offset);
+	void playAifcMusic(const char *path, uint32 offset);
 	void playSfxMusic(int num);
 	void stopMusic();
 	void stopAifcMusic();
@@ -52,7 +52,7 @@ public:
 	void playSoundRaw(byte channel, const byte *data, size_t size,
 		int freq, byte volume);
 	void playSoundWav(byte channel, const byte *data, size_t size,
-		uint16_t freq, byte volume, byte loop);
+		uint16 freq, byte volume, byte loop);
 	void playSoundAiff(byte channel, byte num, byte volume);
 	void stopSound(byte channel);
 };
@@ -73,13 +73,13 @@ struct Mixer {
 	void quit();
 	void update();
 
-	void playSoundRaw(byte channel, const byte *data, uint16_t freq, byte volume);
-	void playSoundWav(byte channel, const byte *data, uint16_t freq, byte volume, byte loop);
+	void playSoundRaw(byte channel, const byte *data, uint16 freq, byte volume);
+	void playSoundWav(byte channel, const byte *data, uint16 freq, byte volume, byte loop);
 	void stopSound(byte channel);
 	void setChannelVolume(byte channel, byte volume);
 	void playMusic(const char *path, byte loop);
 	void stopMusic();
-	void playAifcMusic(const char *path, uint32_t offset);
+	void playAifcMusic(const char *path, uint32 offset);
 	void stopAifcMusic();
 	void playSfxMusic(int num);
 	void stopSfxMusic();
diff --git a/engines/awe/static_res.cpp b/engines/awe/static_res.cpp
index ede78fca056..b6af52791e8 100644
--- a/engines/awe/static_res.cpp
+++ b/engines/awe/static_res.cpp
@@ -63,14 +63,14 @@ const Script::OpcodeStub Script::OPCODE_TABLE[] = {
 	&Script::op_playMusic
 };
 
-const uint16_t Script::PERIOD_TABLE[] = {
+const uint16 Script::PERIOD_TABLE[] = {
 	1076, 1016,  960,  906,  856,  808,  762,  720,  678,  640,
 	 604,  570,  538,  508,  480,  453,  428,  404,  381,  360,
 	 339,  320,  302,  285,  269,  254,  240,  226,  214,  202,
 	 190,  180,  170,  160,  151,  143,  135,  127,  120,  113
 };
 
-const uint8_t Gfx::FONT[] = {
+const uint8 Gfx::FONT[] = {
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00,
 	0x28, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x7E, 0x24, 0x24, 0x7E, 0x24, 0x00,
 	0x08, 0x3E, 0x48, 0x3C, 0x12, 0x7C, 0x10, 0x00, 0x42, 0xA4, 0x48, 0x10, 0x24, 0x4A, 0x84, 0x00,
@@ -420,7 +420,7 @@ const StrEntry Video::STRINGS_TABLE_DEMO[] = {
 	{ 0xFFFF, 0 }
 };
 
-const uint16_t Video::STRINGS_ID_15TH[] = {
+const uint16 Video::STRINGS_ID_15TH[] = {
 	0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, 0x008, 0x00A, 0x00B, 0x00C, 0x00D, 0x00E, 0x00F, 0x010, 0x011,
 	0x012, 0x013, 0x014, 0x015, 0x016, 0x017, 0x018, 0x019, 0x01A, 0x01B, 0x01C, 0x021, 0x022, 0x023, 0x024, 0x025,
 	0x026, 0x027, 0x028, 0x029, 0x02A, 0x02B, 0x02C, 0x031, 0x032, 0x033, 0x034, 0x035, 0x036, 0x037, 0x038, 0x039,
@@ -810,7 +810,7 @@ const char *Video::END_TEXT_3DO = {
 	"Bill \"Angus\" Guschwan at 3DO\n"
 };
 
-static const uint8_t VERTICES_DATA_3DO[] = {
+static const uint8 VERTICES_DATA_3DO[] = {
 	0x0f, 0x10, 0x05, 0x10, 0x05, 0x0f, 0x05, 0x0e, 0x04, 0x0e, 0x04, 0x0d, 0x03, 0x0c, 0x03, 0x0b,
 	0x02, 0x0b, 0x02, 0x0a, 0x01, 0x09, 0x01, 0x08, 0x01, 0x08, 0x01, 0x07, 0x01, 0x06, 0x01, 0x06,
 	0x01, 0x06, 0x00, 0x05, 0x0b, 0x17, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x01, 0x07,
@@ -1206,7 +1206,7 @@ static const uint8_t VERTICES_DATA_3DO[] = {
 	0x01, 0x02, 0x00, 0x00, 0x06, 0x04, 0x00, 0x03, 0x01, 0x04, 0x03, 0x04, 0x04, 0x05, 0x00, 0x00
 };
 
-const uint8_t *Video::VERTICES_3DO[201] = {
+const uint8 *Video::VERTICES_3DO[201] = {
 	&VERTICES_DATA_3DO[0],
 	&VERTICES_DATA_3DO[36],
 	&VERTICES_DATA_3DO[84],
@@ -1410,7 +1410,7 @@ const uint8_t *Video::VERTICES_3DO[201] = {
 	&VERTICES_DATA_3DO[6276],
 };
 
-const uint16_t Gfx::SHAPES_MASK_OFFSET[] = {
+const uint16 Gfx::SHAPES_MASK_OFFSET[] = {
 	0x0000, 0x0022, 0x0052, 0x006c, 0x008c, 0x00ca, 0x0110, 0x0142,
 	0x0180, 0x01a8, 0x01fe, 0x021c, 0x025a, 0x0298, 0x02c2, 0x0314,
 	0x0334, 0x034e, 0x0376, 0x039e, 0x03c0, 0x03e8, 0x0402, 0x0440,
@@ -1441,7 +1441,7 @@ const uint16_t Gfx::SHAPES_MASK_OFFSET[] = {
 
 const int Gfx::SHAPES_MASK_COUNT = ARRAYSIZE(SHAPES_MASK_OFFSET);
 
-const uint8_t Gfx::SHAPES_MASK_DATA[] = {
+const uint8 Gfx::SHAPES_MASK_DATA[] = {
 	0x0f, 0x10, 0x07, 0xff, 0x07, 0xfe, 0x0f, 0xfe, 0x0f, 0xfc, 0x1f, 0xf8, 0x1f, 0xf0, 0x3f, 0xf0,
 	0x3f, 0xe0, 0x7f, 0xc0, 0x7f, 0x80, 0x7f, 0x80, 0x7f, 0x00, 0x7e, 0x00, 0x7e, 0x00, 0x7e, 0x00,
 	0xfc, 0x00, 0x0b, 0x17, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x7f, 0x00, 0x7f, 0x00,
@@ -1899,7 +1899,7 @@ const uint8_t Gfx::SHAPES_MASK_DATA[] = {
 };
 
 // from https://en.wikipedia.org/wiki/Enhanced_Graphics_Adapter
-const uint8_t Video::PALETTE_EGA[] = {
+const uint8 Video::PALETTE_EGA[] = {
         0x00, 0x00, 0x00, // black #0
         0x00, 0x00, 0xAA, // blue #1
         0x00, 0xAA, 0x00, // green #2
diff --git a/engines/awe/system_stub.cpp b/engines/awe/system_stub.cpp
index b3b2f75ab29..d3fcffe6f72 100644
--- a/engines/awe/system_stub.cpp
+++ b/engines/awe/system_stub.cpp
@@ -52,8 +52,8 @@ struct SystemStubScummVM : SystemStub {
 	void setPalette(const Color pal[16]) override;
 
 	void processEvents() override;
-	void sleep(uint32_t duration) override;
-	virtual uint32_t getTimeStamp() override;
+	void sleep(uint32 duration) override;
+	virtual uint32 getTimeStamp() override;
 
 	void setAspectRatio(int w, int h);
 };
@@ -206,11 +206,11 @@ void SystemStubScummVM::processEvents() {
 	}
 }
 
-void SystemStubScummVM::sleep(uint32_t duration) {
+void SystemStubScummVM::sleep(uint32 duration) {
 	g_system->delayMillis(duration);
 }
 
-uint32_t SystemStubScummVM::getTimeStamp() {
+uint32 SystemStubScummVM::getTimeStamp() {
 	return g_system->getMillis();
 }
 
diff --git a/engines/awe/system_stub.h b/engines/awe/system_stub.h
index 9cae2e67398..2cac4af9122 100644
--- a/engines/awe/system_stub.h
+++ b/engines/awe/system_stub.h
@@ -34,7 +34,7 @@ struct PlayerInput {
 		DIR_DOWN = 1 << 3
 	};
 
-	uint8_t dirMask = 0;
+	uint8 dirMask = 0;
 	bool action = false; // run,shoot
 	bool jump = false;
 	bool code = false;
@@ -56,7 +56,7 @@ struct DisplayMode {
 };
 
 struct SystemStub {
-	typedef void (*AudioCallback)(void *param, uint8_t *stream, int len);
+	typedef void (*AudioCallback)(void *param, uint8 *stream, int len);
 
 	PlayerInput _pi;
 	DisplayMode _dm;
@@ -75,8 +75,8 @@ struct SystemStub {
 	virtual void setScreenPixels(const Graphics::Surface &src) = 0;
 
 	virtual void processEvents() = 0;
-	virtual void sleep(uint32_t duration) = 0;
-	virtual uint32_t getTimeStamp() = 0;
+	virtual void sleep(uint32 duration) = 0;
+	virtual uint32 getTimeStamp() = 0;
 };
 
 extern SystemStub *SystemStub_create();
diff --git a/engines/awe/unpack.cpp b/engines/awe/unpack.cpp
index c1be8ae0176..2a19b6d4160 100644
--- a/engines/awe/unpack.cpp
+++ b/engines/awe/unpack.cpp
@@ -26,10 +26,10 @@ namespace Awe {
 
 struct UnpackCtx {
 	int size;
-	uint32_t crc;
-	uint32_t bits;
-	uint8_t *dst;
-	const uint8_t *src;
+	uint32 crc;
+	uint32 bits;
+	uint8 *dst;
+	const uint8 *src;
 };
 
 static bool nextBit(UnpackCtx *uc) {
@@ -63,7 +63,7 @@ static void copyLiteral(UnpackCtx *uc, int bitsCount, int len) { // getd3chr
 		uc->size = 0;
 	}
 	for (int i = 0; i < count; ++i) {
-		*(uc->dst - i) = (uint8_t)getBits(uc, 8);
+		*(uc->dst - i) = (uint8)getBits(uc, 8);
 	}
 	uc->dst -= count;
 }
@@ -81,7 +81,7 @@ static void copyReference(UnpackCtx *uc, int bitsCount, int count) { // copyd3by
 	uc->dst -= count;
 }
 
-bool bytekiller_unpack(uint8_t *dst, int dstSize, const uint8_t *src, int srcSize) {
+bool bytekiller_unpack(uint8 *dst, int dstSize, const uint8 *src, int srcSize) {
 	UnpackCtx uc;
 	uc.src = src + srcSize - 4;
 	uc.size = READ_BE_UINT32(uc.src); uc.src -= 4;
diff --git a/engines/awe/unpack.h b/engines/awe/unpack.h
index aeb57b7b054..c2dc6985053 100644
--- a/engines/awe/unpack.h
+++ b/engines/awe/unpack.h
@@ -27,7 +27,7 @@
 
 namespace Awe {
 
-extern bool bytekiller_unpack(uint8_t *dst, int dstSize, const uint8_t *src, int srcSize);
+extern bool bytekiller_unpack(uint8 *dst, int dstSize, const uint8 *src, int srcSize);
 
 } // namespace Awe
 
diff --git a/engines/awe/util.cpp b/engines/awe/util.cpp
index 1eb90bee174..3064177e770 100644
--- a/engines/awe/util.cpp
+++ b/engines/awe/util.cpp
@@ -23,7 +23,7 @@
 
 namespace Awe {
 
-uint16_t g_debugMask;
+uint16 g_debugMask;
 
 void string_lower(char *p) {
 	for (; *p; ++p) {
diff --git a/engines/awe/util.h b/engines/awe/util.h
index 7d9d28bcb5e..879bb6bbdd3 100644
--- a/engines/awe/util.h
+++ b/engines/awe/util.h
@@ -28,7 +28,7 @@
 
 namespace Awe {
 
-extern uint16_t g_debugMask;
+extern uint16 g_debugMask;
 
 extern void string_lower(char *p);
 extern void string_upper(char *p);
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index 63bba627f0e..f4be6d421c3 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -45,18 +45,18 @@ void Video::setDefaultFont() {
 	_graphics->setFont(0, 0, 0);
 }
 
-void Video::setFont(const uint8_t *font) {
+void Video::setFont(const uint8 *font) {
 	int w, h;
-	uint8_t *buf = decode_bitmap(font, true, -1, &w, &h);
+	uint8 *buf = decode_bitmap(font, true, -1, &w, &h);
 	if (buf) {
 		_graphics->setFont(buf, w, h);
 		free(buf);
 	}
 }
 
-void Video::setHeads(const uint8_t *src) {
+void Video::setHeads(const uint8 *src) {
 	int w, h;
-	uint8_t *buf = decode_bitmap(src, true, 0xF06080, &w, &h);
+	uint8 *buf = decode_bitmap(src, true, 0xF06080, &w, &h);
 	if (buf) {
 		_graphics->setSpriteAtlas(buf, w, h, 2, 2);
 		free(buf);
@@ -64,13 +64,13 @@ void Video::setHeads(const uint8_t *src) {
 	}
 }
 
-void Video::setDataBuffer(uint8_t *dataBuf, uint16_t offset) {
+void Video::setDataBuffer(uint8 *dataBuf, uint16 offset) {
 	_dataBuf = dataBuf;
 	_pData.pc = dataBuf + offset;
 }
 
-void Video::drawShape(uint8_t color, uint16_t zoom, const Point *pt) {
-	uint8_t i = _pData.fetchByte();
+void Video::drawShape(uint8 color, uint16 zoom, const Point *pt) {
+	uint8 i = _pData.fetchByte();
 	if (i >= 0xC0) {
 		if (color & 0x80) {
 			color = i & 0x3F;
@@ -90,7 +90,7 @@ void Video::drawShape(uint8_t color, uint16_t zoom, const Point *pt) {
 
 void Video::drawShapePart3DO(int color, int part, const Point *pt) {
 	assert(part < (int)ARRAYSIZE(VERTICES_3DO));
-	const uint8_t *vertices = VERTICES_3DO[part];
+	const uint8 *vertices = VERTICES_3DO[part];
 	const int w = *vertices++;
 	const int h = *vertices++;
 	const int x = pt->x - w / 2;
@@ -120,7 +120,7 @@ void Video::drawShape3DO(int color, int zoom, const Point *pt) {
 		const int y0 = pt->y - _pData.fetchByte() * zoom / 64;
 		int count = _pData.fetchByte() + 1;
 		do {
-			uint16_t offset = _pData.fetchWord();
+			uint16 offset = _pData.fetchWord();
 			Point po;
 			po.x = x0 + _pData.fetchByte() * zoom / 64;
 			po.y = y0 + _pData.fetchByte() * zoom / 64;
@@ -134,7 +134,7 @@ void Video::drawShape3DO(int color, int zoom, const Point *pt) {
 				}
 			}
 			offset <<= 1;
-			uint8_t *bak = _pData.pc;
+			uint8 *bak = _pData.pc;
 			_pData.pc = _dataBuf + offset;
 			drawShape3DO(color, zoom, &po);
 			_pData.pc = bak;
@@ -204,16 +204,16 @@ void Video::drawShape3DO(int color, int zoom, const Point *pt) {
 	}
 }
 
-void Video::fillPolygon(uint16_t color, uint16_t zoom, const Point *pt) {
-	const uint8_t *p = _pData.pc;
+void Video::fillPolygon(uint16 color, uint16 zoom, const Point *pt) {
+	const uint8 *p = _pData.pc;
 
-	uint16_t bbw = (*p++) * zoom / 64;
-	uint16_t bbh = (*p++) * zoom / 64;
+	uint16 bbw = (*p++) * zoom / 64;
+	uint16 bbh = (*p++) * zoom / 64;
 
-	int16_t x1 = pt->x - bbw / 2;
-	int16_t x2 = pt->x + bbw / 2;
-	int16_t y1 = pt->y - bbh / 2;
-	int16_t y2 = pt->y + bbh / 2;
+	int16 x1 = pt->x - bbw / 2;
+	int16 x2 = pt->x + bbw / 2;
+	int16 y1 = pt->y - bbh / 2;
+	int16 y2 = pt->y + bbh / 2;
 
 	if (x1 > 319 || x2 < 0 || y1 > 199 || y2 < 0)
 		return;
@@ -239,18 +239,18 @@ void Video::fillPolygon(uint16_t color, uint16_t zoom, const Point *pt) {
 	}
 }
 
-void Video::drawShapeParts(uint16_t zoom, const Point *pgc) {
+void Video::drawShapeParts(uint16 zoom, const Point *pgc) {
 	Point pt;
 	pt.x = pgc->x - _pData.fetchByte() * zoom / 64;
 	pt.y = pgc->y - _pData.fetchByte() * zoom / 64;
-	int16_t n = _pData.fetchByte();
+	int16 n = _pData.fetchByte();
 	debugC(kDebugVideo, "Video::drawShapeParts n=%d", n);
 	for (; n >= 0; --n) {
-		uint16_t offset = _pData.fetchWord();
+		uint16 offset = _pData.fetchWord();
 		Point po(pt);
 		po.x += _pData.fetchByte() * zoom / 64;
 		po.y += _pData.fetchByte() * zoom / 64;
-		uint16_t color = 0xFF;
+		uint16 color = 0xFF;
 		if (offset & 0x8000) {
 			color = _pData.fetchByte();
 			const int num = _pData.fetchByte();
@@ -280,7 +280,7 @@ void Video::drawShapeParts(uint16_t zoom, const Point *pgc) {
 			color &= 0x7F;
 		}
 		offset <<= 1;
-		uint8_t *bak = _pData.pc;
+		uint8 *bak = _pData.pc;
 		_pData.pc = _dataBuf + offset;
 		drawShape(color, zoom, &po);
 		_pData.pc = bak;
@@ -298,7 +298,7 @@ static const char *findString(const StrEntry *stringsTable, int id) {
 	return 0;
 }
 
-void Video::drawString(uint8_t color, uint16_t x, uint16_t y, uint16_t strId) {
+void Video::drawString(uint8 color, uint16 x, uint16 y, uint16 strId) {
 	bool escapedChars = false;
 	const char *str = 0;
 	if (_res->getDataType() == DT_15TH_EDITION || _res->getDataType() == DT_20TH_EDITION) {
@@ -330,7 +330,7 @@ void Video::drawString(uint8_t color, uint16_t x, uint16_t y, uint16_t strId) {
 		return;
 	}
 	debugC(kDebugVideo, "drawString(%d, %d, %d, '%s')", color, x, y, str);
-	uint16_t xx = x;
+	uint16 xx = x;
 	int len = strlen(str);
 	for (int i = 0; i < len; ++i) {
 		if (str[i] == '\n' || str[i] == '\r') {
@@ -354,8 +354,8 @@ void Video::drawString(uint8_t color, uint16_t x, uint16_t y, uint16_t strId) {
 	}
 }
 
-uint8_t Video::getPagePtr(uint8_t page) {
-	uint8_t p;
+uint8 Video::getPagePtr(uint8 page) {
+	uint8 p;
 	if (page <= 3) {
 		p = page;
 	} else {
@@ -375,36 +375,36 @@ uint8_t Video::getPagePtr(uint8_t page) {
 	return p;
 }
 
-void Video::setWorkPagePtr(uint8_t page) {
+void Video::setWorkPagePtr(uint8 page) {
 	debugC(kDebugVideo, "Video::setWorkPagePtr(%d)", page);
 	_buffers[0] = getPagePtr(page);
 }
 
-void Video::fillPage(uint8_t page, uint8_t color) {
+void Video::fillPage(uint8 page, uint8 color) {
 	debugC(kDebugVideo, "Video::fillPage(%d, %d)", page, color);
 	_graphics->clearBuffer(getPagePtr(page), color);
 }
 
-void Video::copyPage(uint8_t src, uint8_t dst, int16_t vscroll) {
+void Video::copyPage(uint8 src, uint8 dst, int16 vscroll) {
 	debugC(kDebugVideo, "Video::copyPage(%d, %d)", src, dst);
 	if (src >= 0xFE || ((src &= ~0x40) & 0x80) == 0) { // no vscroll
 		_graphics->copyBuffer(getPagePtr(dst), getPagePtr(src));
 	} else {
-		uint8_t sl = getPagePtr(src & 3);
-		uint8_t dl = getPagePtr(dst);
+		uint8 sl = getPagePtr(src & 3);
+		uint8 dl = getPagePtr(dst);
 		if (sl != dl && vscroll >= -199 && vscroll <= 199) {
 			_graphics->copyBuffer(dl, sl, vscroll);
 		}
 	}
 }
 
-static void decode_amiga(const uint8_t *src, uint8_t *dst) {
+static void decode_amiga(const uint8 *src, uint8 *dst) {
 	static const int plane_size = 200 * 320 / 8;
 	for (int y = 0; y < 200; ++y) {
 		for (int x = 0; x < 320; x += 8) {
 			for (int b = 0; b < 8; ++b) {
 				const int mask = 1 << (7 - b);
-				uint8_t color = 0;
+				uint8 color = 0;
 				for (int p = 0; p < 4; ++p) {
 					if (src[p * plane_size] & mask) {
 						color |= 1 << p;
@@ -417,12 +417,12 @@ static void decode_amiga(const uint8_t *src, uint8_t *dst) {
 	}
 }
 
-static void decode_atari(const uint8_t *src, uint8_t *dst) {
+static void decode_atari(const uint8 *src, uint8 *dst) {
 	for (int y = 0; y < 200; ++y) {
 		for (int x = 0; x < 320; x += 16) {
 			for (int b = 0; b < 16; ++b) {
 				const int mask = 1 << (15 - b);
-				uint8_t color = 0;
+				uint8 color = 0;
 				for (int p = 0; p < 4; ++p) {
 					if (READ_BE_UINT16(src + p * 2) & mask) {
 						color |= 1 << p;
@@ -435,7 +435,7 @@ static void decode_atari(const uint8_t *src, uint8_t *dst) {
 	}
 }
 
-static void deinterlace555(const uint8_t *src, int w, int h, uint16_t *dst) {
+static void deinterlace555(const uint8 *src, int w, int h, uint16 *dst) {
 	for (int y = 0; y < h / 2; ++y) {
 		for (int x = 0; x < w; ++x) {
 			dst[x] = READ_BE_UINT16(src) & 0x7FFF; src += 2;
@@ -445,18 +445,18 @@ static void deinterlace555(const uint8_t *src, int w, int h, uint16_t *dst) {
 	}
 }
 
-static void yflip(const uint8_t *src, int w, int h, uint8_t *dst) {
+static void yflip(const uint8 *src, int w, int h, uint8 *dst) {
 	for (int y = 0; y < h; ++y) {
 		memcpy(dst + (h - 1 - y) * w, src, w);
 		src += w;
 	}
 }
 
-void Video::scaleBitmap(const uint8_t *src, int fmt) {
+void Video::scaleBitmap(const uint8 *src, int fmt) {
 	_graphics->drawBitmap(_buffers[0], src, BITMAP_W, BITMAP_H, fmt);
 }
 
-void Video::copyBitmapPtr(const uint8_t *src, uint32_t size) {
+void Video::copyBitmapPtr(const uint8 *src, uint32 size) {
 	if (_res->getDataType() == DT_DOS || _res->getDataType() == DT_AMIGA) {
 		decode_amiga(src, _tempBitmap);
 		scaleBitmap(_tempBitmap, FMT_CLUT);
@@ -468,19 +468,19 @@ void Video::copyBitmapPtr(const uint8_t *src, uint32_t size) {
 		scaleBitmap(_tempBitmap, FMT_CLUT);
 	} else if (_res->getDataType() == DT_3DO) {
 		deinterlace555(src, BITMAP_W, BITMAP_H, _bitmap555);
-		scaleBitmap((const uint8_t *)_bitmap555, FMT_RGB555);
+		scaleBitmap((const uint8 *)_bitmap555, FMT_RGB555);
 	} else { // .BMP
 		if (Gfx::_is1991) {
 			const int w = READ_LE_UINT32(src + 0x12);
 			const int h = READ_LE_UINT32(src + 0x16);
 			if (w == BITMAP_W && h == BITMAP_H) {
-				const uint8_t *data = src + READ_LE_UINT32(src + 0xA);
+				const uint8 *data = src + READ_LE_UINT32(src + 0xA);
 				yflip(data, w, h, _tempBitmap);
 				scaleBitmap(_tempBitmap, FMT_CLUT);
 			}
 		} else {
 			int w, h;
-			uint8_t *buf = decode_bitmap(src, false, -1, &w, &h);
+			uint8 *buf = decode_bitmap(src, false, -1, &w, &h);
 			if (buf) {
 				_graphics->drawBitmap(_buffers[0], buf, w, h, FMT_RGB);
 				free(buf);
@@ -489,21 +489,21 @@ void Video::copyBitmapPtr(const uint8_t *src, uint32_t size) {
 	}
 }
 
-static void readPaletteWin31(const uint8_t *buf, int num, Color pal[16]) {
-	const uint8_t *p = buf + num * 16 * sizeof(uint16_t);
+static void readPaletteWin31(const uint8 *buf, int num, Color pal[16]) {
+	const uint8 *p = buf + num * 16 * sizeof(uint16);
 	for (int i = 0; i < 16; ++i) {
-		const uint16_t index = READ_LE_UINT16(p); p += 2;
-		const uint32_t color = READ_LE_UINT32(buf + 0xC04 + index * sizeof(uint32_t));
+		const uint16 index = READ_LE_UINT16(p); p += 2;
+		const uint32 color = READ_LE_UINT32(buf + 0xC04 + index * sizeof(uint32));
 		pal[i].r = color & 255;
 		pal[i].g = (color >> 8) & 255;
 		pal[i].b = (color >> 16) & 255;
 	}
 }
 
-static void readPalette3DO(const uint8_t *buf, int num, Color pal[16]) {
-	const uint8_t *p = buf + num * 16 * sizeof(uint16_t);
+static void readPalette3DO(const uint8 *buf, int num, Color pal[16]) {
+	const uint8 *p = buf + num * 16 * sizeof(uint16);
 	for (int i = 0; i < 16; ++i) {
-		const uint16_t color = READ_BE_UINT16(p); p += 2;
+		const uint16 color = READ_BE_UINT16(p); p += 2;
 		const int r = (color >> 10) & 31;
 		const int g = (color >> 5) & 31;
 		const int b = color & 31;
@@ -513,20 +513,20 @@ static void readPalette3DO(const uint8_t *buf, int num, Color pal[16]) {
 	}
 }
 
-static void readPaletteEGA(const uint8_t *buf, int num, Color pal[16]) {
-	const uint8_t *p = buf + num * 16 * sizeof(uint16_t);
+static void readPaletteEGA(const uint8 *buf, int num, Color pal[16]) {
+	const uint8 *p = buf + num * 16 * sizeof(uint16);
 	p += 1024; // EGA colors are stored after VGA (Amiga)
 	for (int i = 0; i < 16; ++i) {
-		const uint16_t color = READ_BE_UINT16(p); p += 2;
+		const uint16 color = READ_BE_UINT16(p); p += 2;
 		if (1) {
-			const uint8_t *ega = &Video::PALETTE_EGA[3 * ((color >> 12) & 15)];
+			const uint8 *ega = &Video::PALETTE_EGA[3 * ((color >> 12) & 15)];
 			pal[i].r = ega[0];
 			pal[i].g = ega[1];
 			pal[i].b = ega[2];
 		} else { // lower 12 bits hold other colors
-			const uint8_t r = (color >> 8) & 0xF;
-			const uint8_t g = (color >> 4) & 0xF;
-			const uint8_t b = color & 0xF;
+			const uint8 r = (color >> 8) & 0xF;
+			const uint8 g = (color >> 4) & 0xF;
+			const uint8 b = color & 0xF;
 			pal[i].r = (r << 4) | r;
 			pal[i].g = (g << 4) | g;
 			pal[i].b = (b << 4) | b;
@@ -534,20 +534,20 @@ static void readPaletteEGA(const uint8_t *buf, int num, Color pal[16]) {
 	}
 }
 
-static void readPaletteAmiga(const uint8_t *buf, int num, Color pal[16]) {
-	const uint8_t *p = buf + num * 16 * sizeof(uint16_t);
+static void readPaletteAmiga(const uint8 *buf, int num, Color pal[16]) {
+	const uint8 *p = buf + num * 16 * sizeof(uint16);
 	for (int i = 0; i < 16; ++i) {
-		const uint16_t color = READ_BE_UINT16(p); p += 2;
-		const uint8_t r = (color >> 8) & 0xF;
-		const uint8_t g = (color >> 4) & 0xF;
-		const uint8_t b = color & 0xF;
+		const uint16 color = READ_BE_UINT16(p); p += 2;
+		const uint8 r = (color >> 8) & 0xF;
+		const uint8 g = (color >> 4) & 0xF;
+		const uint8 b = color & 0xF;
 		pal[i].r = (r << 4) | r;
 		pal[i].g = (g << 4) | g;
 		pal[i].b = (b << 4) | b;
 	}
 }
 
-void Video::changePal(uint8_t palNum) {
+void Video::changePal(uint8 palNum) {
 	if (palNum < 32 && palNum != _currentPal) {
 		Color pal[16];
 		if (_res->getDataType() == DT_WIN31) {
@@ -564,7 +564,7 @@ void Video::changePal(uint8_t palNum) {
 	}
 }
 
-void Video::updateDisplay(uint8_t page, SystemStub *stub) {
+void Video::updateDisplay(uint8 page, SystemStub *stub) {
 	debugC(kDebugVideo, "Video::updateDisplay(%d)", page);
 	if (page != 0xFE) {
 		if (page == 0xFF) {
@@ -580,7 +580,7 @@ void Video::updateDisplay(uint8_t page, SystemStub *stub) {
 	_graphics->drawBuffer(_buffers[1], stub);
 }
 
-void Video::setPaletteColor(uint8_t color, int r, int g, int b) {
+void Video::setPaletteColor(uint8 color, int r, int g, int b) {
 	Color c;
 	c.r = r;
 	c.g = g;
@@ -588,7 +588,7 @@ void Video::setPaletteColor(uint8_t color, int r, int g, int b) {
 	_graphics->setPalette(&c, 1);
 }
 
-void Video::drawRect(uint8_t page, uint8_t color, int x1, int y1, int x2, int y2) {
+void Video::drawRect(uint8 page, uint8 color, int x1, int y1, int x2, int y2) {
 	Point pt;
 	pt.x = x1;
 	pt.y = y1;
diff --git a/engines/awe/video.h b/engines/awe/video.h
index 90e1fc99e8e..afa18e280fa 100644
--- a/engines/awe/video.h
+++ b/engines/awe/video.h
@@ -27,7 +27,7 @@
 namespace Awe {
 
 struct StrEntry {
-	uint16_t id;
+	uint16 id;
 	const char *str;
 };
 
@@ -45,14 +45,14 @@ struct Video {
 	static const StrEntry STRINGS_TABLE_FR[];
 	static const StrEntry STRINGS_TABLE_ENG[];
 	static const StrEntry STRINGS_TABLE_DEMO[];
-	static const uint16_t STRINGS_ID_15TH[];
+	static const uint16 STRINGS_ID_15TH[];
 	static const char *STRINGS_TABLE_15TH[];
 	static const char *_str0x194AtariDemo;
 	static const StrEntry STRINGS_TABLE_3DO[];
 	static const char *NOTE_TEXT_3DO;
 	static const char *END_TEXT_3DO;
-	static const uint8_t *VERTICES_3DO[201];
-	static const uint8_t PALETTE_EGA[];
+	static const uint8 *VERTICES_3DO[201];
+	static const uint8 PALETTE_EGA[];
 
 	static bool _useEGA;
 
@@ -61,38 +61,38 @@ struct Video {
 	bool _hasHeadSprites = false;
 	bool _displayHead = true;
 
-	uint8_t _nextPal = 0, _currentPal = 0;
-	uint8_t _buffers[3] = { 0 };
+	uint8 _nextPal = 0, _currentPal = 0;
+	uint8 _buffers[3] = { 0 };
 	Ptr _pData;
-	uint8_t *_dataBuf = nullptr;
+	uint8 *_dataBuf = nullptr;
 	const StrEntry *_stringsTable = nullptr;
-	uint8_t _tempBitmap[BITMAP_W * BITMAP_H] = { 0 };
-	uint16_t _bitmap555[BITMAP_W * BITMAP_H] = { 0 };
+	uint8 _tempBitmap[BITMAP_W * BITMAP_H] = { 0 };
+	uint16 _bitmap555[BITMAP_W * BITMAP_H] = { 0 };
 
 	Video(Resource *res);
 	~Video() {}
 	void init();
 
 	void setDefaultFont();
-	void setFont(const uint8_t *font);
-	void setHeads(const uint8_t *src);
-	void setDataBuffer(uint8_t *dataBuf, uint16_t offset);
-	void drawShape(uint8_t color, uint16_t zoom, const Point *pt);
+	void setFont(const uint8 *font);
+	void setHeads(const uint8 *src);
+	void setDataBuffer(uint8 *dataBuf, uint16 offset);
+	void drawShape(uint8 color, uint16 zoom, const Point *pt);
 	void drawShapePart3DO(int color, int part, const Point *pt);
 	void drawShape3DO(int color, int zoom, const Point *pt);
-	void fillPolygon(uint16_t color, uint16_t zoom, const Point *pt);
-	void drawShapeParts(uint16_t zoom, const Point *pt);
-	void drawString(uint8_t color, uint16_t x, uint16_t y, uint16_t strId);
-	uint8_t getPagePtr(uint8_t page);
-	void setWorkPagePtr(uint8_t page);
-	void fillPage(uint8_t page, uint8_t color);
-	void copyPage(uint8_t src, uint8_t dst, int16_t vscroll);
-	void scaleBitmap(const uint8_t *src, int fmt);
-	void copyBitmapPtr(const uint8_t *src, uint32_t size = 0);
-	void changePal(uint8_t pal);
-	void updateDisplay(uint8_t page, SystemStub *stub);
-	void setPaletteColor(uint8_t color, int r, int g, int b);
-	void drawRect(uint8_t page, uint8_t color, int x1, int y1, int x2, int y2);
+	void fillPolygon(uint16 color, uint16 zoom, const Point *pt);
+	void drawShapeParts(uint16 zoom, const Point *pt);
+	void drawString(uint8 color, uint16 x, uint16 y, uint16 strId);
+	uint8 getPagePtr(uint8 page);
+	void setWorkPagePtr(uint8 page);
+	void fillPage(uint8 page, uint8 color);
+	void copyPage(uint8 src, uint8 dst, int16 vscroll);
+	void scaleBitmap(const uint8 *src, int fmt);
+	void copyBitmapPtr(const uint8 *src, uint32 size = 0);
+	void changePal(uint8 pal);
+	void updateDisplay(uint8 page, SystemStub *stub);
+	void setPaletteColor(uint8 color, int r, int g, int b);
+	void drawRect(uint8 page, uint8 color, int x1, int y1, int x2, int y2);
 	void drawBitmap3DO(const char *name, SystemStub *stub);
 };
 


Commit: f46196d21d2f6d6b4a71f5fdbd1b91a46dab379c
    https://github.com/scummvm/scummvm/commit/f46196d21d2f6d6b4a71f5fdbd1b91a46dab379c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Handle jump keybinding in non-anniversary versions

Changed paths:
    engines/awe/awe.cpp
    engines/awe/system_stub.cpp
    engines/awe/system_stub.h


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 3034f699908..68f00d5f7ae 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -165,7 +165,10 @@ Common::Error AweEngine::run() {
 		}
 	}
 
-	SystemStub *stub = SystemStub_create();
+	SystemStub *stub = SystemStub_create(
+		dataType == DT_15TH_EDITION ||
+		dataType == DT_20TH_EDITION
+	);
 	stub->init(dm);
 	e->setSystemStub(stub, graphics);
 
diff --git a/engines/awe/system_stub.cpp b/engines/awe/system_stub.cpp
index d3fcffe6f72..9706541cd47 100644
--- a/engines/awe/system_stub.cpp
+++ b/engines/awe/system_stub.cpp
@@ -32,6 +32,10 @@
 namespace Awe {
 
 struct SystemStubScummVM : SystemStub {
+private:
+	bool _isAnniversaryEdition;
+
+public:
 	static const int kJoystickIndex = 0;
 	static const int kJoystickCommitValue = 16384;
 	static const float kAspectRatio;
@@ -40,7 +44,8 @@ struct SystemStubScummVM : SystemStub {
 	float _aspectRatio[4] = { 0.0 };
 	int _screenshot = 0;
 
-	SystemStubScummVM() {}
+	SystemStubScummVM(bool isAnniversaryEdition) :
+		_isAnniversaryEdition(isAnniversaryEdition) {}
 	~SystemStubScummVM() override;
 
 	void init(const DisplayMode &dm) override;
@@ -108,6 +113,13 @@ void SystemStubScummVM::setPalette(const Color pal[16]) {
 void SystemStubScummVM::processEvents() {
 	Common::Event ev;
 	while (g_system->getEventManager()->pollEvent(ev)) {
+		// WORKAROUND: Anniversary editions have a separate
+		// jump button than the up arrow; for earlier releases,
+		// remap the jump to up, which does the same thing
+		if (!_isAnniversaryEdition &&
+			ev.customType == KEYBIND_JUMP)
+			ev.customType = KEYBIND_UP;
+
 		switch (ev.type) {
 		case Common::EVENT_QUIT:
 		case Common::EVENT_RETURN_TO_LAUNCHER:
@@ -243,8 +255,8 @@ void SystemStubScummVM::setAspectRatio(int w, int h) {
 	}
 }
 
-SystemStub *SystemStub_create() {
-	return new SystemStubScummVM();
+SystemStub *SystemStub_create(bool isAnniversaryEdition) {
+	return new SystemStubScummVM(isAnniversaryEdition);
 }
 
 } // namespace Awe
diff --git a/engines/awe/system_stub.h b/engines/awe/system_stub.h
index 2cac4af9122..3410b3522c2 100644
--- a/engines/awe/system_stub.h
+++ b/engines/awe/system_stub.h
@@ -79,7 +79,7 @@ struct SystemStub {
 	virtual uint32 getTimeStamp() = 0;
 };
 
-extern SystemStub *SystemStub_create();
+extern SystemStub *SystemStub_create(bool isAnniversaryEdition);
 
 } // namespace Awe
 


Commit: 6621333974e26cd67a5d2b2b882a1e5657dd2fef
    https://github.com/scummvm/scummvm/commit/6621333974e26cd67a5d2b2b882a1e5657dd2fef
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Janitorial - Consistantly use nullptr instead of 0

Changed paths:
    engines/awe/awe.cpp
    engines/awe/bitmap.cpp
    engines/awe/detection_tables.h
    engines/awe/graphics_soft.cpp
    engines/awe/pak.cpp
    engines/awe/resource.cpp
    engines/awe/resource.h
    engines/awe/resource_3do.cpp
    engines/awe/resource_nth.cpp
    engines/awe/resource_win31.cpp
    engines/awe/script.cpp
    engines/awe/sfx_player.cpp
    engines/awe/static_res.cpp
    engines/awe/video.cpp


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 68f00d5f7ae..5bf1c73b795 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -43,7 +43,7 @@ static const struct {
 	{ "original", GRAPHICS_ORIGINAL },
 	{ "software", GRAPHICS_SOFTWARE },
 	{ "gl", GRAPHICS_GL },
-	{ 0,  -1 }
+	{ nullptr,  -1 }
 };
 
 static const struct {
@@ -53,7 +53,7 @@ static const struct {
 	{ "easy", DIFFICULTY_EASY },
 	{ "normal", DIFFICULTY_NORMAL },
 	{ "hard", DIFFICULTY_HARD },
-	{ 0,  -1 }
+	{ nullptr,  -1 }
 };
 
 bool Gfx::_is1991;
@@ -77,7 +77,7 @@ static Gfx *createGraphics(int type) {
 #endif
 	}
 
-	return 0;
+	return nullptr;
 }
 
 static int getGraphicsType(DataType type) {
diff --git a/engines/awe/bitmap.cpp b/engines/awe/bitmap.cpp
index 37870d1ecf0..1d95defbd68 100644
--- a/engines/awe/bitmap.cpp
+++ b/engines/awe/bitmap.cpp
@@ -50,7 +50,7 @@ static void clut(const uint8 *src, const uint8 *pal, int pitch, int w, int h, in
 
 uint8 *decode_bitmap(const uint8 *src, bool alpha, int colorKey, int *w, int *h) {
 	if (memcmp(src, "BM", 2) != 0) {
-		return 0;
+		return nullptr;
 	}
 	const uint32 imageOffset = READ_LE_UINT32(src + 0xA);
 	const int width = READ_LE_UINT32(src + 0x12);
@@ -59,13 +59,13 @@ uint8 *decode_bitmap(const uint8 *src, bool alpha, int colorKey, int *w, int *h)
 	const int compression = READ_LE_UINT32(src + 0x1E);
 	if ((depth != 8 && depth != 32) || compression != 0) {
 		warning("Unhandled bitmap depth %d compression %d", depth, compression);
-		return 0;
+		return nullptr;
 	}
 	const int bpp = (!alpha && colorKey < 0) ? 3 : 4;
 	uint8 *dst = (uint8 *)malloc(width * height * bpp);
 	if (!dst) {
 		warning("Failed to allocate bitmap buffer, width %d height %d bpp %d", width, height, bpp);
-		return 0;
+		return nullptr;
 	}
 	if (depth == 8) {
 		const uint8 *palette = src + 14 /* BITMAPFILEHEADER */ + 40 /* BITMAPINFOHEADER */;
diff --git a/engines/awe/detection_tables.h b/engines/awe/detection_tables.h
index 495294f4ac4..5f370b0f716 100644
--- a/engines/awe/detection_tables.h
+++ b/engines/awe/detection_tables.h
@@ -23,7 +23,7 @@ namespace Awe {
 
 const PlainGameDescriptor aweGames[] = {
 	{ "anotherworld", "Another World - Out of this World" },
-	{ 0, 0 }
+	{ nullptr, nullptr }
 };
 
 const AweGameDescription gameDescriptions[] = {
diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
index ebdffafdcfb..b76dbfe00b0 100644
--- a/engines/awe/graphics_soft.cpp
+++ b/engines/awe/graphics_soft.cpp
@@ -88,7 +88,7 @@ GraphicsSoft::GraphicsSoft() {
 GraphicsSoft::~GraphicsSoft() {
 	for (int i = 0; i < 4; ++i) {
 		free(_pagePtrs[i]);
-		_pagePtrs[i] = 0;
+		_pagePtrs[i] = nullptr;
 	}
 }
 
diff --git a/engines/awe/pak.cpp b/engines/awe/pak.cpp
index c7e8f3ae369..140fcacf9c6 100644
--- a/engines/awe/pak.cpp
+++ b/engines/awe/pak.cpp
@@ -46,7 +46,7 @@ static uint8 *decode_toodc(uint8 *p, int count) {
 const char *Pak::FILENAME = "Pak01.pak";
 
 Pak::Pak()
-	: _entries(0), _entriesCount(0) {
+	: _entries(nullptr), _entriesCount(0) {
 }
 
 Pak::~Pak() {
@@ -59,7 +59,7 @@ void Pak::open(const char *dataPath) {
 
 void Pak::close() {
 	free(_entries);
-	_entries = 0;
+	_entries = nullptr;
 	_entriesCount = 0;
 }
 
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 8e1f1fd7e0a..0af50dc584b 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -83,7 +83,7 @@ const AmigaMemEntry *Resource::detectAmigaAtari() {
 		{ 244674, Resource::MEMLIST_AMIGA_FR },
 		{ 244868, Resource::MEMLIST_AMIGA_EN },
 		{ 227142, Resource::MEMLIST_ATARI_EN },
-		{ 0, 0 }
+		{ 0, nullptr }
 	};
 	if (f.open("bank01")) {
 		const uint32 size = f.size();
@@ -248,7 +248,7 @@ void Resource::dumpEntries() {
 
 void Resource::load() {
 	while (1) {
-		MemEntry *me = 0;
+		MemEntry *me = nullptr;
 
 		// get resource with max rankNum
 		uint8 maxNum = 0;
@@ -259,13 +259,13 @@ void Resource::load() {
 				me = it;
 			}
 		}
-		if (me == 0) {
+		if (me == nullptr) {
 			break; // no entry found
 		}
 
 		const int resourceNum = me - _memList;
 
-		uint8 *memPtr = 0;
+		uint8 *memPtr = nullptr;
 		if (me->type == RT_BITMAP) {
 			memPtr = _vidCurPtr;
 		} else {
@@ -369,7 +369,7 @@ static const uint8 *getSoundsList3DO(int num) {
 	default: break;
 	}
 
-	return 0;
+	return nullptr;
 }
 
 void Resource::update(uint16 num, PreloadSoundProc preloadSound, void *data) {
@@ -428,17 +428,17 @@ void Resource::update(uint16 num, PreloadSoundProc preloadSound, void *data) {
 
 void Resource::loadBmp(int num) {
 	uint32 size = 0;
-	uint8 *p = 0;
+	uint8 *p = nullptr;
 	switch (_dataType) {
 	case DT_15TH_EDITION:
 	case DT_20TH_EDITION:
 		p = _nth->loadBmp(num);
 		break;
 	case DT_WIN31:
-		p = _win31->loadFile(num, 0, &size);
+		p = _win31->loadFile(num, nullptr, &size);
 		break;
 	case DT_3DO:
-		p = _3do->loadFile(num, 0, &size);
+		p = _3do->loadFile(num, nullptr, &size);
 		break;
 	default:
 		break;
@@ -455,7 +455,7 @@ uint8 *Resource::loadDat(int num) {
 		return _memList[num].bufPtr;
 	}
 	uint32 size = 0;
-	uint8 *p = 0;
+	uint8 *p = nullptr;
 	switch (_dataType) {
 	case DT_15TH_EDITION:
 	case DT_20TH_EDITION:
@@ -506,7 +506,7 @@ uint8 *Resource::loadWav(int num, uint32 *size) {
 	uint32 dummy = 0;
 	if (!size)
 		size = &dummy;
-	uint8 *p = 0;
+	uint8 *p = nullptr;
 	switch (_dataType) {
 	case DT_15TH_EDITION:
 	case DT_20TH_EDITION:
@@ -518,7 +518,7 @@ uint8 *Resource::loadWav(int num, uint32 *size) {
 	default:
 		break;
 	}
-	if (p && size != 0) {
+	if (p && size != nullptr) {
 		_scriptCurPtr += *size;
 		_memList[num].bufPtr = p;
 		_memList[num].status = STATUS_LOADED;
@@ -537,11 +537,11 @@ const char *Resource::getString(int num) {
 	default:
 		break;
 	}
-	return 0;
+	return nullptr;
 }
 
 const char *Resource::getMusicPath(int num, char *buf, int bufSize, uint32 *offset) {
-	const char *name = 0;
+	const char *name = nullptr;
 	switch (_dataType) {
 	case DT_15TH_EDITION:
 	case DT_20TH_EDITION:
@@ -563,7 +563,7 @@ const char *Resource::getMusicPath(int num, char *buf, int bufSize, uint32 *offs
 		return buf;
 	}
 
-	return 0;
+	return nullptr;
 }
 
 const uint8 Resource::MEMLIST_PARTS[][4] = {
@@ -655,7 +655,7 @@ void Resource::allocMemBlock() {
 
 void Resource::freeMemBlock() {
 	free(_memPtrStart);
-	_memPtrStart = 0;
+	_memPtrStart = nullptr;
 }
 
 void Resource::readDemo3Joy() {
diff --git a/engines/awe/resource.h b/engines/awe/resource.h
index 255ab3358a6..0e8d0e2b2ec 100644
--- a/engines/awe/resource.h
+++ b/engines/awe/resource.h
@@ -160,7 +160,7 @@ struct Resource {
 	void loadHeads();
 	uint8 *loadWav(int num, uint32 *size = nullptr);
 	const char *getString(int num);
-	const char *getMusicPath(int num, char *buf, int bufSize, uint32 *offset = 0);
+	const char *getMusicPath(int num, char *buf, int bufSize, uint32 *offset = nullptr);
 	void setupPart(int part);
 	void allocMemBlock();
 	void freeMemBlock();
diff --git a/engines/awe/resource_3do.cpp b/engines/awe/resource_3do.cpp
index 7d03b5c9aed..7cd5b9bbd5b 100644
--- a/engines/awe/resource_3do.cpp
+++ b/engines/awe/resource_3do.cpp
@@ -134,14 +134,14 @@ uint8 *Resource3do::loadFile(int num, uint8 *dst, uint32 *size) {
 			dst = (uint8 *)malloc(sz);
 			if (!dst) {
 				warning("Unable to allocate %d bytes", sz);
-				return 0;
+				return nullptr;
 			}
 		}
 		*size = sz;
 		f.read(dst, sz);
 	} else {
 		warning("Failed to load '%s'", path);
-		return 0;
+		return nullptr;
 	}
 
 	if (dst && memcmp(dst, "\x00\xf4\x01\x00", 4) == 0) {
@@ -150,13 +150,13 @@ uint8 *Resource3do::loadFile(int num, uint8 *dst, uint32 *size) {
 		if (!tmp) {
 			warning("Unable to allocate %d bytes", SZ);
 			if (in != dst) free(dst);
-			return 0;
+			return nullptr;
 		}
 		const int decodedSize = decodeLzss(dst + 4, *size - 4, tmp);
 		if (in != dst) free(dst);
 		if (decodedSize != SZ) {
 			warning("Unexpected LZSS decoded size %d", decodedSize);
-			return 0;
+			return nullptr;
 		}
 		*size = decodedSize;
 		return tmp;
diff --git a/engines/awe/resource_nth.cpp b/engines/awe/resource_nth.cpp
index 850de4de754..93ee4240956 100644
--- a/engines/awe/resource_nth.cpp
+++ b/engines/awe/resource_nth.cpp
@@ -35,7 +35,7 @@ static char *loadTextFile(File &f, const int size) {
 		if (count != size) {
 			warning("Failed to read %d bytes (%d expected)", count, size);
 			free(buf);
-			return 0;
+			return nullptr;
 		}
 		buf[count] = 0;
 	}
@@ -56,7 +56,7 @@ struct Resource15th : ResourceNth {
 		_hasRemasteredMusic = Common::FSNode(_dataPath).isDirectory();
 		Common::strcpy_s(_dataPath, "Data");
 		Common::strcpy_s(_menuPath, "Menu");
-		_textBuf = 0;
+		_textBuf = nullptr;
 		memset(_stringsTable, 0, sizeof(_stringsTable));
 	}
 
@@ -71,7 +71,7 @@ struct Resource15th : ResourceNth {
 	}
 
 	virtual uint8 *load(const char *name) {
-		uint8 *buf = 0;
+		uint8 *buf = nullptr;
 		const PakEntry *e = _pak.find(name);
 		if (e) {
 			buf = (uint8 *)malloc(e->size);
@@ -105,12 +105,12 @@ struct Resource15th : ResourceNth {
 		} else {
 			warning("Unable to load '%s'", name);
 		}
-		return 0;
+		return nullptr;
 	}
 
 	virtual uint8 *loadWav(int num, uint8 *dst, uint32 *size) {
 		char name[32];
-		const PakEntry *e = 0;
+		const PakEntry *e = nullptr;
 		if (Script::_useRemasteredAudio) {
 			snprintf(name, sizeof(name), "rmsnd/file%03d.wav", num);
 			e = _pak.find(name);
@@ -134,12 +134,12 @@ struct Resource15th : ResourceNth {
 		} else {
 			warning("Unable to load '%s'", name);
 		}
-		return 0;
+		return nullptr;
 	}
 
 	void loadStrings(Language lang) {
 		if (!_textBuf) {
-			const char *name = 0;
+			const char *name = nullptr;
 			switch (lang) {
 			case Common::FR_FRA:
 				name = "Francais.Txt";
@@ -199,11 +199,11 @@ struct Resource15th : ResourceNth {
 		if ((uint32)num < ARRAYSIZE(_stringsTable)) {
 			return _stringsTable[num];
 		}
-		return 0;
+		return nullptr;
 	}
 
 	virtual const char *getMusicName(int num) {
-		const char *path = 0;
+		const char *path = nullptr;
 		switch (num) {
 		case 7:
 			if (_hasRemasteredMusic && Script::_useRemasteredAudio) {
@@ -233,19 +233,19 @@ static uint8 *inflateGzip(const char *filepath) {
 	File f;
 	if (!f.open(filepath)) {
 		warning("Unable to open '%s'", filepath);
-		return 0;
+		return nullptr;
 	}
 	const uint16 sig = f.readUint16LE();
 	if (sig != 0x8B1F) {
 		warning("Unexpected file signature 0x%x for '%s'", sig, filepath);
-		return 0;
+		return nullptr;
 	}
 	f.seek(-4, SEEK_END);
 	const uint32 dataSize = f.readUint32LE();
 	uint8 *out = (uint8 *)malloc(dataSize);
 	if (!out) {
 		warning("Failed to allocate %d bytes", dataSize);
-		return 0;
+		return nullptr;
 	}
 	f.seek(0);
 
@@ -275,7 +275,7 @@ static uint8 *inflateGzip(const char *filepath) {
 #else
 	error("TODO: inflateGzip");
 #endif
-	return 0;
+	return nullptr;
 }
 
 struct Resource20th : ResourceNth {
@@ -286,7 +286,7 @@ struct Resource20th : ResourceNth {
 	char _datName[32];
 	const char *_bitmapSize;
 
-	Resource20th() : _textBuf(0) {
+	Resource20th() : _textBuf(nullptr) {
 		memset(_stringsTable, 0, sizeof(_stringsTable));
 		_musicType = 0;
 		_datName[0] = 0;
@@ -297,7 +297,7 @@ struct Resource20th : ResourceNth {
 	}
 
 	virtual bool init() {
-		static const char *dirs[] = { "BGZ", "DAT", "WGZ", 0 };
+		static const char *dirs[] = { "BGZ", "DAT", "WGZ", nullptr };
 		for (int i = 0; dirs[i]; ++i) {
 			char path[MAXPATHLEN];
 			snprintf(path, sizeof(path), "game/%s", dirs[i]);
@@ -317,9 +317,9 @@ struct Resource20th : ResourceNth {
 			"768x480",
 			"480x300",
 			"320x200",
-			0
+			nullptr
 		};
-		_bitmapSize = 0;
+		_bitmapSize = nullptr;
 		for (int i = 0; bmps[i]; ++i) {
 			char path[MAXPATHLEN];
 			snprintf(path, sizeof(path), "game/BGZ/data%s", bmps[i]);
@@ -340,7 +340,7 @@ struct Resource20th : ResourceNth {
 			return inflateGzip("game/BGZ/Heads.bgz");
 		}
 
-		return 0;
+		return nullptr;
 	}
 
 	virtual uint8 *loadBmp(int num) {
@@ -356,10 +356,10 @@ struct Resource20th : ResourceNth {
 
 	void preloadDat(int part, int type, int num) {
 		static const char *names[] = {
-			"INTRO", "EAU", "PRI", "CITE", "arene", "LUXE", "FINAL", 0
+			"INTRO", "EAU", "PRI", "CITE", "arene", "LUXE", "FINAL", nullptr
 		};
 		static const char *exts[] = {
-			"pal", "mac", "mat", 0
+			"pal", "mac", "mat", nullptr
 		};
 		if (part > 0 && part < 8) {
 			if (type == 3) {
@@ -396,7 +396,7 @@ struct Resource20th : ResourceNth {
 			*size = dataSize;
 		} else {
 			warning("Unable to open '%s/%s'", path, _datName);
-			dst = 0;
+			dst = nullptr;
 		}
 		_datName[0] = 0;
 		return dst;
@@ -469,7 +469,7 @@ struct Resource20th : ResourceNth {
 
 	void loadStrings(Language lang) {
 		if (!_textBuf) {
-			const char *name = 0;
+			const char *name = nullptr;
 			switch (lang) {
 			case Common::FR_FRA:
 				name = "FR";
@@ -493,7 +493,7 @@ struct Resource20th : ResourceNth {
 			static const char *fmt[] = {
 				"game/TXT/%s.txt",
 				"game/TXT/Linux/%s.txt",
-				0
+				nullptr
 			};
 			bool isOpen = false;
 			File f;
@@ -524,7 +524,7 @@ struct Resource20th : ResourceNth {
 		if ((uint32)num < ARRAYSIZE(_stringsTable)) {
 			return _stringsTable[num];
 		}
-		return 0;
+		return nullptr;
 	}
 
 	virtual const char *getMusicName(int num) {
@@ -557,7 +557,7 @@ struct Resource20th : ResourceNth {
 				}
 				/* fall-through */
 			default:
-				return 0;
+				return nullptr;
 			}
 		}
 		return _musicName;
@@ -579,7 +579,7 @@ ResourceNth *ResourceNth::create(int edition) {
 	case 20:
 		return new Resource20th();
 	}
-	return 0;
+	return nullptr;
 }
 
 } // namespace Awe
diff --git a/engines/awe/resource_win31.cpp b/engines/awe/resource_win31.cpp
index ce05e2e4da6..d87e010a1e5 100644
--- a/engines/awe/resource_win31.cpp
+++ b/engines/awe/resource_win31.cpp
@@ -61,7 +61,7 @@ struct Bitstream {
 	int _len;
 
 	Bitstream()
-		: _f(0), _size(0), _bits(0), _len(0) {
+		: _f(nullptr), _size(0), _bits(0), _len(0) {
 	}
 
 	void reset(File *f, int size) {
@@ -282,7 +282,7 @@ bool ResourceWin31::readEntries() {
 			readStrings();
 		}
 	}
-	return _entries != 0;
+	return _entries != nullptr;
 }
 
 uint8 *ResourceWin31::loadFile(int num, uint8 *dst, uint32 *size) {
@@ -293,7 +293,7 @@ uint8 *ResourceWin31::loadFile(int num, uint8 *dst, uint32 *size) {
 			dst = (uint8 *)malloc(e->size);
 			if (!dst) {
 				warning("Unable to allocate %d bytes", e->size);
-				return 0;
+				return nullptr;
 			}
 		}
 		// check for unpacked data
@@ -310,19 +310,19 @@ uint8 *ResourceWin31::loadFile(int num, uint8 *dst, uint32 *size) {
 		}
 	}
 	warning("Unable to load resource #%d", num);
-	return 0;
+	return nullptr;
 }
 
 void ResourceWin31::readStrings() {
 	uint32 len, offset = 0;
-	_textBuf = loadFile(148, 0, &len);
+	_textBuf = loadFile(148, nullptr, &len);
 	while (1) {
 		const uint32 sep = READ_LE_UINT32(_textBuf + offset); offset += 4;
 		const uint16 num = sep >> 16;
 		if (num == 0xFFFF) {
 			break;
 		}
-		if (num < ARRAYSIZE(_stringsTable) && _stringsTable[num] == 0) {
+		if (num < ARRAYSIZE(_stringsTable) && _stringsTable[num] == nullptr) {
 			_stringsTable[num] = (const char *)_textBuf + offset;
 		}
 		while (offset < len && _textBuf[offset++] != 0);
@@ -344,7 +344,7 @@ const char *ResourceWin31::getMusicName(int num) const {
 	case 138:
 		return "X.mid";
 	}
-	return 0;
+	return nullptr;
 }
 
 } // namespace Awe
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index e9cf0ac0f65..d737e2a52e2 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -31,7 +31,7 @@
 namespace Awe {
 
 Script::Script(Sound *snd, Resource *res, SfxPlayer *ply, Video *vid)
-	: _sound(snd), _res(res), _ply(ply), _vid(vid), _stub(0) {
+	: _sound(snd), _res(res), _ply(ply), _vid(vid), _stub(nullptr) {
 }
 
 void Script::init() {
diff --git a/engines/awe/sfx_player.cpp b/engines/awe/sfx_player.cpp
index a8b22cb37b1..a2c37b6b0dc 100644
--- a/engines/awe/sfx_player.cpp
+++ b/engines/awe/sfx_player.cpp
@@ -187,7 +187,7 @@ void SfxPlayer::handlePattern(uint8 channel, const uint8 *data) {
 		uint16 sample = (pat.note_2 & 0xF000) >> 12;
 		if (sample != 0) {
 			uint8 *ptr = _sfxMod.samples[sample - 1].data;
-			if (ptr != 0) {
+			if (ptr != nullptr) {
 				debugC(kDebugSound, "SfxPlayer::handlePattern() preparing sample %d", sample);
 				pat.sampleVolume = _sfxMod.samples[sample - 1].volume;
 				pat.sampleStart = 8;
@@ -226,7 +226,7 @@ void SfxPlayer::handlePattern(uint8 channel, const uint8 *data) {
 		*_syncVar = pat.note_2;
 	} else if (pat.note_1 == 0xFFFE) {
 		_channels[channel].sampleLen = 0;
-	} else if (pat.note_1 != 0 && pat.sampleBuffer != 0) {
+	} else if (pat.note_1 != 0 && pat.sampleBuffer != nullptr) {
 		assert(pat.note_1 >= 0x37 && pat.note_1 < 0x1000);
 		// convert Amiga period value to hz
 		const int freq = kPaulaFreq / (pat.note_1 * 2);
diff --git a/engines/awe/static_res.cpp b/engines/awe/static_res.cpp
index b6af52791e8..6ad3fbe4908 100644
--- a/engines/awe/static_res.cpp
+++ b/engines/awe/static_res.cpp
@@ -262,7 +262,7 @@ const StrEntry Video::STRINGS_TABLE_FR[] = {
 	{ 0x193, "Monsieur est en parfaite sante." },
 	{ 0x194, "O" },
 	{ 0x193, "AU BOULOT !!!\n" },
-	{ 0xFFFF, 0 }
+	{ 0xFFFF, nullptr }
 };
 
 const StrEntry Video::STRINGS_TABLE_ENG[] = {
@@ -406,7 +406,7 @@ const StrEntry Video::STRINGS_TABLE_ENG[] = {
 	{ 0x193, "Monsieur est en parfaite sante." },
 	{ 0x194, "Y\n" },
 	{ 0x193, "AU BOULOT !!!\n" },
-	{ 0xFFFF, 0 }
+	{ 0xFFFF, nullptr }
 };
 
 const StrEntry Video::STRINGS_TABLE_DEMO[] = {
@@ -417,7 +417,7 @@ const StrEntry Video::STRINGS_TABLE_DEMO[] = {
 	{ 0x1F8, "Nature decides to put a little\n    extra spin on the ball" },
 	{ 0x1F9, "And sends you ..." },
 	{ 0x1FA, "     Out of this World\nA Cinematic Action Adventure\n from Interplay Productions\n                    \n       By Eric CHAHI      \n\n  IBM version : D.MORAIS\n" },
-	{ 0xFFFF, 0 }
+	{ 0xFFFF, nullptr }
 };
 
 const uint16 Video::STRINGS_ID_15TH[] = {
@@ -703,7 +703,7 @@ const StrEntry Video::STRINGS_TABLE_3DO[] = {
 	{ 401, "I see you have driven here in your\nFerrari." },
 	{ 402, "IDENTIFICATION" },
 	{ 404, "Y" },
-	{ 0xFFFF, 0 }
+	{ 0xFFFF, nullptr }
 };
 
 const char *Video::NOTE_TEXT_3DO = {
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index f4be6d421c3..6c40517b954 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -42,7 +42,7 @@ void Video::init() {
 }
 
 void Video::setDefaultFont() {
-	_graphics->setFont(0, 0, 0);
+	_graphics->setFont(nullptr, 0, 0);
 }
 
 void Video::setFont(const uint8 *font) {
@@ -295,12 +295,12 @@ static const char *findString(const StrEntry *stringsTable, int id) {
 			return se->str;
 		}
 	}
-	return 0;
+	return nullptr;
 }
 
 void Video::drawString(uint8 color, uint16 x, uint16 y, uint16 strId) {
 	bool escapedChars = false;
-	const char *str = 0;
+	const char *str = nullptr;
 	if (_res->getDataType() == DT_15TH_EDITION || _res->getDataType() == DT_20TH_EDITION) {
 		for (int i = 0; i < NTH_EDITION_STRINGS_COUNT; ++i) {
 			if (Video::STRINGS_ID_15TH[i] == strId) {


Commit: c6e7cff0aacd1f579fc1cc9bf4e80d664ef6702d
    https://github.com/scummvm/scummvm/commit/c6e7cff0aacd1f579fc1cc9bf4e80d664ef6702d
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Janitorial - Add some constness

Changed paths:
    engines/awe/aifc_player.cpp
    engines/awe/awe.cpp
    engines/awe/graphics_soft.cpp
    engines/awe/pak.cpp
    engines/awe/resource.cpp
    engines/awe/script.cpp
    engines/awe/sfx_player.cpp
    engines/awe/video.cpp


diff --git a/engines/awe/aifc_player.cpp b/engines/awe/aifc_player.cpp
index e7040b934af..1da927d9ae2 100644
--- a/engines/awe/aifc_player.cpp
+++ b/engines/awe/aifc_player.cpp
@@ -122,7 +122,7 @@ int8 AifcPlayer::readSampleData() {
 }
 
 void AifcPlayer::decodeSamples() {
-	for (uint32 pos = _rate.getInt(); pos == _rate.getInt(); _rate.offset += _rate.inc) {
+	for (const uint32 pos = _rate.getInt(); pos == _rate.getInt(); _rate.offset += _rate.inc) {
 		_sampleL = decodeSDX2(_sampleL, readSampleData());
 		_sampleR = decodeSDX2(_sampleR, readSampleData());
 	}
diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 5bf1c73b795..29f0075d337 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -112,7 +112,7 @@ Common::Error AweEngine::run() {
 		warning("Sound initialization failed.");
 	}
 
-	int part = 16001;
+	const int part = 16001;
 	const Language lang = getLanguage();
 	const DataType dataType = getDataType();
 	int graphicsType = GRAPHICS_SOFTWARE;
@@ -123,8 +123,8 @@ Common::Error AweEngine::run() {
 	dm.height = GFX_H;
 	dm.opengl = (graphicsType == GRAPHICS_GL);
 
-	bool defaultGraphics = true;
-	bool demo3JoyInputs = false;
+	const bool defaultGraphics = true;
+	const bool demo3JoyInputs = false;
 
 	Sound snd(_mixer);
 	Awe::Engine *e = new Awe::Engine(&snd, dataType, part);
diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
index b76dbfe00b0..c7aad66391d 100644
--- a/engines/awe/graphics_soft.cpp
+++ b/engines/awe/graphics_soft.cpp
@@ -112,7 +112,7 @@ void GraphicsSoft::setSize(int w, int h) {
 
 static uint32 calcStep(const Point &p1, const Point &p2, uint16 &dy) {
 	dy = p2.y - p1.y;
-	uint16 delta = (dy <= 1) ? 1 : dy;
+	const uint16 delta = (dy <= 1) ? 1 : dy;
 	return ((p2.x - p1.x) * (0x4000 / delta)) << 2;
 }
 
@@ -151,14 +151,14 @@ void GraphicsSoft::drawPolygon(uint8 color, const QuadStrip &quadStrip) {
 	uint32 cpt2 = x2 << 16;
 
 	int numVertices = qs.numVertices;
-	while (1) {
+	while (true) {
 		numVertices -= 2;
 		if (numVertices == 0) {
 			return;
 		}
 		uint16 h;
-		uint32 step1 = calcStep(qs.vertices[j + 1], qs.vertices[j], h);
-		uint32 step2 = calcStep(qs.vertices[i - 1], qs.vertices[i], h);
+		const uint32 step1 = calcStep(qs.vertices[j + 1], qs.vertices[j], h);
+		const uint32 step2 = calcStep(qs.vertices[i - 1], qs.vertices[i], h);
 
 		++i;
 		--j;
@@ -248,7 +248,7 @@ void GraphicsSoft::drawSpriteMask(int x, int y, uint8 color, const uint8 *data)
 static void blend_rgb555(uint16 *dst, const uint16 b) {
 	static const uint16 RB_MASK = 0x7c1f;
 	static const uint16 G_MASK = 0x03e0;
-	uint16 a = *dst;
+	const uint16 a = *dst;
 	if ((a & 0x8000) == 0) { // use bit 15 to prevent additive blending
 		uint16 r = 0x8000;
 		r |= (((a & RB_MASK) + (b & RB_MASK)) >> 1) & RB_MASK;
@@ -295,9 +295,9 @@ void GraphicsSoft::drawPoint(int16 x, int16 y, uint8 color) {
 }
 
 void GraphicsSoft::drawLineT(int16 x1, int16 x2, int16 y, uint8 color) {
-	int16 xmax = MAX(x1, x2);
-	int16 xmin = MIN(x1, x2);
-	int w = xmax - xmin + 1;
+	const int16 xmax = MAX(x1, x2);
+	const int16 xmin = MIN(x1, x2);
+	const int w = xmax - xmin + 1;
 	const int offset = (y * _w + xmin) * _byteDepth;
 	if (_byteDepth == 1) {
 		for (int i = 0; i < w; ++i) {
@@ -315,8 +315,8 @@ void GraphicsSoft::drawLineT(int16 x1, int16 x2, int16 y, uint8 color) {
 }
 
 void GraphicsSoft::drawLineN(int16 x1, int16 x2, int16 y, uint8 color) {
-	int16 xmax = MAX(x1, x2);
-	int16 xmin = MIN(x1, x2);
+	const int16 xmax = MAX(x1, x2);
+	const int16 xmin = MIN(x1, x2);
 	const int w = xmax - xmin + 1;
 	const int offset = (y * _w + xmin) * _byteDepth;
 	if (_byteDepth == 1) {
@@ -335,8 +335,8 @@ void GraphicsSoft::drawLineP(int16 x1, int16 x2, int16 y, uint8 color) {
 	if (_drawPagePtr == _pagePtrs[0]) {
 		return;
 	}
-	int16 xmax = MAX(x1, x2);
-	int16 xmin = MIN(x1, x2);
+	const int16 xmax = MAX(x1, x2);
+	const int16 xmin = MIN(x1, x2);
 	const int w = xmax - xmin + 1;
 	const int offset = (y * _w + xmin) * _byteDepth;
 	memcpy(_drawPagePtr + offset, _pagePtrs[0] + offset, w * _byteDepth);
diff --git a/engines/awe/pak.cpp b/engines/awe/pak.cpp
index 140fcacf9c6..76788f5e2e8 100644
--- a/engines/awe/pak.cpp
+++ b/engines/awe/pak.cpp
@@ -25,8 +25,9 @@
 namespace Awe {
 
 // static const uint32 XOR_KEY1 = 0x31111612;
+// static const uint32 CHECKSUM = 0x20202020;
+
 static const uint32 XOR_KEY2 = 0x22683297;
-static const uint32 CHECKSUM = 0x20202020;
 
 static uint8 *decode_toodc(uint8 *p, int count) {
 	uint32 key = XOR_KEY2;
@@ -102,19 +103,20 @@ void Pak::readEntries() {
 		debugC(kDebugPak, "Pak::readEntries() buf '%s' size %d", e->name, e->size);
 	}
 	qsort(_entries, _entriesCount, sizeof(PakEntry), comparePakEntry);
+
+#if 0
 	// the original executable descrambles the (ke)y.txt file and check the last 4 bytes.
 	// this has been disabled in later re-releases and a key is bundled in the data files
-	if (0) {
-		uint8 buf[128];
-		const PakEntry *e = find("check.txt");
-		if (e && e->size <= sizeof(buf)) {
-			uint32 size = 0;
-			loadData(e, buf, &size);
-			assert(size >= 4);
-			const uint32 num = READ_LE_UINT32(buf + size - 4);
-			assert(num == CHECKSUM);
-		}
+	uint8 buf[128];
+	const PakEntry *e = find("check.txt");
+	if (e && e->size <= sizeof(buf)) {
+		uint32 size = 0;
+		loadData(e, buf, &size);
+		assert(size >= 4);
+		const uint32 num = READ_LE_UINT32(buf + size - 4);
+		assert(num == CHECKSUM);
 	}
+#endif
 }
 
 const PakEntry *Pak::find(const char *name) {
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 0af50dc584b..8e0fd99667a 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -154,7 +154,7 @@ void Resource::readEntries() {
 				if (me->status == 0xFF) {
 					const int num = MEMLIST_PARTS[8][1]; // 16008 bytecode
 					assert(num < _numMemList);
-					Common::String bank = Common::String::format(
+					const Common::String bank = Common::String::format(
 						"%s%02x", _bankPrefix, _memList[num].bankNum);
 					_hasPasswordScreen = Common::File::exists(bank.c_str());
 					return;
@@ -617,7 +617,7 @@ void Resource::setupPart(int ptrId) {
 			uint8 ivd1 = 0;
 			uint8 ivd2 = 0;
 			if (ptrId >= 16000 && ptrId <= 16009) {
-				uint16 part = ptrId - 16000;
+				const uint16 part = ptrId - 16000;
 				ipal = MEMLIST_PARTS[part][0];
 				icod = MEMLIST_PARTS[part][1];
 				ivd1 = MEMLIST_PARTS[part][2];
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index d737e2a52e2..6357990713f 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -62,22 +62,22 @@ void Script::init() {
 }
 
 void Script::op_movConst() {
-	uint8 i = _scriptPtr.fetchByte();
-	int16 n = _scriptPtr.fetchWord();
+	const uint8 i = _scriptPtr.fetchByte();
+	const int16 n = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_movConst(0x%02X, %d)", i, n);
 	_scriptVars[i] = n;
 }
 
 void Script::op_mov() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint8 j = _scriptPtr.fetchByte();
+	const uint8 i = _scriptPtr.fetchByte();
+	const uint8 j = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_mov(0x%02X, 0x%02X)", i, j);
 	_scriptVars[i] = _scriptVars[j];
 }
 
 void Script::op_add() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint8 j = _scriptPtr.fetchByte();
+	const uint8 i = _scriptPtr.fetchByte();
+	const uint8 j = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_add(0x%02X, 0x%02X)", i, j);
 	_scriptVars[i] += _scriptVars[j];
 }
@@ -99,14 +99,14 @@ void Script::op_addConst() {
 			snd_playSound(0x5B, 1, 64, 1);
 		}
 	}
-	uint8 i = _scriptPtr.fetchByte();
-	int16 n = _scriptPtr.fetchWord();
+	const uint8 i = _scriptPtr.fetchByte();
+	const int16 n = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_addConst(0x%02X, %d)", i, n);
 	_scriptVars[i] += n;
 }
 
 void Script::op_call() {
-	uint16 off = _scriptPtr.fetchWord();
+	const uint16 off = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_call(0x%X)", off);
 	if (_stackPtr == 0x40) {
 		error("Script::op_call() ec=0x%X stack overflow", 0x8F);
@@ -131,21 +131,21 @@ void Script::op_yieldTask() {
 }
 
 void Script::op_jmp() {
-	uint16 off = _scriptPtr.fetchWord();
+	const uint16 off = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_jmp(0x%02X)", off);
 	_scriptPtr.pc = _res->_segCode + off;
 }
 
 void Script::op_installTask() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint16 n = _scriptPtr.fetchWord();
+	const uint8 i = _scriptPtr.fetchByte();
+	const uint16 n = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_installTask(0x%X, 0x%X)", i, n);
 	assert(i < 0x40);
 	_scriptTasks[1][i] = n;
 }
 
 void Script::op_jmpIfVar() {
-	uint8 i = _scriptPtr.fetchByte();
+	const uint8 i = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_jmpIfVar(0x%02X)", i);
 	--_scriptVars[i];
 	if (_scriptVars[i] != 0) {
@@ -167,9 +167,9 @@ void Script::op_condJmp() {
 		WRITE_BE_UINT16(script + 153, 0xced);
 	}
 
-	uint8 op = _scriptPtr.fetchByte();
+	const uint8 op = _scriptPtr.fetchByte();
 	const uint8 var = _scriptPtr.fetchByte();
-	int16 b = _scriptVars[var];
+	const int16 b = _scriptVars[var];
 	int16 a;
 	if (op & 0x80) {
 		a = _scriptVars[_scriptPtr.fetchByte()];
@@ -236,7 +236,7 @@ void Script::op_condJmp() {
 }
 
 void Script::op_setPalette() {
-	uint16 i = _scriptPtr.fetchWord();
+	const uint16 i = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_changePalette(%d)", i);
 	const int num = i >> 8;
 	if (_vid->_graphics->_fixUpPalette == FIXUP_PALETTE_REDRAW) {
@@ -253,12 +253,12 @@ void Script::op_setPalette() {
 
 void Script::op_changeTasksState() {
 	uint8 start = _scriptPtr.fetchByte();
-	uint8 end = _scriptPtr.fetchByte();
+	const uint8 end = _scriptPtr.fetchByte();
 	if (end < start) {
 		warning("Script::op_changeTasksState() ec=0x%X (end < start)", 0x880);
 		return;
 	}
-	uint8 state = _scriptPtr.fetchByte();
+	const uint8 state = _scriptPtr.fetchByte();
 
 	debugC(kDebugScript, "Script::op_changeTasksState(%d, %d, %d)", start, end, state);
 
@@ -274,27 +274,27 @@ void Script::op_changeTasksState() {
 }
 
 void Script::op_selectPage() {
-	uint8 i = _scriptPtr.fetchByte();
+	const uint8 i = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_selectPage(%d)", i);
 	_vid->setWorkPagePtr(i);
 }
 
 void Script::op_fillPage() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint8 color = _scriptPtr.fetchByte();
+	const uint8 i = _scriptPtr.fetchByte();
+	const uint8 color = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_fillPage(%d, %d)", i, color);
 	_vid->fillPage(i, color);
 }
 
 void Script::op_copyPage() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint8 j = _scriptPtr.fetchByte();
+	const uint8 i = _scriptPtr.fetchByte();
+	const uint8 j = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_copyPage(%d, %d)", i, j);
 	_vid->copyPage(i, j, _scriptVars[VAR_SCROLL_Y]);
 }
 
 void Script::op_updateDisplay() {
-	uint8 page = _scriptPtr.fetchByte();
+	const uint8 page = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_updateDisplay(%d)", page);
 	inp_handleSpecialKeys();
 
@@ -331,54 +331,54 @@ void Script::op_removeTask() {
 }
 
 void Script::op_drawString() {
-	uint16 strId = _scriptPtr.fetchWord();
-	uint16 x = _scriptPtr.fetchByte();
-	uint16 y = _scriptPtr.fetchByte();
-	uint16 col = _scriptPtr.fetchByte();
+	const uint16 strId = _scriptPtr.fetchWord();
+	const uint16 x = _scriptPtr.fetchByte();
+	const uint16 y = _scriptPtr.fetchByte();
+	const uint16 col = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_drawString(0x%03X, %d, %d, %d)", strId, x, y, col);
 	_vid->drawString(col, x, y, strId);
 }
 
 void Script::op_sub() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint8 j = _scriptPtr.fetchByte();
+	const uint8 i = _scriptPtr.fetchByte();
+	const uint8 j = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_sub(0x%02X, 0x%02X)", i, j);
 	_scriptVars[i] -= _scriptVars[j];
 }
 
 void Script::op_and() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint16 n = _scriptPtr.fetchWord();
+	const uint8 i = _scriptPtr.fetchByte();
+	const uint16 n = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_and(0x%02X, %d)", i, n);
 	_scriptVars[i] = (uint16)_scriptVars[i] & n;
 }
 
 void Script::op_or() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint16 n = _scriptPtr.fetchWord();
+	const uint8 i = _scriptPtr.fetchByte();
+	const uint16 n = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_or(0x%02X, %d)", i, n);
 	_scriptVars[i] = (uint16)_scriptVars[i] | n;
 }
 
 void Script::op_shl() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint16 n = _scriptPtr.fetchWord();
+	const uint8 i = _scriptPtr.fetchByte();
+	const uint16 n = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_shl(0x%02X, %d)", i, n);
 	_scriptVars[i] = (uint16)_scriptVars[i] << n;
 }
 
 void Script::op_shr() {
-	uint8 i = _scriptPtr.fetchByte();
-	uint16 n = _scriptPtr.fetchWord();
+	const uint8 i = _scriptPtr.fetchByte();
+	const uint16 n = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_shr(0x%02X, %d)", i, n);
 	_scriptVars[i] = (uint16)_scriptVars[i] >> n;
 }
 
 void Script::op_playSound() {
-	uint16 resNum = _scriptPtr.fetchWord();
-	uint8 freq = _scriptPtr.fetchByte();
-	uint8 vol = _scriptPtr.fetchByte();
-	uint8 channel = _scriptPtr.fetchByte();
+	const uint16 resNum = _scriptPtr.fetchWord();
+	const uint8 freq = _scriptPtr.fetchByte();
+	const uint8 vol = _scriptPtr.fetchByte();
+	const uint8 channel = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_playSound(0x%X, %d, %d, %d)", resNum, freq, vol, channel);
 	snd_playSound(resNum, freq, vol, channel);
 }
@@ -388,7 +388,7 @@ static void preloadSoundCb(void *userdata, int soundNum, const uint8 *data) {
 }
 
 void Script::op_updateResources() {
-	uint16 num = _scriptPtr.fetchWord();
+	const uint16 num = _scriptPtr.fetchWord();
 	debugC(kDebugScript, "Script::op_updateResources(%d)", num);
 	if (num == 0) {
 		_ply->stop();
@@ -400,9 +400,9 @@ void Script::op_updateResources() {
 }
 
 void Script::op_playMusic() {
-	uint16 resNum = _scriptPtr.fetchWord();
-	uint16 delay = _scriptPtr.fetchWord();
-	uint8 pos = _scriptPtr.fetchByte();
+	const uint16 resNum = _scriptPtr.fetchWord();
+	const uint16 delay = _scriptPtr.fetchWord();
+	const uint8 pos = _scriptPtr.fetchByte();
 	debugC(kDebugScript, "Script::op_playMusic(0x%X, %d, %d)", resNum, delay, pos);
 	snd_playMusic(resNum, delay, pos);
 }
@@ -453,7 +453,7 @@ void Script::setupTasks() {
 	}
 	for (int i = 0; i < 0x40; ++i) {
 		_scriptStates[0][i] = _scriptStates[1][i];
-		uint16 n = _scriptTasks[1][i];
+		const uint16 n = _scriptTasks[1][i];
 		if (n != 0xFFFF) {
 			_scriptTasks[0][i] = (n == 0xFFFE) ? 0xFFFF : n;
 			_scriptTasks[1][i] = 0xFFFF;
@@ -464,7 +464,7 @@ void Script::setupTasks() {
 void Script::runTasks() {
 	for (int i = 0; i < 0x40 && !_stub->_pi.quit; ++i) {
 		if (_scriptStates[0][i] == 0) {
-			uint16 n = _scriptTasks[0][i];
+			const uint16 n = _scriptTasks[0][i];
 			if (n != 0xFFFF) {
 				_scriptPtr.pc = _res->_segCode + n;
 				_stackPtr = 0;
@@ -480,14 +480,14 @@ void Script::runTasks() {
 
 void Script::executeTask() {
 	while (!_scriptPaused) {
-		uint8 opcode = _scriptPtr.fetchByte();
+		const uint8 opcode = _scriptPtr.fetchByte();
 		if (opcode & 0x80) {
 			const uint16 off = ((opcode << 8) | _scriptPtr.fetchByte()) << 1;
 			_res->_useSegVideo2 = false;
 			Point pt;
 			pt.x = _scriptPtr.fetchByte();
 			pt.y = _scriptPtr.fetchByte();
-			int16 h = pt.y - 199;
+			const int16 h = pt.y - 199;
 			if (h > 0) {
 				pt.y = 199;
 				pt.x += h;
@@ -626,7 +626,7 @@ void Script::executeTask() {
 void Script::updateInput() {
 	_stub->processEvents();
 	if (_res->_currentPart == kPartPassword) {
-		char c = _stub->_pi.lastChar;
+		const char c = _stub->_pi.lastChar;
 		if (c == 8 || /*c == 0xD ||*/ c == 0 || (c >= 'a' && c <= 'z')) {
 			_scriptVars[VAR_LAST_KEYCHAR] = c & ~0x20;
 			_stub->_pi.lastChar = 0;
diff --git a/engines/awe/sfx_player.cpp b/engines/awe/sfx_player.cpp
index a2c37b6b0dc..3453e9906d1 100644
--- a/engines/awe/sfx_player.cpp
+++ b/engines/awe/sfx_player.cpp
@@ -63,7 +63,7 @@ void SfxPlayer::prepareInstruments(const uint8 *p) {
 	memset(_sfxMod.samples, 0, sizeof(_sfxMod.samples));
 	for (int i = 0; i < 15; ++i) {
 		SfxInstrument *ins = &_sfxMod.samples[i];
-		uint16 resNum = READ_BE_UINT16(p); p += 2;
+		const uint16 resNum = READ_BE_UINT16(p); p += 2;
 		if (resNum != 0) {
 			ins->volume = READ_BE_UINT16(p);
 			MemEntry *me = &_res->_memList[resNum];
@@ -100,7 +100,7 @@ static void mixChannel(int16 &s, SfxChannel *ch) {
 	if (ch->sampleLen == 0) {
 		return;
 	}
-	int pos1 = ch->pos.offset >> Frac::BITS;
+	const int pos1 = ch->pos.offset >> Frac::BITS;
 	ch->pos.offset += ch->pos.inc;
 	int pos2 = pos1 + 1;
 	if (ch->sampleLoopLen != 0) {
@@ -184,7 +184,7 @@ void SfxPlayer::handlePattern(uint8 channel, const uint8 *data) {
 	pat.note_1 = READ_BE_UINT16(data + 0);
 	pat.note_2 = READ_BE_UINT16(data + 2);
 	if (pat.note_1 != 0xFFFD) {
-		uint16 sample = (pat.note_2 & 0xF000) >> 12;
+		const uint16 sample = (pat.note_2 & 0xF000) >> 12;
 		if (sample != 0) {
 			uint8 *ptr = _sfxMod.samples[sample - 1].data;
 			if (ptr != nullptr) {
@@ -193,7 +193,7 @@ void SfxPlayer::handlePattern(uint8 channel, const uint8 *data) {
 				pat.sampleStart = 8;
 				pat.sampleBuffer = ptr;
 				pat.sampleLen = READ_BE_UINT16(ptr) * 2;
-				uint16 loopLen = READ_BE_UINT16(ptr + 2) * 2;
+				const uint16 loopLen = READ_BE_UINT16(ptr + 2) * 2;
 				if (loopLen != 0) {
 					pat.loopPos = pat.sampleLen;
 					pat.loopLen = loopLen;
@@ -202,15 +202,15 @@ void SfxPlayer::handlePattern(uint8 channel, const uint8 *data) {
 					pat.loopLen = 0;
 				}
 				int16 m = pat.sampleVolume;
-				uint8 effect = (pat.note_2 & 0x0F00) >> 8;
+				const uint8 effect = (pat.note_2 & 0x0F00) >> 8;
 				if (effect == 5) { // volume up
-					uint8 volume = (pat.note_2 & 0xFF);
+					const uint8 volume = (pat.note_2 & 0xFF);
 					m += volume;
 					if (m > 0x3F) {
 						m = 0x3F;
 					}
 				} else if (effect == 6) { // volume down
-					uint8 volume = (pat.note_2 & 0xFF);
+					const uint8 volume = (pat.note_2 & 0xFF);
 					m -= volume;
 					if (m < 0) {
 						m = 0;
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index 6c40517b954..0dc668de69c 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -207,13 +207,13 @@ void Video::drawShape3DO(int color, int zoom, const Point *pt) {
 void Video::fillPolygon(uint16 color, uint16 zoom, const Point *pt) {
 	const uint8 *p = _pData.pc;
 
-	uint16 bbw = (*p++) * zoom / 64;
-	uint16 bbh = (*p++) * zoom / 64;
+	const uint16 bbw = (*p++) * zoom / 64;
+	const uint16 bbh = (*p++) * zoom / 64;
 
-	int16 x1 = pt->x - bbw / 2;
-	int16 x2 = pt->x + bbw / 2;
-	int16 y1 = pt->y - bbh / 2;
-	int16 y2 = pt->y + bbh / 2;
+	const int16 x1 = pt->x - bbw / 2;
+	const int16 x2 = pt->x + bbw / 2;
+	const int16 y1 = pt->y - bbh / 2;
+	const int16 y2 = pt->y + bbh / 2;
 
 	if (x1 > 319 || x2 < 0 || y1 > 199 || y2 < 0)
 		return;
@@ -330,8 +330,8 @@ void Video::drawString(uint8 color, uint16 x, uint16 y, uint16 strId) {
 		return;
 	}
 	debugC(kDebugVideo, "drawString(%d, %d, %d, '%s')", color, x, y, str);
-	uint16 xx = x;
-	int len = strlen(str);
+	const uint16 xx = x;
+	const int len = strlen(str);
 	for (int i = 0; i < len; ++i) {
 		if (str[i] == '\n' || str[i] == '\r') {
 			y += 8;
@@ -390,8 +390,8 @@ void Video::copyPage(uint8 src, uint8 dst, int16 vscroll) {
 	if (src >= 0xFE || ((src &= ~0x40) & 0x80) == 0) { // no vscroll
 		_graphics->copyBuffer(getPagePtr(dst), getPagePtr(src));
 	} else {
-		uint8 sl = getPagePtr(src & 3);
-		uint8 dl = getPagePtr(dst);
+		const uint8 sl = getPagePtr(src & 3);
+		const uint8 dl = getPagePtr(dst);
 		if (sl != dl && vscroll >= -199 && vscroll <= 199) {
 			_graphics->copyBuffer(dl, sl, vscroll);
 		}


Commit: b39466743072d429a8a14a54d53528c9d67deffd
    https://github.com/scummvm/scummvm/commit/b39466743072d429a8a14a54d53528c9d67deffd
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Janitorial - check the other while statements

Changed paths:
    engines/awe/resource.cpp
    engines/awe/resource_win31.cpp


diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 8e0fd99667a..7068aa9d86a 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -247,7 +247,7 @@ void Resource::dumpEntries() {
 }
 
 void Resource::load() {
-	while (1) {
+	while (true) {
 		MemEntry *me = nullptr;
 
 		// get resource with max rankNum
diff --git a/engines/awe/resource_win31.cpp b/engines/awe/resource_win31.cpp
index d87e010a1e5..f8da14eab33 100644
--- a/engines/awe/resource_win31.cpp
+++ b/engines/awe/resource_win31.cpp
@@ -316,7 +316,7 @@ uint8 *ResourceWin31::loadFile(int num, uint8 *dst, uint32 *size) {
 void ResourceWin31::readStrings() {
 	uint32 len, offset = 0;
 	_textBuf = loadFile(148, nullptr, &len);
-	while (1) {
+	while (true) {
 		const uint32 sep = READ_LE_UINT32(_textBuf + offset); offset += 4;
 		const uint16 num = sep >> 16;
 		if (num == 0xFFFF) {
@@ -325,7 +325,8 @@ void ResourceWin31::readStrings() {
 		if (num < ARRAYSIZE(_stringsTable) && _stringsTable[num] == nullptr) {
 			_stringsTable[num] = (const char *)_textBuf + offset;
 		}
-		while (offset < len && _textBuf[offset++] != 0);
+		while (offset < len && _textBuf[offset++] != 0)
+			;
 		// strings are not always '\0' terminated
 		if (_textBuf[offset + 1] != 0) {
 			--offset;


Commit: 8bc3ba66ccb8460372355f93c392a2208a362321
    https://github.com/scummvm/scummvm/commit/8bc3ba66ccb8460372355f93c392a2208a362321
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Janitorial - add missing default values to switches

Changed paths:
    engines/awe/awe.cpp
    engines/awe/engine.cpp
    engines/awe/graphics_gl.cpp
    engines/awe/graphics_soft.cpp
    engines/awe/resource_3do.cpp
    engines/awe/resource_nth.cpp
    engines/awe/resource_nth.h
    engines/awe/resource_win31.cpp
    engines/awe/script.cpp
    engines/awe/sound.cpp
    engines/awe/video.cpp


diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 29f0075d337..0e3618d9b30 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -74,7 +74,13 @@ static Gfx *createGraphics(int type) {
 		debugC(kDebugInfo, "Using GL graphics");
 #ifdef USE_GL
 		return GraphicsGL_create();
+#elsif
+		break;
 #endif
+
+	default:
+		break;
+
 	}
 
 	return nullptr;
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index 2f30cff0f4e..0e746d577c5 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -81,9 +81,13 @@ void Engine::run() {
 			case 16000:
 				_state = kStateTitle3DO;
 				break;
+			default:
+				break;
 			}
 		}
 		break;
+	default:
+		break;
 	}
 }
 
@@ -133,7 +137,6 @@ void Engine::setup(Language lang, int graphicsType) {
 	case DT_WIN31:
 	case DT_15TH_EDITION:
 	case DT_20TH_EDITION:
-		break;
 	case DT_3DO:
 		break;
 	}
diff --git a/engines/awe/graphics_gl.cpp b/engines/awe/graphics_gl.cpp
index bb9e049419c..a5982b263c3 100644
--- a/engines/awe/graphics_gl.cpp
+++ b/engines/awe/graphics_gl.cpp
@@ -531,6 +531,8 @@ void GraphicsGL::drawBitmap(int listNum, const uint8 *data, int w, int h, int fm
 		_backgroundTex.clear();
 		_backgroundTex.readRGB555((const uint16 *)data, w, h);
 		break;
+	default:
+		break;
 	}
 	_fptr.glBindFramebuffer(GL_FRAMEBUFFER, _fbPage0);
 	glDrawBuffer(GL_COLOR_ATTACHMENT0 + listNum);
diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
index c7aad66391d..53aa1337da8 100644
--- a/engines/awe/graphics_soft.cpp
+++ b/engines/awe/graphics_soft.cpp
@@ -398,6 +398,8 @@ void GraphicsSoft::drawBitmap(int buffer, const uint8 *data, int w, int h, int f
 			return;
 		}
 		break;
+	default:
+		break;
 	}
 	warning("GraphicsSoft::drawBitmap() unhandled fmt %d w %d h %d", fmt, w, h);
 }
diff --git a/engines/awe/resource_3do.cpp b/engines/awe/resource_3do.cpp
index 7cd5b9bbd5b..4c0f2ee987f 100644
--- a/engines/awe/resource_3do.cpp
+++ b/engines/awe/resource_3do.cpp
@@ -70,14 +70,17 @@ static void decodeCcb16(int ccbWidth, int ccbHeight, File *f, uint32 dataSize, u
 				dst += count;
 				break;
 			case 3:
-			{
+				{
 				const uint16 color = f->readUint16BE();
 				for (int i = 0; i < count; ++i) {
 					*dst++ = color;
 				}
 				scanlineLen += 2;
-			}
-			break;
+				}
+				break;
+				
+			default:
+				break;
 			}
 			w -= count;
 		}
diff --git a/engines/awe/resource_nth.cpp b/engines/awe/resource_nth.cpp
index 93ee4240956..5ff7271f8e0 100644
--- a/engines/awe/resource_nth.cpp
+++ b/engines/awe/resource_nth.cpp
@@ -219,6 +219,9 @@ struct Resource15th : ResourceNth {
 				path = "Music/AW/End2004.wav";
 			}
 			break;
+			
+		default:
+			break;
 		}
 		return path;
 	}
@@ -417,23 +420,24 @@ struct Resource20th : ResourceNth {
 
 		switch (num) {
 		case 81:
-		{
+			{
 			const int r = g_engine->getRandomNumber(1, 3);
 			snprintf(path, sizeof(path), "game/WGZ/file081-EX-%d.wgz", r);
-		}
-		break;
+			}
+			break;
+
 		case 85:
-		{
+			{
 			const int r = g_engine->getRandomNumber(1, 2);
 			const char *snd = "IN";
 			if (_musicType == 1) {
 				snd = "EX";
 			}
 			snprintf(path, sizeof(path), "game/WGZ/file085-%s-%d.wgz", snd, r);
-		}
-		break;
+			}
+			break;
 		case 96:
-		{
+			{
 			const int r = g_engine->getRandomNumber(1, 3);
 			const char *snd = "GR";
 			if (_musicType == 1) {
@@ -442,10 +446,10 @@ struct Resource20th : ResourceNth {
 				snd = "IN";
 			}
 			snprintf(path, sizeof(path), "game/WGZ/file096-%s-%d.wgz", snd, r);
-		}
-		break;
+			}
+			break;
 		case 163:
-		{
+			{
 			const char *snd = "GR";
 			if (_musicType == 1) {
 				snd = "EX";
@@ -453,15 +457,14 @@ struct Resource20th : ResourceNth {
 				snd = "IN";
 			}
 			snprintf(path, sizeof(path), "game/WGZ/file163-%s-1.wgz", snd);
-		}
-		break;
-		default: {
+			}
+			break;
+		default:
 			snprintf(path, sizeof(path), "game/WGZ/file%03d.wgz", num);
 			if (!Common::File::exists(path)) {
 				snprintf(path, sizeof(path), "game/WGZ/file%03dB.wgz", num);
 			}
-		}
-		break;
+			break;
 		}
 		*size = 0;
 		return inflateGzip(path);
@@ -578,6 +581,8 @@ ResourceNth *ResourceNth::create(int edition) {
 		return new Resource15th();
 	case 20:
 		return new Resource20th();
+	default:
+		break;
 	}
 	return nullptr;
 }
diff --git a/engines/awe/resource_nth.h b/engines/awe/resource_nth.h
index 9790d1f388b..0b747341dad 100644
--- a/engines/awe/resource_nth.h
+++ b/engines/awe/resource_nth.h
@@ -33,8 +33,7 @@ struct ResourceNth {
 	virtual bool init() = 0;
 	virtual uint8 *load(const char *name) = 0;
 	virtual uint8 *loadBmp(int num) = 0;
-	virtual void preloadDat(int part, int type, int num) {
-	}
+	virtual void preloadDat(int part, int type, int num) {}
 	virtual uint8 *loadDat(int num, uint8 *dst, uint32 *size) = 0;
 	virtual uint8 *loadWav(int num, uint8 *dst, uint32 *size) = 0;
 	virtual const char *getString(Language lang, int num) = 0;
diff --git a/engines/awe/resource_win31.cpp b/engines/awe/resource_win31.cpp
index f8da14eab33..b580a5d03d8 100644
--- a/engines/awe/resource_win31.cpp
+++ b/engines/awe/resource_win31.cpp
@@ -344,6 +344,8 @@ const char *ResourceWin31::getMusicName(int num) const {
 		return "y.mid";
 	case 138:
 		return "X.mid";
+	default:
+		break;
 	}
 	return nullptr;
 }
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index 6357990713f..53327a51b77 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -612,13 +612,15 @@ void Script::executeTask() {
 					::debug("Time = %d", _scriptVars[0xF7]);
 				}
 				continue;
+					
+			default:
+					break;
 				}
 			}
-			if (opcode > 0x1A) {
+			if (opcode > 0x1A)
 				error("Script::executeTask() ec=0x%X invalid opcode=0x%X", 0xFFF, opcode);
-			} else {
-				(this->*OPCODE_TABLE[opcode])();
-			}
+
+			(this->*OPCODE_TABLE[opcode])();
 		}
 	}
 }
@@ -768,7 +770,11 @@ static uint8 getWavLooping(uint16 resNum) {
 	case 104:
 	case 106:
 	case 132:
-	case 139: return 1;
+	case 139:
+		return 1;
+		
+	default:
+		break;
 	}
 	return 0;
 }
@@ -899,11 +905,15 @@ void Script::fixUpPalette_changeScreen(int part, int screen) {
 			pal = 8;
 		}
 		break;
+
 	case 16006:
 		if (screen == 0x4A) { // bitmap resources #144, #145
 			pal = 1;
 		}
 		break;
+
+	default:
+		break;
 	}
 	if (pal != -1) {
 		debugC(kDebugScript, "Setting palette %d for part %d screen %d", pal, part, screen);
diff --git a/engines/awe/sound.cpp b/engines/awe/sound.cpp
index d171011b08d..39c9b9627b0 100644
--- a/engines/awe/sound.cpp
+++ b/engines/awe/sound.cpp
@@ -307,6 +307,8 @@ struct Mixer_impl {
 		case kMixerTypeAiff:
 			Mix_AllocateChannels(kMixChannels);
 			break;
+		default:
+			break;
 		}
 	}
 	void quit() {
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index 0dc668de69c..9b68b9fc56a 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -275,6 +275,9 @@ void Video::drawShapeParts(uint16 zoom, const Point *pgc) {
 				}
 				case 0x50:
 					return;
+
+				default:
+					break;
 				}
 			}
 			color &= 0x7F;
@@ -344,6 +347,9 @@ void Video::drawString(uint8 color, uint16 x, uint16 y, uint16 strId) {
 					y += 8;
 					x = xx;
 					break;
+
+				default:
+					break;
 				}
 			}
 		} else {


Commit: 64c259ca28e794dbdf24eac7ee85c74e751fcd1d
    https://github.com/scummvm/scummvm/commit/64c259ca28e794dbdf24eac7ee85c74e751fcd1d
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Janitorial - remove dead code in resource.cpp

Changed paths:
    engines/awe/resource.cpp


diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index 7068aa9d86a..f933195c1af 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -265,7 +265,7 @@ void Resource::load() {
 
 		const int resourceNum = me - _memList;
 
-		uint8 *memPtr = nullptr;
+		uint8 *memPtr;
 		if (me->type == RT_BITMAP) {
 			memPtr = _vidCurPtr;
 		} else {
@@ -594,10 +594,6 @@ void Resource::setupPart(int ptrId) {
 			for (int i = 0; i < 4; ++i) {
 				const int num = MEMLIST_PARTS[ptrId - 16000][i];
 				if (num != 0) {
-					if (_dataType == DT_20TH_EDITION && 0) {
-						// HD assets
-						_nth->preloadDat(ptrId - 16000, i, num);
-					}
 					*segments[i] = loadDat(num);
 				}
 			}


Commit: 687dbacdbd50dcbd93ca16bb13a69c3ae3579db3
    https://github.com/scummvm/scummvm/commit/687dbacdbd50dcbd93ca16bb13a69c3ae3579db3
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Remove utils

Changed paths:
  R engines/awe/util.cpp
  R engines/awe/util.h
    engines/awe/aifc_player.cpp
    engines/awe/awe.cpp
    engines/awe/bitmap.cpp
    engines/awe/engine.cpp
    engines/awe/file.cpp
    engines/awe/graphics_gl.cpp
    engines/awe/graphics_soft.cpp
    engines/awe/module.mk
    engines/awe/pak.cpp
    engines/awe/resource.cpp
    engines/awe/resource_3do.cpp
    engines/awe/resource_nth.cpp
    engines/awe/resource_win31.cpp
    engines/awe/script.cpp
    engines/awe/sfx_player.cpp
    engines/awe/sound.cpp
    engines/awe/system_stub.cpp
    engines/awe/unpack.cpp
    engines/awe/video.cpp


diff --git a/engines/awe/aifc_player.cpp b/engines/awe/aifc_player.cpp
index 1da927d9ae2..d5ea6d2bf36 100644
--- a/engines/awe/aifc_player.cpp
+++ b/engines/awe/aifc_player.cpp
@@ -20,7 +20,7 @@
  */
 
 #include "awe/aifc_player.h"
-#include "awe/util.h"
+#include "awe/detection.h"
 
 namespace Awe {
 
diff --git a/engines/awe/awe.cpp b/engines/awe/awe.cpp
index 0e3618d9b30..5ace831d881 100644
--- a/engines/awe/awe.cpp
+++ b/engines/awe/awe.cpp
@@ -28,7 +28,6 @@
 #include "awe/resource.h"
 #include "awe/script.h"
 #include "awe/system_stub.h"
-#include "awe/util.h"
 #include "awe/video.h"
 
 namespace Awe {
diff --git a/engines/awe/bitmap.cpp b/engines/awe/bitmap.cpp
index 1d95defbd68..49f64a7f809 100644
--- a/engines/awe/bitmap.cpp
+++ b/engines/awe/bitmap.cpp
@@ -19,8 +19,8 @@
  *
  */
 
+#include "common/textconsole.h"
 #include "awe/bitmap.h"
-#include "awe/util.h"
 
 namespace Awe {
 
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index 0e746d577c5..73e182877b1 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -24,7 +24,6 @@
 #include "awe/gfx.h"
 #include "awe/resource_nth.h"
 #include "awe/system_stub.h"
-#include "awe/util.h"
 
 namespace Awe {
 
diff --git a/engines/awe/file.cpp b/engines/awe/file.cpp
index 8ed7aeea47f..738fc152bde 100644
--- a/engines/awe/file.cpp
+++ b/engines/awe/file.cpp
@@ -20,7 +20,6 @@
  */
 
 #include "awe/file.h"
-#include "awe/util.h"
 
 namespace Awe {
 
diff --git a/engines/awe/graphics_gl.cpp b/engines/awe/graphics_gl.cpp
index a5982b263c3..f2325e3e3af 100644
--- a/engines/awe/graphics_gl.cpp
+++ b/engines/awe/graphics_gl.cpp
@@ -20,7 +20,6 @@
  */
 
 #include "awe/gfx.h"
-#include "awe/util.h"
 #include "awe/system_stub.h"
 
 namespace Awe {
diff --git a/engines/awe/graphics_soft.cpp b/engines/awe/graphics_soft.cpp
index 53aa1337da8..e37943dc2c9 100644
--- a/engines/awe/graphics_soft.cpp
+++ b/engines/awe/graphics_soft.cpp
@@ -20,8 +20,8 @@
  */
 
 #include "graphics/managed_surface.h"
+#include "common/textconsole.h"
 #include "awe/gfx.h"
-#include "awe/util.h"
 #include "awe/system_stub.h"
 
 namespace Awe {
diff --git a/engines/awe/module.mk b/engines/awe/module.mk
index eeabc223db8..a162af93d24 100644
--- a/engines/awe/module.mk
+++ b/engines/awe/module.mk
@@ -22,7 +22,6 @@ MODULE_OBJS = \
 	static_res.o \
 	system_stub.o \
 	unpack.o \
-	util.o \
 	video.o
 
 # This module can be built as a plugin
diff --git a/engines/awe/pak.cpp b/engines/awe/pak.cpp
index 76788f5e2e8..99369291325 100644
--- a/engines/awe/pak.cpp
+++ b/engines/awe/pak.cpp
@@ -20,7 +20,7 @@
  */
 
 #include "awe/pak.h"
-#include "awe/util.h"
+#include "awe/detection.h"
 
 namespace Awe {
 
diff --git a/engines/awe/resource.cpp b/engines/awe/resource.cpp
index f933195c1af..ed80d54078f 100644
--- a/engines/awe/resource.cpp
+++ b/engines/awe/resource.cpp
@@ -27,7 +27,6 @@
 #include "awe/resource_win31.h"
 #include "awe/resource_3do.h"
 #include "awe/unpack.h"
-#include "awe/util.h"
 #include "awe/video.h"
 
 namespace Awe {
diff --git a/engines/awe/resource_3do.cpp b/engines/awe/resource_3do.cpp
index 4c0f2ee987f..be2974a3a22 100644
--- a/engines/awe/resource_3do.cpp
+++ b/engines/awe/resource_3do.cpp
@@ -20,7 +20,6 @@
  */
 
 #include "awe/resource_3do.h"
-#include "awe/util.h"
 
 namespace Awe {
 
diff --git a/engines/awe/resource_nth.cpp b/engines/awe/resource_nth.cpp
index 5ff7271f8e0..ec0b7a2a648 100644
--- a/engines/awe/resource_nth.cpp
+++ b/engines/awe/resource_nth.cpp
@@ -22,7 +22,6 @@
 #include "common/fs.h"
 #include "awe/pak.h"
 #include "awe/resource_nth.h"
-#include "awe/util.h"
 #include "awe/script.h"
 #include "awe/awe.h"
 
diff --git a/engines/awe/resource_win31.cpp b/engines/awe/resource_win31.cpp
index b580a5d03d8..9090eacec31 100644
--- a/engines/awe/resource_win31.cpp
+++ b/engines/awe/resource_win31.cpp
@@ -20,7 +20,7 @@
  */
 
 #include "awe/resource_win31.h"
-#include "awe/util.h"
+#include "awe/detection.h"
 
 namespace Awe {
 
diff --git a/engines/awe/script.cpp b/engines/awe/script.cpp
index 53327a51b77..147a825fc86 100644
--- a/engines/awe/script.cpp
+++ b/engines/awe/script.cpp
@@ -26,7 +26,6 @@
 #include "awe/sfx_player.h"
 #include "awe/sound.h"
 #include "awe/system_stub.h"
-#include "awe/util.h"
 
 namespace Awe {
 
diff --git a/engines/awe/sfx_player.cpp b/engines/awe/sfx_player.cpp
index 3453e9906d1..b89ffa750ec 100644
--- a/engines/awe/sfx_player.cpp
+++ b/engines/awe/sfx_player.cpp
@@ -23,7 +23,6 @@
 #include "awe/resource.h"
 #include "awe/sound.h"
 #include "awe/system_stub.h"
-#include "awe/util.h"
 
 namespace Awe {
 
diff --git a/engines/awe/sound.cpp b/engines/awe/sound.cpp
index 39c9b9627b0..556099d609c 100644
--- a/engines/awe/sound.cpp
+++ b/engines/awe/sound.cpp
@@ -30,7 +30,6 @@
 #include "awe/aifc_player.h"
 #include "awe/sound.h"
 #include "awe/sfx_player.h"
-#include "awe/util.h"
 
 namespace Awe {
 
diff --git a/engines/awe/system_stub.cpp b/engines/awe/system_stub.cpp
index 9706541cd47..ca0047cbf78 100644
--- a/engines/awe/system_stub.cpp
+++ b/engines/awe/system_stub.cpp
@@ -27,7 +27,6 @@
 #include "awe/gfx.h"
 #include "awe/metaengine.h"
 #include "awe/system_stub.h"
-#include "awe/util.h"
 
 namespace Awe {
 
diff --git a/engines/awe/unpack.cpp b/engines/awe/unpack.cpp
index 2a19b6d4160..f9941a72851 100644
--- a/engines/awe/unpack.cpp
+++ b/engines/awe/unpack.cpp
@@ -19,8 +19,8 @@
  *
  */
 
+#include "common/textconsole.h"
 #include "awe/unpack.h"
-#include "awe/util.h"
 
 namespace Awe {
 
diff --git a/engines/awe/util.cpp b/engines/awe/util.cpp
deleted file mode 100644
index 3064177e770..00000000000
--- a/engines/awe/util.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "awe/util.h"
-
-namespace Awe {
-
-uint16 g_debugMask;
-
-void string_lower(char *p) {
-	for (; *p; ++p) {
-		if (*p >= 'A' && *p <= 'Z') {
-			*p += 'a' - 'A';
-		}
-	}
-}
-
-void string_upper(char *p) {
-	for (; *p; ++p) {
-		if (*p >= 'a' && *p <= 'z') {
-			*p += 'A' - 'a';
-		}
-	}
-}
-
-} // namespace Awe
diff --git a/engines/awe/util.h b/engines/awe/util.h
deleted file mode 100644
index 879bb6bbdd3..00000000000
--- a/engines/awe/util.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef AWE_UTIL_H
-#define AWE_UTIL_H
-
-#include "common/textconsole.h"
-#include "awe/intern.h"
-#include "awe/detection.h"
-
-namespace Awe {
-
-extern uint16 g_debugMask;
-
-extern void string_lower(char *p);
-extern void string_upper(char *p);
-
-} // namespace Awe
-
-#endif
diff --git a/engines/awe/video.cpp b/engines/awe/video.cpp
index 9b68b9fc56a..ae953d70fe4 100644
--- a/engines/awe/video.cpp
+++ b/engines/awe/video.cpp
@@ -26,7 +26,6 @@
 #include "awe/resource.h"
 #include "awe/resource_3do.h"
 #include "awe/system_stub.h"
-#include "awe/util.h"
 
 namespace Awe {
 


Commit: 1ee38274b4287378f222bdb160f12035b892bc81
    https://github.com/scummvm/scummvm/commit/1ee38274b4287378f222bdb160f12035b892bc81
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Fix formatting in resource_3do

Changed paths:
    engines/awe/resource_3do.cpp


diff --git a/engines/awe/resource_3do.cpp b/engines/awe/resource_3do.cpp
index be2974a3a22..f2579cf2a06 100644
--- a/engines/awe/resource_3do.cpp
+++ b/engines/awe/resource_3do.cpp
@@ -95,7 +95,7 @@ static void decodeCcb16(int ccbWidth, int ccbHeight, File *f, uint32 dataSize, u
 }
 
 static const uint8 _ccb_bppTable[8] = {
-		0, 1, 2, 4, 6, 8, 16, 0
+	0, 1, 2, 4, 6, 8, 16, 0
 };
 
 static uint16 *decodeShapeCcb(File *f, int dataSize, int *w, int *h) {


Commit: 01d1b3e63476e8203641ce291a039dcd1955c595
    https://github.com/scummvm/scummvm/commit/01d1b3e63476e8203641ce291a039dcd1955c595
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Add some stubs in engine.cpp

Changed paths:
    engines/awe/detection.h
    engines/awe/engine.cpp


diff --git a/engines/awe/detection.h b/engines/awe/detection.h
index 7b03ee7e79c..ce5c8fee926 100644
--- a/engines/awe/detection.h
+++ b/engines/awe/detection.h
@@ -44,7 +44,7 @@ enum DataType {
 	DT_20TH_EDITION,
 	DT_WIN31,
 	DT_3DO,
-	DT_ATARI_DEMO, // ST Action Issue44 Disk28
+	DT_ATARI_DEMO // ST Action Issue44 Disk28
 };
 
 struct AweGameDescription {
diff --git a/engines/awe/engine.cpp b/engines/awe/engine.cpp
index 73e182877b1..edd1ca139a2 100644
--- a/engines/awe/engine.cpp
+++ b/engines/awe/engine.cpp
@@ -211,9 +211,11 @@ void Engine::doEndCredits() {
 }
 
 void Engine::playCinepak(const char *name) {
+	warning("STUB: Engine::playCinepak()");
 }
 
 void Engine::scrollText(int a, int b, const char *text) {
+	warning("STUB: Engine::scrollText()");
 }
 
 void Engine::titlePage() {
@@ -249,9 +251,11 @@ void Engine::titlePage() {
 }
 
 void Engine::saveGameState(uint8 slot, const char *desc) {
+	warning("STUB: Engine::saveGameState()");
 }
 
 void Engine::loadGameState(uint8 slot) {
+	warning("STUB: Engine::loadGameState()");
 }
 
 } // namespace Awe


Commit: 1d8efad26912e1219a4507a7b9a7fd144fdd5f20
    https://github.com/scummvm/scummvm/commit/1d8efad26912e1219a4507a7b9a7fd144fdd5f20
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Add Potfiles

Changed paths:
  A engines/awe/POTFILES


diff --git a/engines/awe/POTFILES b/engines/awe/POTFILES
new file mode 100644
index 00000000000..6761df5774e
--- /dev/null
+++ b/engines/awe/POTFILES
@@ -0,0 +1 @@
+engines/awe//metaengine.cpp


Commit: 70796b68df38280c8eca5b7e327a20c9ced1eb78
    https://github.com/scummvm/scummvm/commit/70796b68df38280c8eca5b7e327a20c9ced1eb78
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Update debug channels

Changed paths:
    engines/awe/detection.h


diff --git a/engines/awe/detection.h b/engines/awe/detection.h
index ce5c8fee926..1cfe2e23aef 100644
--- a/engines/awe/detection.h
+++ b/engines/awe/detection.h
@@ -27,13 +27,13 @@
 namespace Awe {
 
 enum AweDebugChannels {
-	kDebugScript = 1 << 0,
-	kDebugBank = 1 << 1,
-	kDebugVideo = 1 << 2,
-	kDebugSound = 1 << 3,
-	kDebugInfo = 1 << 4,
-	kDebugPak = 1 << 5,
-	kDebugResource = 1 << 6
+	kDebugScript = 1,
+	kDebugBank,
+	kDebugVideo,
+	kDebugSound,
+	kDebugInfo,
+	kDebugPak,
+	kDebugResource
 };
 
 enum DataType {


Commit: 5f26c2f644b0bb31c59538c5aca3330c97a61cfb
    https://github.com/scummvm/scummvm/commit/5f26c2f644b0bb31c59538c5aca3330c97a61cfb
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-05-05T17:04:52+08:00

Commit Message:
AWE: Remove some includes in detection.cpp

Changed paths:
    engines/awe/detection.cpp


diff --git a/engines/awe/detection.cpp b/engines/awe/detection.cpp
index 1e6cf77a6c4..65a1fe7e99b 100644
--- a/engines/awe/detection.cpp
+++ b/engines/awe/detection.cpp
@@ -22,9 +22,6 @@
 #include "base/plugins.h"
 #include "common/config-manager.h"
 #include "common/file.h"
-#include "common/md5.h"
-#include "common/str-array.h"
-#include "common/translation.h"
 #include "common/util.h"
 #include "awe/detection.h"
 #include "awe/detection_tables.h"




More information about the Scummvm-git-logs mailing list