in order to understand the sin/cos table, you need to understand the basics of trigonometry (speaking in general, not to you)

given a radius (distance from the center of a circle) and an angle, the table allows you to obtain X and Y distance from the center (aka position on the circle)

radius * sin(angle) = Ydisp

radius * cos(angle) = Xdisp

note that cos(angle) = sin(angle+90deg)

to obtain the sine of an angle, multiply it by 2 and use it as an index into the table (the value you get is the sine * 256)

for cosine, add 128 to your angle, multiply by 2, and then use it as an index

multiply this result with your radius, and then take the high byte of the result as your Ydisp (or Xdisp)

and yeah, if the angle is above 255 (since it goes from 0-511), you need to inverse the result

i made

this a while ago, it basically uses the same SMW table but i cut out the high bytes (since most were 0). ironically i manually calculated the values in the table before realizing that it's the same as SMW's

and yeah, dont claim you discovered the sin/cos table. plenty of other things make use of it

## Follow Us On