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 > assembly sin gen code request
2011-12-30 12:14
Flavioweb

Registered: Nov 2011
Posts: 447
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
Skate

Registered: Jul 2003
Posts: 491
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.
2012-01-06 05:16
ChristopherJam

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

Registered: Aug 2004
Posts: 1380
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
Glasnost
Account closed

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...
http://lab.polygonal.de/2007/07/18/fast-and-accurate-sinecosine..
...but the link is not working anymore..
2012-01-12 09:17
Skate

Registered: Jul 2003
Posts: 491
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...
2012-01-12 16:31
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. ?

:)
2012-01-12 19:47
Cruzer

Registered: Dec 2001
Posts: 1048
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: 3136
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
2012-01-13 20:57
Wisdom

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

http://lab.polygonal.de/?p=205
2012-01-17 07:05
ChristopherJam

Registered: Aug 2004
Posts: 1380
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
Advanced
Users Online
Scrapper
rexbeng
Menace/Spaceballs
Kakka/Extend, Damone..
Guests online: 151
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Logo Graphicians
1 Sander  (9.9)
2 Facet  (9.6)
3 Mermaid  (9.4)
4 Pal  (9.4)
5 Shine  (9.3)

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