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

Forums > C64 Coding > assembly sin gen code request
2011-12-30 12:14

Registered: Nov 2011
Posts: 352
assembly sin gen code request

i need a code (assembly) to gen sin table. I need to set start, end and step value. Someone could help?
... 17 posts hidden. Click here to view all posts....
2012-01-05 22:46

Registered: Jul 2003
Posts: 470
I usually choose one of the suggestions above but maybe bresenham's circle algorithm, mid point algorithm or a mixture like below may help you to generate a sine table. if you can draw a circle, you can generate a sine table using one of the x or y coordinates, right? The only problem I see here is not being able to get a certain table length but maybe this can be solved somehow.


Edit: @ChristopherJam: I just checked CORDIC and it looks like a good fit. I didn't know about it before. Thanks for sharing.
2012-01-06 05:16

Registered: Aug 2004
Posts: 786
@Skate You're welcome.

I've a feeling it was John West (he who co-authored 64doc with Marko Mäkelä) who originally suggested I check it out, some 20 years ago now. I'd forgotten how it worked until I looked it up again for this post.
2012-01-06 05:25

Registered: Aug 2004
Posts: 786
Hmm, the problem with using Bresenham is each pixel generated is at a constant x-increment from the one before, rather than a constant theta-increment.

However, I was wondering if perhaps you could use something Bresehnham-like to normalise the result of repeatedly doing a fixed rotation, that might otherwise drift in scale?
2012-01-11 17:37

Registered: Aug 2011
Posts: 26
There is a fast and simple approximation.

Calculate first the hyperbolic approximated sine described earlier (sinH)

Then correct with this:

sin = 0.225 * (sinH * sinH - sinH) + sinH;

0.1% error in worst case compared to the real sinus..

Found it on...
...but the link is not working anymore..
2012-01-12 09:17

Registered: Jul 2003
Posts: 470
Thanks Glasnost, nice article there.

P.S: You can reach the page using the archive.org's link below. (takes a while to load, be patient)

2012-01-12 16:31
Account closed

Registered: Apr 2002
Posts: 2238
i havent really ever seen a C64 sine gen in asm.

i use a basic line we made 25 years ago, then mod it for moves.

another way is to use excell spreadsheet, and generate curves from formulas there, and export to c64.

what i want to say really, is, why dont someone make a c64 tool ? if its so important, then make a c64 generator. ?

2012-01-12 19:47

Registered: Dec 2001
Posts: 959
SIDWave: Nowadays you can just use an assembler script to generate stuff like that. E.g. KickAss where you have access to all the basic math functions from Java. What this discussion is about is generating it in machine code, in order to avoid having to load it from disk.
2012-01-12 19:50
iAN CooG

Registered: May 2002
Posts: 1895
Jan: are you joking? apart that it's explained on codbase how to do it in asm, there is a plethora of native sinus table generators, I even mentioned one in my 1st post (wix bouncer), and if in doubt just search sinus:
2012-01-13 20:57

Registered: Dec 2001
Posts: 88
Working link for the article Glasnost referred to:

2012-01-17 07:05

Registered: Aug 2004
Posts: 786
Might be an interesting challenge to make a 'fewest bytes' sine table generator, criteria "can generate a 256 entry table for floor(128.5+127*sin(i*pi/128.0))", with errors of no more than +-1, at least 170 entries exact.

Of course, it's possible a delta compression scheme might end up winning out over a calculation.. and any entry of more than 256 bytes of code is pretty much an automatic fail!
Previous - 1 | 2 | 3 - 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
Users Online
Guests online: 34
Top Demos
1 Uncensored  (9.7)
2 Edge of Disgrace  (9.7)
3 Coma Light 13  (9.6)
4 The Shores of Reflec..  (9.6)
5 Comaland 100%  (9.6)
6 We Come in Peace  (9.6)
7 Lunatico  (9.6)
8 Incoherent Nightmare  (9.5)
9 Wonderland XII  (9.5)
10 Wonderland XIII  (9.5)
Top onefile Demos
1 FMX Music Demo  (9.5)
2 Pandemoniac Part 2 o..  (9.5)
3 Daah, Those Acid Pil..  (9.5)
4 Dawnfall V1.1  (9.5)
5 Treu Love [reu]  (9.5)
6 In Memoriam BHF  (9.5)
7 Merry Xmas 2017  (9.4)
8 Dawnfall  (9.4)
9 SWiRL  (9.4)
10 Synthesis  (9.4)
Top Groups
1 Oxyron  (9.4)
2 Booze Design  (9.4)
3 Censor Design  (9.4)
4 Finnish Gold  (9.4)
5 Crest  (9.3)
Top Swappers
1 Derbyshire Ram  (10)
2 Splatterhead  (9.8)
3 Zyron  (9.8)
4 Acidchild  (9.8)
5 Walker  (9.7)

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