Subpixel
A fraction of a pixel that a game keeps in a position or speed but never draws.
Facts
- Evidence
- Code (2)
Verified (1)
Dev blog (1) - Sources
- 5
On this page
A subpixel is the undrawn fraction of a pixel in a position or speed. It lets things move by less than a pixel per frame, as in a slow walk. The fraction sits beside the whole-pixel position and carries into it when it adds up to a pixel. Its storage and resolution decide which speeds a game can represent.
- Super Mario Bros. stores vertical speed as a pixel byte and a fraction byte, in 1/256 px. Each frame, it adds the fraction into a subpixel byte of the position1. Horizontal speeds are coarser, in 1/16 px/frame2.
- Sonic the Hedgehog keeps 32-bit 16.16 positions and shifts 8.8 speeds into them, so its motion also resolves to 1/256 px3.
- Celeste keeps whole-pixel positions plus a float remainder per axis, and moves by the rounded remainder4.
All three draw only the whole-pixel part, so jump heights here are in whole drawn pixels.
References
- ^CodeXkeeper0/smb1prg.asm 6666–6687
How we know
Vertical motion is 8.8 fixed point; each frame, the gravity routine adds speed to position, the fraction via a subpixel byte, then gravity to speed.
6668 ADC SprObject_Y_MoveForce,x 6669 STA SprObject_YMF_Dummy,x ⋮ 6676 ADC SprObject_Y_Position,x ; add vertical position to vertical speed plus carry ⋮ 6683 ADC $00 ; add downward movement amount to contents of $0433 ⋮ 6685 LDA SprObject_Y_Speed,x ; add carry to vertical speed and store
src/prg.asm lines 6666–6687 at 1cc3c92 · upstream ↗ - ^CodeXkeeper0/smb1prg.asm 6492–6503
How we know
Horizontal speeds are 4.4 fixed point, whole pixels and sixteenths per frame; the horizontal-move routine shifts the sixteenths into the subpixel byte.
6495 ASL ; and move low nybble to high 6496 ASL 6497 ASL ⋮ 6500 LSR ; move high nybble to low 6501 LSR 6502 LSR 6503 LSR
src/prg.asm lines 6492–6503 at 1cc3c92 · upstream ↗ - ^Verifiedsonicretro/s1disasm · Sonic Retro, “Sonic Physics Guide: Calculations (Pixel and Subpixel)”sub ObjectFall & SpeedToPos.asm 16–20
How we know
In the running game, the object fall routine and the speed-to-position routine move Sonic's 32-bit position each frame by his speed shifted left 8 bits, X by this frame's X speed and Y, in the air, by the Y speed before gravity, so positions are 16.16 and speeds 8.8 fixed point.
16 move.w obVelY(a0),d0 ; load vertical speed 17 addi.w #gravity,obVelY(a0) ; increase vertical speed (apply gravity) 18 ext.l d0 ; extend speed to longword 19 asl.l #8,d0 ; shift speed up a byte (16.16 fixed point) 20 add.l d0,d3 ; add speed to Y-axis position
_incObj/sub ObjectFall & SpeedToPos.asm lines 16–20 at 15dfa3a · upstream ↗ Each pixel is effectively split into 256 slices along both axis and this means the finest fidelity available for movement is 1/256th of a pixel (aka 0.00390625).
Pixel and Subpixel · archived copy ↗ Measured by a script. It fails if the result disagrees with the claim.
- ^Dev blogThorson 2020 · NoelFB/CelestePlayer.cs 935
How we know
Celeste's actors sit on whole pixels; the vertical move adds the float distance to a remainder, moves by its rounded value, and keeps the fraction.
xRemainder += amount; int move = Round(xRemainder); if (move != 0) { xRemainder -= move;
Actor Basics · archived copy ↗ 935 MoveV(Speed.Y * Engine.DeltaTime, onCollideV);Source/Player/Player.cs line 935 at 1b0ce45 · upstream ↗
Sources
Code
- doppelganger and Xkeeper. 2022. “smb1: Super Mario Bros. disassembly for asm6f (Xkeeper0/smb1).” Commit 1cc3c92. Xkeeper0/smb1 @ 1cc3c92 · licence, all uses
- Sonic Retro contributors. 2026. “s1disasm: Sonic the Hedgehog (16-bit) disassembly (sonicretro/s1disasm).” Commit 15dfa3a. sonicretro/s1disasm @ 15dfa3a · licence, all uses
- Thorson, Maddy and Noel Berry. 2021. “Celeste: released class files (NoelFB/Celeste).” Commit 1b0ce45. NoelFB/Celeste @ 1b0ce45 · licence, all uses
Primary
- Thorson, Maddy. 2020. “Celeste and TowerFall Physics.” Medium. original · archived · licence, all uses
Secondary
- Sonic Retro contributors. n.d. “Sonic Physics Guide: Calculations (Pixel and Subpixel).” Sonic Retro. original · archived · licence, all uses