pls, pls, pls... Add a meaningful prefix to all files and functions, maybe "tust". A bunch of procedural bmap functions would be nice. I got no time at all for the next 3 months, but maybe you can get inspired by "bmap.c" in http://www.indiegamedeveloper.org/downloads/256kS.zip
The functions are not pretty, not stable, stupid like hell, quick & dirty, but they are a starting point.