theKeithD / thmj3g-tools

Collection of tools to unpack and repack data used by the D.N.A.Softwares doujin game, Touhou Unreal Mahjong 3rd Generation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

thmj3g-tools

Tools to unpack and repack data files for Touhou Unreal Mahjong 3rd Generation, produced by D.N.A.Softwares. The intent behind creating these tools is to create an English translation of the game.

This game uses the AIMS 2D game engine, which in turn makes heavy use of the (now defunct) D3D library Luna. A few of the utilities included in both the AIMS SDK as well as the bin/ directory of this repository come from the Luna library, specifically LLZSS.exe and LPACK.exe.

The .lua files contained within the packfiles of thmj3g.p (and likely those of certain other games) are precompiled, so a disassembler (and an understanding of LASM) will be necessary to modify them. Lua Assembly Tools is recommended for disassembling and recompiling these files.

To use blowpack or lunpack -b, you will need to provide a 448-bit key file named thmj3g.key. The file should be 56 bytes long and contain a binary representation of the key.

blowpack

Encrypts/decrypts a file using a non-chaining Blowfish implementation and adds/strips a bogus LZSS header as necessary. The bogus header is used by thmj3g's loader to determine the length of the original unpadded file. ...yes, really. It's not compressed at all.

  • If the file has an LZSS header, it is assumed to be encrypted.
  • If an encrypted file is passed in with no switches or invalid switches, the file will be ignored. (useful for batch scripts).
  • If an unencrypted file is passed in with the -d switch , the -d switch will be ignored. (also useful for batch scripts).

Usage

blowpack filename [-d]

  • -d will attempt to strip the LZSS header and decrypt the file. The program is smart enough to encrypt only what is needed, and decrypt only what is needed.

The file is overwritten, so be careful!

TODO

  • Allow keyfile to be specified as an argument

lunpack

Unpacker utility for games created using the AIMS 2D game engine by D.N.A.Softwares.

Usage

lunpack packfile.p [-b/-l]

  • -b will decrypt files using non-chaining Blowfish. (used by Touhou Unreal Mahjong 3rd Generation)
  • -l will attempt to decompress files in the packfile using LLZSS.exe. (used in other games)

The two switches cannot be combined. Choose one or the other.

Outputs files into packfile/ (or packfile-music/ if processing a .mus file).

TODO

  • Allow keyfile to be specified as an argument

Notes and Credit

LLZSS.exe and LPACK.exe from the AIMS 1.8.0 toolkit (and subsequently, the Luna library) are included for convenience.

The Blowfish implementation used for these tools is Paul Kocher's version, written in 1997.

The copies of blowpack.exe and lunpack.exe in this repository were compiled on Win7 x64 using MinGW.

About

Collection of tools to unpack and repack data used by the D.N.A.Softwares doujin game, Touhou Unreal Mahjong 3rd Generation.


Languages

Language:C 100.0%