Completely re-written from scratch.

Now uses an event-driven engine instead of parasitsing critical game
functions.