Collision is based on three 40 byte tables that are generated from Embedded bytes in the Inlay(SSC).
Embedded Bytes are a range of byte values that are not normally used in HIRES but may be used to indicate extra content such as collision markers.
Byte codes 32 to 63 hold the collision type, and these bytes are inversed(+128) if the same position is used as a ceiling or floor height mark.
Once extracted the collision value is reduced to 0 to 31 and stored in the Collision table (the third table).
Since the screen is copied top down both ceiling and floor markers can be the same code ($A0) and the relative Y position is stored in the Ceiling or Floor Table using the current X position as the index.
For each frame of the hero on the ground, the minimum y position is sampled from the floor table (Based on the width of the hero) and becomes the new Y position of the hero.
When the hero is airbourne (Such as when he jumps) the ceiling table limits the height he can jump. This prevents any corruption of background graphics that use both odd and even lines.
As the hero moves accross the screen, each new x position can be used to index the collision table and identify ground collisions. The first 5 values (32-36 or 0-4 as held in Collision table) have default definitions but codes beyond 36 are used for screen specific collisions.
Default Collisions
Embedded Code | Collision Code | Ceiling/Floor Marker | Definition |
---|---|---|---|
20 | 0 | No | No Collision |
21 | 1 | No | Left Exit |
22 | 2 | No | Right Exit |
23 | 3 | No | Wall |
24 | 4 | No | Instant Death |
25-3F | 5-31 | No | Screen Specific collision |
A0 | 0 | Yes | No Collision |
A1 | 1 | Yes | Left Exit |
A2 | 2 | Yes | Right Exit |
A3 | 3 | Yes | Wall |
A4 | 4 | Yes | Instant Death |
A5-BF | 5-31 | Yes | Screen Specific collision |