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

Chip tiny.png The following article is a Notes Page for Donkey Kong Country (Game Boy Color).

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 (when xxxxxxx > 0): Run-length encoding. Write a certain byte (yyyyyyyy) xxxxxxx times. xxxxxxx can range from 0x01 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.
  • A 0x00 byte (when not part of a byte stream) denotes the end of the data.

Map Data

Each map consists of 32x32-pixel metatiles, and the game engine allows for up to 65,536 metatiles (though in reality, maps use far less than this). Therefore, each metatile consists of 16 bits. However, when the metatiles are stored into RAM, they are broken up into 8-bit chunks. The upper 8 bits of the metatiles are stored from 2:D000-DFFF in RAM, and the lower 8 bits of the metatiles are stored from 1:D000-DFFF in RAM. For example, if the first metatile of a map has the value 0x031A, then 2:D000 has the value of 03 and 1:D000 has the value of 1A.

(TODO: Larger maps may possibly use even more RAM? Look into this.)

Due to this data, each map has two pointers. For example, Jungle Hijinxs has the ROM pointers 0x38821C (whose map data is decompressed and written to 1:D000) and 0x388587 (whose map data is decompressed and written to 2:D000). (These ROM pointers are located at 0x126DE and 0x126E0.)