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?
 
... 20 posts hidden. Click here to view all posts....
 
2012-01-18 08:57
Graham
Account closed

Registered: Dec 2002
Posts: 990
Quoting Cruzer
I'm also usually using Graham's mirror trick in bigger productions, even with only a 64 byte table. :)

Yes, if you add an offset of 0.5 to the sinus index (0.5 to 255.5 instead of 0 to 255), you can use a 64 byte table. This works nice for plasmas, sinus movements etc. However for "real maths" like 3D rotation or similar, it's better to use a sinus wave without that 0.5 index.
2012-01-18 20:54
Wisdom

Registered: Dec 2001
Posts: 90
Quoting ChristopherJam
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!


In Tied, there is a simple delta encoded sinus table, consisting of only 8 bytes, but the decoder itself is around 38 bytes (might change due to initialization in a different perspective). Extends a full sinus for 00-3F values to a 256 bytes table.

There is also a second one, which has a more complex shape, consisting of a 32 bytes table and a separate 40 bytes decoder (again, might be different a byte or two in a different initialization scenario). Again, extends to a 256 bytes table with values between 00-3F.
2012-01-19 12:45
Adam

Registered: Jul 2009
Posts: 323
Quoting SIDwave
... what i want to say really, is, why dont someone make a c64 tool ? if its so important, then make a c64 generator? :)


Hi Jan, Here is a tool that will allow you to generate sine waves using MS-Windows:

Sinus Creator V3 by 'The Gang'
http://www.thegang.nu/get_data.php?type=attachment&id=160

The website says version 2.x but the program in the zip archive is version 3. This program is very useful ;)
Output: Binary, Assembler, BASIC, C, C Source and WAV Audio samples =D

2012-01-19 13:43
ChristopherJam

Registered: Aug 2004
Posts: 1409
This routine has an accuracy ±3 (should be able to improve that by tweaking the table a little), but relies on interrupts being clear, character DMA disabled, and voice 3 of SID being fully decayed with a release rate of zero! 58 bytes including table, piecewise linear using env3 to select one of 13 segments:

sin=$4000
v3ctrl = $d40e+4
v3AD   = $d40e+5
v3SR   = $d40e+6
env3   = $d41c

initSin
	ldx#$50
	stx v3AD
	inc v3ctrl
	lda#127
	clc
lp 
ly  ldy#63
  	eor#$ff
	sta sin-$50,x
	sta sin+64,y
	eor#$ff
	sta sin+128-$50,x
	sta sin+192,y           ;26 cycles

	rol  ; note this will clear carry
	ldy env3  ; increases by 1 every 208 cycles for attack=5,
	sbc dt,y
  	lsr
	inx
	dec ly+1
  	bpl lp            ; 22+26 =48 for entire loop

	rts
dt
	.byt 5,5,5,5,5, 4,4,3,3,2, 2,1,0,255


CIA would probably be a better bet than SID, but I'm not very familiar with it, and it's less of an evil hack :)
2012-01-19 19:10
Cruzer

Registered: Dec 2001
Posts: 1048
Generating sines with the SID, now that's what I call a hack! Is it based on sine-like waveforms, or is the SID just used as a counter as the comments imply?
2012-01-19 19:27
chatGPZ

Registered: Dec 2001
Posts: 11386
the envelope generator uses some sort of spline approximation, so its linear steps and the slope changes at a few points.
2012-01-19 20:38
ChristopherJam

Registered: Aug 2004
Posts: 1409
Much simpler than all that; I just needed a value that increased by one every four or five iterations through the loop. The sin table generated is a linear approximation calculated in 8.1 fixed point, with a new slope value for each envelope increment.

Envelope generation is itself piecewise linear in the decay and release phases, but attack (as used here) just increases at a constant rate.
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
Andy/AEG
rikib80
CreaMD/React
Erol
DeMOSic/MS^LSD^ONS
The Syndrom/TIA/Pret..
Nordischsound/Hokuto..
psych
Guests online: 107
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 Censor Design  (9.3)
5 Triad  (9.3)
Top Graphicians
1 Mirage  (9.8)
2 Archmage  (9.7)
3 Pal  (9.6)
4 Carrion  (9.6)
5 Sulevi  (9.6)

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