Cosinus Sinus Table Generating 68000 code

All 680x0 related coding posts in this section please.

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
GT Turbo
Captain Atari
Captain Atari
Posts: 335
Joined: Tue Feb 17, 2004 9:41 am
Location: Alsace, France
Contact:

Cosinus Sinus Table Generating 68000 code

Postby GT Turbo » Fri Jul 16, 2004 8:56 am

Some years, when we beginning to do 3d, we have always a little problems, the Sinus and Cosinus table, some people done table in gfa and then loaded the file in asm. That's possible, but when you don't have harddisk and not enough memory for using ramdisk, that's not easy !!


Azrael has thinked a little bit on this problem and have done this rout.

This is 68xxx code, that's enough interresting for demo and games coding.

So use it and enjoy !



If you want to thanks somebody, thanks Azrael he has done this rout and he was ok to spread it with you !!


GT Turbo (C.V.) 8)
Never forget : Power is in your minds !!!

http://Cerebral-Vortex.net

http://Jagware.org

User avatar
tobe
Atari God
Atari God
Posts: 1459
Joined: Sat Jan 24, 2004 10:06 am
Location: Lyon, France
Contact:

Postby tobe » Fri Jul 16, 2004 11:37 am

Nice :D !
step 1: introduce bug, step 2: fix bug, step 3: goto step 1.

User avatar
Zorro 2
Administrator
Administrator
Posts: 2198
Joined: Tue May 21, 2002 12:44 pm
Location: Saint Cloud (France)
Contact:

Postby Zorro 2 » Fri Jul 16, 2004 12:28 pm

Many thanks to Azrael !!!
Member of NoExtra Team

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5032
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Postby simonsunnyboy » Fri Jul 16, 2004 12:57 pm

Afaik ray/tscc has a 20 liner in asm for this purpose on his website.
I'm not sure if it is suitable though.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
GT Turbo
Captain Atari
Captain Atari
Posts: 335
Joined: Tue Feb 17, 2004 9:41 am
Location: Alsace, France
Contact:

Postby GT Turbo » Fri Jul 16, 2004 3:09 pm

simonsunnyboy wrote:Afaik ray/tscc has a 20 liner in asm for this purpose on his website.
I'm not sure if it is suitable though.



This is an 'very old rout', Azrael has coded it, 10 years ago !! That's why this rout is a little bit long !!



GT Turbo (C.V. ) :D
Never forget : Power is in your minds !!!



http://Cerebral-Vortex.net



http://Jagware.org

User avatar
Azrael_CV
Atarian
Atarian
Posts: 8
Joined: Thu Apr 01, 2004 4:11 pm
Location: Paris
Contact:

Postby Azrael_CV » Fri Jul 16, 2004 3:50 pm

As Gt Turbo said, anybody can use it. It's like the music you use in a demo, just cite the group from where it comes.

Yes, Ray of TSCC has done a 20 lines rout. Usually the shorter is the faster and the better. Nevertheless it's not the case here.

Ray made an approximation which maximal relative error is between 20 %and 30% when you goes near zero. And the absolute error is maximal near 108 degrees (I'm talking in degrees, radiis are not convenient in computer world).

SimonSunnyboy 8), take off your sunglasses 8O and take a closer look to Ray's sin table. He did a cool job, but this a global approximation of the only sin table only between 0 and 180 degrees.

Our rout generate recursively the sin AND cos tables BETWEEN 0 and 360 degrees by step of 1 degree. The recursivity allows us to be more precise than the global interpolation of Ray. The methods are differents, the results too.

But SimonSunnyBoy, you don't care about it, trigonometric functions are implemented in GFA.

This is only for who wants to save space disk by generating their own trigonometric table.

For all the coders, the table is multiplied by 4096, but you already saw it in the code. :wink:

Have fun.
Az.
Last edited by Azrael_CV on Fri Jul 16, 2004 7:38 pm, edited 1 time in total.

User avatar
tobe
Atari God
Atari God
Posts: 1459
Joined: Sat Jan 24, 2004 10:06 am
Location: Lyon, France
Contact:

Postby tobe » Fri Jul 16, 2004 7:20 pm

Thank again Azrael :D

One day a PSX coder tell me it was possible to compute a sin/cos in asm using some precedent values, it is what you done ?

You say :
I'm talking in degrees, radiis are not convenient in computer world

But evey day, at work, i use radians to compute models transformation on (ugly ;)) pcs. As it seem you are pretty good with math (GT Turbo say your are the best), can you explain me why we use radians ?
I must admit i'm not very good with maths ;)
step 1: introduce bug, step 2: fix bug, step 3: goto step 1.

User avatar
Azrael_CV
Atarian
Atarian
Posts: 8
Joined: Thu Apr 01, 2004 4:11 pm
Location: Paris
Contact:

Postby Azrael_CV » Fri Jul 16, 2004 7:33 pm

Tobe, you're right, sin and cos are mathematically defined with radians, but as far as it is hard to figure an angle for 3D design, I would rather use degrees.

As far as I remember, the rout in asm uses two values of sin and cos: sin(45), cos(45), sin(1) and cos(1).

To compute cos(46), I use the trigonometric identity cos(a+b)=cos(a)cos(b)-sin(a)sin(b). It leads to cos(46)=cos(45+1)=cos(45)cos(1)-sin(45)sin(1). And also sin(46)=sin(45+1)=sin(45)cos(1)+sin(1)cos(45).

To compute cos(47), I calulate cos(46+1) with the preceeding values. And so on.

Now you know everything about this rout.

Az

User avatar
tobe
Atari God
Atari God
Posts: 1459
Joined: Sat Jan 24, 2004 10:06 am
Location: Lyon, France
Contact:

Postby tobe » Fri Jul 16, 2004 8:36 pm

ok ;)
step 1: introduce bug, step 2: fix bug, step 3: goto step 1.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5032
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Postby simonsunnyboy » Mon Jul 19, 2004 9:40 am

I never claimed anything about itsquality. I just stated a 20 liner does exist. For asm I personally would use a precalced table anyway.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

rebb
Atariator
Atariator
Posts: 27
Joined: Fri Jul 01, 2011 3:13 pm

Re: Cosinus Sinus Table Generating 68000 code

Postby rebb » Wed Jul 25, 2012 8:26 pm

Old topic, eh?
I am trying to plot sinecurve created with this
piece of code. Failing of course :)

I have no idea how to use mon in devpack to actually see this
table.
Any ideas on what this generated table looks like? And yes i am newbie coder :)

User avatar
GT Turbo
Captain Atari
Captain Atari
Posts: 335
Joined: Tue Feb 17, 2004 9:41 am
Location: Alsace, France
Contact:

Re: Cosinus Sinus Table Generating 68000 code

Postby GT Turbo » Wed Jul 25, 2012 9:24 pm

Hello,

Do you want an example ? :)


GT :)
Never forget : Power is in your minds !!!



http://Cerebral-Vortex.net



http://Jagware.org

rebb
Atariator
Atariator
Posts: 27
Joined: Fri Jul 01, 2011 3:13 pm

Re: Cosinus Sinus Table Generating 68000 code

Postby rebb » Thu Jul 26, 2012 2:26 am

Anything moving me on :)

rebb
Atariator
Atariator
Posts: 27
Joined: Fri Jul 01, 2011 3:13 pm

Re: Cosinus Sinus Table Generating 68000 code

Postby rebb » Fri Aug 03, 2012 9:23 pm

I ended up using old sinustable i had, and with help from #atariscne (Hi Defjam!), problem was solved. Everything works more than fine!

User avatar
MiggyMog
Atari Super Hero
Atari Super Hero
Posts: 837
Joined: Sun Oct 30, 2005 4:43 pm
Location: Scotland

Re: Cosinus Sinus Table Generating 68000 code

Postby MiggyMog » Tue Aug 07, 2012 8:18 pm

Did someone not do a bootsector demo which drew circles a few years ago, this must have generated SIN/COS?

512bytes should be easy to reverse for those inclined ?
('< o o o o |''| STM,2xSTFM,2xSTE+HD,C-Lab Falcon MK2+HD,Satandisk,Ultrasatandisk,Ethernat.

seedy1812
Atari User
Atari User
Posts: 33
Joined: Tue May 18, 2010 2:04 pm

Re: Cosinus Sinus Table Generating 68000 code

Postby seedy1812 » Wed Sep 12, 2012 2:17 pm

MiggyMog wrote:Did someone not do a bootsector demo which drew circles a few years ago, this must have generated SIN/COS?

512bytes should be easy to reverse for those inclined ?



You dont need sin cos tables for circles , instead use Bresenham's circle algorithm.
http://en.wikipedia.org/wiki/Midpoint_circle_algorithm.

defjam
Retro freak
Retro freak
Posts: 11
Joined: Mon Sep 25, 2006 10:50 am
Location: Dresden/Germany
Contact:

Re: Cosinus Sinus Table Generating 68000 code

Postby defjam » Wed Nov 07, 2012 9:58 am

Do you refer to this http://www.pouet.net/prod.php?which=53189 one ?

I used: x^2 + y^2 = r^2

This way you can generate a MxN field with a circular structure,
but you also need a sqrt (I used a table iirc).


Social Media

     

Return to “680x0”

Who is online

Users browsing this forum: No registered users and 2 guests