I'm having a lot of difficulty making a function that correctly clips a RECT for BltFast. Does anyone have a function for doing this?

(sees if it is partially offscreen, if so then change the rect)