Views: 828,619,461
35 users online: Agent Q, Alex_X8, AmperSam,  BeeKaaaay, chickaDEE Magazine,  Dan, Darolac, Dominicentek, Erik_The_Swift, ExONightZ,  Flagpole1up, fome82, imamelia, Infinity, JamesD28, Koop the Koopa, Koopster, LOLRyan2006 Mario Fan, OnyxFusion, orka-bln, Poison, qantuum, Sapphire,  Sinc-X, smw_andz, Some_J_Name, SquidMan_Raps, StackDino, SteamyPanini, Synergic, TheJavabrew, TheLastGamer09, tomato jonson, TruffledToad, xxmagegagexx - Guests: 95 - Bots: 147 Users: 44,389 (2,540 active)
Tip: Take advantage of easy to install Patches in your hack. The No More Sprite Tile Limits patch should be considered if you're encountering glitches where Mario and/or sprites are turning invisible.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?

Give thanks to RPG hacker for working on Asar.
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)

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
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.

Give thanks to RPG hacker for working on Asar.
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.

Copyright © 2005 - 2020 - SMW Central
Legal Information - Privacy Policy - Link To Us

Total queries: 16


Follow Us On

  • YouTube
  • Twitch
  • Twitter


  • Super Mario Bros. X Community
  • Mario Fan Games Galaxy