vec_for_screen() projects your vector into your world, if you just have the xy plane as plane, your normal is 0, 0, 1 and 0, 0, h is a good origin. With that knowledge you can build the HNF for the plane, which is something like:
Code:
0
0  *  v - h = a
1



vec_for_screen(vector(0, 0, 1), camera) - camera.xyz (you will have to use some temp vector and vec_substract or something like that) gives you the direction of your line and camera.xyz is a position on it.
So as a next step you have to enter your cameras position as v into the hnf:
Code:
camera.z - h = a



After this, a is the cameras distance to the plane. If you now normalize your direction, multiply it with a/z and add the cameras position, you´ve got your point:
Code:
mousedir*((camera.z-h)/mousedir.z)+camera.xyz = position



It is a bit more tricky with an arbitary normal, but the approach is basicly the same and this should already do it for your example.