Re: [cc65] OT: SIN/LOG/EXP/SQR calculations?

From: Karri Kaksonen <karri1sipo.fi>
Date: 2012-03-22 20:36:58
On 03/22/2012 07:15 PM, Joseph Rose wrote:
> Sorry about the OT question, but I want to calculate the functions in 
> the subject heading for future work with graphics.  I could probably 
> use other functions as well.  I have only a high-school education; 
> otherwise, I wouldn't be asking here.  :(

The easiest way is to use a table.

;
; NB : each table is indexed by a 5 bit 2's comp number, and provides 32
; entries for trig tables in radians with the 5 bits commencing 3 after the
; decimal point
;
         .global SinLow
         .global SinHigh
SinLow:
.byte $00, $3f, $7f, $bf, $ff, $3f, $7f, $bf, $ff, $3f, $7f, $bf, $ff, 
$3f, $7f, $bf
.byte $01, $41, $81, $c1, $01, $41, $81, $c1, $01, $41, $81, $c1, $01, 
$41, $81, $c1
SinHigh:
.byte $00, $00, $00, $00, $00, $01, $01, $01, $01, $02, $02, $02, $02, 
$03, $03, $03
.byte $fc, $fc, $fc, $fc, $fd, $fd, $fd, $fd, $fe, $fe, $fe, $fe, $ff, 
$ff, $ff, $ff

 From this table you can get values between fc01 (negative number) to 
03bf (positive number)

-
Karri


----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Mar 22 20:37:07 2012

This archive was generated by hypermail 2.1.8 : 2012-03-22 20:37:11 CET