I built this for a game i'm working on yesterday. It's based on some of the code in this video here: http://youtu.be/cNVX0Qp7JL8
The generator is a rough translation of that GMK to C2. It's nothing fancy, but maybe someone can learn from it/tear it apart for their own use. It's also a little unusual (and probably backwards) in that it doesn't use any arrays.
Feel free to drop comments, and if anyone can use it for something, don't hesitate