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: 463
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?
2011-12-30 13:32
iAN CooG

Registered: May 2002
Posts: 3194
http://codebase64.org/doku.php?id=base:6502_6510_maths

anyway I'd use wixbouncer or other sintable generators and include the generated table, unless you're going to make a 256byte intro
2011-12-31 12:17
Style

Registered: Jun 2004
Posts: 498
wouldnt you be better off generating the table in BASIC before running the demo or whatever?
2011-12-31 13:16
Flavioweb

Registered: Nov 2011
Posts: 463
is better to have pre-calculated sin, but i want to write my own routine first for learning purpose then to make my code stand alone easy reusable simply changing some bytes...
2011-12-31 14:15
tlr

Registered: Sep 2003
Posts: 1790
You could use the kernal routines to implement basic-like generation of sine.

Faster would be to use a fixed point implementation of the MacLaurin series of sin(x).

Faster yet would be something like this: http://codebase64.org/doku.php?id=base:generating_approximate_s..
2011-12-31 14:21
iAN CooG

Registered: May 2002
Posts: 3194
I already linked the section on codebase64, but went unnoticed I think =)
2012-01-05 14:48
ChristopherJam

Registered: Aug 2004
Posts: 1409
CORDIC might be an interesting way to go.

There's a decent article on Wikipedia, but basically you start with a vector pointing along the X axis and perform a set series of rotation+scales using matrices whose components are all either 1 or a power of two. Each step you accumulate the angle you've rotated so far (fixed point addition of constant from very small table), and step either CW or CCW, depending if you've currently overshot. The angles get successively smaller, so it's close to a binary search. Total scale factor is a constant, so you can prescale your start vector by the inverse.

You could get away with only two or three distinct step sizes (and hence just hard code 2 or 3 shift amounts) if you were willing to do some extra iterations (say 20 large steps, 20 small).

Thoughts?
2012-01-05 16:51
Achim
Account closed

Registered: Jan 2010
Posts: 28
If you only need some sin-tables: Sinus Creator V2.0
2012-01-05 22:46
Skate

Registered: Jul 2003
Posts: 494
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: 1409
@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: 1409
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?
 
... 17 posts hidden. Click here to view all posts....
 
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
Act-Otl/Outlaws
zscs
rexbeng
Guests online: 88
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 Logo Graphicians
1 t0m3000  (10)
2 Sander  (9.8)
3 Mermaid  (9.5)
4 Facet  (9.4)
5 Shine  (9.4)

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