248 lines
6.4 KiB
NASM
248 lines
6.4 KiB
NASM
.FILE "GXTRIG.ASM"
|
||
.TITLE "<<< GENERATION X -- TRIG FUNCTIONS >>>"
|
||
.WIDTH 132
|
||
.OPTION B,D,L,T
|
||
.MNOLIST
|
||
|
||
**************************************************************************
|
||
* *
|
||
* COPYRIGHT (C) 1992 MIDWAY MANUFACTURING COMPANY. *
|
||
* ALL RIGHTS RESERVED. *
|
||
* *
|
||
**************************************************************************
|
||
|
||
.DEF GETSIN,GETCOS
|
||
|
||
HALFPI .set 102944
|
||
PI .set 205887
|
||
X3HALFPI .set 308831
|
||
X2PI .set 411775
|
||
|
||
W .set 0
|
||
L .set 1
|
||
|
||
.text
|
||
******************************************************************
|
||
GETSIN:
|
||
; PARMS - A0 = theta in s15.16
|
||
; RETURNS - A0 = sin(theta) in s15.16
|
||
;return A14 = theta normalized to range of 0 to 2Pi
|
||
|
||
move A2,-*SP,L
|
||
|
||
;long int getsin (theta)
|
||
;long int theta;
|
||
;{
|
||
;int indx;
|
||
;long int retval;
|
||
|
||
;while (theta < 0) theta += X2PI;
|
||
move A0,A0
|
||
jrnn TRIGSK1
|
||
TRIGLP1 addi X2PI,A0
|
||
jrn TRIGLP1
|
||
TRIGSK1:
|
||
;while (theta > X2PI) theta -= X2PI;
|
||
TRIGLP2:
|
||
cmpi X2PI,A0,L
|
||
jrle TRIGSK2
|
||
subi X2PI,A0,L
|
||
jruc TRIGLP2
|
||
TRIGSK2:
|
||
move A0,A14 ;A14 theta normalized
|
||
|
||
;if (theta < HALFPI) {
|
||
; indx = ((theta) >> 8);
|
||
; retval = sintbl[indx];
|
||
; }
|
||
cmpi HALFPI,A0,L
|
||
jrnn TRIGSK3
|
||
move A0,A2
|
||
jruc GotIndx
|
||
TRIGSK3:
|
||
|
||
;else if (theta <= PI) {
|
||
; indx = ((PI - theta) >> 8);
|
||
; retval = sintbl[indx];
|
||
; }
|
||
cmpi PI,A0,L
|
||
jrp TRIGSK4
|
||
movi PI,A2,L
|
||
sub A0,A2
|
||
; jruc GotIndx
|
||
******************************************************************
|
||
;***EXIT FOR BOTH GETSIN AND GETCOS***
|
||
GotIndx:
|
||
sra 8,A2
|
||
sll 4,A2
|
||
addi SINTBL,A2
|
||
move *A2,A0,W
|
||
zext A0,W
|
||
move *SP+,A2,L
|
||
rets
|
||
******************************************************************
|
||
TRIGSK4:
|
||
|
||
;else if (theta < X3HALFPI) {
|
||
; indx = ((theta - PI) >> 8);
|
||
; retval = sintbl[indx];
|
||
; retval = -retval;
|
||
; }
|
||
cmpi X3HALFPI,A0,L
|
||
jrnn TRIGSK5
|
||
move A0,A2
|
||
subi PI,A2,L
|
||
jruc NGotIndx
|
||
TRIGSK5:
|
||
|
||
;else {
|
||
; indx = ((X2PI - theta) >> 8);
|
||
; retval = sintbl[indx];
|
||
; retval = -retval;
|
||
; }
|
||
movi X2PI,A2,L
|
||
sub A0,A2
|
||
; jruc NGotIndx
|
||
******************************************************************
|
||
;***EXIT FOR BOTH GETSIN AND GETCOS***
|
||
NGotIndx:
|
||
sra 8,A2
|
||
sll 4,A2
|
||
addi SINTBL,A2
|
||
move *A2,A0,W
|
||
zext A0,W
|
||
neg A0
|
||
move *SP+,A2,L
|
||
rets
|
||
******************************************************************
|
||
GETCOS:
|
||
; PARMS - A0 = theta in s15.16
|
||
; RETURNS - A0 = cos(theta) in s15.16
|
||
|
||
move A2,-*SP,L
|
||
|
||
;long int getcos (theta)
|
||
;long int theta;
|
||
;{
|
||
;int indx;
|
||
;long int retval;
|
||
|
||
;while (theta < 0) theta += X2PI;
|
||
move A0,A0
|
||
jrnn TRIGSK6
|
||
TRIGLP3 addi X2PI,A0,L
|
||
jrn TRIGLP3
|
||
TRIGSK6:
|
||
;while (theta > X2PI) theta -= X2PI;
|
||
TRIGLP4:
|
||
cmpi X2PI,A0,L
|
||
jrn TRIGSK7
|
||
subi X2PI,A0,L
|
||
jruc TRIGLP4
|
||
TRIGSK7:
|
||
move A0,A14 ;A14 theta normalized
|
||
|
||
;if (theta < HALFPI) {
|
||
; indx = ((HALFPI - theta) >> 8);
|
||
; retval = sintbl[indx];
|
||
; }
|
||
cmpi HALFPI,A0,L
|
||
jrnn TRIGSK8
|
||
movi HALFPI,A2,L
|
||
sub A0,A2
|
||
jruc GotIndx
|
||
TRIGSK8:
|
||
|
||
|
||
;else if (theta <= PI) {
|
||
; indx = ((theta - HALFPI) >> 8);
|
||
; retval = sintbl[indx];
|
||
; retval = -retval;
|
||
; }
|
||
cmpi PI,A0,L
|
||
jrp TRIGSK9
|
||
move A0,A2
|
||
subi HALFPI,A2,L
|
||
jruc NGotIndx
|
||
TRIGSK9:
|
||
|
||
|
||
;else if (theta < X3HALFPI) {
|
||
; indx = ((X3HALFPI - theta) >> 8);
|
||
; retval = sintbl[indx];
|
||
; retval = -retval;
|
||
; }
|
||
cmpi X3HALFPI,A0,L
|
||
jrnn TRIGSK10
|
||
movi X3HALFPI,A2,L
|
||
sub A0,A2
|
||
jruc NGotIndx
|
||
TRIGSK10:
|
||
|
||
;else {
|
||
; indx = (((theta - X3HALFPI) + 5) >> 9);
|
||
; retval = sintbl[indx];
|
||
; }
|
||
move A0,A2
|
||
subi X3HALFPI,A2,L
|
||
jruc GotIndx
|
||
*****************************************************************
|
||
|
||
.data
|
||
.even
|
||
SINTBL:
|
||
;/* Table of sin from 0 through PI/2 Radians in 2**-8 increments */
|
||
;generated by mksin.c
|
||
.word 0,255,511,767,1023,1279,1535,1791
|
||
.word 2047,2303,2559,2815,3070,3326,3582,3837
|
||
.word 4093,4348,4604,4859,5114,5369,5625,5880
|
||
.word 6135,6389,6644,6899,7153,7408,7662,7916
|
||
.word 8170,8424,8678,8932,9185,9439,9692,9945
|
||
.word 10198,10451,10703,10956,11208,11460,11712,11964
|
||
.word 12216,12467,12718,12969,13220,13471,13721,13971
|
||
.word 14221,14471,14721,14970,15219,15468,15717,15965
|
||
.word 16213,16461,16709,16956,17204,17450,17697,17943
|
||
.word 18189,18435,18681,18926,19171,19416,19660,19904
|
||
.word 20148,20391,20634,20877,21120,21362,21604,21845
|
||
.word 22086,22327,22568,22808,23048,23287,23526,23765
|
||
.word 24004,24242,24479,24717,24953,25190,25426,25662
|
||
.word 25897,26132,26367,26601,26835,27068,27301,27533
|
||
.word 27766,27997,28228,28459,28690,28920,29149,29378
|
||
.word 29607,29835,30063,30290,30517,30743,30969,31194
|
||
.word 31419,31644,31867,32091,32314,32536,32758,32980
|
||
.word 33201,33421,33641,33861,34080,34298,34516,34733
|
||
.word 34950,35166,35382,35597,35812,36026,36240,36453
|
||
.word 36665,36877,37088,37299,37509,37719,37928,38137
|
||
.word 38344,38552,38758,38965,39170,39375,39579,39783
|
||
.word 39986,40189,40391,40592,40793,40993,41192,41391
|
||
.word 41589,41787,41984,42180,42375,42570,42765,42958
|
||
.word 43151,43344,43535,43726,43917,44106,44295,44484
|
||
.word 44671,44858,45045,45230,45415,45599,45783,45966
|
||
.word 46148,46329,46510,46690,46869,47048,47226,47403
|
||
.word 47579,47755,47930,48104,48278,48450,48622,48794
|
||
.word 48964,49134,49303,49471,49639,49806,49972,50137
|
||
.word 50301,50465,50628,50790,50951,51112,51272,51431
|
||
.word 51589,51747,51903,52059,52214,52369,52522,52675
|
||
.word 52827,52978,53128,53278,53426,53574,53721,53867
|
||
.word 54013,54157,54301,54444,54586,54727,54868,55007
|
||
.word 55146,55284,55421,55557,55693,55827,55961,56094
|
||
.word 56226,56357,56487,56616,56745,56872,56999,57125
|
||
.word 57250,57374,57498,57620,57741,57862,57982,58101
|
||
.word 58219,58336,58452,58567,58682,58795,58908,59020
|
||
.word 59131,59240,59349,59458,59565,59671,59776,59881
|
||
.word 59985,60087,60189,60290,60390,60489,60587,60684
|
||
.word 60780,60875,60970,61063,61156,61247,61338,61427
|
||
.word 61516,61604,61691,61777,61862,61946,62029,62111
|
||
.word 62192,62272,62352,62430,62507,62584,62659,62734
|
||
.word 62807,62880,62952,63022,63092,63161,63229,63296
|
||
.word 63361,63426,63490,63553,63615,63676,63736,63795
|
||
.word 63854,63911,63967,64022,64076,64129,64182,64233
|
||
.word 64283,64333,64381,64428,64475,64520,64564,64608
|
||
.word 64650,64692,64732,64772,64810,64848,64884,64920
|
||
.word 64954,64988,65020,65052,65082,65112,65140,65168
|
||
.word 65195,65220,65245,65268,65291,65313,65333,65353
|
||
.word 65371,65389,65406,65421,65436,65449,65462,65474
|
||
.word 65484,65494,65503,65510,65517,65522,65527,65531
|
||
.word 65533,65535,65535,65535
|
||
|
||
|