Code Monkey home page Code Monkey logo

freemote's Introduction

FreeMote

Build Status

Managed EMT/PSB tool libs.

Download FreeMote Toolkit

It's required to attach the text of FreeMote.LICENSE with your release if you're using FreeMote codes or binaries.

About PSB

FreeMote is a set of tool/libs for M2 Packaged Struct Binary file format. The file header usually starts with PSB/PSZ/mdf, and the file extensions usually are .psb|.psz|.mdf|.pimg|.scn|.mmo|.emtbytes|.mtn|.dpak|.psb.m.

However, there are some other file formats using the same extensions. They are NOT supported:

  • .psb: PlayStation Binary (PS3) | PhotoShop Big (Photoshop)
  • .mdf: Mirror Disc File (Alcohol 120%) | Primary Data File (MSSQL)
  • .mtn: Motion File (Live2D)

Before submitting an issue or asking a question, please check your PSB file header with a hex editor.

Components

FreeMote

Basic functions. Decrypt or encrypt EMT PSB files.

FreeMote SDK

Special API libs for EMT engine, which take pure (unencrypted) PSB files as input.

FreeMote.Psb

Parse and generate PSB.

FreeMote.PsBuild

Compile and decompile PSB files. Convert PSB among different platforms. Recover EMT projects.

FreeMote.Plugins

External/Experimental features. Read wiki for usages.

FreeMote.Purify (Unreleased)

Infer and calculate the key used by EMT PSB file just from the PSB file (rather than get from engine).

Tools

Read wiki for detailed usages.

EmtConvert (FreeMote.Tools.EmtConvert)

Convert EMT PSB files.

PsbDecompile (FreeMote.Tools.PsbDecompile)

Decompile PSB files to json files and resources.

PsBuild (FreeMote.Tools.PsBuild)

Compile PSB json files and resources to PSB.

EmtMake (FreeMote.Tools.EmtMake) (Preview)

Convert an EMT PSB to MMO project. The output file is always licensed under CC BY-NC-SA 4.0. No commercial usage allowed!

FreeMote Viewer (FreeMote.Tools.Viewer)

Open and render EMT pure PSB. This tool is powered by FreeMote.NET.

Build

This project requires VS 2022 and .NET 4.8 to build.

FreeMote.Plugins / FreeMote.Plugins.x64 require a MyGet feed to get external libs made by us. If you don't need FreeMote Plugins, you can unload Plugins projects and remove them from other projects' reference.

To install our own nuget packages, add this feed to your IDE:

https://www.myget.org/F/monarchsolutions/api/v3/index.json

Test

Get PSB samples for test and research from FreeMote.Samples.

Thanks for everyone who provided these samples!


by Ulysses ([email protected])

Creative Commons License
FreeMote is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0).

Some outputs of FreeMote (mmo/psd etc.) are transformed from FreeMote code and are considered as Adapted Material. Therefore they're always licensed under CC BY-NC-SA 4.0. wiki

Issue Report · Pull Request · Wiki

Support Us

Thanks

freemote's People

Contributors

ulysseswu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

freemote's Issues

Recent update broken the CLI command --extract

For Version 2.3 and Version 2.5 FreeMote PsbDecompile
PsbDecompile will ignore extract command and directly output tlg file, like original C++ version PsbDecompile.
But it works fine on version 2.0.

问题描述: 2.5和2.3版本PsbDecompile的extract参数无效。
程序行为和原始C++版本一致,直接输出tlg文件。
游戏类型:M2_KrkrZ
Test Game:
CafeStella (Yuzu Soft)
image
image

Implement win/common <-> krkr platform conversion

PSB in krkr spec is quite different from other specs.
For many PSBs from krkr games, we need a way to convert it to win/common spec to use.

This may need a lot of time, so if you want to help, just do it.

I think win/common -> krkr is easier because it is going to splits textures rather than packs them. But krkr -> win/common is more useful to me. What do you think?

Nekopara vol. 1-3 [Nintendo Switch] (*psb.m and *.bin)

Hey. I encountered one problem when trying to unpack scenario_info.psb.m and scenario_body.bin using Freemote. I also tried using exm2lib but it didn't help either.
I think that in order to unpack these files I need to decrypt them first using the key and key size, but the problem is that I don't know where to find the key and key size for the switch version.
Maybe you can decrypt them without using the key. Or Freemote does not support switch formats at all?

samples

[Question] Support UI/Menu PSB?

  1. what game are you test on?
  2. does it support non-emote? if yes, will you add support on it? cuz in my case, this tools only compatible with Dracu-Riot, but not with other kirikiri games... even though they have the same format (PSB)

Unable to unpack PSB from Kami-machi Sana-chan

i have tried all parameter already, but it gave me this error...

FreeMote

PSB Decompiler
by Ulysses, [email protected]
6 Plugins Loaded.

Decompiling: ap_bup_yu02_02
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at FreeMote.Psb.PsbArray.get_Item(Int32 index)
at FreeMote.Psb.PSB.LoadFromDullahan(Stream stream, Int32 detectSize)
at FreeMote.PsBuild.PsbDecompiler.Decompile(String path, PSB& psb, Dictionary2 context) at FreeMote.PsBuild.PsbDecompiler.DecompileToFile(String inputPath, PsbImageOption imageOption, PsbImageFormat extractFormat, Boolean useResx, Nullable1 key)
at FreeMote.Tools.PsbDecompile.Program.Decompile(String path, Boolean extractImage, Boolean uncompress, Boolean usePng, Nullable`1 key)
Done.

here some sample: kamisana.zip

[New game! The Challange Stage] Support MT19937 MDF

This is a additional request to the previous one I made. Like the title says, New Game mdf (*.psb.m) files are obfuscated/encrypted with a crypt key.
exm2lib is able to decrypt the files by passing in a game key and a file name.
Samples will be later. but for now here is how to get the raw psb files.
Here is just the decryption of the psb.m: https://zenhax.com/viewtopic.php?t=4115#p22488

To decrypt you will need to change the GAME_SEED

set GAME_SEED binary "9362abe723sfe"
math key_len = 0x83

The decryption is pretty simple:

1. The "FileSeed" is created from the Game's Seed and the file name in full. [GameSeed + FileName]  
1b. Hash the seed with MD5. "MD5 Hash"  
2. Key is then generated using mt19937 random generator with the seed predefined as "MD5 Hash".  
3. Decrypt with Xor.  
4. And thats it. you now have the psb file.

Samples

[PsBuild]Sound Archives don't compile

I was trying to recompile some sound archives I had decompiled using psbdecompile with the -raw option. But I keep on getting a [WARN](resource#) is not used. error and the output is an empty psb archive.
I've tried this with Tokyo School Life's sound archives and Plastic Memories' sound archives.

TSL Sample:

aoi_epaoi11_001.psb.txt

aoi_epaoi11_001.json.txt

PlaMemo Sample:

pm_a01_01_eru0000.psb.txt

pm_a01_01_eru0000.json.txt

I'm also sorry for the closed issue I added a few moments before this one, I had accidentally pressed enter before writing it all down.

Move dlls to lib folder

Hello, @UlyssesWu
Can you say how to build all apps with this structure?

FreeMoteToolkit/EmtConvert.exe
FreeMoteToolkit/FreeMoteViewer.exe
FreeMoteToolkit/PsBuild.exe
FreeMoteToolkit/PsbDecompile.exe
FreeMoteToolkit/dll/FastBitmapLib.dll
FreeMoteToolkit/dll/FreeMote.NET.dll
FreeMoteToolkit/dll/FreeMote.Plugins.dll
FreeMoteToolkit/dll/FreeMote.PsBuild.dll
FreeMoteToolkit/dll/FreeMote.Psb.dll
FreeMoteToolkit/dll/FreeMote.dll
FreeMoteToolkit/dll/K4os.Compression.LZ4.Streams.dll
FreeMoteToolkit/dll/K4os.Compression.LZ4.dll
FreeMoteToolkit/dll/K4os.Hash.xxHash.dll
FreeMoteToolkit/dll/Newtonsoft.Json.dll
FreeMoteToolkit/dll/PhotoShop.dll
FreeMoteToolkit/dll/System.Buffers.dll
FreeMoteToolkit/dll/System.Memory.dll
FreeMoteToolkit/dll/System.Runtime.CompilerServices.Unsafe.dll
FreeMoteToolkit/dll/System.ValueTuple.dll
FreeMoteToolkit/dll/TlgLib.dll
FreeMoteToolkit/dll/XmpCore.dll
FreeMoteToolkit/dll/emotedriver.dll

Support files larger than 2GB

When extracting image_body.bin (3.72GB) from a PS4 game, PSB Decompiler returns:

X:\konosuba-PS4> PsbDecompile info-psb -k 38757621acf82 image_info.psb.m -l 131
...
Extracting info from image_info.psb.m ...
System.IO.IOException: 该文件太长。此操作当前仅限于支持大小小于 2 GB 的文件。
   在 System.IO.File.InternalReadAllBytes(String path, Boolean checkHost)
   在 FreeMote.Tools.PsbDecompile.Program.<>c__DisplayClass0_3.<Main>b__6()
Done.

Extracting other smaller files, such as motion_body.bin (201MB), running smoothly:

X:\konosuba-PS4> PsbDecompile info-psb -k 38757621acf82 motion_info.psb.m -l 131
...
Extracting info from motion_info.psb.m ...
66 files extracted.
Done.

Tried set gcAllowVeryLargeObjects to true as mentioned here, but still reports same error.

Example files: https://mega.nz/folder/9Y0kHQQQ#DQKtb4mnMwtVPM6Ek4t52A

(Just extracting some images for fun, maybe not an important issue for now.)

[PsbDecompile/PsBuild] Troubles with font (ttf)

I try to decompile this files (key is 523aad2de7132):
FontPSBs.zip
When i used this command it's throw exciption.
./PsbDecompile.exe -raw info-psb -k 523aad2de7132 ../font_info.psb.m
But when i used this command with -raw flag it's works, but the files list don't match with font_info.psb.m.json
In json I have: tt_humming-d.ttf.m
In folder I have: tt_humming-d.ttf.m.psb.m
I try to use exm2lib and it gave to me tt_humming-d.ttf.m
I put it in the directory which FreeMote decompiled files and delete tt_humming-d.ttf.m.psb.m
After that I used PsBuild. He did his job successfully, but when I launch game it's crash.
Such problems were not observed with other files that did not contain fonts.

[EmtMake] Program output cannot be licensed by the program's creator, only the user.

The output file is always licensed under CC-BY-NC-SA 4.0. No commercial usage allowed!
Is unenforcable under most copyright law, given that you are not the legal "author" of that data:
In general this is legally impossible; copyright law does not give you any say in the use of the output people make from their data using your program. If the user uses your program to enter or convert her own data, the copyright on the output belongs to her, not you. More generally, when a program translates its input into some other form, the copyright status of the output inherits that of the input it was generated from. (Source: GPL FAQ)

You can still make a request that commercial users donate, though. (and in fact, I would encourage it, too many people take and don't give back, despite their business riding on the stuff they've "taken")

EDIT: It also conflicts with the "additional clause" at the bottom of the README saying If the input is not made by yourself, you are NOT allowed to use the output for any commercial purposes. in that it makes no distinction.

I'd advise clarifying the latter line to a notice, rather than an "additional license clause" since that's written into law anyways (and (L)GPL doesn't allow for those). something along the lines of "The output of this program inherits the license of the input. It is your responsibility to check the input file's license before distributing the output or using it commercially"

Error unpacking previously repacked .psb files

Hello, @UlyssesWu

Tested on versions:

PsbDecompile - 2.5.0.0, 2.6.0.0, 2.7.0.0
PsBuild - 2.5.0.0, 2.6.0.0, 2.7.0.0

Unpack config_message_en.pimg:

./PsbDecompile.exe config_message_en.pimg
FreeMote PSB Decompiler
by Ulysses, [email protected]
9 Plugins Loaded.

Decompiling: config_message_en
Done.

Repacking modified files in config_message_en.pure.pimg:

 ./PsBuild.exe config_message_en.json
FreeMote PSB Compiler
by Ulysses, [email protected]
9 Plugins Loaded.

Compiling config_message_en ...
Compile config_message_en done.
Done.

I try to unpack the created config_message_en.pure.pimg and get an error:

# ./PsbDecompile.exe config_message_en.pure.pimg
FreeMote PSB Decompiler
by Ulysses, [email protected]
9 Plugins Loaded.

Decompiling: config_message_en.pure
System.NullReferenceException: Object reference does not point to an instance of an object.
   в FreeMote.TlgImageConverter.ReadTlg(BinaryReader src, TlgMetaData info)
   в FreeMote.TlgImageConverter.ReadAndGetMetaData(BinaryReader file, TlgMetaData& md)
   в FreeMote.Psb.PsbResHelper.OutputImageResources(PSB psb, FreeMountContext context, String name, String dirPath, PsbExtractOption extractOption, PsbImageFormat extractFormat)
   в FreeMote.PsBuild.PsbDecompiler.OutputResources(PSB psb, FreeMountContext context, String filePath, PsbExtractOption extractOption, PsbImageFormat extractFormat, Boolean useResx)
   в FreeMote.PsBuild.PsbDecompiler.DecompileToFile(String inputPath, PsbExtractOption extractOption, PsbImageFormat extractFormat, Boolean useResx, Nullable`1 key)
   в FreeMote.Tools.PsbDecompile.Program.Decompile(String path, Boolean keepRaw, PsbImageFormat format, Nullable`1 key)
Done.

After repacking the changed files, in the .psb archive one file is broken 0 bites

image

But in the original archive it is working 1305 bites

image

Could you please fix this?

config_message_en.zip

[PsBuild] MMO Compiler

A managed open-source emote project compiler, will let you create pure emote PSB (instead of just GIFs) with free editors.

This feature is not important to me, but you are welcomed to support me to let me know you want it.

[Question] ImageMetadata.SetData

I'm trying create a new ImageMetadata with this code

var Resource = new ImageMetadata
{
     Compress = PsbCompressType.Tlg,
     Name = $"{ID}.tlg"
};
Resource.SetData(Texture);

Here is where the SetData create the TLG:

case PsbCompressType.Tlg:
Data = FreeMount.CreateContext().BitmapToResource(".tlg", bmp);
break;

As you can see, looks like the supported Formats isn't initialized yet...?
image

By the way, I already called the FreeMount.Init();
What I did wrong?

PSB 图像问题

大佬,托您的福,一切汉化进展都顺利,但是字库的图片,导出时没问题,导入后就会撕裂了,是我“PsBuild textfont24.psb.json”用法不对吗?
textfont24.zip

[Question]export still pictures

I find that FreeMoteViewer.exe is capable to read the psb files and PsbDecompile.exe is able to extract the files with single components, but I wonder whether it can extract still complete pictures. In other words, extract one frame from the animation.

Support ems Spec

ems spec comes up with Emote 3.9.
It should be easy but I'm working on another branch so I haven't pushed this.

问题:如何使用原始压缩格式

在解包pimg格式后,自动生成了png文件,改动后封装生成了新的.pure.pimg。可是此时文件体积增大了。再对新生成文件解包,对比前后的resx.json发现context中少了"TlgVersion": 6这么一行。感觉生成时没有使用tlg压缩了,不过通过查看内部文件确实是tlg文件,感觉不压缩会对游戏有影响。求解dalao

Support PSBv4

The newest version appeared in Neko vol.3.
There are much more confusing fields than PSBv3.

_info.psb.m & _body.bin

大佬你也玩崩3啊,我就想问问你这个工具,只能解_info.psb.m的吗?_body.bin的似乎不能解,我试过根据_info.psb.m解出来的psb里的json内容,在 _body.bin里找到偏移然后单独复制出来,但是EmtConvert 似乎并不认
J674S O45S 9(}XAA 31H R
Q%)(CH{_SDCRQXB0K~R9ION
B0A~)YYGJG61JK9NOOVOXXA

exm2lib只能解不能打包,我想汉化《为美好的世界献上祝福》psv的游戏
`W$ W_9}VM12C K%J9ZB

[Feature Request]支持dpak

只能得到json文件,文件夹是空的。
游戏名:お兄ちゃん、キッスの準備はまだですか? エッチの準備もまだですか?

Support DXT5 Texture

DXT5(or even other DXT) Textures are allowed in Emote. I didn't know if someone would use them but at least now I have found one game using DXT5. So I'm going to support it in decompilation.
If you have similar issues, post it and provide PSB files.

Use a real command line parser

In previous versions, FreeMote tools just parse the command line args in a static, informal way. Things will change in FreeMote 2 (or since 1.9). PsBuild, PsbDecompile and EmtConvert will be refactored.

Before:

PsBuild /v4 /pkrkr simple.psb

After: (GNU compatible)

PsBuild -v 4 -p krkr simple.psb

You can check out the new command style via -h.

[SoundArchive] Extract audio

Extract audio from sound archive. No plan to support repack audio since many audio formats still lack of encoders.

Planned audio format: AT9, OPUS, XWMA.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.