Hacking Phantom Kingdom Portable: English Translation

Linka

Well-Known Member
Member
Joined
Sep 13, 2013
Messages
248
Trophies
0
Age
34
XP
189
Country
United States
that kinda sucks that english audio is out of the question unless we rip our own ps2 cd's
dont let that discourage you chep chep! we still waiting for the epic patch.

im doing my best playing PKP with 0 japanese skills. XD i have the habbit of trying to heal a friendly unit, then i kill em with a book flare or something :/ XD dont know the attacks


I recommend maybe keeping a note of your character's abilities. If you can find a Japanese keyboard webapp for instance (like http://www.lexilogos.com/keyboard/hiragana.htm or the sort), you can also try to transcribe some of the moves down to notepad or something and then put down what the skill might be for now. It's basically what I did for skills for LPR before the patch!
 

heatblade12

Well-Known Member
Newcomer
Joined
Dec 15, 2013
Messages
53
Trophies
0
Age
30
XP
93
Country
Canada
I recommend maybe keeping a note of your character's abilities. If you can find a Japanese keyboard webapp for instance (like http://www.lexilogos.com/keyboard/hiragana.htm or the sort), you can also try to transcribe some of the moves down to notepad or something and then put down what the skill might be for now. It's basically what I did for skills for LPR before the patch!

what i did was more or so make a mental note of the ability use, ie "RES"and its location, third from top? forth from bottom? eh, but the first time is always the bad part

and well... i do not use an emulator, i play with my PSP 2000 :D
 

Linka

Well-Known Member
Member
Joined
Sep 13, 2013
Messages
248
Trophies
0
Age
34
XP
189
Country
United States
I played LPR first on my own PSP (I own the game, along with PKP) and how I got through any of it was by transcription. It's a bit of work but it's nice to have a reference sheet, you know?
 

heatblade12

Well-Known Member
Newcomer
Joined
Dec 15, 2013
Messages
53
Trophies
0
Age
30
XP
93
Country
Canada
a reference sheet.. now thats an idea, i can just google the attacks from makai kingdom wiki or something and then follow that up. until they are translated hehe,
 

Cyan

GBATemp's lurking knight
Former Staff
Joined
Oct 27, 2002
Messages
23,749
Trophies
4
Age
45
Location
Engine room, learning
XP
15,648
Country
France
Sorry that it's making it more complicated. nobody wants issues with developers/publishers.
It shouldn't be too hard to follow a guide to extract from PS2 (a simple file copy from disc, it's not compressed/encrypted), convert the audio format if needed (a simple batch to run by the end user), inject the audio in PSP version with UMDGen, and recreate the iso.

I remember someone released an audio patch for Rhapsody DS, it was big and not very legal ... but it was available for users who knew where to look.


Linka: Yes, I prefer starting from the first game in the series.
I don't know the newer games, so it should be fine to play the old one. My only problem is I don't have enough time to play all the games I want, and I heard Disgaea games were very long :lol:
I'm still playing LPR, chapter 8 ... I try to level up to beat Lv100 boss.
/me look at his game wishlist and backlog... :cry:
 

Linka

Well-Known Member
Member
Joined
Sep 13, 2013
Messages
248
Trophies
0
Age
34
XP
189
Country
United States
Well at the least, starting with Disgaea 1 on the PSP works out if you wanna get it done a little faster/level up quickly. There's a glitch in the PSP entry of the series where a specific type of equip, the Foresight, which is glasses (meaning you would have to pass the "sell glasses in stores" bill along with the "more expensive items" bills) that have a bit of a bug in them. Basically, it results in them having super maxed out Innocents (which gives specific abilities or stat boosts) on there that could raise how much EXP or Mana or whatever you'd get by equipping them, but you need to be careful as a result. I think if you equip only one Foresight, your ability to move spaces shoots down like a rock, but if you equip two, it negates itself on that point.
 

SkyBladeCloud

Well-Known Member
Member
Joined
Oct 7, 2010
Messages
452
Trophies
0
Age
33
XP
1,420
Country
Since people seems to be very interested in this, i had another look (deeper this time) and I can say IMY are indeed partially compressed images, I got the algorithm, it's a dictionary-based compression (looks like a huffman variant, though I haven't confirmed this). Shouldn't be such a big deal to write a decompressor.

Still, here is a very quick, semi-manual decompression test, of the very first image in the game, does it ring a bell? :)

2f09gf8.png

*Note: It's a very bright image that is supposed to appear in a dark background, otherwise it might be difficult to see :P

~Sky
 

Linka

Well-Known Member
Member
Joined
Sep 13, 2013
Messages
248
Trophies
0
Age
34
XP
189
Country
United States
Difficult nothing, I had to double check so many times that there was actually an image there!
 

SkyBladeCloud

Well-Known Member
Member
Joined
Oct 7, 2010
Messages
452
Trophies
0
Age
33
XP
1,420
Country
haha, yeah, well... Here is one that you will recognize more easily ^^

r8dt7d.png


EDIT:

Aww men... The frgging color palette is interlaced too... Anyway, this is how it looks after processing it as well (after applying palette unswizzling it shows the correct result):

nci629.png


~Sky
 

heatblade12

Well-Known Member
Newcomer
Joined
Dec 15, 2013
Messages
53
Trophies
0
Age
30
XP
93
Country
Canada
amazing, im happy that we now have more eyes on this project!
just want to say sky is pretty cool for looking into this a bit deeper :)
 

ChepChep

Well-Known Member
OP
Member
Joined
Feb 9, 2011
Messages
611
Trophies
0
XP
876
Country
United States
Cyan,

Personally I am not a big fan of the english voice overs but had a few requests for it for PKP. Completely forgot about the issues with voices since I am just creating a file that creates a list of differences between the two versions.

I doubt I will be able to make a tutorial for people to do it themselves. It will require acquiring the PS2 voices, converting vag to wav and then to SPS and matching up the PSP and PS2 files (they all have different names). Then inserting them into a file container called data.dat which has many checks inside the file and then finally insert the data.dat file into the iso. It is very technical and most people will not be able to do it since it will require running python scripts and many different editing programs.

SkyBladeCloud,

Any hints how you decoded the IMY format?
 
  • Like
Reactions: Star-scream

Cyan

GBATemp's lurking knight
Former Staff
Joined
Oct 27, 2002
Messages
23,749
Trophies
4
Age
45
Location
Engine room, learning
XP
15,648
Country
France
I see, it's more complicated than a simple file format conversion.
A single batch to do all the operation is probably not possible or easy to do.

I don't know if a lot of other projects did audio swap (with translation patch, not undub only), it would be interested to see which method they used: releasing a patch with audio in it, a tools to automate the conversion, or a guide, two different patches (text only, text+audio)?
How are most undub projects doing it?
 

Densetsu

Pubic Ninja
Former Staff
Joined
Feb 2, 2008
Messages
3,434
Trophies
0
Location
Wouldn't YOU like to know?
Website
gbatemp.net
XP
2,707
Country
United States
Translation team:
Programmer: ChepChep, Ignis00
Translator: ChepChep, Ignis00
My biggest issue is that I do not know Japanese. I have been using the PS2 script for games to translate the PSP games and then finding someone who is willing to translate the extra content. I not sure I am willing to tackle a game yet that is all in Japanese.
Then you are not a translator.
I just also got the complete translation of the bonus material from my translator for LPR.
If you're using the same translator from LPR, then you should make sure that hatsubai is properly credited in the OP of this thread.

It may not seem like a big deal, but I take issue with it because I've spent weeks translating for others in the past and none of my work was credited. If someone is going to do some unpaid work for you, then the least you can do is make sure his work gets recognized. And it's a huge pet peeve among translators when someone who doesn't know the source language (in this case, Japanese) calls himself a "translator."
 

ChepChep

Well-Known Member
OP
Member
Joined
Feb 9, 2011
Messages
611
Trophies
0
XP
876
Country
United States
Densetsu,

Hatsubai helped on LPR but has not translated a single word in PKP.

Ignis00 has done all the work and I have done some using the English from the PS2 version of the game.

For example I have done the entire eboot.bin myself but Ignis00 wants it redone.

So far there has only been the two of us working on this project with a little help from SkyBladeCloud possibly on the IMY format.
 

heatblade12

Well-Known Member
Newcomer
Joined
Dec 15, 2013
Messages
53
Trophies
0
Age
30
XP
93
Country
Canada
its scary when credits and legal rights are introduced, but chep chep is amazing at defending himself...

Densetsu,

Hatsubai helped on LPR but has not translated a single word in PKP.

Ignis00 has done all the work and I have done some using the English from the PS2 version of the game.

For example I have done the entire eboot.bin myself but Ignis00 wants it redone.

So far there has only been the two of us working on this project with a little help from SkyBladeCloud possibly on the IMY format.


i could not of said it better myself, but of course even small details are sometimes overlooked and everybody makes mistakes, even myself believe it or not, but i hope we dwell in a friendly community where these mistakes are forgiven, (provided there fixed)
 

SkyBladeCloud

Well-Known Member
Member
Joined
Oct 7, 2010
Messages
452
Trophies
0
Age
33
XP
1,420
Country
Hum, so I was about to suggest extracting the whole script from the PS2 version and automatically inserting it in the PSP version. Even if file names and text distribution are different in both versions, one can always sort everything using some brute force coding with text comparing. Even if the Japanese text is a little bit different in both versions, we have the Levensthein distance algorithm for that (Yeah, I've done automatic "translations" in the scene, using official localizations from different versions of a same game xD).

BUT... Looks like everything one could get from the PS2 versions is already on PSP so nvm xD.

Now on IMY format...

***In the beginning they were all regular graphics (like any PNG one can come across), more specifically, RGBA8888 images.
***Then they were reduced to 8, or 4 bit indexed images (depending of the image size and color count), keeping the alpha channel, and coded in a custom (very simple) format:

---A header with some information such as signature and resolution.
---A color palette that can be either 16 or 256 colors (4/8 bits pixels respectively)
---The pixels themselves, each one being an index to the color palette, which actually holds RGBA8888 colors.

***Then they were compressed adding some compression flags to the header.

And that's an IMY. Now all that has to be reverted... It actually sounds harder that it is.

First step... Decompression! Well, this can be done looking at the game's ASM code in a MIPS debugger (PPSSPP/JPCSP). You can also use a dissembler, but it's kind of a pain to find anything just with it. Monitoring the ram we can tell when an image is being decompressed and look the routine writing to the output buffer (the decompressiion routine).

In our specific case, the color palette is uncompressed in IMY files, so we trace the pixels decompression routine. An here we have it:

Code:
z_un_08825b14:
 
    addiu    sp,sp,-0x10
    li    a0,-0x2
    mult    t0,a3
    subu    t1,zero,a3
    sw    a0,0x0(sp)
    addiu    a0,t1,-0x2
    sw    t1,0x4(sp)
    addiu    a3,t1,0x2
    sw    a0,0x8(sp)
    sw    a3,0xC(sp)
    lhu    a3,0x0(a2)
    mflo    a0
    addu    a0,a1,a0
    bne    zero,a3,pos_08825B68
    addiu    a2,a2,0x2
    addiu    a3,a2,0x2
    lhu    t0,0x0(a2)
    lhu    t1,0x0(a3)
    addiu    a2,a3,0x2
    sll    a3,t1,0x10
    or    a3,t0,a3
 
pos_08825B68:
 
    addu    t0,a3,a2
    lbu    a3,0x0(a2)
 
pos_08825B70:
 
    addiu    t1,a3,-0x10
    bgez    t1,pos_08825BAC
    addiu    a2,a2,0x1
    addiu    a3,a3,0x1
 
pos_08825B80:
 
    lh    t1,0x0(t0)
    addiu    t0,t0,0x2
    sh    t1,0x0(a1)
    addiu    a3,a3,-0x1
    bne    zero,a3,pos_08825B80
    addiu    a1,a1,0x2
    sltu    a3,a1,a0
    bnel    zero,a3,pos_08825B70
    lbu    a3,0x0(a2)
    b    pos_08825C24
    nop
 
pos_08825BAC:
 
    addiu    a3,a3,-0xC0
    bgezl    a3,pos_08825BE8
    sra    t1,a3,0x4
    addu    a3,t1,t1
    subu    a3,zero,a3
    addu    a3,t0,a3
    lh    a3,-0x2(a3)
    sh    a3,0x0(a1)
    addiu    a1,a1,0x2
    sltu    a3,a1,a0
    bnel    zero,a3,pos_08825B70
    lbu    a3,0x0(a2)
    b    pos_08825C24
    nop
    sra    t1,a3,0x4
 
pos_08825BE8:
 
    sll    t1,t1,0x2
    addu    t1,sp,t1
    lw    t1,0x0(t1)
    andi    a3,a3,0xF
    addiu    a3,a3,0x1
    addu    t1,a1,t1
 
pos_08825C00:
 
    lh    t2,0x0(t1)
    addiu    t1,t1,0x2
    sh    t2,0x0(a1)
    addiu    a3,a3,-0x1
    bne    zero,a3,pos_08825C00
    addiu    a1,a1,0x2
    sltu    a3,a1,a0
    bnel    zero,a3,pos_08825B70
    lbu    a3,0x0(a2)
 
pos_08825C24:
 
    jr    ra
    addiu    sp,sp,0x10

The important registers you must take into account are:

--- a1 -> Output buffer (obviously empty at the beginning of the routine xD)
--- a2 -> input buffer (the one with the compressed pixel data)
--- a3 -> image width (from the IMY header)
--- t0 -> image height (from the IMY header as well)

Once the routine returns the output buffer contains the pixels decompressed.

Now we have color palette, pixels and dimensions, we can reproduce an image right? Yeah... but no, reproducing the image just like that would result in garbage, as both parts (pixels and palette) are interlaced. There is no standard way of interlacing and depending on the image color depth, color count, and dimensions you may need different interlacing implementations. There is no way to get the interlacing algorithm out of the game's data, since this is done at hardware level, and no one is gonna code a PSP graphic memory simulator just for this :)...

...Mainly because for 100% of cases you can tweak this code and get a perfectly deinterlaced pixel matrix:

Code:
        public static void UnSwizzle(ref byte[] Buf, int Pointer, int Width, int Height)
        {
            // Make a copy of the unswizzled input
            byte[] Swizzled = new byte[Buf.Length - Pointer];
            Array.Copy(Buf, Pointer, Swizzled, 0, Swizzled.Length);
 
            int rowblocks = (Width / 16);
 
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    int blockx = x / 16;
                    int blocky = y / 8;
 
                    int block_index  = blockx + (blocky * rowblocks);
                    int block_address = block_index * 16 * 8;
 
                    Buf[Pointer + x + (y * Width)] = Swizzled[block_address + (x - blockx * 16) + ((y - blocky * 8) * 16)];
                }
            }
        }

No you can reproduce the graphic using the unswizzled pixels and the color palette right? Yeah... but... kinda no, as color would be incorrect (see the comparison in my previous post), so yeah, time to do the same to the color palette. This is due to the fact that both sections are loaded in graphic memory before being "decompressed" to a full color texture (then the graphic pipeline rasterizes everything and the PSP's screen shows the result)

In general, one does not treat the color palette as another image, so an alternative is to simply rearrange colors on it. Note that only 256 color-palettes are interlaced; 16 color ones are two small and fit in a single memory block (thus no interlacing needed). I use this code to rearrange colors (each color is supposed to be a 4bytes structure containing RGBA values, 8 bits per channel):

Code:
        private void sort(Color[] colors)
        {
            if (colors.Length != 0x100)
                return;
            int ptr = 0;
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    Color temp = colors[ptr + 8 + j];
                    colors[ptr + 8 + j] = colors[ptr + 16 + j];
                    colors[ptr + 16 + j] = temp;
                }
                ptr += 32;
            }
        }

And that's it, now you can recreate the image with both the pixels and the palette deinterlaced, right? RIGHT!.

Keep in mind that when editing you'll have to either:

---Limit the edition to the already existing colors
---Convert the image to full color and then quantize back to 256 / 16 colors (depending on the original color count), always keeping the alpha channel (there are a lot of programs that have problems quantizing alpha channels, it's just a matter of choosing the right ones).

Then, when reinserting everything, you'll notice that there is a step where we'll have to re-compress the data, but we have no compression algorithm, reverting the decompression one would be much of a pain and the game does not contain an IMY compression algorithm (it only needs to decompress them).

However, if you get the idea behind the compression scheme, you'll notice that there are some uncompressed blocks. We can simply put the whole edited file in uncompressed blocks, the resulting file will be bigger (since it has decompressed data plus some block descriptors), but it should work in-game just fine. This is known as Fake-Compression ^^"

But that's... another story ^^

~Sky
 

heatblade12

Well-Known Member
Newcomer
Joined
Dec 15, 2013
Messages
53
Trophies
0
Age
30
XP
93
Country
Canada
found out the heaven's bliss is in fact a lucky doll... for someone who beat makai kingdom ps2, and owns PKP and put in 100's of hours, i still feel like such a noob... XD
 

ChepChep

Well-Known Member
OP
Member
Joined
Feb 9, 2011
Messages
611
Trophies
0
XP
876
Country
United States
SkyBladeCloud,

I have been trying to follow your guide to IMY format and I an running into issues with compressed pixel data.

Here is a screenshot of my understanding of the IMY file format in an hexeditor:
1zeuzdh.jpg
So I have tried putting the 0x04 at location 0x20 into the ASM code as the a2 (input buffer w/ pixel data) and when I go through the routine, I cannot get any values out for a1 (output buffer)
I can see it is outputting to the output buffer A1 in three different places:

pos_08825B80:
...
sh t1,0x0(a1)

pos_08825BAC:
...
sh a3,0x0(a1)
pos_08825C00:
...
sh t2,0x0(a1)
Does the assembly run from top to bottom and then branch based on the various logical branching statements such as bne, bnel, b, bgezl?

I have been using this page as reference for all the MIPS commands:
http://en.wikipedia.org/wiki/MIPS_instruction_set
Do you have any pseudo code for the algorithm used?

Thanks,
-ChepChep
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: https://youtu.be/MddR6PTmGKg?si=mU2EO5hoE7XXSbSr