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 13:14
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....
 
2012-01-05 23:46
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.
2012-01-06 06:16
ChristopherJam

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

Registered: Aug 2004
Posts: 656
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 18:37
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/fast-and-accurate-sinecosine..
...but the link is not working anymore..
2012-01-12 10:17
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...
2012-01-12 17: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 20:47
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.
2012-01-12 20:50
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
2012-01-13 21:57
Wisdom

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

http://lab.polygonal.de/?p=205
2012-01-17 08:05
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
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
A3/AFL
Han
Knight Rider/Formby ..
hedning/G★P
Shadow/Noice
Stein/Prosonix/Offence
xIII/ATL
Almighty God/L64/Ons..
Isildur/Samar
St☯rmfr☯nt/ExCeSs
user/MYD
TomoAlien
Guests online: 68
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 Lunatico  (9.6)
6 Quad Core 100%  (9.5)
7 Comaland 100%  (9.5)
8 Incoherent Nightmare  (9.5)
9 Wonderland XII  (9.5)
10 Comaland  (9.5)
Top onefile Demos
1 Pandemoniac Part 2 o..  (9.6)
2 Synthesis  (9.6)
3 Dawnfall V1.1  (9.5)
4 Daah, Those Acid Pil..  (9.5)
5 Field Sort  (9.4)
6 Treu Love [reu]  (9.4)
7 Dawnfall  (9.3)
8 Globe 2016 [reu]  (9.3)
9 KAOS 64  (9.3)
10 Hardware Accelerated..  (9.2)
Top Groups
1 Booze Design  (9.4)
2 Censor Design  (9.4)
3 Oxyron  (9.4)
4 Crest  (9.3)
5 Finnish Gold  (9.3)
Top Swappers
1 Jerry  (10)
2 Zyron  (10)
3 Derbyshire Ram  (10)
4 Splatterhead  (9.8)
5 Walker  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2017
Page generated in: 0.33 sec.