Kodewerx
https://www.kodewerx.org/forum/

What would sin() and cos() look like in an N64 game?
https://www.kodewerx.org/forum/viewtopic.php?f=2&t=6813
Page 1 of 1

Author:  HyperHacker [ Sat Jun 06, 2009 12:10 pm ]
Post subject:  What would sin() and cos() look like in an N64 game?

Just wondering if anyone knows what specifically to look for. The only things I can think of are "look for a series of incrementing floats" or "find some code that uses them and try to track them down", neither of which sound appealing. Just looking for the values of sin(1), sin(2), etc may not work due to varying precision and even varying degrees (at least on NDS, it's common to divide circles into 512 pieces instead of 360). Since my code is already over 200 lines and these already must exist in the game, I don't exactly feel like sticking a sin table into the code. V_v

Author:  Parasyte [ Sat Jun 06, 2009 8:05 pm ]
Post subject:  Re: What would sin() and cos() look like in an N64 game?

Looking through the PsyQ libraries in IDA Pro might help (although I recommend ignoring IDA Pro as best you can)

Author:  Hextator [ Sun Jun 07, 2009 1:01 am ]
Post subject:  Re: What would sin() and cos() look like in an N64 game?

HyperHacker wrote:
Just looking for the values of sin(1), sin(2), etc may not work due to varying precision

For that case, can't you just ignore a few bits?

I'm eager to see what this looks like, too. I'm surprised I haven't ran into it yet.

Author:  Tyler24 [ Mon Jun 08, 2009 10:19 pm ]
Post subject:  Re: What would sin() and cos() look like in an N64 game?

Zeld wrote:
HyperHacker wrote:
Just looking for the values of sin(1), sin(2), etc may not work due to varying precision

For that case, can't you just ignore a few bits?

I'm eager to see what this looks like, too. I'm surprised I haven't ran into it yet.


You could have a look up table. However, this would produce somewhat inaccurate results. And for that reason, a series of values might be calculated... n=0, to n=?, where the series is [(-1)n * x^(2n+1)]/(2n+1)! for sin, and [(-1)n * x^(2n)]/(2n)! for cosine. Sin and cosine converge very quickly (as long as it is restricted to +/- 180 degrees)... it doesn't take many calculations to achieve a relatively accurate value... accurate enough for graphics calculations on a decade old console, anyways.

I would expect to see a for loop, where the author already calculated the number of loops that have to be done in order to achieve a certain accuracy, where sum+= the series for that n, again from n=0 to n=?.

Author:  Parasyte [ Tue Jun 09, 2009 6:58 pm ]
Post subject:  Re: What would sin() and cos() look like in an N64 game?

Considering almost (?) all commercial N64 games were written with the PsyQ development kit, they use the "libultra" standard library. libultra (like most standard libs) contains its own math suite. If sin(), cos(), and relatives are not in libultra, developing 3D games on N64 would have been infeasible.

Again, I suggest looking there.

Author:  HyperHacker [ Sat Jun 20, 2009 4:33 pm ]
Post subject:  Re: What would sin() and cos() look like in an N64 game?

So what would I be looking for? Would there be some convenient map file that tells the name and address of each function?

Author:  Parasyte [ Sun Jun 21, 2009 7:44 pm ]
Post subject:  Re: What would sin() and cos() look like in an N64 game?

How do you imagine a compiler "knows" where to find the sin() and cos() functions in your standard math library when it attempts to link the objects into a usable executable?

Hint: Symbol tables.

IDA Pro, much to my chagrin, is 'decent' at combining the provided symbol tables along side the disassembly output of unlinked library object files.

Ergo: Just disassemble the lib and look for "sin", "cos", ... ?

Page 1 of 1 All times are UTC - 8 hours [ DST ]
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/