Might be somewhere in the handle bounds asm script.
(Sorry darkhog, I can’t make any test to confirm you and be more specific, right now, I am not with my pc)
Looks like Line 27 of Routines\Basic\ModuleScripts\MainScripts\BoundsHandlers\DoTopBoundsUpdate.asm but I'm not sure exactly how that should be edited to keep you from wrapping around and just falling off the bottom of the screen.