Views: 637,690,991Time: 2018-05-21 05:32:56 AM 8 users online: danwaleby, idol, Khastvrokg, MarkVD100, MasterMario97, Sariel, slakkmichael, Vic Rattlehead - Guests: 39 - Bots: 260 Users: 34,872 (1,403 active)Latest: TSG
 Tip: Keep track of ALL patches and hex edits in case you need to transfer your data to a new ROM. It's definitely worth the trouble. Not logged in.
Smw's sine/cosine table feedback
Forum Index - SMW Hacking - Resource & Tool Releases - SMW Data Repository - Smw's sine/cosine table feedback
 Pages: 1
(Closest forum I could find. If moved, please PM me, thanks.)

Hey, I'm working on making a document (and a tutorial) on how to use smw's sine/cosine table.

Here is the BETA.

How is it?

--------------------
Really hope Asar's %CallMacro() issues are fixed.
Quote
GreenHammerBro (ID: 18802) for discovering smw's sine/cosine table.

Not to be harsh but you didn't discover the trigonometry table. Many people have worked with it before. I'll assume you misworded or something.
I'll check more later, haven't worked with stuff like this in SMW before so it might come handy.

edit: in your example code in the html file you missed a STZ \$01 after ...PositiveHalf, but it's there in the ASM file.
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)

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
Oops, I'm going to make some changes to it to turn it into a tutorial. Also, I mentioned that SMW 's "unit circle" is a value of 256, this is because radix point "(decimal of") aren't allowed, as they are rounded to zero. It has to use a value out of 256 in order to get a fractional unit.

--------------------
Really hope Asar's %CallMacro() issues are fixed.
The sin table at \$07F7DB is really just a 8bit fixed point decimal values. That contain the first 180 degree (or pi in radians). In 256 word long entries.
Given the geometry of a sin, the other 180 degree are just the value times -1.
As such, you can simply multiply the table entry with any other value to get the x/y offset.

So really, all you need to know to work with them is basic geometry and understanding of fixed point decimal values.

--------------------
Anime statistic on MyAnimeList:
400 animes completed ✓
6000 episodes completed ✓
100 Days completed ✓
... what even am I doing with my life?
 Pages: 1
Forum Index - SMW Hacking - Resource & Tool Releases - SMW Data Repository - Smw's sine/cosine table feedback

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.