Repository navigation
Expand file tree
/
Copy pathrun.ps1
More file actions
128 lines (117 loc) · 4.1 KB
/
Copy pathrun.ps1
File metadata and controls
128 lines (117 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
param(
[switch]$MouseAim,
[switch]$VerticalLook,
[switch]$ModernControls,
[switch]$Widescreen,
[switch]$GeometryCorrection,
[switch]$PerspectiveTextures
)
$ErrorActionPreference = 'Stop'
$Root = Split-Path -Parent $MyInvocation.MyCommand.Path
$Disc = Join-Path $Root 'input/Disruptor (USA).cue'
$BuildName = if ($env:DISRUPTOR_BUILD_DIRECTORY) {
$env:DISRUPTOR_BUILD_DIRECTORY
} else {
'build'
}
$Candidates = @(
(Join-Path $Root "$BuildName/DisruptorRecompiled.exe"),
(Join-Path $Root "$BuildName/Release/DisruptorRecompiled.exe")
)
$Runtime = $Candidates | Where-Object { Test-Path $_ } | Select-Object -First 1
if (!$Runtime) { throw "DisruptorRecompiled.exe was not found. Run .\build.ps1 first." }
if (!(Test-Path $Disc)) {
throw "The full Disruptor BIN/CUE is required. Expected: input/Disruptor (USA).cue"
}
if ($MouseAim -or $VerticalLook -or $ModernControls) {
if (!(Test-Path (Join-Path $Root 'mouse-aim.ini'))) {
throw 'mouse-aim.ini is missing.'
}
Write-Host 'Mouse camera input enabled: middle-click in gameplay to capture; middle-click or Esc releases.'
}
$RuntimeDirectory = Split-Path -Parent $Runtime
$KeybindPresetName = if ($ModernControls) {
'config/keybinds-modern.ini'
} else {
'config/keybinds-original.ini'
}
$KeybindPreset = Join-Path $Root $KeybindPresetName
Copy-Item -LiteralPath $KeybindPreset -Destination (Join-Path $RuntimeDirectory 'keybinds.ini') -Force
$GameConfig = if ($Widescreen) { 'game-widescreen.toml' } else { 'game.toml' }
if ($Widescreen) {
Write-Host 'Experimental native-wide 16:9 enabled; menus and movies remain 4:3.'
}
if ($ModernControls) {
Write-Host 'Modern controls enabled: WASD, LMB fire, RMB psionic, Space jump, E use.'
}
if ($VerticalLook) {
Write-Host 'Experimental vertical camera and weapon aim enabled.'
}
if ($GeometryCorrection -or $PerspectiveTextures) {
Write-Host 'Exact-provenance presentation geometry enabled.'
}
if ($PerspectiveTextures) {
Write-Host 'Perspective textures enabled for exact world polygons; canonical VRAM and UI remain affine.'
}
Write-Host 'OpenGL dev-menu builds: press the backquote (`) key; Escape closes it.'
$EnvironmentOverrides = @{
PSX_DISRUPTOR_CONTROL_PROBE = '0'
}
if ($Widescreen) {
$EnvironmentOverrides['PSX_VIDEO_ASPECT'] = '16:9'
}
if ($ModernControls) {
$EnvironmentOverrides['PSX_DISRUPTOR_MODERN_CONTROLS'] = '1'
}
if ($VerticalLook) {
$EnvironmentOverrides['PSX_DISRUPTOR_VERTICAL_LOOK'] = '1'
}
if ($MouseAim -or $ModernControls) {
$EnvironmentOverrides['PSX_DISRUPTOR_MOUSE_AIM'] = '1'
}
if ($MouseAim -or $VerticalLook -or $ModernControls) {
$EnvironmentOverrides['PSX_FPS_TELEMETRY'] = '0'
}
if ($GeometryCorrection -or $PerspectiveTextures) {
$EnvironmentOverrides['PSX_GEOMETRY_CORRECTION'] = '1'
}
if ($PerspectiveTextures) {
$EnvironmentOverrides['PSX_TEXTURE_CORRECTION'] = '1'
}
$EnvironmentVariableNames = @($EnvironmentOverrides.Keys)
$SavedEnvironment = @{}
foreach ($Name in $EnvironmentVariableNames) {
$Entry = Get-Item -LiteralPath "Env:$Name" -ErrorAction SilentlyContinue
$SavedEnvironment[$Name] = @{
Exists = $null -ne $Entry
Value = if ($null -ne $Entry) { $Entry.Value } else { $null }
}
}
$LocationPushed = $false
$RuntimeExitCode = 1
try {
# Only explicitly requested launch options override persisted settings.
# These process-environment changes are restored after the child exits.
foreach ($Name in $EnvironmentVariableNames) {
[Environment]::SetEnvironmentVariable($Name, $EnvironmentOverrides[$Name], 'Process')
}
Push-Location $Root
$LocationPushed = $true
& $Runtime --game $GameConfig --disc $Disc
$RuntimeExitCode = $LASTEXITCODE
}
finally {
if ($LocationPushed) {
Pop-Location
}
foreach ($Name in $EnvironmentVariableNames) {
$SavedValue = $SavedEnvironment[$Name]
if ($SavedValue.Exists) {
[Environment]::SetEnvironmentVariable($Name, $SavedValue.Value, 'Process')
}
else {
[Environment]::SetEnvironmentVariable($Name, $null, 'Process')
}
}
}
exit $RuntimeExitCode