Toukiden - Hacking and Translating

Discussion in 'PSP - Hacking & Homebrew' started by 1NSaNe, Mar 18, 2014.

  1. 1NSaNe
    OP

    1NSaNe Member

    Newcomer
    35
    27
    Mar 16, 2014
    [​IMG]
    Hi! I think this game is awesome for PSP but nobody pay attention because its in Japanese, so a few days ago i started the adventure about translating it! I can change the texts without problem or crashing, could replace almost all: Weapon Names, Materials, Skill Names, NPCs, Dialogs, Etc...

    [​IMG]
    File System:
    All the game's data is stored in 2 files:
    [​IMG] LINKDATA_A.BIN -> The data package,(bigfile)
    [​IMG] LINKDATA_B.BIN -> file system descriptor (contains information on how the files are stored in the bigfile)


    In order to decompress the bigfile, you have two options:
    [​IMG]356resource.exe , tool made by @Adtech for extract LINKDATA_A.BIN for Dynasty Warriors.
    [​IMG]Sky Lastest Tool - im not posting the link here, just check in the forum.

    [​IMG]Audio:
    Stored in [​IMG]BGM.BIN and [​IMG]LINKDATA_A.BIN, can be easy extracted and replaced with lastest sky tool. ( Format: [​IMG].AT3 )

    [​IMG]Video:
    Separated from the bigfile, is easy to edit-replace-compress the video files in the iso using the normal way. ( Format: [​IMG].PMF )

    [​IMG]Models:
    Easy to extract and replace with lastest sky tool. ( Format: [​IMG].GMO )

    [​IMG]Graphics:
    The problem is the game have compressed image that i want to translate but its very hard, because i tryed Sky's BigFile Tool and only found 2 PNG that i dont need, and using a LINKDATA_A.BIN extractor i can see the bigfile have some lzp2 compressed files that i have no idea to uncompress.

    [​IMG]



    This is the graphic i want to change, if someone can help me to do that, could be awesome.



    [​IMG]


    Please, if someone is able to help me extracting the graphics will be very nice, beacuse im having nightmares with this :D
    Im using MadEdit / 365Resource (LINKDATA_A.BIN Extractor) / Lastest Sky Tool

    ---------------​
    Some screens:​
    [​IMG]

    Progress:
    (···)Missions | (··)Materials | (▪··)Menus
    (100%)Skills | (100%)Weapons | (····)NPCs
    (··)Spirits | (·····)Armors | (·····)Story


    UPDATE 16 MAY 2014
    I have too much less time now for continue so i will be pausing the project for about 2 months, im very sorry for that.​
    If someone want to help, can pm me for info about replacing the texts.​
    Also you can still help fixing the character creation menu i broke. I know how to do it but have no time.​
    Dialogues are not translated and the description of the tamafuri is short. You can see the percentage of translation in first message.​
    Enjoy​


    How to apply the patch​

    -Open any toukiden .iso (linkdata_a.bin must be untouched) with UMDGen.​
    -Search for LINKDATA_A.BIN, right click then Apply PPF Patch, and select ppf.ppf​
    -Save as new .iso or .cso​


    ATTENTION: Any problem ocurred when translating the character creation menu, and there is a bug when you start a new game.
    My suggestion is to create new game with untouched iso, save, then apply the patch. Tutorial is working in the patch.


    DOWNLOAD PPF PATCH: http://goo.gl/uJ7KfR
     
    Hargrun and 6SoulTriox like this.
  2. Ryupower

    Ryupower Brood

    Member
    2,938
    443
    Oct 8, 2007
    United States
  3. GameWinner

    GameWinner Take your heart

    Member
    4,190
    1,689
    Jun 14, 2009
    United States
    Just get it on Vita.
     
  4. 1NSaNe
    OP

    1NSaNe Member

    Newcomer
    35
    27
    Mar 16, 2014
    Thanks, I know is on vita, but will be not released on Eu/Usa for PSP, so i want to adapt the translation.
    Any help with the graphics? ^^
     
  5. SkyBladeCloud

    SkyBladeCloud GBAtemp Fan

    Member
    435
    867
    Oct 7, 2010
    Feel free to upload one of those images that look compressed (or pretty much anything you think could be an image), so we can have a look ;)

    ~Sky
     
  6. 1NSaNe
    OP

    1NSaNe Member

    Newcomer
    35
    27
    Mar 16, 2014
    I use 365resource.exe, a LINKDATA_A.BIN extractor/injector. It can only replace LZP2 compressed files, so for example i take this
    [​IMG]

    i uploaded it with 1.txt, just replace .txt with .lzp2 or something. I have no LZP2 extractor and no idea if i can change ingame images. Thanks in advance.
     

    Attached Files:

    • 1.txt
      File size:
      215.8 KB
      Views:
      292
  7. SkyBladeCloud

    SkyBladeCloud GBAtemp Fan

    Member
    435
    867
    Oct 7, 2010
    Alright this... Is a rather... tricky LZSS + RLE custom algorithm, I found the decompressing ASM routine and I kinda understand it, but I think your best bet would be to implement the routine using any programming language.

    EDIT: A vague explanation of the algorithm (reading ASM):

    -Read flag
    **If (flag & 0x80) -> apply LZSS ( read keyword (11 bits for offset + 4 bits for length) + threshold of 3)
    **If (flag & 0x40) -> apply RLE (read length + read value + threshold of 4)
    **Else -> Data is uncompressed (flag = length + read raw data)

    It actually makes sense: since it reads and extra byte for RLE, it applies an extra byte to the threshold. On the other hand, LZSS bits are 11 + 4 + 1 = 16 bits from both flag and keyword.

    The decompression routine is located at 0x088350A4; and once it returns, the LZP2 is decompressed in memory (note that the decompressed data can be a package containing recompressed stuff, so it may have packed LZP2 files).

    As I said, if you forget about all these and implement the routine in a high level programming language, the data will be uncompressed.

    EDIT2:

    Here is the routine itself. Register a0 contains the LZP2, while register a1 contains the output buffer (you can know the size of it reading the header of the LZP2, as it contains both compressed and decompressed sizes):

    Code:
    z_un_088350ac:
     
        addiu    sp,sp,-0x20
        sw    s0,0x8(sp)
        sw    s1,0xC(sp)
        move    s0,a0
        move    s1,a1
        sll    a0,a2,0x18
        sll    a1,a3,0x18
        sra    a0,a0,0x18
        sra    a1,a1,0x18
        sw    ra,0x10(sp)
        bne    zero,s1,pos_08835138
        addiu    a2,s0,0x10
        beq    zero,a1,pos_08835110
        lw    s1,0x8(s0)
        sw    a0,0x4(sp)
        jal    z_un_08885344
        sw    a2,0x0(sp)
        move    a0,v0
        move    a1,s1
        jal    z_un_08885988
        li    a2,0x10
        lw    a2,0x0(sp)
        move    s1,v0
        b    pos_08835138
        lw    a0,0x4(sp)
     
    pos_08835110:
     
        sw    a0,0x4(sp)
        jal    z_un_08885344
        sw    a2,0x0(sp)
        move    a0,v0
        move    a1,s1
        jal    z_un_088857a4
        li    a2,0x10
        lw    a2,0x0(sp)
        move    s1,v0
        lw    a0,0x4(sp)
     
    pos_08835138:
     
        lbu    a3,0x0(a2)
        move    a1,s1
        beq    zero,a3,pos_08835214
        addiu    a2,a2,0x1
     
    pos_08835148:
     
        andi    t1,a3,0x80
        bne    zero,t1,pos_088351C0
        addiu    t0,a2,0x1
        andi    t1,a3,0x40
        bnel    zero,t1,pos_08835188
        andi    a3,a3,0x3F
     
    pos_08835160:
     
        lbu    t1,0x0(a2)
        move    a2,t0
        sb    t1,0x0(a1)
        addiu    a1,a1,0x1
        addiu    a3,a3,-0x1
        bne    zero,a3,pos_08835160
        addiu    t0,a2,0x1
        b    pos_0883520C
        lbu    a3,0x0(a2)
        andi    a3,a3,0x3F
     
    pos_08835188:
     
        lbu    a2,0x0(a2)
        sll    a3,a3,0x8
        addu    t1,a2,a3
        lbu    a3,0x0(t0)
        addiu    a2,t0,0x1
        addiu    t1,t1,0x4
        beq    zero,t1,pos_08835208
        addiu    t0,a2,0x1
     
    pos_088351A8:
     
        sb    a3,0x0(a1)
        addiu    t1,t1,-0x1
        bne    zero,t1,pos_088351A8
        addiu    a1,a1,0x1
        b    pos_0883520C
        lbu    a3,0x0(a2)
     
    pos_088351C0:
     
        andi    t1,a3,0x78
        andi    a3,a3,0x7
        lbu    a2,0x0(a2)
        sra    t1,t1,0x3
        sll    t2,a3,0x8
        addiu    a3,t1,0x3
        or    t1,t2,a2
        move    a2,t0
        subu    t1,a1,t1
        addiu    t1,t1,-0x1
        beq    zero,a3,pos_08835208
        addiu    t0,a2,0x1
     
    pos_088351F0:
     
        lbu    t2,0x0(t1)
        addiu    t1,t1,0x1
        sb    t2,0x0(a1)
        addiu    a3,a3,-0x1
        bne    zero,a3,pos_088351F0
        addiu    a1,a1,0x1
     
    pos_08835208:
     
        lbu    a3,0x0(a2)
     
    pos_0883520C:
     
        bne    zero,a3,pos_08835148
        move    a2,t0
     
    pos_08835214:
     
        beq    zero,a0,pos_08835230
        nop
        jal    z_un_08885344
        nop
        move    a0,v0
        jal    z_un_088859cc
        move    a1,s0
     
    pos_08835230:
     
        move    v0,s1
        lw    s0,0x8(sp)
        lw    s1,0xC(sp)
        lw    ra,0x10(sp)
        jr    ra
        addiu    sp,sp,0x20
    
    As you can see there are some sub-routines, but they are so small I wouldn't worry about them ;)

    ~Sky
     
  8. john032194

    john032194 Member

    Newcomer
    41
    4
    Mar 7, 2014
    Philippines
    i hope this project will continue, since it will not be an issue with translation and the fact that i am too financially incapable of purchasing a vita.
     
  9. tuandragon

    tuandragon Newbie

    Newcomer
    3
    0
    Mar 21, 2014
    1NSaNe
    Wow, this is great. I'm thinking of patching this game myself in free time. But since you already go this far, i think i should spend time helping u is better. I'm a pro programmer myself, but my japanese is very little. I can write you tools in java/C#/C++ to do things if you want. I'll look into the image compress issue, if i know something I'll write tool for u to use!
    Keep it up!

    Skyblade, thanks for your info, I can have some general idea of the data, it seems there are 2 kind of file, 1 with header LZP2, the other is 2ina.
    The LZP2 header is 16 byte. the Integer at pos 12 is (=file size-16). So I think this is the length of compressed data. The integer at pos 8 maybe the decompressed size.
    Flag 0x40 : have 2 byte after, it maybe the length of RLE and value.
    Flag 0x80 : have only 1 byte after. For example 80 03, 80 07... if it's LZSS as u talked it's not seem to make sense. The things about raw data seems right! I haven't worked with LZSS before (it need offset, len, and dictionary???)

    example : [05-01-00-00-00-10]-[40-07-00]-[01-51]-[80-03]-[01-15]-[80-07]-[09-67-03-00-00-B9-06-00-00-D5]-[80-03]....

    I studied assembler when I was very small, so forget most of it. Since age of windows, I never work with it anymore. If you can give me more info, thanks!
     
  10. SkyBladeCloud

    SkyBladeCloud GBAtemp Fan

    Member
    435
    867
    Oct 7, 2010
    tuandragon:

    That's correct, except for the fact that "flag 0x80" is not really 0x80, you have to apply an AND bitwise operation to the flag, and if the result is 0x80 (if the 1st bit is 1), then you read the other byte and apply LZSS, so basically flags 0x80 to 0xFF ALSO apply LZSS. Same for RLE (if the 2nd it is 1, you apply RLE; but in this case, I've never seen a flag different than 0x40 itself).

    To recompress you can simply use raw data (AKA fake compression). I don't think you can use flag 0x7F for raw data, because it would trigger RLE (since 0x7f & 0x40 = 0x40). But you should be able to use blocks of 0x3F ;)

    For LZSS you get offset and length from both the flag and the next byte, and the dictionary is the output buffer.

    I also find this project pretty interesting and would like to collaborate on it too... Too bad I don't have time for it (-_-")

    ~Sky
     
  11. 1NSaNe
    OP

    1NSaNe Member

    Newcomer
    35
    27
    Mar 16, 2014
    Thanks both for the interest, any help is apreciated. At the moment, there are two ways to help this project

    1. Asking via PM for Jap text for translate to Eng

    2. Trying to extract the image for replace.
    Since im beginner in this world, i have poor idea about making my decompressor, but i can edit the images and translate if u could extract as a .bmp or .png or something. So we need:
    -Tool for extract LZP2 files (we have already one)
    -Tool to decompress/compress LZP2 files
    -Tool for inject new LZP2 files
    (Probably we need a tool that replenish KB for the new images, for have same size.)


    If someone read this and have enough time and interest to help, feel free. This project is totally open right now. Thanks to all :)
     
  12. JuliusEra

    JuliusEra majestix1988

    Newcomer
    75
    9
    Jul 24, 2012
    or ask someone who got vita version[then write all things on vita version on paper then put it on psp version /they are the same like god eater 2
     
  13. tuandragon

    tuandragon Newbie

    Newcomer
    3
    0
    Mar 21, 2014
    SkyBladeCloud : it's harder than I expected. Still no luck.
    Unless I can read the ASM code, and where did u get that decompress code in ASM. Still need more info and luck! Thanks!
     
  14. SkyBladeCloud

    SkyBladeCloud GBAtemp Fan

    Member
    435
    867
    Oct 7, 2010
    Don't worry, I'll end up doing it sooner or later, when I get some free time, and if nobody does it before xD. In the meantime the translation can keep going forward.
    I got the ASM code using memory breakpoints in the PPSSPP debugger.
     
  15. tuandragon

    tuandragon Newbie

    Newcomer
    3
    0
    Mar 21, 2014
    OK, I'm using ppsspp to play some of my favourite games (ff7 crisis, monster hunter...). It's a great emulator. Yesterday I look at the Debug tool, it support breakpoint. I will look more into that. It's better than just trying out luck with the binary. Cant be hasty!
     
  16. john032194

    john032194 Member

    Newcomer
    41
    4
    Mar 7, 2014
    Philippines
    so, any updates?
     
  17. 1NSaNe
    OP

    1NSaNe Member

    Newcomer
    35
    27
    Mar 16, 2014
    Im on it. Im solo atm translating so it takes me some time ^^U
     
  18. john032194

    john032194 Member

    Newcomer
    41
    4
    Mar 7, 2014
    Philippines
    oh that's good to know, I also like to help but nihonggo isn't exactly my strong suit.
     
  19. Cursed Kaiser

    Cursed Kaiser Member

    Newcomer
    40
    17
    Aug 27, 2013
    i'm looking forward for this one
     
  20. gwapogi187

    gwapogi187 Newbie

    Newcomer
    3
    1
    Apr 28, 2014
    finally someone who cares about the psp version, i dont have a vita so please continue on working for this project and btw An updated version of Toukiden is coming to the PSP and PlayStation Vita ...Toukiden Kyoku (or Toukiden Extreme, when translated to English)
     
    mhunteralexander likes this.