2014-05-31 00:46:55 +00:00
|
|
|
;ACME 0.94.12
|
2024-01-29 00:59:41 +00:00
|
|
|
;!to "trigono.o", plain
|
2013-04-07 21:29:09 +00:00
|
|
|
* = $c000
|
2012-02-27 21:14:46 +00:00
|
|
|
|
|
|
|
PI = 3.14159265358979323846
|
|
|
|
|
|
|
|
!raw "cos[0,pi/2] scaled to 0-255 range"
|
|
|
|
!align $f, 0, 0 ; make output file look better in hex editor :)
|
|
|
|
|
2014-05-31 00:46:55 +00:00
|
|
|
!for x, 0, 255 {
|
|
|
|
!byte cos(float(x) / 255 * PI/2) * 255 + 0.5
|
2012-02-27 21:14:46 +00:00
|
|
|
}
|
|
|
|
; "float()" makes sure this calculation is done in float mode now
|
|
|
|
; "/255*half_PI" converts interval [0,255] to interval [0,PI/2]
|
|
|
|
; "cos()" returns cosine. Wow.
|
|
|
|
; "*255" converts interval [0,1] to interval [0,255]
|
|
|
|
; "+0.5" ensures correct rounding to integer
|
|
|
|
|
|
|
|
!align $f, 0, 0
|
|
|
|
!raw "sin[-pi/2,pi/2] scaled to full range of 16b.16b fixed point"
|
|
|
|
!align $f, 0, 0
|
|
|
|
|
2014-05-31 00:46:55 +00:00
|
|
|
!for x, 0, 1023 {
|
|
|
|
!32 sin(float(x - 512) / 1024 * PI) * 65536 + 0.5
|
2012-02-27 21:14:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
;undefined = 0.0 / 0.0 ; throws error when active
|
|
|
|
;range = arcsin(-10) ; throws error when active
|
|
|
|
!by 1 / 2 * 2 ; should give 0
|
|
|
|
!by 1 / 2 * 2.0 ; should give 0
|
|
|
|
!by 1 / 2.0 * 2 ; should give 1
|
|
|
|
!by 1 / 2.0 * 2.0 ; should give 1
|
|
|
|
!by 1.0 / 2 * 2 ; should give 1
|
|
|
|
!by 1.0 / 2 * 2.0 ; should give 1
|
|
|
|
!by 1.0 / 2.0 * 2 ; should give 1
|
|
|
|
!by 1.0 / 2.0 * 2.0 ; should give 1
|