?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.  
  2.     ; Sinus table generator - using lua script, because sjasmplus itself does not have
  3.     ; floating point arithmetics and sin/cos/... functions.
  4.  
  5.     org $8000
  6.  
  7. sin_table:  ; check listing file to see resulting table bytes
  8.     lua allpass ; EVERY pass must emit the machine code to not affect following labels
  9.         -- 256 bytes (index 0..255):
  10.         for i = 0, 255, 1 do
  11.  
  12.             -- index 0..255 will cover angle range < 0, 2Pi )
  13.             -- i.e. going in sinus values 0 -> +1 -> 0 -> -1 -> 0
  14.             -- For different range, the /128.0 must be modified:
  15.             --     /256.0 is 0..Pi, /512.0 is 0..Pi/2, etc
  16.  
  17.             -- The *15.5 is amplitude of final values
  18.             -- to be -15 .. +15 (+0.5 for "floor" compensation)
  19.             -- in this example values are signed byte (-15 == 241 == 0xF1)
  20.  
  21.             sj.add_byte(math.floor(math.sin(math.pi * i / 128.0) * 15.5))
  22.         end
  23.     endlua
  24.  
  25.     jr  start
  26. start:
  27.