Editing Wikifang:Telefang 2 Translation Patch/NatsumeGBA compression

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
'''NatsumeGBA compression''' (formerly Malias2 compression) is the compression system used in numerous Natsume GBA games, including Telefang 2 and Medarot 2 CORE. Similarly to its predecesor, [[Wikifang:Telefang_1_Translation_Patch/NatsumeGB_compression|NatsumeGB compression]], it is a predictable variation upon LZ77. Why they didn't just use the GBA BIOS LZ77 compression functions is beyond me. (Seriously, why? Unless Nintendo doesn't document their own BIOS functions...)
"Malias2" compression is the compression system used in Telefang 2. Like its namesake [[Wikifang:Telefang_1_Translation_Patch/Malias_compression|Malias compression]], it is a predictable variation upon LZ77. Why they didn't just use the GBA BIOS LZ77 compression functions is beyond me. (Seriously, why? Unless Nintendo doesn't document their own BIOS functions...)


== NatsumeGBA format ==
== Malias2 format ==
(All reads are little-endian, the default endianness of ARM, unless otherwise specified)
(All reads are little-endian, the default endianness of ARM, unless otherwise specified)


Like NatsumeGB, it has a header and bundles. The header is different - instead of a single "is compressed" byte, there is instead a 16-bit magic value 0x4C 0x65 ("Le") followed by a 32-bit size value. Only the lower 24 bits of this value are actually used. If the magic is invalid, something else happens (I'm not sure yet). The size value is how many bytes of uncompressed data should be written.
Like Malias, it has a header and bundles. The header is different - instead of a single "is compressed" byte, there is instead a 16-bit magic value 0x4C 0x65 ("Le") followed by a 32-bit size value. Only the lower 24 bits of this value are actually used. If the magic is invalid, something else happens (I'm not sure yet). The size value is how many bytes of uncompressed data should be written.


NatsumeGBA commands are encoded as bundles of four commands. There are four types of commands. Thus, each bundle's command list fits snugly within a single byte. Command lists are read from the lower bits upwards, two bits at a time.
Malias2 commands are encoded as bundles of four commands. There are four types of commands. Thus, each bundle's command list fits snugly within a single byte. Command lists are read from the lower bits upwards, two bits at a time.


During this discourse we will talk about a "write head". This is the location of the next byte to write to in memory.
During this discourse we will talk about a "write head". This is the location of the next byte to write to in memory.
Line 30: Line 30:
== See Also ==
== See Also ==
* [[User:Kmeisthax/Findings/2012/2/4/Malias2_Listing |A disassembly of the Telefang 2 decompression routine]]
* [[User:Kmeisthax/Findings/2012/2/4/Malias2_Listing |A disassembly of the Telefang 2 decompression routine]]
* Coming Soon - Codemodule support for NatsumeGB and NatsumeGBA
* Coming Soon - Codemodule support for Malias and Malias2
* [https://github.com/Sanky/romhacking/blob/master/telefang/puneedle.py puneedle.py] is a Python NatsumeGBA decompresser implementation.
* [https://github.com/Sanky/romhacking/blob/master/telefang/puneedle.py puneedle.py] is a Python Malias2 decompressor implementation.
Please note that all contributions to Wikifang are considered to be released under the Attribution-NonCommercial-ShareAlike 3.0 Unported (see Wikifang:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)