Research / Sonic 2 / Sprites and objects placement

Sprites and objects placement:

*Posted by Weird Person on May 21 2005.*
*Corrected by Sonic Hachelle-Bee.*

The sprites coordinates:

By making your sprites and objects placement with an hex editor, you see in run-time, how your sprites and objects will work in the game.

Enter the game in debug mode. There are many hexadecimal values, right?

Piece of cake, right? Let's go to place our objects now!

Before I say everything, let's make a little exercise:

Look at this screenshot:

As you can see, the object is at $0228 (X coordinate) and $027D (Y coordinate).

The sprites placement format:

For each sprite defined, it takes 6 bytes. There is a format:


X: X coordinate of the object.
Y: Y coordinate of the object.
T: Object type, or object ID.
S: Object subparameter.
F: Sprite flag. The first nybble of the Y coordinate is always 0. Then, this nybble is used for something else. The sprite flag tells the initial direction of the sprite, and if the sprite respawns after being destroyed or not (usually, badnicks and monitors won't respawn). Here is a small table of values:

Sprite flagEffect on the sprite
2Horizontal flip
4Vertical flip
6Horizontal and vertical flip
8Normal without respawn
AHorizontal flip without respawn
CVertical flip without respawn
EHorizontal and vertical flip without respawn

Reader: "What we have to do now?"
Now, we have to write these 6 bytes somewhere in the ROM. Each act of the game own a huge list where all sprites placement are stored. For Emerald Hill zone, this huge list of sprites begins at $E684A. Each 6 bytes is a new sprite. At the end of the list, you have FF FF 00 00 written.

As an example, let's take our red spring above. You can replace the first sprite (a coconut) by our spring by writing this:

02 28 02 7D 41 04

0228 is our X coordinate. 027D is our Y coordinate. 41 04 is a red spring facing up.
Let's take another example with a ring monitor:

02 28 82 7D 26 04

At the same place, a ring monitor should appear. Break it and go away. Then go back and verify that the monitor still broken. The sprite flag (8) disable the ability of the sprite to be respawned after being destroyed! Simple enough, isn't it?

Of course, you will want to place other sprites and objects. Here is a list of some objects you can place in every level (without having any graphical glitches):
Sprites and objects reference

Sprites and objects addresses:

Now, here is the list of every addresses for every level, where to find the list of objects.
There is an offset index for each level (2 bytes for an act) located at $E6800.

LevelActAddress for the list of sprites
Emerald Hill zoneAct 1$E684A
Act 2$E6B7A
Metropolis zoneAct 1$E6F34
Act 2$E73C0
Act 3$E78EE
Wing Fortress zone$E7F48
Hill Top zoneAct 1$E8302
Act 2$E8668
Hidden Palace zoneAct 1$E8C80
Act 2$E8D94 (empty)
Oil Ocean zoneAct 1$E8DA0
Act 2$E9214
Mystic Cave zoneAct 1$E968E
Act 2$E99A0
Casino Night zoneAct 1$E9D1E
Act 2$EA3D8
Chemical Plant zoneAct 1$EA9D2
Act 2$EAD6E
Death Egg zone$EB230
Aquatic Ruin zoneAct 1$EB25A
Act 2$EB6A4
Sky Chase zone$EBBDE
Unused space that you can use$EBD48 to $EBFFF

Back | Printer friendly
<< 1. Collision array and collision index | 3. Sprites and objects reference >>

© 2004, 2005 drx, Don't copy without permission yadda yadda yadda.