vn-tools / arc_unpacker

CLI tool for extracting images and sounds from visual novels.
GNU General Public License v3.0
562 stars 83 forks source link

Game Request: [Akabei Soft2][100624]Kourin no Machi, Lavender no Shoujo #45

Closed fro0116 closed 8 years ago

fro0116 commented 8 years ago

VNDB: https://vndb.org/v3095

It's an older game with an awesome soundtrack that has never been released AFAIK, so I'm trying to extract it instead.

I gave this game a try with --plugin=noop but the resulting files were unreadable. It's a kirikiri/xp3 game, so I'm guessing it will probably require a custom plugin, but unfortunately I have no idea how to proceed further because that's the extent of my technical knowledge.

Let me know if you need me to upload the data files or tpm file somewhere or if there's anything else I can do to help!

Thanks!

rr- commented 8 years ago

XP3 should be easy to work with - I'll take a look tomorrow or at Thursday. It probably uses CXDEC, which changes from game to game.

rr- commented 8 years ago

Unfortunately it's not CXDEC == it isn't trivial == needs a good number of hours to reverse fully. Since I'm short of time these days, maybe you could ask GARbro's maintainer to support this game faster?

If you do, here's some info I've collected in preliminary analysis, which should save them a bit of work:

  1. The entry point to the whole thing seems to be located at lavender.tpm+0xE70. Specifically, it can be reached by analyzing references to zlib's uncompress function, and comparing it to kirikiri source code by tracking down usages of TVPXP3ArchiveExtractionFilter upwards.
  2. I also noticed the game executes code from dynamically allocated regions, which probably means that it uses dynamic assembly like CXDEC did. Also, it too uses "encryption control block" as well as two constants in form of (x & A) + B, all looking familiar to CXDEC, but don't let it fool you - later it does everything differently, and I think it starts with compiling repeatedly mini-functions that serve as LCGs at a later time.
  3. To prove without doubt that it's not CXDEC, there's not even one mention of 0x41C64E6D, which served an essential role in the CXDEC as a part of its RNG.

Haven't progressed much further than that and I don't know when I'll have more time to dive deeper. :persevere:

fro0116 commented 8 years ago

Thank you so much for taking the time to look into this @rr-!

I have shared your findings with the GARbro devs as you suggested in the following issue: https://github.com/morkt/GARbro/issues/26

morkt commented 8 years ago

it's CXDEC, constants are

  Mask = 0x181,
  Offset = 0x635,
  PrologOrder     = { 2, 1, 0 },
  OddBranchOrder  = { 4, 0, 1, 5, 2, 3 },
  EvenBranchOrder = { 7, 5, 2, 3, 6, 1, 4, 0 },
rr- commented 8 years ago

Oh? I was pretty sure it wasn't, I feel embarrassed... sorry for the trouble, @morkt.

rr- commented 8 years ago

Added dc4da95adab477c05886186ca2ebd8faf938ea8b + 4ea2eda63105f6b096120778972e23397fece8e1. There's problem with nightly builds server, but the ISP is already sorting this out, so it should be probably up again tomorrow.