So, I actually did it already, oops. Was ‘fairly’ simple to figure out after I reversed how to map it all back together.
The code is here: