Actions

Source code/Technical information

From Sonic Retro

Revision as of 19:54, 14 March 2024 by BenoitRen (talk | contribs) (Added Routines/Functions and Glossary)

This page contains information about names and labels used in the original source code of the Mega Drive and Mega CD games.

Global variables

Name Description
actwk Action object work. An array of sprite status objects. In Sonic the Hedgehog and Sonic CD, it has 128 elements. In Sonic 2, it has 152 elements. In Sonic 3, Sonic & Knuckles, and Sonic 3 & Knuckles, it has 110 elements.
chibi_flag Chibi is Japanese slang for small. Zero when the player is in a normal state. Non-zero when the player has been shrinked by a shrink ray in Metallic Madness. Sonic CD only.
chibi_s Chibi save. Stores the the value of chibi_flag at the time of the last checkpoint activation.
editmode Zero when edit mode is not enabled. Non-zero if edit mode is enabled.
editno Edit numero. When edit mode is enabled and the player is cycling through the objects that can be placed, this contains the index of the current object.
emyscorecnt Enemy score count. Stores the number of enemies, multiplied by 2, that the player has destroyed while in the air. When the player lands on the ground, it's reset to zero.
generate_flag Zero if the robot transporter hasn't been destroyed (yet). 1 if it has been destroyed. Sonic CD only.
markerno Marker numero. Stores the identifier of the last activated checkpoint.
pl_suu Player lives. suu is the Japanese verb for breathing.
plpower_b Player power baria. Baria is the Japanese word for barrier. Zero when the player character doesn't have a shield. 1 when the player character has a shield.
plpower_m Player power muteki. Muteki is the Japanese word for invincible. Zero when not invincible. 1 when invincible.
plring Player rings.
plring_s Player rings save. Stores the value of plring at the time of the last checkpoint activation.
plscore Player score.
pltime Player time. The duration of time since starting the act. Stored as three bytes: 1/60 seconds, seconds,and minutes.
pltime_s Player time save. Stores the value of pltime at the time of the last checkpoint activation.
plxposi_s Player x position save. Stores the x position of the last activated checkpoint.
plyposi_s Player y position save. Stores the y position of the last activated checkpoint.
projector_flag Zero if the Metal Sonic projector hasn't been destroyed (yet). 1 if it has been destroyed. Sonic CD only.
ranum Random number. The seed for generating the next random number.
ringbonus The bonus score for the amount of rings the player has when finishing the act.
stageno Stage numero. This variable is a combination of two values: the high byte contains the zero-based zone number, and the low byte contains the zero-based act number.
swdata1 This variable is a combination of two values related to controller 1: the low byte contains a bit field of buttons that have been newly pressed this frame, and the high byte contains a bit field of buttons that were already pressed this frame.
swdata2 This variable is a combination of two values related to controller 2: the low byte contains a bit field of buttons that have been newly pressed this frame, and the high byte contains a bit field of buttons that were already pressed this frame.
ta_flag Time attack flag. Zero during regular play. Non-zero when in Time Attack mode. Sonic CD only.
time_flag This flag is a combination of two values: the most significant bit stores the player currently has the power of time travel, and the rest of the byte stores a time period. If the player doesn't have the power of time travel, the time period is the current time period. If the player has the power of time travel, the time period is the one the player will travel to when time-traveling. The possible time period values are zero for past, 1 for present, and 2 for future.
time_item Stores the value of the last activated Time Warp Plate. Possible values: 0 for none, 1 for future, and -1 for past. Sonic CD only.
timebonus The bonus score for length of time it took the player to finish the act.

Routines/Functions

Name Description
actionsub Queues a sprite status object for display.
bgmset Plays background music.
frameout Clears (logical delete) a sprite status object.
patchg Updates the sprite's animation.
random Generates a random number.
scoreup Adds obtained points to the player's score.
sinset Gets the sinus and cosinus values for a given angle.
soundset Plays a sound effect.

Glossary

The original programmers used certain terms and abbreviations in the source code that unintentionally obfuscate the original meaning if one isn't familiar with them.

Term Meaning
emie Amy
emy enemy
act action object
bye "I'm outta here!"
coli collision
marker checkpoint
pat pattern
pl player
pri priority