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:
XXXX FYYY TTSS
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:
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.
Back | Printer friendly
<< 1. Collision array and collision index | 3. Sprites and objects reference >>