I'm very new to this, but I'm working on a TAS of Pokemon Pinball Ruby & Sapphire, and I want to reverse-engineer how the physics engine decides how far the ball should move from frame to frame to help with planning. I've found the memory addresses for x position (pixel and subpixel), y position (pixel and subpixel), x velocity, and y velocity. No other variables have an effect that I can see, the same velocities produce the same change in x and y position regardless of what else is going on. Here's what I know so far:
Each frame, the X position changes by 4*x_velocity.
Each frame, the Y position changes by 4*y_velocity, plus an offset. The offset is +9 for velocities <99>=200.
Both of those values have a cap; the position will never change by more than 1340 subpixels X or more than 1344 subpixels Y (both reached at velocity of 335).
Here's where we hit the point where I don't understand the rules. The caps described above only apply when you have only one velocity, and 0 of the other. When you have both, the cap decreases. What I'm trying to figure out is how the cap is determined, and how the relative x and y changes are determined. The data I've collected is linked below (I was just trying to get it recorded, sorry about the lack of formatting), any help or advice is appreciated!
https://docs.google.com/spreadsheets/d/1uIjwvN0hxTkXjoC_NjfXyfd8DU3A3PCzLFUeRNdXnKg/edit?usp=sharing