Welcome to the Creatures Wiki! Log in and join the community.

Editing MNG files

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 save the changes below to finish undoing the edit.

Latest revision Your text
Line 214: Line 214:
 
</pre>
 
</pre>
  
===Java Function===
+
===C Function===
<pre>
 
public static final int MNG_START = 0x5;
 
public static final int MNG_STEP = 0xC1;
 
 
 
/* Note: This function differs from the above VB version
 
* in that it modifies its first argument,
 
* rather than returning a new byte string.
 
*
 
* For those unfamiliar with array-offset-length functions, they're useful for circumstances where the data you want to act upon is only a subsection of the data in the actual array; they pop up a lot in the Java standard library
 
*/
 
public static void scramble(byte[] data, int offset, int length)
 
{
 
    byte key = MNG_START; //used for xor'ing
 
   
 
    for (int i = 0; i < length; i++)
 
    {
 
        data[offset+i] = (byte)(data[offset+i] ^ key);
 
        key += MNG_STEP;
 
    }
 
}
 
 
 
public static void scramble(byte[] data)
 
{
 
    scramble(data, 0, data.length);
 
}
 
</pre>
 
  
===C Function===
 
 
<pre>
 
<pre>
 
#define MNG_START 0x5
 
#define MNG_START 0x5

All contributions to Creatures Wiki are considered to be released under the CC-BY-SA and GFDL (see Creatures Wiki:Copyrights for details).

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

Cancel Editing help (opens in new window)