touhou-reimpl/extract.nu

31 lines
1 KiB
Plaintext
Raw Normal View History

2025-01-26 03:34:55 -05:00
def main [game_folder: path, version: int] {
let game = if $version == 10 {
2025-01-26 03:34:55 -05:00
{ folder: "mof", version: $version }
} else if $version == 11 {
2025-01-26 03:34:55 -05:00
{ folder: "sa", version: $version }
} else {
return (error make {msg: "version not supported", label: { text: "expected 10 or 11", span: (metadata $version).span } })
exit 1
}
2025-01-26 03:34:55 -05:00
let assets = $"assets/($game.folder)"
2025-01-26 03:40:33 -05:00
mkdir $assets
2025-01-26 03:34:55 -05:00
let thver = $"th($game.version)"
thdat -C $assets -x $version $"($game_folder)/($thver).dat"
try {
ln -s $"($game_folder)/thbgm.dat" $"($assets)/thbgm.dat"
} catch { }
2025-01-26 03:34:55 -05:00
let research = $"research/dump/($game.folder)"
2025-01-26 03:40:33 -05:00
mkdir $research
2025-01-26 03:34:55 -05:00
let replt = {|ext| str replace $ext $"t($ext)"};
let dump = {|ext|
ls $assets | get name | where {str ends-with $".($ext)"} | each {path basename}
| each {|name| run-external $"tru($ext)" "decompile" "-g" $game.version $"($assets)/($name)" "-m" $"utils/($thver).($ext)m" | save -f $"($research)/($name | do $replt $ext)"}
};
do $dump "anm"
do $dump "ecl"
do $dump "std"
}