Skip to content

Commit 6ceae51

Browse files
Proton support, compatibility and rendering improvements
Fixed black screens under Proton and various Windows configurations by using a separate overlay window. Fixed video playback by adding 32-bit blitting support and removing the previous workaround. Improved OpenGL renderer and software renderer performance. Allow custom width/height settings for DirectDraw. Added experimental ASLR/DEP support. Added a safeguard against executing unimplemented functions. Added minimal support for the Technical Demo.
2 parents 3a1c2e4 + c6f305f commit 6ceae51

51 files changed

Lines changed: 2065 additions & 929 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/action-development.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
jobs:
66
build:
77
name: Build SubTitans
8-
runs-on: windows-2019
8+
runs-on: windows-2022
99
steps:
1010
- name: Create Timestamp
1111
id: create_timestamp
@@ -23,15 +23,16 @@ jobs:
2323

2424
- name: Compile
2525
shell: cmd
26-
run: msbuild SubTitans.sln -p:Configuration=Release -p:Platform=x86
26+
run: msbuild SubTitans.sln -p:Configuration=Release -p:Platform=x86 -p:PlatformToolset=v142
2727

2828
- name: Create Zip
2929
shell: powershell
3030
run: |
3131
Rename-Item -Path README.md -NewName readme.txt
32+
Rename-Item -Path PROTON-v1_0-v1_1.md -NewName PROTON-v1_0-v1_1.txt
3233
Rename-Item -Path LICENSE -NewName license.txt
3334
$compress = @{
34-
Path = "Release/*.dll", "readme.txt", "license.txt", "Release/*.ini"
35+
Path = "Release/*.dll", "readme.txt", "PROTON-v1_0-v1_1.txt", "license.txt", "Release/*.ini"
3536
DestinationPath = "SubTitans.zip"
3637
Force = $True
3738
}

.github/workflows/action-release.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
jobs:
66
build:
77
name: Build SubTitans
8-
runs-on: windows-2019
8+
runs-on: windows-2022
99
steps:
1010
- name: Create Timestamp
1111
id: create_timestamp
@@ -21,15 +21,16 @@ jobs:
2121

2222
- name: Compile
2323
shell: cmd
24-
run: msbuild SubTitans.sln -p:Configuration=Release -p:Platform=x86
24+
run: msbuild SubTitans.sln -p:Configuration=Release -p:Platform=x86 -p:PlatformToolset=v142
2525

2626
- name: Create Zip
2727
shell: powershell
2828
run: |
2929
Rename-Item -Path README.md -NewName readme.txt
30+
Rename-Item -Path PROTON-v1_0-v1_1.md -NewName PROTON-v1_0-v1_1.txt
3031
Rename-Item -Path LICENSE -NewName license.txt
3132
$compress = @{
32-
Path = "Release/*.dll", "readme.txt", "license.txt", "Release/*.ini"
33+
Path = "Release/*.dll", "readme.txt", "PROTON-v1_0-v1_1.txt", "license.txt", "Release/*.ini"
3334
DestinationPath = "SubTitans.zip"
3435
Force = $True
3536
}

Debug/subtitans.ini

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ MovieHeap=true
2626
; Replaces the default FPS limiter with a better implementation.
2727
ImprovedFPSLimiter=true
2828
; Improves the smoothness of scrolling in-game.
29-
SmoothScroll=true
29+
SmoothScroll=true
30+
31+
[SECURITY]
32+
; Stop the execution of the game when a path of SubTitans has been hit that is not implemented.
33+
; Setting this flag to false could result in undefined behavior, advised is to keep this as-is.
34+
PreventExecutingUnimplemented=true
35+
; EXPERIMENTAL! Patches the executable to enable ASLR and DEP, these are modern security mitigations.
36+
; Could crash the game as it was never designed to run with ASLR or DEP enabled.
37+
EnableASLRAndDEP=false

PROTON-v1_0-v1_1.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Linux & Proton (Steam) -> Upgrade from v1.0 to v1.1
2+
If you are running the game on Linux via Steam/Proton, the upgrade to v1.1 requires a workaround.
3+
4+
### How to Run the Patch via Steam/Proton
5+
Because the patcher needs to run within your game's specific Wine context, use this renaming workaround to launch it through Steam:
6+
7+
0. **Download:** Ignore the guide and just download the patch file from https://steamcommunity.com/sharedfiles/filedetails/?id=2129291420
8+
1. **Register fix:** Before attempting to patch, **launch the game at least once** with `subtitans.dll` already placed in your game folder. This will fix the version registry key.
9+
2. **Create a Backup:** Navigate to your game folder and find `STEditor.exe`. Create a backup copy of it.
10+
3. **Rename the Patcher:** Copy the patch file `st1_mj0to0_1_usa.exe` to the game folder and rename it to `STEditor.exe`.
11+
4. **Launch the Patcher:** Launch the game and select the **"Game Editor"** option in Steam. This tricks Proton into executing the patcher with the correct context.
12+
5. **Restore Original Files:** Once patching is finished you must delete the patch file `STEditor.exe`. Don't forget to restore your backup copy of `STEditor.exe`

README.md

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,67 @@
1-
# SubTitans
2-
Unofficial Submarine Titans patch \
3-
![GitHub all releases](https://img.shields.io/github/downloads/UnknownException/SubTitans/total)
1+
# SubTitans ![GitHub all releases](https://img.shields.io/github/downloads/UnknownException/SubTitans/total)
2+
## Unofficial patch for Submarine Titans
43

5-
**Requirements**
6-
* Windows 7, Windows 10, Windows 11 or Wine (+ Ubuntu)
7-
* Supports Steam/Retail v1.0, Retail v1.1 and GOG v1.1
4+
### Requirements
5+
* Windows 11 or a Linux distribution with Wine or Proton
6+
* Retail v1.1 or GOG v1.1
87

9-
**Features**
8+
> Support for v1.0, Demo, and the Technology Demo is limited.
9+
> These versions are not actively tested, and some features may be missing.
10+
11+
### Instructions
12+
1. Copy & paste d3drm.dll, subtitans.dll and subtitans.ini into your Submarine Titans folder.
13+
2. Open STConfig.exe and select 1280x1024.
14+
3. Run the game.
15+
16+
> **For Steam users**: At least start the game once before applying this patch. steam_installscript.vdf will not be applied if you skip this step.
17+
18+
### Features
1019
* Support for any resolution in-game (tested up to 3840x2160)
1120
* OpenGL and Software rendering replacement for DirectDraw to improve compatibility and performance
1221
* DInput replacement
1322
* Improved scrolling
1423
* Added mission skip cheat (Retail/GOG v1.1; workaround for progression bugs)
1524
* Fixes various internal errors
1625
* Fixes alt-tab crashes
26+
* Fixes video issues
1727
* Support for display scaling
18-
* Windows 7 palette color fix
28+
* Palette color fix
1929

20-
**Instructions**
21-
1. Copy & paste d3drm.dll, subtitans.dll and subtitans.ini into your Submarine Titans folder.
22-
2. Open STConfig.exe and select 1280x1024.
23-
3. Run the game.
24-
25-
**Q&A** \
26-
Q: How do I use the mission skip cheat? \
27-
A: Load the mission you want to skip and write 'orbiton' without quotes in the chatbox. \
28-
Exit to the menu and select a random campaign to start the next mission. \
29-
\
30-
Q: Help, I'm getting MSVCP140.dll errors! \
31-
A: Install vc_redist.x86.exe ( https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads ). \
32-
\
33-
Q: How to update Submarine Titans to version 1.1? \
34-
A: https://steamcommunity.com/sharedfiles/filedetails/?id=2129291420 \
35-
\
36-
Q: I've got a problem in-game with my mouse and/or keyboard. \
37-
A: Open SubTitans.ini and set CustomInput to false, this should revert the input handling changes. \
38-
\
39-
Q: I've got a problem with the OpenGL/Software renderer and want to use a custom DDraw wrapper. \
40-
A: Open SubTitans.ini and set Renderer to 1. \
41-
\
42-
Q: The Submarine Titans demo crashes with or without this patch. \
43-
A: The support for the demo version of Submarine Titans is bare minimum. Please don't report issues regarding the demo, it will be ignored.
44-
45-
**Known bugs**
30+
### Known bugs
4631
* Regions next to the in-game command panel aren't selectable/clickable.
4732

48-
**Uninstall**
49-
* Deleting SubTitans.dll will disable the in-game patches.
33+
## Question and Answers
34+
### How to update Submarine Titans to version 1.1?
35+
> Window: https://steamcommunity.com/sharedfiles/filedetails/?id=2129291420 \
36+
> Linux: See [PROTON-v1_0-v_1_1.md](PROTON-v1_0-v1_1.md)
37+
38+
### Why am I getting MSVCP140.dll errors?
39+
> You're missing some libraries on your computer, you'll need to install the Visual C++ redistributable provided by Microsoft. \
40+
> vc_redist.x86.exe ( https://aka.ms/vc14/vc_redist.x86.exe )
41+
42+
### I've got a problem in-game with my mouse and/or keyboard.
43+
> Open SubTitans.ini and set CustomInput to *false*. \
44+
> This will turn off the DInput reimplementation.
45+
46+
### How can I use a custom or GOG's DDraw wrapper?
47+
> Open SubTitans.ini and set Renderer to **1**.
48+
>
49+
> Only the OpenGL renderer and Software renderer are tested while developing this patch. \
50+
> Custom wrappers might introduce new issues, please validate if issues you observe also occur under the OpenGL/Software renderer.
51+
52+
### The Submarine Titans (technology) demo crashes with or without this patch.
53+
> The support for the demo versions of Submarine Titans is bare minimum. Please don't report issues regarding the demo, it will be ignored.
54+
55+
### Why would I want to enable the experimental ASLR/DEP option?
56+
> Many (older) applications have inherent vulnerabilities, and exposing them over the internet (such as in multiplayer modes) increases the attack vector by a huge margin.
57+
>
58+
> By enabling **ASLR (Address Space Layout Randomization)** and **DEP (Data Execution Prevention)**, you tighten security by making the application's memory space less predictable. While this doesn't patch the vulnerabilities within the game itself, it makes them significantly harder for an attacker to successfully exploit
59+
60+
### How do I use the mission skip cheat?
61+
> Load the mission you want to skip and write 'orbiton' without quotes in the chatbox. \
62+
> Exit to the menu and select a random campaign to start the next mission. \
63+
64+
### How do I uninstall the patch?
65+
> Deleting SubTitans.dll will disable the in-game patches.
66+
>
67+
> Do **NOT** delete d3drm.dll, the game will stop working without it.

Release/subtitans.ini

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ MovieHeap=true
2626
; Replaces the default FPS limiter with a better implementation.
2727
ImprovedFPSLimiter=true
2828
; Improves the smoothness of scrolling in-game.
29-
SmoothScroll=true
29+
SmoothScroll=true
30+
31+
[SECURITY]
32+
; Stop the execution of the game when a path of SubTitans has been hit that is not implemented.
33+
; Setting this flag to false could result in undefined behavior, advised is to keep this as-is.
34+
PreventExecutingUnimplemented=true
35+
; EXPERIMENTAL! Patches the executable to enable ASLR and DEP, these are modern security mitigations.
36+
; Could crash the game as it was never designed to run with ASLR or DEP enabled.
37+
EnableASLRAndDEP=false

d3drm/d3drm.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
#include "../shared/file.h"
77
#include "injector.h"
88

9-
#ifdef _DEBUG
10-
#pragma comment(lib, "../Debug/shared.lib")
11-
#else
12-
#pragma comment(lib, "../Release/shared.lib")
13-
#endif
14-
159
#pragma comment(linker, "/EXPORT:D3DRMVectorModulus=_D3DRMVectorModulus@4")
1610
extern "C" float __stdcall D3DRMVectorModulus(D3DVector3* vector)
1711
{
@@ -26,14 +20,17 @@ uint32_t GetSubTitansVersion()
2620
WCHAR applicationPath[MAX_PATH];
2721
GetModuleFileName(NULL, applicationPath, MAX_PATH);
2822

29-
uint32_t checkSum = File::CalculateChecksum(applicationPath);
23+
uint32_t checkSum = File::CalculateChecksumW(applicationPath);
3024

3125
switch (checkSum)
3226
{
33-
case Shared::ST_GAMEVERSION_RETAIL_UNPATCHED:
34-
case Shared::ST_GAMEVERSION_RETAIL_PATCHED:
35-
case Shared::ST_GAMEVERSION_GOG_MODIFIED:
36-
case Shared::ST_GAMEVERSION_DEMO:
27+
case Shared::ST_GAMEVERSION_0_0_6:
28+
case Shared::ST_GAMEVERSION_0_1_6:
29+
case Shared::ST_GAMEVERSION_1_0_0:
30+
case Shared::ST_GAMEVERSION_1_1_0:
31+
case Shared::ST_GAMEVERSION_1_1_0_ASLR_DEP:
32+
case Shared::ST_GAMEVERSION_1_1_0_GOG:
33+
case Shared::ST_GAMEVERSION_1_1_0_GOG_ASLR_DEP:
3734
return checkSum;
3835
default:
3936
return 0;

d3drm/d3drm.vcxproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@
8484
<ClCompile Include="d3drm.cpp" />
8585
<ClCompile Include="injector.cpp" />
8686
</ItemGroup>
87+
<ItemGroup>
88+
<ProjectReference Include="..\shared\shared.vcxproj">
89+
<Project>{5f2c7921-4b31-4712-8722-c99eff304ec4}</Project>
90+
</ProjectReference>
91+
</ItemGroup>
8792
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
8893
<ImportGroup Label="ExtensionTargets">
8994
</ImportGroup>

d3drm/injector.cpp

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,27 @@ namespace Injector {
125125
GameVersion = gameVersion;
126126
switch (GameVersion)
127127
{
128-
case Shared::ST_GAMEVERSION_RETAIL_UNPATCHED:
128+
case Shared::ST_GAMEVERSION_0_0_6:
129+
{
130+
LoadModule_JmpFrom = 0x005CE3CE;
131+
LoadModule_JmpBack = LoadModule_JmpFrom + LoadModule_DetourSize;
132+
133+
UnloadModule_JmpFrom = 0x005CE3D3;
134+
UnloadModule_JmpBack = UnloadModule_JmpFrom + UnloadModule_DetourSize;
135+
136+
StartApplicationAddress = 0x00401ACD;
137+
} break;
138+
case Shared::ST_GAMEVERSION_0_1_6:
139+
{
140+
LoadModule_JmpFrom = 0x0071A25E;
141+
LoadModule_JmpBack = LoadModule_JmpFrom + LoadModule_DetourSize;
142+
143+
UnloadModule_JmpFrom = 0x0071A263;
144+
UnloadModule_JmpBack = UnloadModule_JmpFrom + UnloadModule_DetourSize;
145+
146+
StartApplicationAddress = 0x00401FF0;
147+
} break;
148+
case Shared::ST_GAMEVERSION_1_0_0:
129149
{
130150
LoadModule_JmpFrom = 0x00734B6E;
131151
LoadModule_JmpBack = LoadModule_JmpFrom + LoadModule_DetourSize;
@@ -135,8 +155,8 @@ namespace Injector {
135155

136156
StartApplicationAddress = 0x00401FEB;
137157
} break;
138-
case Shared::ST_GAMEVERSION_RETAIL_PATCHED:
139-
case Shared::ST_GAMEVERSION_GOG_MODIFIED:
158+
case Shared::ST_GAMEVERSION_1_1_0:
159+
case Shared::ST_GAMEVERSION_1_1_0_GOG:
140160
{
141161
LoadModule_JmpFrom = 0x007337FE;
142162
LoadModule_JmpBack = LoadModule_JmpFrom + LoadModule_DetourSize;
@@ -146,15 +166,20 @@ namespace Injector {
146166

147167
StartApplicationAddress = 0x00401FF5;
148168
} break;
149-
case Shared::ST_GAMEVERSION_DEMO:
169+
case Shared::ST_GAMEVERSION_1_1_0_ASLR_DEP:
170+
case Shared::ST_GAMEVERSION_1_1_0_GOG_ASLR_DEP:
150171
{
151-
LoadModule_JmpFrom = 0x0071A25E;
172+
const unsigned int originalBaseAddress = Shared::IMAGE_BASE;
173+
const unsigned int baseAddress = (unsigned int)GetModuleHandle(NULL);
174+
175+
LoadModule_JmpFrom = 0x007337FE - originalBaseAddress + baseAddress;
152176
LoadModule_JmpBack = LoadModule_JmpFrom + LoadModule_DetourSize;
153177

154-
UnloadModule_JmpFrom = 0x0071A263;
178+
UnloadModule_JmpFrom = 0x00733803 - originalBaseAddress + baseAddress;
155179
UnloadModule_JmpBack = UnloadModule_JmpFrom + UnloadModule_DetourSize;
156180

157-
StartApplicationAddress = 0x00401FF0;
181+
StartApplicationAddress = 0x00401FF5 - originalBaseAddress + baseAddress;
182+
158183
} break;
159184
default:
160185
return false;

game/subtitans.ini

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ MovieHeap=true
2626
; Replaces the default FPS limiter with a better implementation.
2727
ImprovedFPSLimiter=true
2828
; Improves the smoothness of scrolling in-game.
29-
SmoothScroll=true
29+
SmoothScroll=true
30+
31+
[SECURITY]
32+
; Stop the execution of the game when a path of SubTitans has been hit that is not implemented.
33+
; Setting this flag to false could result in undefined behavior, advised is to keep this as-is.
34+
PreventExecutingUnimplemented=true
35+
; EXPERIMENTAL! Patches the executable to enable ASLR and DEP, these are modern security mitigations.
36+
; Could crash the game as it was never designed to run with ASLR or DEP enabled.
37+
EnableASLRAndDEP=false

0 commit comments

Comments
 (0)