 
Flavioweb
Registered: Nov 2011 Posts: 342 
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.... 
 
Skate
Registered: Jul 2003 Posts: 467 
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.
http://willperone.net/Code/codecircle.php
Edit: @ChristopherJam: I just checked CORDIC and it looks like a good fit. I didn't know about it before. Thanks for sharing. 
 
ChristopherJam
Registered: Aug 2004 Posts: 656 
@Skate You're welcome.
I've a feeling it was John West (he who coauthored 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. 
 
ChristopherJam
Registered: Aug 2004 Posts: 656 
Hmm, the problem with using Bresenham is each pixel generated is at a constant xincrement from the one before, rather than a constant thetaincrement.
However, I was wondering if perhaps you could use something Bresehnhamlike to normalise the result of repeatedly doing a fixed rotation, that might otherwise drift in scale? 
 
Glasnost
Registered: Aug 2011 Posts: 24 
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...
http://lab.polygonal.de/2007/07/18/fastandaccuratesinecosine..
...but the link is not working anymore.. 
 
Skate
Registered: Jul 2003 Posts: 467 
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)
http://web.archive.org/web/20101229221122/http://lab.polygonal... 
 
SIDWAVE 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. ?
:) 
 
Cruzer
Registered: Dec 2001 Posts: 896 
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. 
 
iAN CooG
Registered: May 2002 Posts: 1734 
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:
http://csdb.dk/search/?seinsel=releases&search=sinus&all=1 
 
Wisdom
Registered: Dec 2001 Posts: 88 
Working link for the article Glasnost referred to:
http://lab.polygonal.de/?p=205

 
ChristopherJam
Registered: Aug 2004 Posts: 656 
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 