Adding custom M or G codes to Marlin 2.0
The code in 2.0.x is similar to the old branch 1.1.x, G-code is parsed in gcode.cpp, specifically in process_parsed_command:

void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/)


In the case statement the codes read from the G-code files are parsed (interpreted) and the appropriate method is called (e.g. G28() calls void GcodeSuite::G28())

If you want to create your own codes, it could be an idea to start there. Also think of using a different letter and/or codes in the 10,000 range so that it will not collide with new implemented G-codes.