There are two functions which are critical to this which would probably be very easy to fix to someone who understands the math.
This function seems to convert the x/y/z position of the 3D object into values of 0.0-1.0 which correspond to screen position (0.0 being up/left, 1.0 being down/right)
tx = input->x - View_position.x;
ty = input->y - View_position.y;
tz = input->z - View_position.z;
x = tx * View_matrix.right_vector.x;
x += ty * View_matrix.right_vector.y;
x += tz * View_matrix.right_vector.z;
y = tx * View_matrix.up_vector.x;
y += ty * View_matrix.up_vector.y;
y += tz * View_matrix.up_vector.z;
z = tx * View_matrix.forward_vector.x;
z += ty * View_matrix.forward_vector.y;
z += tz * View_matrix.forward_vector.z;
output->x = x;
output->y = y;
output->z = z;
And then the function that converts these values into actual pixel coordinates
w = 1.0f / input->z;
output->x = (Screen_width + (input->x*Screen_width*w))*0.5f;
output->y = (Screen_height - (input->y*Screen_height*w))*0.5f;
I've modified the variable names to make both of these code snippets more understandable. Otherwise, these are extracted directly from the code, and seem to be the only chunks which handle the actual calculations.