Dark Souls - BND Import [XBOX360]
Posted: Tue Dec 23, 2014 3:53 pm
Please help me with importing the files back to the BND. Found this script, but it is only for the PC version. The only difference between the PC and XBOX, it's endiand. In the XBOX 360 uses a large endiand. Please, help me with convert this script under XBOX 360.
Sorry for my bad English.
Sorry for my bad English.
Code: Select all
$bndpath = FileOpenDialog("Select the BND file", @ScriptDir, "bnd files (*.bnd)", 1)
If @error = 1 Then Exit
$bndfile = FileOpen($bndpath, 16)
$dir = FileSelectFolder("Select the folder...", "", "", @ScriptDir)
If $dir = "" Then
Exit
EndIf
Dim $names, $pos = 33
_filereadtoarray($dir & "\" & "names.txt", $names)
FileSetPos($bndfile, 20, 0)
$baseoffset = _binarytoint32(FileRead($bndfile, 4))
$basepad = 16 - Mod($baseoffset, 16)
If $basepad < 16 Then
$baseoffset += $basepad
EndIf
FileSetPos($bndfile, 0, 0)
$newfilehead = FileRead($bndfile, $baseoffset)
$newfiletext = Binary("0x00")
For $i = 1 To $names[0]
$file = FileOpen($dir & "\" & $names[$i], 0 + 16)
$size = FileGetSize($dir & "\" & $names[$i])
$padding = 16 - Mod($size, 16)
If $padding < 16 Then
$newfiletext &= FileRead($file) & _binaryrandom($padding, 0, 0)
Else
$newfiletext &= FileRead($file)
EndIf
$newfilehead = _binarypoke($newfilehead, $pos + 4, $size, "dword")
$newfilehead = _binarypoke($newfilehead, $pos + 8, $baseoffset, "dword")
$newfilehead = _binarypoke($newfilehead, $pos + 20, $size, "dword")
$pos += 24
If $padding < 16 Then
$baseoffset += $size + $padding
Else
$baseoffset += $size
EndIf
FileClose($file)
Next
$hnewfile = FileOpen(compgetfilename($bndpath), 2 + 16)
FileWrite($hnewfile, $newfilehead & BinaryMid($newfiletext, 2))
FileClose($hnewfile)
TrayTip("Importer", "Finish!", 3)
Func compgetfilename($path)
If StringLen($path) < 4 Then Return -1
$ret = StringSplit($path, "\", 2)
If IsArray($ret) Then
Return $ret[UBound($ret) - 1]
EndIf
If @error Then Return -1
EndFunc