Post subject: Subpixel positioning
Joined: 5/17/2007
Posts: 48
I've seen that quite a few TASes are optimized through use of subpixel positioning. I was wondering, how exactly does one go about finding the hex addresses for subpixel position?
Joined: 10/15/2007
Posts: 685
Not every physics model will have position values at a subpixel level, but you'd find them the same way you'd find any other position value - searching memory addresses based on grid coordinates. If the position values allow for a greater resolution than what is displayed onscreen, then movement and placement are calculated at a subpixel level.
Kirby said so, so it must be true. ( >'.')>
Editor, Experienced player (734)
Joined: 6/13/2006
Posts: 3300
Location: Massachussetts, USA
Sometimes it's even easier than that. For most games (all? I'm not sure) the sub pixel position is exactly next to the pixel position memory address. Any game that has acceleration will have sub pixel positioning.
Homepage ☣ Retired
Skilled player (1827)
Joined: 4/20/2005
Posts: 2161
Location: Norrköping, Sweden
Once you have the pixel positions, finding subpixel positioning isn't very hard (if, of course, there is a subpixel address, which there usually is for platformers. Here's one way to do it: You need to study how your pixel positon changes when running forward, for example. If your pixel position increases by 1-2-1-2-1-2-... then it's likely that your X pixel increases by 1 and X-subpixel increases by 128 every frame. Thus you need to search for an address that alternates between two values that differ by 128, probably 0 and 128. Of couse, different movement patterns give you a different subpixel speed. If you X pixel position increases by 1-1-1-2-1-1-1-2-... then it's most likely that your X-subpixel increases by 64 each frame. For vertical subpixel you can use pretty much the same technique, but it can be a little harder to find the exact speed. A thumb rule rule is that if you move x+1 pixels on a frame where you suspected that you should have moved x pixels, your subpixel position probably hit 256 and was reset back to 0. But overall, what Comicalflop said is often true - if you do have the pixel addresses, the subpixel addresses are often very close, but not always. Hope this made some sense.
Banned User
Joined: 12/23/2004
Posts: 1850
Basically what was said previously; it's likely that it's stored near the full pixel coordinates. What you could also try is freezing the pixel value and looking for values that change while moving and stop while not. Those can be a good indication.
Perma-banned
Banned User
Joined: 3/10/2004
Posts: 7698
Location: Finland
I really wonder why it doesn't cause any visual jerkiness if a sprite alternates between moving 1 pixel and 2 pixels at a time. The effect should be worse if it only moves 2 pixels sometimes but 1 pixel most of the time.
Joined: 10/15/2007
Posts: 685
It's a combination of the oscillation of movement being so rapid, the variation between distance traveled in opposing frames being minute, and the movement being accompanied by character animation. The human brain likes to disregard a lot of information it takes in visually, and movements that subtle at 1/60th (and even 1/30th) of a second tend to just go unnoticed when placed against the whole.
Kirby said so, so it must be true. ( >'.')>
Site Admin, Skilled player (1254)
Joined: 4/17/2010
Posts: 11475
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
& what about usual subpixel management? Adeliket in his 'ram search tutorial' says how subpixel values help/hinder speedrunning, but english live speach isn't clear enough for me. So may it be described in writing?
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Emulator Coder, Skilled player (1113)
Joined: 5/1/2010
Posts: 1217
Comicalflop wrote:
Any game that has acceleration will have sub pixel positioning.
Actually, some games have acceleration but don't seem to have subpixels (DOS Mario&Luigi, DOS Jazz Jackrabbit). At least I didn't see any behavior of position addresses that would indicate presence of subpixels when TASing those games. Also some games measure position in units that are finer than 1 unit per pixel (often units per pixel is some power of two). There are no separate subpixel addresses in that case (DOS Skyroads, DOS Lada: The Ultimate Challenge).
Editor, Player (69)
Joined: 1/18/2008
Posts: 663
As another example, Somari has an acceleration counter but no subpixels. The counter is used for various things including pixel per frame speed, whether to skid if pressing the opposite direction, speed in water etc.
true on twitch - lsnes windows builds 20230425 - the date this site is buried
Post subject: Subpixels. How to Find and Make Use of Them
CoolHandMike
He/Him
Editor, Judge, Experienced player (895)
Joined: 3/9/2019
Posts: 695
So I would like to know more subpixels. What ways are there to find subpixels? As a bonus could I also get an explanation of the best ways of using them as a practical way of improving a tas?
discord: CoolHandMike#0352
RetroEdit
Any
Editor, Reviewer, Player (169)
Joined: 8/8/2019
Posts: 152
These might also be useful to reference: Post #14890, Post #15277, Post #16932 In general, I would say subpixels are just a subset of coordinate data relevant to certain games. Finding the coordinate data is what's broadly useful, since it allows you to make nonobvious optimizations. If the game uses subpixels, you're then optimizing for the subpixel value rather than guessing based on what the movement visually appears to be. This generally allows more granular refinement. One way I've used subpixel is when you're travelling vertically and your horizontal progression is restricted. With subpixels, you can cut close to corners without bumping into the corner. Basically the idea is, you use the vertical airtime where you're not really progressing to optimize the subpixel position for the next section of the same level.