Jump to content

Recommended Posts

I'm fairly new to VisualbB having only picked it up over the last week.

 

After looking through the forums and help files I'm unable to find any code to generate Sine and Cosine.

 

I've put together an example file where I've hard coded the Sine into a data Array but as the array length is 255 it's taking up a large chunk of my code.

Is there a way to generate sin in ASM?

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

LEFT/RIGHT - Select Sine/s

UP/DOWN - Adjust Sine/Cosine frequency

FIRE - Change sound

 

Dueling sines.bas.bin

 

Dueling sines.bas

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

P.S Thanks to the community, it's given me a great introduction to programming for the 2600

Share this post


Link to post
Share on other sites

A quick google search turned up this discussion about it. But you'd probably be hard pressed to come up with something that's both short in terms of code but also without a reasonably-sized lookup table.

Share this post


Link to post
Share on other sites

Thanks for the quick reply.

 

I'll try and wrap my head around that code. I'm finding ASM is a bit overwhelming at the moment

Share this post


Link to post
Share on other sites

If you only need an approximation and can get away with a small deviation from a "real" sine function (I often can), you can also use parabolas to generate sine tables in assembly.

 

EDIT: Of course RAM to store the table is a problem here, but you only need half a sine table (or even only a quarter) and can mirror the other half, and also a shorter table (128 or even 64 bytes for the full sine table) might be sufficient.

Edited by Kylearan
  • Like 1

Share this post


Link to post
Share on other sites

I've never considered splitting into 4 sections before as every other language I've used normally has a function you can access directly.

 

Now you've mentioned that it seems really obvious, just check the overflow amount and invert accordingly.

 

Again thanks for the great advice.

Share this post


Link to post
Share on other sites

there's some stuff with tables here

 

the last one (that notes that it's not very accurate) could be made accurate without too much trouble

I should have done an accurate one and one not so accurate for comparison, but I was in a hurry

I doubt the difference would be obvious

 

edit: there's also this thread

 

I know I've seen 6502 CORDIC code but I can't remember where

Edited by bogax

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...