I decided to scrap almost all of my original code. The function table idea could have worked but I just didn't plan it out well enough so it became a huge pain to debug.
Progress on my new version though
No colours yet and I still have a few more opcodes to work on.
and obviously the graphics there are wrong, need to fix that too.