Ouch. Less than 1 degree of accuracy? Well, I guess if it’s good enough for Asteroid, it’s good enough for me
It indeed used (-128, 128) for (-180°,180°)
For instance, here it is using 64 (written as "40", because hexadecimal) for "PI/2":
COS: CLC ;COS(A)=SIN(A+PI/2)
ADC I,40
; JMP SIN
It implements COS in terms of SIN, and SIN wraps everything to be in the domain [0,64] (that is [0°,90°] ) then retrieves that from the lookup table.code: https://github.com/historicalsource/asteroids/blob/main/A351...
table: https://github.com/historicalsource/asteroids/blob/main/A351...
sin(x) = -sin(-x) = sin(pi - x) = cos(pi/2 - x)
cos(x) = cos(-x) = -cos(pi - x) = sin(pi/2 - x)