Hacking YKCMP compressed files

Eldinen

Well-Known Member
OP
Newcomer
Joined
Mar 30, 2009
Messages
45
Trophies
0
Location
Spain
XP
440
Country
Hi!

I am working in some YKCMP files, I saw ChepChep and jjjewel worked on this format

I used his tool to decompress another YKCMP files from other game of NIS. And it works sometimes but there are other files in the same game where I think it is not working.

I attached a zip with 2 compressed YKCMP files (and decompressed too with the ChepChep tool), the same from the english and japanese version of the game, and when I replace one for the other, the game main title graphics change from english to japanese.

So I think we can be sure this file has the main title graphics, but after using the tool, I cannot see the graphics, I use CrystalTile2 to look for the graphics, and as I said, it works in other files and I see the graphics, but not in this one.

Maybe the format here its a bit different, not sure. can someone see if the format in this YKCMP is different?

The tool to decompress YKCMP is here:

Thanks for everything
 
  • Like
Reactions: Luatsenpai

Eldinen

Well-Known Member
OP
Newcomer
Joined
Mar 30, 2009
Messages
45
Trophies
0
Location
Spain
XP
440
Country
I have been investigating more. I attach a new zip with 4 files, the same from before but this time one is the PC version and the other one is from playstation version.

I added a decompressed file too in the same zip, and as you can see, the PC version file is smaller than the PS version but when I decompress both files, the PC version file is bigger than the PS version, and I am able to see graphics inside the PC version file but not inside the PS version, so it seems the PS version is not decompressed well.

I think the YKCMP format is a bit different in the PS version, but I do not see the difference :(
 

jjjewel

Well-Known Member
Member
Joined
Dec 17, 2009
Messages
1,010
Trophies
0
XP
522
Country
United States
I don't have time to help with this, but what hackers like me (I mean hackers who don't know ASM) usually do in this case would be to play the game on emulator and check for decompressed graphics from memory dump. Then compare the compressed and decompressed files and try to figure out the decompression algorithm.

Another way is to get help from people who know ASM and they can trace how the game decompress the file.
 

flame1234

Well-Known Member
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States
What game?
Run GE debugger for title graphic draw because I want to know the resolution of the title graphic texture. Looks like 512 x 512.
 
Last edited by flame1234,

Eldinen

Well-Known Member
OP
Newcomer
Joined
Mar 30, 2009
Messages
45
Trophies
0
Location
Spain
XP
440
Country
Yes, that is what I am trying to do, get a memory dump of this game.

I create this thread in the weong section, its a ps vita game, we cannot use GE Debugger. Anyway the resolution is 1024 x 512, you can see the title graphics texture in the pc file.
 

flame1234

Well-Known Member
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States
Here is what I got for the PC version image. It looks like 1024x1024. To me, anyway.
I bet the Vita one is 512x512. The first 0x400 is palette data and the next 0x40000 is pixel data. It's enough for a 512x512 image.

I'm going to try unswizzling.

--------------------- MERGED ---------------------------

I got it... I hope. That looks like something. See attached image.

I worked just lightly on a Vita app before. I wanted to extract the graphics for personal use (not for use in-game or anything). In that game, images, or at least the pixel data for the images was swizzled and I had to unswizzle them. I modified the program I wrote back then to work with your image.

Here's the program I used.
https://pastebin.com/VcEYMcf5
Let me know if you need help understanding how it works. You'll need to modify it some if you're doing a large batch. You need to figure out how to get programmatically the width and height. The data that's after 0x40400 in your file: I think this is image meta data but I'm not sure. You might be able to use that.

The unswizzling part of the program, which is most of it, heavily based on this unswizzling code I found somewhere else:
http://forum.xentax.com/viewtopic.php?p=21148#p21148
 

Attachments

  • 1.jpg
    1.jpg
    108.8 KB · Views: 267
  • output.png
    output.png
    20 KB · Views: 285
  • Like
Reactions: Eldinen

Eldinen

Well-Known Member
OP
Newcomer
Joined
Mar 30, 2009
Messages
45
Trophies
0
Location
Spain
XP
440
Country
Thanks flame1234! It looks great!

I have installed the PyPNG, I have never used it, but I am getting an error:
File "png.py", line 253, in check_palette
if int(x) != x or not(0 <= x <= 255):
ValueError: invalid literal for int() with base 10: ''

I am using the same file as you, python 2.7 and the last version of pypng https://github.com/drj11/pypng

Its a problem with the palette, if I change the PNG.Write line to
w = png.Writer(len(p[0]), len(p), greyscale=True)
I get the image. Am I doing something wrong or using a wrong version?

By the way, how could I encode this again to create the original format file again?
 
Last edited by Eldinen,

flame1234

Well-Known Member
Member
Joined
May 17, 2009
Messages
734
Trophies
0
XP
957
Country
United States
I use Python 3.6, sorry about that.

I don't know about recoding or converting it back to swizzled. There is a hint regarding this at the Xentax link I posted earlier. I did not program it up for Python because I didn't need to for my application.

PyPNG docs here: https://pythonhosted.org/pypng/png.html

PyPNG is used because I need an easy way to output an image that can be read by an external program. Because it is an extreme pain to use TiledGGD every time.

You are setting up an output format with the writer object and then feeding it boxed rows of pixels.
The chunks subroutine breaks up things into boxed rows.

The palette thing feeds it boxed lists of 4 values each.
-------------------------------------------
The first 0x400 is palette data. The next 0x40000 is bitmap data. The rest is metadata which I don't think you need to change.

Edit the image and export it using indexed colors (256-color) to BMP. Once you have that:
Extract palette data
Extract bitmap data
Swizzle bitmap data
Copy metadata from original
Output image file - it's just palette + bitmap + metadata

And it should work.

You should do the roundtrip just to make sure it worked (extract your edited image using the unswizzle program), then compress it and try it on your Vita.
 
Last edited by flame1234,
  • Like
Reactions: Eldinen

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • K3Nv2 @ K3Nv2:
    I'll reformat and have a 3tb raid0 m. 2 at least
    +1
  • K3Nv2 @ K3Nv2:
    Lmao that sold out fast
    +1
  • Veho @ Veho:
    Yeet the cat.
    +1
  • K3Nv2 @ K3Nv2:
    Good idea
    +1
  • The Real Jdbye @ The Real Jdbye:
    i thought everybody knew cocktails are like 75% ice
  • Veho @ Veho:
    Yeah but not like this.
  • Veho @ Veho:
    It's not like they're complaining that their Slurpee is 99% ice or something, but if the cocktail calls for "shot of vodka, shot of vermouth, shot of gin, shot of Campari, three shots of juice, squirt of lemon" and ends up being a thimbleful of booze, that's a problem.
  • The Real Jdbye @ The Real Jdbye:
    the funny thing is cocktails in norway are only allowed to have 1 20ml shot of booze
  • The Real Jdbye @ The Real Jdbye:
    so..... yeah
  • The Real Jdbye @ The Real Jdbye:
    we're used to only having a thimbleful of booze
  • Veho @ Veho:
    Booo.
  • The Real Jdbye @ The Real Jdbye:
    same thing if you want whisky on the rocks or something, you can't get a double
  • The Real Jdbye @ The Real Jdbye:
    but you could buy as many shots of whisky (or anything else) as you want and ask for a glass of ice and pour them in
  • The Real Jdbye @ The Real Jdbye:
    it's dumb
  • Veho @ Veho:
    Maybe.
  • Veho @ Veho:
    There was a comparison of the number of Ibuprofen poisonings before and after they limited the maximum dosage per box or per pill (i'll look that up). No limit on the number of boxes you can still buy as many as you want, so people argued it was pointless.
  • Veho @ Veho:
    But the number of (accidental) poisonings dropped because drinking an entire package of ibuprofen pills went from "I need a new liver" to "I need a new box of Ibuprofen".
  • Veho @ Veho:
    Here we have ketoprofen that used to be prescription-only because of the risk of toxic dosages, but then they halved the dose per pill and sell them in bottles of six pills apiece instead of twenty and it doesn't need a prescription any more. Yes you can buy more than one bottle but people simply don't.
  • Psionic Roshambo @ Psionic Roshambo:
    Usually accidentally overdose of ibuprofen here is from people taking like cold medicine then ibuprofen for a headache and the combination is over what they need
    Veho @ Veho: https://imgur.com/gallery/QQkYnQu