there's some nonsense going on here with pascal calling convention but I think I'm too tired already to figure out the exact details well enough to explain it.