ZQF-ReVN / RxGSD

Atelier Sakura/Fizz's GSD Engine Tools. | .gsp .spt .bmz
9 stars 2 forks source link

Some info about this engine #1

Closed Cosetto closed 10 months ago

Cosetto commented 10 months ago

First of fall, thanks for making this tool, this is such a coincidence since I'm looking for this engine's tools. As for the infos: _ We can extract .gsp archive with GARbro and arc_conv. Arc_conv supports archive creation of this engine with command: arc_conv.exe --pack gsp in_folder outgsp For .bmz, GARbro to convert from and to .bmz with GARbro image Is there a better command for line for SPT tool?

Dir-A commented 10 months ago

Actually, I don't even know them. But I think I'm almost done.

The structure of a gsp pack is simple enough that it can be easily repack, but no one wants to release an entire pack as a patch,So So I hooked the engine's virtual filesystem to read the individual files.

bmz is actually a fully structured bmp image with zlib compression, but through reverse analysis of the engine, I found that the engine can actually read bmp images directly, you just need to convert bmz to bmp and then change the file extension to bmz (if you don't care about the file size) The reasoning is that the engine will determine if the first four bytes are 'ZLC3' to decompress them

The spt script garbro will not decrypt, but crass will, but I have not used crass, through my analysis of the spt file decryption, I found that it has two times to decrypt, respectively, need to use the two bytes at the beginning of the file, that is, each byte control a decryption condition. For the first decryption, there are three modes, controlled by the second byte of the file, but this byte is encrypted need xor 0xF0, this byte can only be 0-2 otherwise not decrypted. For the second decryption, it is controlled by the first byte, which is not decrypted if it is greater than or equal to 8. So all you need to do is decrypt the spt file and change the first two bytes to 0xFF and the game will read it normally without encrypting it back.

I'm doing some research on text importing for spt these days, and I've noticed that spt files seem to be some sort of data structure that is read by chunks.

I've actually written out tools to export spt text to json and import it back, just haven't perfected it yet.The principle is to insert text directly, after testing no problems have been found. https://github.com/Dir-A/GSDTools/blob/main/src/SPT_Decoder/main.cpp#L53 https://github.com/Dir-A/GSDTools/blob/main/src/SPT_Decoder/main.cpp#L244

Cosetto commented 10 months ago

Can you test with this game? When I tried to insert the text, the tool didn't throw any exception, but it didn't create new file either.

Cosetto commented 10 months ago

Okay, I figured it out. It looks like "0x00" byte is something that present the furigana, but the tool doesn't work when it's there. image Also, the game still runs after packing without compressing: image

Cosetto commented 10 months ago

For reference, the font size is in init_text.spt and set before font's name like this: image image

Cosetto commented 10 months ago

image Is this the correct code to batch insert the script? I'm confused

Dir-A commented 10 months ago

Don't use it, it has serious bugs, I'm writing a new tool

Cosetto commented 10 months ago

Got it

Cosetto commented 10 months ago

I got this error when coming to this script:

Processing file: input_script\scene_s0727a.spt Unknow Char Type!

scene_s0727a.zip

Dir-A commented 10 months ago

Use the latest commit code

Cosetto commented 10 months ago

image

Dir-A commented 10 months ago

0x5 is to control the text color, does not affect the normal import I haven't had time to write the import code for the control character.

Cosetto commented 10 months ago

Oh, okay

Cosetto commented 10 months ago

Another bug I found. So there are Sys_title.bmz and Sys_title_start.bmz, if I edit them, the button in-game will literally freeze.

Sys_title Sys_title_start

I don't know if my edit skill is bad or there's a file control the images?

Dir-A commented 10 months ago

try the latest commit

Cosetto commented 10 months ago

Thanks bro, it works when we create new Image.gsp, while the VFS hook still freezes

Dir-A commented 9 months ago

try 3a053caa16fdbe5f5947e6096b32035e70ea6ec1

Cosetto commented 9 months ago

Thanks again, it works like a charm now!

Cosetto commented 9 months ago

Bro, can you also add support for the files contain names info? image We can edit Globat.dat with hex editor, but in bl_windup.spt and color_font.spt, the Romanize names are too long to fit in and likely overwrite 0x11 byte (idk what is it but game crashed if we touch it), e.g: 新一 as Shin'ichi, 正義 as Masayoshi. And the names must be in that offset to display its color in-game correctly, so I can't make use of the 00 bytes behind the names. image Aside from that, do you know how to disable the full-width rendering on ASCII characters? image

Dir-A commented 8 months ago

Now you can use spt_parser to convert spt to json and modify contents of json and then convert json back to spt, thatmeans you can edit the spt via json. I haven't tested the code carefully yet, just experimenting at the moment.

The submodules has been added to the project, make sure that when you clone the project you also clone the submodule.