Before diving in, it's important to understand that you must own an official copy of Sonic CD.
The process requires the original .rsdk file, which is only found in legitimate copies of the game.
Without it, the decompilation will not work. Obtaining this file through unofficial sources is illegal.
This tutorial focuses on Sonic CD, but same steps apply to Sonic 1 and Sonic 2.
I decided to focus on Sonic CD because for Sonic 1 we have Forever and for Sonic 2 Absolute