Dark Souls 2 - DCX file - Help needed

Textures, recreate headers, conversions, algorithms and parsing of image files
The_Reaper_CooL
Posts: 69
Joined: Sat Dec 05, 2015 2:31 pm

Dark Souls 2 - DCX file - Help needed

Post by The_Reaper_CooL »

Hey there people!

I'm translating Dark Souls 2 on PC, and as you may have known the name of the places in-game are stored in texture files (and stuff like "YOU DIED!" and so on).

Using Atvaark's BinderTool I can easily extract the textures from these .tpf files (and they become a .dds file), but I can't put them back.

Is there a method to do so, or we need a tool for it?
Last edited by The_Reaper_CooL on Wed Nov 16, 2016 8:59 pm, edited 1 time in total.
The_Reaper_CooL
Posts: 69
Joined: Sat Dec 05, 2015 2:31 pm

Dark Souls 2 - DCX file - Help needed

Post by The_Reaper_CooL »

Image

Okay, so... I think I've got a solution (took me a while to figure it out, but hey, at least it works :D).

The way I can change any ingame texture without needing GeDoSaTo or anything like that (in Dark Souls 2):

1. Extract the files with Bindertool (the modified 0.2 one)
2. Rename the decrypted.dat file on drive C: and copy it back
3. Now I've found out that the files I need are in the GameDataEbl\menu\tex\Icon\MapName\English\ folder (or some of it)
4. With a newer Bindertool (0.4.1) I could extract the DDS files from these TPF files (although now that I think of it, I might not need it).
5. Then I edited the DDS to my liking, and saved as a DXT5 Interpolated Alpha DDS.
6. This is the part where I needed help. What I did is that I've opened the TPF file and the DDS file in HEX Workshop, and compared the two together.

I've realised that the only difference is some bytes in the beginning of the TPF file, and then the DDS file comes. So what I did is I deleted the TPF file's DDS section, and inserted my DDS file's whole HEX section into it, saving the file in the process.

7. There's the darksouls2_bdt_import.exe file, and I have the source (because it's included with the modified Bindertool 0.2). So I modified it to re-import .tpf files and not .fmg files.
8. I've re-imported the modified file like I usually do with the FMG files, and voila! It works! :D

Good luck for everyone who also want to mod textures this way :)

ADDENDUM:
Why I said that maybe I don't need Bindertool to get a DDS out of the TPF file? Because I only need to delete the TPF file's "header HEX" section (right up to the DDS part), and then I can get the DDS file I need by saving the TPF file as DDS.

You're welcome :)
Last edited by The_Reaper_CooL on Wed Nov 16, 2016 8:59 pm, edited 1 time in total.
The_Reaper_CooL
Posts: 69
Joined: Sat Dec 05, 2015 2:31 pm

Dark Souls 2 - DCX file - Help needed

Post by The_Reaper_CooL »

Heh... I was too happy for too soon:

I can only do this to normal .TPF files, but there are files that are stored in .DCX files, if I extract those then I get a .FETEXBND, which contains a LOT of .TPF files. Now I can't try it out if it works or not, because maybe I could put the .TPF files back into said .FETEXBND by hand, but I don't know how to create a .DCX file out of the .FETEXBND file...

Any ideas on this? :D

EDIT:
I've found out that I can only re-import the .DCX file, but for that I need to know how to compress it again.

I've also found a Wiki site (DarkSoulsDev) where they wrote how a DCX file works. Quoting from that:

DCX files are just Zlib compressed data with some headers, notice the ASCII 'x' before the hex mess. Offsets are always relative to their chunk, so add them to the chunk magic position. Structure names are speculated from the meaning I could guess. Note that for some reason data is stored as big-endian.

Offsets.

struct DcxPackage // DCX
{
/* 0x00 */ uint32_t magic; // 0x44435800, for 'DCX '
/* 0x04 */ uint16_t unk1; // always 1 ?
/* 0x06 */ uint16_t unk2; // always 0 ?
/* 0x08 */ uint32_t dcs_offset; // offset to DCS chunk (= 0x18)
/* 0x0C */ uint32_t dcp_offset; // offset to DCP chunk (= 0x24)
/* 0x10 */ uint32_t unk3; // seems equal to dcp_offset
/* 0x14 */ uint32_t unk4; // seems to point after DFLT (= 0x2C)
}


Can anyone do something about this, or have any idea what this is? Because I certainly don't know what to do with these...

EDIT2:
I've added the two files I've been talking about. One is a DCX file that is a ZLIB compressed archive-thing, and it contains the other file I've included, the FETEXBND one. What I need is that I want to create a DCX file from the FETEXBND one using ZLIB. This is why I need help

EDIT3:
Got a solution from a friend of mine:

First you need to uncompress the English.fetexbnd.dcx file with offzip. Use "offzip -a English.fetexbnd.dcx FOLDER" to unzip it into a folder. You'll get a file, like 0000004C.bnd. You can edit this file with HEX Editor (copy the TPF or DDS parts out of it, edit them, put them back in), and then using packzip, you can easily save this file by overwriting the data.

Using this command: "packzip -0 0x0000004C 0000004C.bnd English.fetexbnd.dcx"

It's nice to see that for this simple solution noone offered any advice in 3 months or so (it took my friend 2 minutes to figure this one out btw...)
cfarl
Posts: 11
Joined: Sun Nov 05, 2017 12:45 am

Re: Dark Souls 2 - DCX file - Help needed

Post by cfarl »

Hi, just to report... I was using your solution to repack the bnd file to the original dcx (to make a xbox translation).

So, I used:

packzip -o 0x0000004C 0000004C.bnd English.fetexbnd.dcx

In my case, when running the game, I was getting message boxes with no text, fatal crash and other strange errors...

After a long time of tests, I found why it was happening.

Then, I add: after building your dcx with packzip you need to update two fields of data in the dcx file.

1) Using a hex editor, locate DCS<space> in your dcx file (bytes 44 43 53 00)

2) Update the next four bytes with the following value: your bnd file size

3) Update the next four bytes with the following value: your dcx file size - 76

After making this, it will work as desired. :D
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Dark Souls 2 - DCX file - Help needed

Post by Acewell »

just for kicks here are some scripts :D

a script for decompressing the English.fetexbnd.dcx sample

Code: Select all

# script for QuickBMS http://aluigi.altervista.org/quickbms.htm

endian big
get NAME basename
idstring "DCX\0"
get VERSION short
get ZERO short
get DCS_OFFSET long
get DCP_OFFSET long
get UNK long
get DCA_REL_OFFSET long
getdstring DCS 4
get SIZE long
get ZSIZE long
getdstring DCP 4
getdstring COMPRESSION_SIG 4
get DCP_HEADERSIZE long
get UNK2 long
get UNK3 long
get UNK4 long
get UNK5 long
get UNK6 long
getdstring DCA 4
get DCA_HEADERSIZE long
savepos OFFSET
clog NAME OFFSET ZSIZE SIZE


a script for extracting the tpf files from the English.fetexbnd file extracted from dcx sample

Code: Select all

# script for QuickBMS http://aluigi.altervista.org/quickbms.htm

idstring "BND4"
get ZERO long
get UNK2 long //0x10000
get FILES long
get TABLE_OFFSET longlong
get UNK4 longlong //0x36354e3831443431
get TABLE_STRIDE longlong
get UNK5 longlong //0x6ad
get UNK6 longlong //0x5400
get ZERO6 longlong
for i = 0 < FILES
   get FORTY long
   get EFFS long
   get SIZE longlong
   get ZSIZE longlong //?
   get OFFSET longlong
   get NAME_OFF long
   savepos TMP
   goto NAME_OFF
   get NAME string
   log NAME OFFSET SIZE
   goto TMP
next i


and a script for extracting images from the tpf files to dds

Code: Select all

# script for QuickBMS http://aluigi.altervista.org/quickbms.htm

get NAME basename
get SIZE asize
idstring "TPF\0"
get UNK long
get FILES long
get UNK long
for i = 0 < FILES
   get OFFSET long
   get SIZE long
   get UNK long
   get STR_OFF long
   get ZERO long
   savepos TMP
   goto STR_OFF
   get NAME string
   string NAME + .dds
   log NAME OFFSET SIZE
   goto TMP
next i


all of them should be available for reimport process with Quickbms too :)
Last edited by Acewell on Fri May 25, 2018 11:29 pm, edited 2 times in total.
cfarl
Posts: 11
Joined: Sun Nov 05, 2017 12:45 am

Re: Dark Souls 2 - DCX file - Help needed

Post by cfarl »

Thanks for your reply, Acewell.
Do you know where I can find the textures for "You Died" and the game locations name?
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Dark Souls 2 - DCX file - Help needed

Post by Acewell »

i sure don't, i don't have or play this game, i just looked at the samples "The_Reaper_CooL" posted. :)
cfarl
Posts: 11
Joined: Sun Nov 05, 2017 12:45 am

Re: Dark Souls 2 - DCX file - Help needed

Post by cfarl »

cfarl wrote:Thanks for your reply, Acewell.
Do you know where I can find the textures for "You Died" and the game locations name?

I found it. Please see this topic here: https://forum.xentax.com/viewtopic.php?f=10&t=17308&p=135509#p135509