General topic

The collision format

Posted by JoseTheBest.
Collision blocks by OrdosAlpha.
Submitted by Sonic Hachelle-Bee on June 5 2005.
Each sonic game (s1/s2/s3/sk) have a "Main" collision data (usually called collision array) where all the collision blocks used in the game are. Then the collision data for each level just use the posible blocks in the collision array, but that's something that we'll see later. For now, let's look on the collision array.

The collision array

First, you have to know that the collision blocks are directly applied to the 16x16 tiles of each zone, that mean that each collision block is always 16x16.



This is basically the table with represents a collision blocks. You probably have noticed that the system looks like x and y positions. Well, in fact is even more simple than that. Each block uses 16 (0F) bytes. There isn't any special format in the collision array. Is just the first 16 bytes the first collision block, the next 16 bytes the second, and so on. But let's look what that 16 bytes mean.

The X position in the table, is just the position of the actual byte. The value of that byte means the Y position. It always create a column below the position. In the table, green numbers mean y value, and blue numbers mean the byte position (or x value) (for now, ignore the grey numbers) For example, if we have this:

00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00

That means will create a column in the second position with altitude of 3. This will be a representation of the position:



And because we said that it creates a column, the result in game will be this:



Also, as you can see, a value of 00 don't create a column.

Another example more complex:

04 05 05 06 06 07 08 08-09 0A 0A 0B 0C 0D 0D 0E



Red boxes mean that these are the actual value of each byte.

"Okay, and what about the grey numbers that we saw before?"

They work like Y positions, but instead of creating a "normal" column, it creates one "inverted".

For example:

00 00 00 FE 00 00 00 00 00 00 00 00 00 00 00 00

The position in the table is:



And it creates an inverted column:



That will create the collision, but you have to set to that block the slope effect. This is where the angle data comes. Each byte of this data correspond to one collision blocks. If the byte is the first, it will take effect on the first collision block in the array, if is the second, the second block, and it follow that. The format is simple, to represent the slope just create two imaginary lines. The first character of the byte is a point in the left line, and the second in the right line. If you create a line between these points, you will have a representation of the slope. Let's look an example:

Block collision number 04 of Sonic 1:



Now we go to the 4 byte on the angle data in Sonic 1 (see below). It says 90. 9 will be the first point and 0 the second. Here is a representation about that:



That's all about the collision block format.


The collision blocks reference chart for Sonic 2:

There is just a link to see all collision blocks definitions of Sonic 2:

Sonic 2 collision blocks reference chart

The collision index

Instead of use directly data like the collision array, each byte represent one block from the collision array, and is directly related to the 16x16 tile position. Is simple. If a byte is 00, it means that it will use the first block collision in the collision array (first 16 bytes). If is 01, it will use second, and it continues. And how the game know in what 16x16 tile use that? Again very simple. The position of the byte, is the position of the tile. I mean, if you use 00 in the first position of the collision data of a level, It will use the block collision 00 in the first 16x16 tile in the level. If is the second position, the second tile. And it continues like that.

Useful addresses to note

Now some info that you maybe want:

Collision Arrays:

Sonic 1 (us) :
Primary collision array: $62A00
Secondary collision array: $63A00
Angle/curve array: $62900

Sonic 2 :
Collision array : $42E50
Angle/curve array: $42D50

Sonic 3 :
$706A0*

Sonic & Knuckles : $96100*


Collision Data :

Sonic 1 (us) :
GHZ : $64A00
LZ : $64B9A
MZ : $64C62
SLZ : $64DF2
SYZ : $64FE6
SBZ : $651DA

Sonic 2 (Note: Data compressed with Kosinski format) :
EHZ and HTZ primary : $44E50
EHZ and HTZ secondary : $44F40
MTZ : $45040
OOZ : $45100
MCZ : $45200
CNZ primary : $452A0
CNZ secondary : $45330
CPZ and DEZ primary : $453C0
CPZ and DEZ secondary : $454E0
ARZ primary : $45610
ARZ secondary : $45760
WFZ/SCZ primary : $458C0
WFZ/SCZ secondary : $459A0

* Note: S3 and SK collision array adress taken from Esrael Homepage.


Back to the main page
Table of contents