Buckaroo Posted May 2, 2017 Share Posted May 2, 2017 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 Quote Link to comment Share on other sites More sharing options...
gauauu Posted May 2, 2017 Share Posted May 2, 2017 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. Quote Link to comment Share on other sites More sharing options...
Buckaroo Posted May 2, 2017 Author Share Posted May 2, 2017 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 Quote Link to comment Share on other sites More sharing options...
Kylearan Posted May 3, 2017 Share Posted May 3, 2017 (edited) 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 May 3, 2017 by Kylearan 1 Quote Link to comment Share on other sites More sharing options...
Buckaroo Posted May 4, 2017 Author Share Posted May 4, 2017 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. Quote Link to comment Share on other sites More sharing options...
bogax Posted May 7, 2017 Share Posted May 7, 2017 (edited) 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 May 7, 2017 by bogax Quote Link to comment Share on other sites More sharing options...
Buckaroo Posted May 8, 2017 Author Share Posted May 8, 2017 Thanks Bogax I missed your example before as I was searching within Atari 2600 Programming and not batari Basic The function in circle2.bas.bin was exactly what I was looking for Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.