C2M: Difference between revisions

234 bytes added ,  6 February 2019
no edit summary
imported>Zrax0111
(Update tile and modifier specifications based on testing.)
 
No edit summary
Line 1: Line 1:
=== Overview ===
A '''C2M '''file (having the extension .c2m) is the file format which [[Chip's Challenge 2]] individual levels are commonly stored in.
A '''C2M '''file (having the extension .c2m) is the file format which [[Chip's Challenge 2]] individual levels are commonly stored in.


Line 6: Line 5:
All data in the file is little-endian.
All data in the file is little-endian.


=== Section header format ===
== Format ==
{| class="article-table"
=== Section header ===
{| class="wikitable" border="1"
!Bytes
!Bytes
!Content
!Content
Line 19: Line 19:


=== Section types ===
=== Section types ===
{| class="article-table"
{| class="wikitable" border="1"
!Section ID
!Section ID
!Content Type
!Content Type
Line 79: Line 79:
=== OPTN section ===
=== OPTN section ===
The size of the section can differ between file versions (and even between files with the same file version). Data beyond the size of the section is not read. (E.g. if the section size is 3, only the time and the view are stored.)
The size of the section can differ between file versions (and even between files with the same file version). Data beyond the size of the section is not read. (E.g. if the section size is 3, only the time and the view are stored.)
{| class="article-table"
{| class="wikitable" border="1"
!Bytes
!Bytes
!Content
!Content
Line 114: Line 114:
The PACK and PRPL sections contain compressed versions of the MAP and REPL sections respectively. The compression scheme is as follows:
The PACK and PRPL sections contain compressed versions of the MAP and REPL sections respectively. The compression scheme is as follows:


{| class="article-table"
{| class="wikitable" border="1"
!Bytes
!Bytes
!Content
!Content
Line 126: Line 126:
|}
|}


==== A Data Block: ====
==== Data Block ====
When encountered during decompression, the data block's N bytes of data are added to the list..
When encountered during decompression, the data block's N bytes of data are added to the list..
{| class="article-table"
{| class="wikitable" border="1"
!Bytes
!Bytes
!Content
!Content
Line 139: Line 139:
|}
|}


==== A Back-Reference Block: ====
==== Back-Reference Block ====
When encountered during decompression, COUNT bytes are copied from position (CURRENT - OFFSET) in the list to position CURRENT in the list. (Where CURRENT is the current position in the list, while COUNT and OFFSET are defined below)
When encountered during decompression, COUNT bytes are copied from position (CURRENT - OFFSET) in the list to position CURRENT in the list. (Where CURRENT is the current position in the list, while COUNT and OFFSET are defined below)


Note that COUNT can be larger than OFFSET, allowing arbitrary pattern repetition to be efficiently encoded.
Note that COUNT can be larger than OFFSET, allowing arbitrary pattern repetition to be efficiently encoded.
{| class="article-table"
{| class="wikitable" border="1"
!Bytes
!Bytes
!Content
!Content
Line 156: Line 156:
=== MAP / PACK section ===
=== MAP / PACK section ===
This section contains the map data. If this is a PACK section, it must be unpacked using the above compression scheme first. The contents of this section is as follows:
This section contains the map data. If this is a PACK section, it must be unpacked using the above compression scheme first. The contents of this section is as follows:
{| class="article-table"
{| class="wikitable" border="1"
!Bytes
!Bytes
!Content
!Content
Line 170: Line 170:
|}
|}


==== Tile specification: ====
==== Tile specification ====
The tile specification consists of 1 or more bytes. The first byte is always the tile value, decoded as follows:
The tile specification consists of 1 or more bytes. The first byte is always the tile value, decoded as follows:
{| class="article-table"
{| class="wikitable" border="1"
!Value
!Value
!Tile
!Tile
Line 764: Line 764:
==== Direction Byte ====
==== Direction Byte ====
The direction byte comes after enemy tiles and some others:
The direction byte comes after enemy tiles and some others:
{| class="article-table"
{| class="wikitable" border="1"
!Value
!Value
!Meaning
!Meaning
Line 783: Line 783:
==== Panel/Canopy Bitmask ====
==== Panel/Canopy Bitmask ====
Any number of these bits can be combined:
Any number of these bits can be combined:
{| class="article-table"
{| class="wikitable" border="1"
!Bitmask
!Bitmask
!Meaning
!Meaning
Line 805: Line 805:
==== Directional Arrows Bitmask ====
==== Directional Arrows Bitmask ====
Any number of these bits can be combined:
Any number of these bits can be combined:
{| class="article-table"
{| class="wikitable" border="1"
!Bitmask
!Bitmask
!Meaning
!Meaning
Line 827: Line 827:
==== Wire Modifier ====
==== Wire Modifier ====
This is an 8-bit modifier that affects floors, metal walls, on/off switches, transformers, and blue/red fans (possibly more?). It adds wires to the tile it affects. Any number of these bits can be combined:
This is an 8-bit modifier that affects floors, metal walls, on/off switches, transformers, and blue/red fans (possibly more?). It adds wires to the tile it affects. Any number of these bits can be combined:
{| class="article-table"
{| class="wikitable" border="1"
!Bitmask
!Bitmask
!Meaning
!Meaning
Line 858: Line 858:
==== ASCII Modifier ====
==== ASCII Modifier ====
This is an 8-bit modifier that affects "sunken" floors by adding a symbol (usually an ASCII symbol) to them:
This is an 8-bit modifier that affects "sunken" floors by adding a symbol (usually an ASCII symbol) to them:
{| class="article-table"
{| class="wikitable" border="1"
!Values
!Values
!Meaning
!Meaning
Line 875: Line 875:
|-
|-
|0x20 through 0x5f
|0x20 through 0x5f
|Corresponding ASCII Characterr (' ' through '_')
|Corresponding ASCII Character (' ' through '_')
|}
|}


==== Clone Machine Arrow Modifier ====
==== Clone Machine Arrow Modifier ====
This is an 8-bit modifier that affects clone machines by specifying their direction. The values can be combined and will show up on the clone machine appropriately, but the game will only clone in one direction:
This is an 8-bit modifier that affects clone machines by specifying their direction. The values can be combined and will show up on the clone machine appropriately, but the game will only clone in one direction:
{| class="article-table"
{| class="wikitable" border="1"
!Value
!Value
!Meaning
!Meaning
Line 899: Line 899:
==== Custom Floor/Wall Modifier ====
==== Custom Floor/Wall Modifier ====
This is an 8-bit modifier that affects custom walls or floors by replaces their style:
This is an 8-bit modifier that affects custom walls or floors by replaces their style:
{| class="article-table"
{| class="wikitable" border="1"
!Value
!Value
!Meaning
!Meaning
Line 914: Line 914:


==== Logic Modifier ====
==== Logic Modifier ====
This is an 8-bit modifier that affects an inverter gate by replacing it with another gate:
This is an 8-bit modifier that affects an inverter gate by replacing it with another gate. Modifiers outside of the ranges specified below will produce [[voodoo tile]]s.
{| class="article-table"
{| class="wikitable" border="1"
!Values
!Values
!Meaning
!Meaning
Line 946: Line 946:
==== Track Modifier ====
==== Track Modifier ====
This is an 8- or 16-bit modifier that affects the train tracks base tile. The low-order byte specifies which tracks exist; any number of bits can be combined:
This is an 8- or 16-bit modifier that affects the train tracks base tile. The low-order byte specifies which tracks exist; any number of bits can be combined:
{| class="article-table"
{| class="wikitable" border="1"
!Bitmask
!Bitmask
!Meaning
!Meaning
Line 971: Line 971:
|Track Switch
|Track Switch
|}
|}
The high order byte is optional and specifies which track is the active one. If omitted, the North East track is the active one. For tiles with a track switch, the active track is the only one that can be used (the other are shown red).
The high order byte is optional and specifies which track is the active one. If omitted, the North East track is the active one. For tiles with a track switch, the active track is the only one that can be used (the other are shown red).
{| class="article-table"
{| class="wikitable" border="1"
!Value
!Value
!Meaning
!Meaning
Line 999: Line 1,000:


The contents of this section are as follows:
The contents of this section are as follows:
{| class="article-table"
{| class="wikitable" border="1"
!Bytes
!Bytes
!Content
!Content
Line 1,018: Line 1,019:
==== Input Change ====
==== Input Change ====
Specifies a change in input:
Specifies a change in input:
{| class="article-table"
{| class="wikitable" border="1"
!Bytes
!Bytes
!Content
!Content
Line 1,031: Line 1,032:
==== Input Bitmask ====
==== Input Bitmask ====
Specifies which keys are pressed, any number of bits can be combined:
Specifies which keys are pressed, any number of bits can be combined:
{| class="article-table"
{| class="wikitable" border="1"
!Bitmask
!Bitmask
!Meaning
!Meaning
Line 1,060: Line 1,061:
|}
|}


<references />
<references/>
 
[[Category:Terminology]]
[[Category:Terminology]]
[[Category:File formats]]