Skip to content

Commit

Permalink
Assets: Milestone 2 Update - 3D Rendering Work
Browse files Browse the repository at this point in the history
  • Loading branch information
thearchivalone committed Nov 13, 2024
1 parent af41cd0 commit 197e991
Show file tree
Hide file tree
Showing 9 changed files with 358 additions and 249 deletions.
252 changes: 154 additions & 98 deletions BRS-Extract.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ $vgmstream_command = Get-Item -Path $vgmstream_command | % { $_.FullName }
$extraction_script = "Scripts\BRS-Extract.bms"
$extraction_script = Get-Item -Path $extraction_script | % { $_.FullName }

$archive_types += @("vol", "bin", "zzz", "gz", "efp", "lpk", "efc")
$archive_types += @("vol", "zzz", "gz")

$sleep = 2
$sleep = 3

Write-Output "Checking If Required Extraction Tools Are Available"

Expand All @@ -42,12 +42,6 @@ if ((Get-Command $quickbms_command -ErrorAction SilentlyContinue) -eq $null)
$download_qbms = 1
}

Write-Output "Checking VgmStream"
if ((Get-Command $vgmstream_command -ErrorAction SilentlyContinue) -eq $null)
{
$download_vgms = 1
}

if ($download_qbms -eq '1' -Or $download_vgms -eq '1') {
$input = Read-Host 'Can I download the missing tools? (y/N)'

Expand All @@ -70,129 +64,191 @@ if ($download_qbms -eq '1' -Or $download_vgms -eq '1') {
}
}
else {
Write-Output "Please download QuickBMS and VgmStream and place them inside of the Tools directory; then run this script again"
Write-Output "Please download QuickBMS and place it inside of the Tools directory; then run this script again"
exit
}
}

Start-Sleep $sleep

Write-Output "Extracting and decrypting game archives. This process can take awhile"
Function Delete {
Write-Output "Removing extracted files. Please wait"
Start-Sleep $sleep
Remove-Item $extraction_dir -Force -Recurse
}

foreach ($item in (Get-ChildItem -Path $game_dir -Force -Recurse | % { $_.FullName })) {
$ext = (Split-Path -Path $item -Leaf).Split(".")[1]
$dir = $item.replace(($game_dir + "\"), ($extraction_dir + "\"))
foreach ($arc in $archive_types) {
if ($ext -eq $arc) {
if (!($item -like '*ITM*ZZZ') -And !($dir -like '*INSDIR*') -And !$($dir -like '*SYSDIR*') -And !($item -like '*UMD*')) {
& $quickbms_command -Y $extraction_script $item $dir
}
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
}
}
# Copy the sound folder over so they get converted
if (($item -like '*SOUND*') -And ($ext -eq 'at3')) {
$sound_dir = $extraction_dir + "\PSP_GAME\USRDIR\GAMEDATA\SOUND"
New-Item -Path $sound_dir -Force -ItemType Directory | Out-null
Copy-Item -Path $item -Destination $sound_dir
}
}

Start-Sleep $sleep

Write-Output "Recursively extracting archives"

Function Extract-Internals {
(Get-ChildItem -Path . -Force -Recurse -File | % { $_.FullName } ) | ForEach-Object -Parallel {
$file = Split-Path $_ -Leaf
$dir = Split-Path $_ -Parent
$extract = $file + '_extract'
$ext = (Split-Path -Path $file -Leaf).Split(".")[1]
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)) {
& $quickbms_command -Y $extraction_script $file $extract
cd $extract
Extract-Internals
} else {
break
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
}
}
}
}

foreach ($item in (Get-ChildItem -Path $extraction_dir -Force -Recurse -File | % { $_.FullName } )) {
$dir = Split-Path $item -Parent
$file = Split-Path $item -Leaf
$extract = $file + '_extract'
$ext = (Split-Path -Path $file -Leaf).Split(".")[1]

cd $dir
foreach ($arc in $archive_types) {
if (($ext -eq $arc)) {
& $quickbms_command -Y $extraction_script $file $extract
cd $extract
Extract-Internals
}
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
}
cd $cwd
}

Start-Sleep $sleep
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
}
}

Write-Output "Preparing asset extraction"
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
}
}

if (!(Test-Path -Path $audio_dir -PathType Container)) {
New-Item -Path . -Name $audio_dir -ItemType Directory | Out-Null
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
}

$audio_dir = Get-Item -Path $audio_dir | % { $_.FullName }
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
}
}

if (!(Test-Path -Path $models_dir -PathType Container)) {
New-Item -Path . -Name $models_dir -ItemType Directory | Out-Null
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
}

$models_dir = Get-Item -Path $models_dir | % { $_.FullName }
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
}

Start-Sleep $sleep
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
}

Write-Output "Extracting and converting assets"

foreach ($item in (Get-ChildItem -Path $extraction_dir -Force -Recurse -File | % { $_.FullName } )) {
$dir = Split-Path $item -Parent
$file = Split-Path $item -Leaf
$extract = $file + '_extract'
$ext = (Split-Path -Path $file -Leaf).Split(".")[1]

# Generate a UID for assets so that all converted files can be placed in Audio directory if they have are named the same on disc
$guid = New-Guid
$audio = (Split-Path -Path $file -Leaf).Split(".")[0]
$audio = $audio + '-' + $guid + '.wav'

$model = (Split-Path -Path $file -Leaf).Split(".")[0]
$model = $model + '-' + $guid + '.mdl'

cd $dir
if ($ext -eq "at3") {
& $vgmstream_command $file -o $audio
Move-Item -Path $audio -Destination $audio_dir
} elseif (($ext -eq "mdl") -Or ($ext -eq "md")) {
Copy-Item -Path $file -Destination $model
Move-Item -Path $model -Destination $models_dir
}
cd $cwd
Function Extract_All {
Extract_Field
Extract_Battle
Extract_Gallery
Extract_Interface
Extract_MiniGames
Extract_MemoryCard
Extract_System
Extract_Title
}

Start-Sleep $sleep
$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 "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 'd') {
Delete
}

Write-Output "Removing empty folders"
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 {}
}
}

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
Do {
Get_User_Input
} While ($Continue -eq '1')

cd $cwd
Clean

Start-Sleep $sleep
Write-Output "Have a wonderful day! Happy modding, digging, and BRSing!!! :D"

Write-Output "Extraction finished."
Write-Output "Models, Audio and other extracted assets can be found in the Assets folder"
#Write-Output "Models, Audio and other extracted assets can be found in the Assets folder"
16 changes: 15 additions & 1 deletion Disc Map/GAMEDATA/FLD/FCHR/FCHR.MD
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# FCHR.BIN Data Structures

* NOTE: All of the files here are SC (Stacked Container) types related to a variety of different game assets. Until we figure out what exactly FLD and FCHR stand for, I won't be fully documenting this section. All of these were contained within GZip compressed BIN files within `GAMEDATA\FLD\FCHR` on the game disc.
This document is separate from the individual FCHR files because there's a specific structure to the entire section (that I will refer to as Namespaces from here on out).

## Namespaces

* FCHR_B - Bosses

* FCHR_G - Gimmicks/Gizmos/Game Objects - It's a grab bag of multiple types of models that are mostly interacted with by the player but aren't enemies

* FCHR_M - Mobs - All of the non-boss enemies the player fights

* FCHR_P - Playable Characters (see SCPM in FileFormats.md doc for notes on a possible second character found)

* FCHR_S - Skills

* FCHR_W - Weapons

=====================================================================

Expand Down
28 changes: 16 additions & 12 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@
This repository will host my findings and various scripts, tools and documentation I've put together from diving into [Black Rock Shooter: The Game](https://web.archive.org/web/20150328084959/http://brs.jrpg.jp/) for the Playstation Portable handheld console. It's a work in progress and contributions are welcomed. All that I ask is that any projects that use anything from this repository will link back here and not claim ownership of anything within.

=====================================================================
## How to Extract the Game Files for Beginners
## How to Quickly Extract Most of the Game Data

* Download and install a modern version of Windows Powershell: https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.4
* Download and install a modern version of Windows [Powershell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.4)

* Copy the `PSP_GAME` directory from a ripped and extracted release of Black Rock Shooter: the Game into the `Game` folder in this directory
* Copy the `PSP_GAME` directory from a ripped and extracted release of Black Rock Shooter: the Game into the `Game` folder

* Open the folder this Directory is in and right-click->Open in Terminal
* Right click and Click "Open in Terminal"

* Run: `.\BRS-Extract.ps1`
* Type `.\BRS-Extract.ps1` and hit enter to run this script

* If you don't have the `Tools` directory or any of the tools installed, it will ask you if you want to download and install them. Type 'y' for yes. This should be the only time you'll need to input anything.
* If you don't have the `Tools` directory or any of the tools installed, it will ask you if you want to download and install them. Type 'y' to download.

* Wait for the script to finish. It can take 15+ minutes due to just how many files there are.
* When prompted, choose what all you want to extract.

* Wait for the script to finish extracting the game files. This used to take 15+ minutes but current optimizations have drastically dropped that number.

* All of the scripts will frequently receive updates for as long as they are needed to improve the process, so expect possible breakage from time to time but updating regularly hopefully won't be required as much.

* NOTE: Depending on your security settings, Windows may say it can't run Powershell scripts. If this happens, you'll either need to run the script with elevated privileges or temporarily set your policy to allow it. See [here](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7.4) for more information

Expand All @@ -32,29 +36,29 @@ This repository will host my findings and various scripts, tools and documentati

* [7-zip](https://www.7-zip.org/) - for extracting the game disc mostly. All of the main archive types can be extracted with BRS-extract.bms without the need of external tools.

* [Vgmstream-cli](https://github.com/vgmstream/vgmstream) - for converting at3 files into a user playable format
* [K-Lite Mega Codec Pack](https://www.codecguide.com/download_k-lite_codec_pack_mega.htm) - Install this with all codec options selected, the audio files for the game won't need to be converted; converting can possibly make modding them an issue when reinjecting them or replacing them in the game (testing needed)

=====================================================================
## Optional Tools

* [Offzip](https://aluigi.altervista.org/mytoolz/offzip.zip) - for extracting data from ZZZ archives; extraction script should work with all of these without issues now

* [Vgmstream-cli](https://github.com/vgmstream/vgmstream) - for converting at3 files into a user playable format; probably not needed if an audio editing tools is found that can work with the audio as is

=====================================================================
## Navigating This Repository

The folder structure is meant to be pretty straight forward, but here's what they represent:

* Disc Map - To help find specific files on the disc without having to fully navigate each directory. If a file is an archive or container, the "Contents" of them will be listed once extracted (unless unnecessary).
* Disc Map - To help find specific files on the disc without having to fully navigate each directory. If a file is an archive or container, the "Contents" of them will be listed once extracted (unless unnecessary)

* Game - Where the game files go

* Scripts - QuickBMS scripts can be found here. See accompanying README in the directory and notes in the script if you need to learn how to use them. Also, feel free to open an issue and / or pull request (if you want to improve the documentation) if they're not clear enough.

* Specifications - The documentation here is meant to be more for tool makers, modders and developers. It's all technical and deals heavily with memory structures of different formats, encryption, etc.

* Tools - Where the tools are downloaded and installed for extracting the game files; right now, this only supports Windows but shouldn't be super hard to get working on the BSDs, Linux, Mac, etc

* Assets - When running the automatic extraction script, any sound files, models, and possibly other asset types will be found in their own directories here. This is for convenience but do note that on subsequent extractions, there will be duplicates of everything unless you remove or move this folder somewhere else
* Tools - Where the tools are downloaded and installed for extracting the game files; right now, this only supports Windows but shouldn't be difficult to get working on the BSDs, Linux, Mac, etc

=====================================================================
## Current TODO
Expand Down
Loading

0 comments on commit 197e991

Please sign in to comment.