thane98 / paragon

Toolkit for editing various FE games.
GNU General Public License v3.0
56 stars 17 forks source link

BCH parsing #26

Closed SinsofSloth closed 4 years ago

SinsofSloth commented 4 years ago

Reminder to self: add license of FEAT and Ohana/spica

thane98 commented 4 years ago

I don't see anything wrong with your syntax. Your code for arc unpacking looks fine in general. Only one thing stood out:

pub fn unpack(archive: &[u8]) -> Result<File>

Shouldn't this return a Result<Vec<File>>? It already reads multiple files, so it should probably return all of them.

SinsofSloth commented 4 years ago

Gonna need to download this crate https://docs.rs/piet/0.0.6/piet/enum.Color.html for this https://github.com/gdkchan/SPICA/blob/42c4181e198b0fd34f0a567345ee7e75b54cb58b/SPICA/PICA/Converters/TextureCompression.cs#L122, but I don't know how to with my terminal.

SinsofSloth commented 4 years ago

ETC1 decompression kinda in limbo atm, as I'm missing some basic functions, but is done being copied. Might be bug hunting it for days lol with all those bitwise operators. Happen to know any function like this https://docs.microsoft.com/en-us/dotnet/api/system.buffer.blockcopy?view=netcore-3.1 ?

Edit: We could just these py scripts and incorporate as module but I wouldn't know to integrate to rust

Do you think you can start to implement an image viewer? I saw this crate https://github.com/emoon/minifb. We could use AID reading of a character for PoC. Cheers 😄

thane98 commented 4 years ago

That's a lot of progress - thanks for all of the hard work!

Adding crates in Rust is easy. Just add a line to the Cargo.toml file under [dependencies]. For example, for Piet you would add the line piet = "0.1.0". You can use crates.io to find the correct version number to use.

Paragon already uses PyO3 to call Rust code from Python. The library also supports calling Python from Rust, so that could be used in a pinch. It might be easier to expose a couple of Rust functions to handle unpacking / parsing and deal with the rest through Python. bin_archive.rs does this by using pyclass + pymethods so that it can return a BinArchive struct to Python, but you can also expose functions on their own (lib.rs does this).

I'll start looking into what we could do for an image viewer. Qt might have a way to do that so we can avoid pulling in a C library.