Welcome to Data Crystal's new home! Data Crystal is now part of the TCRF family (sort of).
The wiki has recently moved; please report any issues in Discord. Pardon the dust.

Donkey Kong Country (Game Boy Color)/Notes

From Data Crystal
Jump to navigation Jump to search

Compression

Maps

DKC (GBC) uses a different format from the DKL games to compress maps, and it is much simpler.

The data is read one byte at a time, and the two most significant bits determine one of three cases.

  • 0xxxxxxx yyyyyyyy: Run-length encoding. Write a certain byte (yyyyyyyy) xxxxxxx times. xxxxxxx can range from 0x00 to 0x7F, since this is a 7-bit value.
    • Example: A byte stream of 10 30 (in hexadecimal) will write the value 0x30 for 0x10 (16 decimal) bytes:
      30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
  • 10xxxxxx yyyyyyyy...: Uncompressed data. Read the next xxxxxx bytes. This length can range from 0x00 to 0x3F, since this is a 6-bit value.
    • Example: A byte stream of 83 01 02 03 (in hexadecimal) will write the next 0x03 bytes, which are:
      01 02 03
  • 11xxxxxx yyyyyyyy: Read a byte sequence already written earlier, then write it again. xxxxxx denotes the length of the data to repeat, which can range from 0x00 to 0x3F, since it is a 6-bit value. yyyyyyyy represents the distance to go back, which can range from 0x00 to 0xFF, since this is an 8-bit value.
    • Example: A byte stream of C4 1C (in hexadecimal) will read four bytes. Assuming that the current RAM address to be written to is 1:D100, then the offset that should be read from is 1:D100 - 1C, or 1:D0E4. Assuming that the data from 1:D0E4-D0E7 is 10 11 12 13, then the data from 1:D100 to 1:D103 will also be 10 11 12 13.