-
Notifications
You must be signed in to change notification settings - Fork 0
/
BRS-Extract.ps1
265 lines (227 loc) · 8.01 KB
/
BRS-Extract.ps1
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# Copyright 2024 - Brad D
# See LICENSE for copyright information.
# Please include this header and that license for any derivative works.
# NOTE: Only the documentation, tools and anything that's not directly a part of the game's data fall under this copyright. I don't claim any ownership of the game or any of its assets
$cwd = (Get-Item . | % { $_.FullName })
$game_dir = "Game"
$tools_dir = "Tools"
$docs_dir = "Docs"
$extraction_dir = "Extraction"
$scripts_dir = "Scripts"
$bones_script = $scripts_dir + "\BRS-Dig-For-Bones.bms"
$bones_script = Get-Item -Path $bones_script | % { $_.FullName }
$extraction_script = $scripts_dir + "\BRS-Extract.bms"
$extraction_script = Get-Item -Path $extraction_script | % { $_.FullName }
$archive_types += @("vol", "zzz", "gz")
$sleep = 3
Write-Output "Checking If Required Extraction Tools Are Available"
if (!(Test-Path -Path $tools_dir -PathType Container)) {
New-Item -Path . -Name $tools_dir -ItemType Directory | Out-Null
}
$quickbms_url = 'https://aluigi.altervista.org/papers/quickbms.zip'
$quickbms_zip = $(Split-Path -Path $quickbms_url -Leaf)
$quickbms_command = $tools_dir + "\quickbms.exe"
Write-Output "Checking QuickBMS"
if ((Get-Command $quickbms_command -ErrorAction SilentlyContinue) -eq $null)
{
$download_qbms = 1
}
if ($download_qbms -eq '1' -Or $download_vgms -eq '1') {
$input = Read-Host 'Can I download the missing tools? (y/N)'
if ($input -eq 'y') {
Write-Output "Preparing Tools"
$output = Get-Item -Path $tools_dir | % { $_.FullName }
if ($download_qbms -eq '1') {
Write-Output "Downloading QuickBMS"
Invoke-WebRequest -Uri $quickbms_url -OutFile $output\$quickbms_zip
Write-Output "Preparing QuickBMS"
Expand-Archive -Path $output\$quickbms_zip -DestinationPath $output
Remove-Item -Path $output\$quickbms_zip
}
if ($download_vgms -eq '1') {
Write-Output "Downloading VgmStream"
Invoke-WebRequest -Uri $vgmstream_url -OutFile $output\$vgmstream_zip
Write-Output "Preparing VgmStream"
Expand-Archive -Path $output\$vgmstream_zip -DestinationPath $output
Remove-Item -Path $output\$vgmstream_zip
}
}
else {
Write-Output "Please download QuickBMS and place it inside of the Tools directory; then run this script again"
exit
}
}
$quickbms_command = Get-Item -Path $quickbms_command | % { $_.FullName }
Start-Sleep $sleep
Function Delete {
Write-Output "Removing extracted files. Please wait"
Start-Sleep $sleep
Remove-Item $extraction_dir -Force -Recurse
}
Function Clean {
Write-Output "Cleaning up. Please wait"
Start-Sleep $sleep
Get-ChildItem -Path $extraction_dir -Force -Recurse -Directory |
Sort-Object -Property FullName -Descending |
Where-Object { $($_ | Get-ChildItem -Force | Select-Object -First 1).Count -eq 0 } |
Remove-Item
foreach ($item in (Get-ChildItem -Path $extraction_dir -Force -Recurse | % { $_.FullName })) {
if ($item -like "*TEMP*") {
Remove-Item $Item -Force
}
}
}
Function Extract_Internals {
Write-Output "Extracting embedded archives. Please wait"
Start-Sleep $sleep
foreach ($item in (Get-ChildItem -Path $extraction_dir -Force -Recurse | % { $_.FullName })) {
$ext = (Split-Path -Path $item -Leaf).Split(".")[1]
$dir = Split-Path -Path $item -Parent
foreach ($arc in $archive_types) {
if (($ext -eq $arc) -And (($dir -like "*SYSTEM*") -Or ($dir -like "*TITLE*") -Or ($dir -like "*IF*"))) {
cd $dir
& $quickbms_command -Y -d $extraction_script $item
cd $cwd
}
}
}
}
Function Extract_Field {
Write-Output "Extracting the Field models"
Start-Sleep $sleep
$field_dir = $game_dir + "\FLD"
foreach ($item in (Get-ChildItem -Path $field_dir -Force -Recurse | % { $_.FullName })) {
$dir = $item.replace(($game_dir + "\"), ($extraction_dir + "\"))
& $quickbms_command -Y -d $extraction_script $item $dir
}
}
Function Extract_Battle {
Write-Output "Extracting the Battle models"
Start-Sleep $sleep
$btl_dir = $game_dir + "\BTL"
foreach ($item in (Get-ChildItem -Path $btl_dir -Force -Recurse | % { $_.FullName })) {
$dir = $item.replace(($game_dir + "\"), ($extraction_dir + "\"))
& $quickbms_command -Y -d $extraction_script $item $dir
}
}
Function Extract_Gallery {
Write-Output "Extracting the Gallery files"
Start-Sleep $sleep
$gallery_dir = $game_dir + "\GALLERY"
foreach ($item in (Get-ChildItem -Path $gallery_dir -Force -Recurse | % { $_.FullName })) {
$dir = $item.replace(($game_dir + "\"), ($extraction_dir + "\"))
& $quickbms_command -Y -d $extraction_script $item $dir
}
}
Function Extract_Interface {
Write-Output "Extracting the Interface files"
Start-Sleep $sleep
$if_dir = $game_dir + "\IF"
foreach ($item in (Get-ChildItem -Path $if_dir -Force -Recurse | % { $_.FullName })) {
$dir = $item.replace(($game_dir + "\"), ($extraction_dir + "\"))
& $quickbms_command -Y -d $extraction_script $item $dir
}
Extract_Internals
}
Function Extract_MiniGames {
Write-Output "Extracting the Mini-Games"
Start-Sleep $sleep
$mg_dir = $game_dir + "\Mini_Game"
foreach ($item in (Get-ChildItem -Path $mg_dir -Force -Recurse | % { $_.FullName })) {
$dir = $item.replace(($game_dir + "\"), ($extraction_dir + "\"))
& $quickbms_command -Y -d $extraction_script $item $dir
}
}
Function Extract_MemoryCard {
Write-Output "Extracting the Memory Card Volume"
Start-Sleep $sleep
$item = $game_dir + "\PSP_GAME\USRDIR\GAMEDATA\MC.VOL"
$item = Get-Item -Path $item | % { $_.FullName }
$dir = $item.replace(($game_dir + "\"), ($extraction_dir + "\"))
$dir = Split-Path $dir -Parent
& $quickbms_command -Y -d $extraction_script $item $dir
}
Function Extract_System {
Write-Output "Extracting the System Volume"
Start-Sleep $sleep
$item = $game_dir + "\PSP_GAME\USRDIR\GAMEDATA\SYSTEM.VOL"
$item = Get-Item -Path $item | % { $_.FullName }
$dir = $item.replace(($game_dir + "\"), ($extraction_dir + "\"))
$dir = Split-Path $dir -Parent
& $quickbms_command -Y -d $extraction_script $item $dir
Extract_Internals
}
Function Extract_Title {
Write-Output "Extracting the Title Volume"
Start-Sleep $sleep
$item = $game_dir + "\PSP_GAME\USRDIR\GAMEDATA\TITLE.VOL"
$item = Get-Item -Path $item | % { $_.FullName }
$dir = $item.replace(($game_dir + "\"), ($extraction_dir + "\"))
$dir = Split-Path $dir -Parent
& $quickbms_command -Y -d $extraction_script $item $dir
Extract_Internals
}
Function Dig_For_Bones {
$model_dir = $extraction_dir + "\PSP_GAME\USRDIR\GAMEDATA\FLD\FCHR\"
$model_dir = Get-Item -Path $model_dir | % { $_.FullName }
foreach ($item in (Get-ChildItem -Path $model_dir -Force -Recurse -File)) {
$doc_item = $docs_dir + "\Technical\Models\Field\" + (Split-Path $item -Leaf).Split(".")[0] + ".MD"
& $quickbms_command -Y $bones_script $item > $doc_item
}
}
Function Extract_All {
Extract_Field
Extract_Battle
Extract_Gallery
Extract_Interface
Extract_MiniGames
Extract_MemoryCard
Extract_System
Extract_Title
}
$Continue = 1
Function Get_User_Input {
Write-Output "What would you like to do today?"
Write-Output "1) Extract the Field models"
Write-Output "2) Extract the Battle models"
Write-Output "3) Extract the Gallery files"
Write-Output "4) Extract the Interface files"
Write-Output "5) Extract the Mini-Game files"
Write-Output "6) Extract the Memory Card Volume"
Write-Output "7) Extract the System Volume"
Write-Output "8) Extract the Title Volume"
Write-Output "a) Extract the important things"
Write-Output "b) Dig for Bones"
Write-Output "q) Quit the program"
Write-Output "d) Remove extracted files"
$input = Read-Host "Type value and press enter"
if ($input -eq 'q') {
break
}
if ($input -eq 'a') {
Extract_All
}
if ($input -eq 'b') {
Dig_For_Bones
}
if ($input -eq 'd') {
Delete
}
switch ($input) {
1 { Extract_Field }
2 { Extract_Battle }
3 { Extract_Gallery }
4 { Extract_Interface }
5 { Extract_MiniGames }
6 { Extract_MemoryCard }
7 { Extract_System }
8 { Extract_Title }
default {}
}
}
Do {
Get_User_Input
} While ($Continue -eq '1')
Clean
Write-Output "Have a wonderful day! Happy modding, digging, and BRSing!!! :D"
#Write-Output "Models, Audio and other extracted assets can be found in the Assets folder"