Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > How easy is it to calculate sine tables from the bare bones in ML?
2008-08-05 09:52
Conrad

Registered: Nov 2006
Posts: 849
How easy is it to calculate sine tables from the bare bones in ML?

Hi!

I'd like to have a go at coding my own routine of calculating sine/cosine tables without use of the BASIC interpreters (pi, sin(), etc) and just use pure ML instead.

Can I ask, how easy (or how SMALL) is this to do? Do I need to do additional algorithms like factorial or are there KERNAL routines for that (if any)? Multiplication code is no problem as I've seen articles on those, I'm just thinking about the rest of math involved with sine calculation.

Thanx in advance.
 
... 22 posts hidden. Click here to view all posts....
 
2008-08-05 10:34
Skate

Registered: Jul 2003
Posts: 494
There are some 256b intros with source code which generates sine tables. Check this one for example.

Too(C)o(M)p(L)ex

Of course try to learn it, not copy & paste it.
2008-08-05 10:38
Radiant

Registered: Sep 2004
Posts: 639
To avoid nasty multiplications you could approximate a circle using an accelerating vector. I think it was Zed Yago who suggested this solution on IRC some time ago, and it sounds good enough for me.
2008-08-05 10:58
Conrad

Registered: Nov 2006
Posts: 849
Thanks everyone for your help! I have a rough idea what to do now! :)

radiantx: what's an accelerating vector? Is it related to I/O registers or is a much more complex formula? Again, I could ask Yago myself :)
2008-08-05 11:02
WVL

Registered: Mar 2002
Posts: 902
Quote: Thanks everyone for your help! I have a rough idea what to do now! :)

radiantx: what's an accelerating vector? Is it related to I/O registers or is a much more complex formula? Again, I could ask Yago myself :)


I guess yago meant that you can approximate a sine with 2 parabolas, and to calculate those you only need to have an acceleration (which matches the amplitude and 'length' of the sine you want.)
2008-08-05 11:06
Cruzer

Registered: Dec 2001
Posts: 1048
@Skate: Too bad it's some ugly sines that are generated that way. It's really just a couple of reverse parabolas, which is not the same as a real sine.
2008-08-05 11:07
Conrad

Registered: Nov 2006
Posts: 849
Ah, now I get ya, after looking up on parabolas ;).
Thanks again, all! .... off to code.

cruzer: that's okay, quick'n'dirty is all I need.
2008-08-05 11:18
Shadow
Account closed

Registered: Apr 2002
Posts: 355
Anyone have an example on how to access the BASIC routines from asm to generate a sine? Also how compact is such a routine, are we talking like 50 bytes or 500 bytes?
2008-08-05 11:22
JackAsser

Registered: Jun 2002
Posts: 2014
Anything you come up with, plz write a small article about it and post it on codebase. Mkaytnku.
2008-08-05 11:36
Skate

Registered: Jul 2003
Posts: 494
@Cruzer: So, your source code comment is the liar! ;)

Well, I like using plain basic for sinus calculations (slow but more flexible with ranges) in small sized intros and precalculated tables in bigger projects.
2008-08-05 13:53
Cruzer

Registered: Dec 2001
Posts: 1048
"generate sine" - yeah, guess that's a stretch. :)

Well, sometimes these parabolic "sines" work pretty good, and other times it's obvious to see that something's wrong, especially in the middle, where it's hard to get the two parabolas to meet precisely. But this is based on 256b routines - it might be possible to tweak it better if the code doesn't have to be super small.
Previous - 1 | 2 | 3 | 4 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Freeze/Blazon
Didi/Laxity
Guests online: 135
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Graphicians
1 Mirage  (9.8)
2 Archmage  (9.7)
3 Pal  (9.6)
4 Carrion  (9.6)
5 Sulevi  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.056 sec.