Technical information (for those interested)

[github.com]

You might be wondering how exactly the editing interface works, especially if you've used Cheat Engine before. If you know Lua, you can look at the scripts yourself (in the "sa2lua" folder, or on Github ), but I'll put a brief explanation here.When you load the cheat table, a Lua script runs. This has the immediately-visible effect of opening the Tools window. However, this script also loads some code into memory (from the "hook.bin" file, which was created from "hook.asm") and modifies the code of the game (in memory, the EXE is not changed) to execute this code every frame. This code checks a region of memory allocated by the script for instructions to call internal functions in the game's code.The Lua script also monitors the internal tables that keep track of the in-game objects currently loaded. This data is used to, for instance, find the closest object to the cursor. Now not all of the tables are actually used for objects that appear in the level. Some of them are only entries saying to run specific code every frame. One function of the Lua code is to monitor these tables for the presence of a specific entry of this type, which doesn't normally exist in the game. If it doesn't find it, it loads the code for it (from "linedraw.bin") if it isn't loaded already, and adds the entry to the list using the same function that's normally used for placing objects.As you may have guessed from the filename, this entry's function is to monitor another section of memory for line drawing specifications. These strings of bytes basically mean "draw a (color) line from (start coordinates) to (end coordinates)." It then goes through the list and calls a function in the game to draw lines there. (This is the same function that draws Tails and Eggman's laser sight, or the streaks that appear behind Sonic and Shadow when they're running at top speed.)When Live Edit Mode is turned on, the Lua code is constantly monitoring the area of the game's memory where the current controller state is stored. When it detects you're holding a direction button, or the cursor is active, it sets a flag that the game uses internally when the player controls should be disabled. This is so you can use the editing interface without the character moving at the same time. It also places line drawing instructions in memory to tell the code mentioned before to draw the cursor and object markers on the screen. As for the text display, that's simply done using Cheat Engine's built-in Direct3D hooking feature.So yeah, none of this is a leftover debugging feature or anything. (Well, except for the noclip feature, but if that wasn't there, it would be really easy to use the existing object-moving interface to do the same thing.) All of it is implemented in Lua, with the exception of the low-level parts that call functions in the game's code.