Hacking Toukiden - Hacking and Translating

1NSaNe

Active Member
OP
Newcomer
Joined
Mar 16, 2014
Messages
36
Trophies
0
Age
35
XP
176
Country
0VAxLZ0.png
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...

3gXiktK.png
File System:
All the game's data is stored in 2 files:
oBPALMw.gif
LINKDATA_A.BIN -> The data package,(bigfile)
oBPALMw.gif
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:
356resource.exe , tool made by @Adtech for extract LINKDATA_A.BIN for Dynasty Warriors.
panLD36.png
Sky Lastest Tool
- im not posting the link here, just check in the forum.

th6VAvz.png
Audio:
Stored in
oBPALMw.gif
BGM.BIN and
oBPALMw.gif
LINKDATA_A.BIN, can be easy extracted and replaced with lastest sky tool. ( Format:
lvzeq7f.gif
.AT3
)
th6VAvz.png
Video:
Separated from the bigfile, is easy to edit-replace-compress the video files in the iso using the normal way. ( Format:
u2EvYo6.gif
.PMF
)
th6VAvz.png
Models:
Easy to extract and replace with lastest sky tool. ( Format:
zqr7pxh.png
.GMO
)
pB2UFNJ.jpg
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.
RbUjr95.png



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



RJajk6P.png


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:​
g1F1YVK.png

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
 

1NSaNe

Active Member
OP
Newcomer
Joined
Mar 16, 2014
Messages
36
Trophies
0
Age
35
XP
176
Country
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? ^^
 

SkyBladeCloud

Well-Known Member
Member
Joined
Oct 7, 2010
Messages
452
Trophies
0
Age
33
XP
1,420
Country
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
 

1NSaNe

Active Member
OP
Newcomer
Joined
Mar 16, 2014
Messages
36
Trophies
0
Age
35
XP
176
Country
I use 365resource.exe, a LINKDATA_A.BIN extractor/injector. It can only replace LZP2 compressed files, so for example i take this
GCy1cCJ.png


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.
 

Attachments

  • 1.txt
    215.8 KB · Views: 702

SkyBladeCloud

Well-Known Member
Member
Joined
Oct 7, 2010
Messages
452
Trophies
0
Age
33
XP
1,420
Country
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
 

john032194

Active Member
Newcomer
Joined
Mar 7, 2014
Messages
41
Trophies
0
Age
30
Location
Philippines
XP
122
Country
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.
 

tuandragon

New Member
Newbie
Joined
Mar 21, 2014
Messages
3
Trophies
0
Age
44
XP
51
Country
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!
 

SkyBladeCloud

Well-Known Member
Member
Joined
Oct 7, 2010
Messages
452
Trophies
0
Age
33
XP
1,420
Country
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
 

1NSaNe

Active Member
OP
Newcomer
Joined
Mar 16, 2014
Messages
36
Trophies
0
Age
35
XP
176
Country
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 :)
 

JuliusEra

majestix1988
Newcomer
Joined
Jul 24, 2012
Messages
75
Trophies
0
XP
71
Country
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
 

tuandragon

New Member
Newbie
Joined
Mar 21, 2014
Messages
3
Trophies
0
Age
44
XP
51
Country
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!
 

SkyBladeCloud

Well-Known Member
Member
Joined
Oct 7, 2010
Messages
452
Trophies
0
Age
33
XP
1,420
Country
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.
 

tuandragon

New Member
Newbie
Joined
Mar 21, 2014
Messages
3
Trophies
0
Age
44
XP
51
Country
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!
 

gwapogi187

New Member
Newbie
Joined
Apr 28, 2014
Messages
3
Trophies
0
Age
31
XP
42
Country
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)
 
  • Like
Reactions: mhunteralexander

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Psionic Roshambo @ Psionic Roshambo: https://www.youtube.com/watch?v=pkYA4rALqEE