title! if you use this with pixel based movement, it becomes somewhat inconsistent with how far on the next map your player needs to be, since the value is rounded down.
if you're going right or down, your player has to be all the way on the next map to trigger the camera to move. but if you're going left or up, the camera moves the second any of your player is on the next map.
i personally fixed it by changing the "mx=flr(p.x/16)*16" (and the y version) in update_map() to "mx=flr((p.x+p.w)/8/16)*16". /8 because pixel movement's x and y don't line up with the grid and the p.w (p.h for the y version) to fix this issue. it's still a little off, but i'm planning on hiding it with a smooth transition animation.