Added a considerable amount of code for handling inverting as well as interrupts
Finished the inversion, interrupt and interrupt mask code.

Finished, meaning written, it's untested until you see a commit where all of the
comments in the header about 'untested' disappear.