Egghead.page Logo

How Sega Master System Handles Collision Detection

The Sega Master System utilizes a combination of hardware-assisted sprite collision flags and software-based tile mapping checks to manage interactions within game worlds. Due to the limitations of the Z80 processor and the VDP, developers relied on efficient bounding box algorithms and specific register readings to determine when objects intersected. This article explores the technical mechanisms behind SMS collision detection, including the role of the VDP status register, sprite saturation limits, and the software strategies used to overcome hardware constraints in complex environments.

Hardware Sprite Collision Flags

At the hardware level, the Video Display Processor (VDP) provides a specific status flag to indicate when two sprites overlap on the screen. When the VDP renders the display, it monitors the sprite layer for pixel-level intersections. If any two sprites share the same screen coordinates, a collision bit is set in the VDP status register. The CPU can read this register to detect that a collision has occurred during the current frame. However, this hardware feature has significant limitations. It does not identify which specific sprites collided, nor does it distinguish between friendly and hostile objects. Consequently, developers often used this flag as a general alert system rather than a precise measurement tool, requiring further software verification to determine the nature of the interaction.

Software-Based Background Collision

Collision between moving objects and the background terrain is handled entirely through software routines. The game engine calculates the position of an entity, typically using a bounding box or a specific hotspot coordinate, and maps this position to the corresponding tile in the background nametable. Each tile in the game’s asset library is assigned attribute data that defines its physical properties, such as solid, hazardous, or passable. When the CPU checks the tile attribute at the entity’s calculated coordinate, it determines if movement should be blocked or if damage should be applied. This method allows for complex level design where specific tiles can trigger events or stop movement without consuming excessive processing power.

Managing Performance and Limits

The Z80 CPU, clocked at approximately 3.58 MHz, imposes strict limits on how many collision checks can be performed per frame. To maintain smooth gameplay in complex environments, developers employed optimization techniques such as spatial partitioning and object pooling. Instead of checking every object against every other object, the engine only checks entities that are active on screen or within a certain proximity. Additionally, because the VDP can only display a limited number of sprites per scanline, developers often flickered sprites or rotated sprite definitions to avoid overflow, which indirectly affected collision logic by ensuring critical hitboxes remained visible and detectable. These combined hardware and software strategies allowed the Sega Master System to deliver responsive gameplay despite its 8-bit architecture constraints.