23 utilisateurs en ligne:  Anorakun, autisticsceptile1993, Children's Digest 1950-2009,  Fernap, Fullcannon, Hidincuzimsmokin, Jolpengammler, Kaiz0bro, Knetog, lordkronos100, MarioTeam, nanec,  NopeContest, Overcrow03, RichardDS90, ShUriK KiD, Smirkov87, Sonikku, The_Big_Dededester, TheBourgyman, Tutuibimg, UlticraftMTT, underway - Invités: 84 - Robots: 189
Utilisateurs: 55 619 (2 425 actifs)
Dernier utilisateur: guizerapro

$00DC4F - How it works

Mario's position data is formatted like this in binary:

ssss0000: Position fraction bits, Stored in RAM $13DA and $13DC
ssss = subpixels, this ranges from 0-15.

PPPPPPPPPPPPPPPP: Position, in pixels (stored in $94 and $96). Ranges from 0-65535 (or (-32768) to 32767 in the signed context)

Mario's speed data ($7B and $7D) is formatted like this in binary:

ssss = subpixels
PPP = pixels. When the S bit is clear, this is treated as 0000000000000PPP, otherwise 1111111111111PPP. Therefore increasing the size and keeping the value it represents.
S = sign bit

To perform movement:
  1. First take the speed value's SPPPssss, move it to the high nybble (4 ASLs, SPPPssss becomes ssss0000) and add it with the fraction bits, store that as the new fraction bits. The carry bit after adding will be used later (if the addition exceeds 15, carry is set, otherwise clear).

  2. Second, we are handling the P bits. The speed value is only 3-bit and the pixel position is 16-bit, so we need to expand the number of bits so that we can correctly adjust to the 16-bit position. We take the speed value, and move the upper nybble to the lower (4 LSRs) so that the PPP bits are at the lowest bit position (it is now 0000SPPP). Check if the S bit is set (CMP #$08), and if not (less than 8), treat it as 0000000000000PPP otherwise (≥ 8) 1111111111111PPP. This handles the data using two's complement when handling signed values.

  3. Finally, perform movement in pixels. We take the expanded value from the previous step, and add by the pixel position, adding with the carry obtained from the first step (so that if enough fractional movement are made, move an additional pixel).