YKCMP compressed files

Discussion in 'PSP - Hacking & Homebrew' started by Eldinen, Apr 8, 2017.

  1. Eldinen
    OP

    Eldinen Member

    Newcomer
    34
    29
    Mar 30, 2009
    Spain
    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
     
  2. Eldinen
    OP

    Eldinen Member

    Newcomer
    34
    29
    Mar 30, 2009
    Spain
    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 :(
     
  3. jjjewel

    jjjewel GBAtemp Maniac

    Member
    1,009
    293
    Dec 17, 2009
    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.
     
  4. flame1234

    flame1234 GBAtemp Advanced Fan

    Member
    711
    399
    May 17, 2009
    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, Apr 9, 2017
  5. Eldinen
    OP

    Eldinen Member

    Newcomer
    34
    29
    Mar 30, 2009
    Spain
    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.
     
  6. flame1234

    flame1234 GBAtemp Advanced Fan

    Member
    711
    399
    May 17, 2009
    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.

    — Posts automatically merged - Please don't double post! —

    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
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      108.8 KB
      Views:
      36
    • output.png
      output.png
      File size:
      38.2 KB
      Views:
      35
    Eldinen likes this.
  7. Eldinen
    OP

    Eldinen Member

    Newcomer
    34
    29
    Mar 30, 2009
    Spain
    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, Apr 9, 2017
  8. flame1234

    flame1234 GBAtemp Advanced Fan

    Member
    711
    399
    May 17, 2009
    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, Apr 9, 2017
    Eldinen likes this.
  9. Eldinen
    OP

    Eldinen Member

    Newcomer
    34
    29
    Mar 30, 2009
    Spain
    Thanks! I have worked in the Swizzle algorithm, and it works!
    Really thank you frame1234!
     
    Last edited by Eldinen, Apr 10, 2017