Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user maak ! (Registered 2024-04-18) 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: 442
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: 3132
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: 442
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: 1703
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: 3132
I already linked the section on codebase64, but went unnoticed I think =)
2012-01-05 14:48
ChristopherJam

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

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: 490
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: 1370
@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: 1370
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
Weasel/Padua/Hitmen/..
CA$H/TRiAD
Alakran_64
Dymo/G★P
Higgie/Kraze/Onslaught
Guests online: 83
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 The Ghost  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.8)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 Wafer Demo  (9.5)
7 TRSAC, Gabber & Pebe..  (9.5)
8 Onscreen 5k  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Diskmag Editors
1 Jazzcat  (9.4)
2 Magic  (9.4)
3 hedning  (9.2)
4 Newscopy  (9.1)
5 Elwix  (9.1)

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